Skip to content

Commit

Permalink
Merge pull request #58 from VenusProtocol/remove-release-funds
Browse files Browse the repository at this point in the history
refactor: remove release funds from conversion cli command
  • Loading branch information
coreyar authored Aug 27, 2024
2 parents 3302a01 + eee744d commit 64423be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@graphql-mesh/cli": "^0.90.5",
"@graphql-mesh/config": "^0.100.5",
"@graphql-mesh/graphql": "^0.98.4",
"@venusprotocol/keeper-bots": "1.0.0-dev.3",
"@venusprotocol/keeper-bots": "1.0.0-dev.4",
"@venusprotocol/venus-protocol": "^9.1.0",
"dotenv": "^16.3.1",
"graphql": "^16.8.1",
Expand Down
51 changes: 4 additions & 47 deletions packages/cli/source/commands/convert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ export const options = zod.object({
)
.optional()
.default(false),
releaseFunds: zod
.boolean()
.describe(
option({
description: "Release funds",
alias: "rf",
}),
)
.optional()
.default(false),
minTradeUsd: zod
.number()
.describe(
Expand Down Expand Up @@ -126,24 +116,13 @@ interface Props {
* Command to search for and execute token conversions based on parameters
*/
export default function Convert({ options }: Props) {
const {
minTradeUsd,
maxTradeUsd,
simulate,
releaseFunds,
assetIn,
assetOut,
converter,
profitable,
loop,
debug,
minIncomeBp,
} = options;
const { minTradeUsd, maxTradeUsd, simulate, assetIn, assetOut, converter, profitable, loop, debug, minIncomeBp } =
options;

const { exit } = useApp();
const { write: writeStdErr } = useStderr();

const [{ completed, messages, releasedFunds }, dispatch] = useReducer(reducer, defaultState);
const [{ completed, messages }, dispatch] = useReducer(reducer, defaultState);
const [error, setError] = useState("");

useEffect(() => {
Expand All @@ -160,16 +139,12 @@ export default function Convert({ options }: Props) {
assetIn,
assetOut,
converter,
releaseFunds: !!releaseFunds,
releaseFunds: false,
});

if (potentialConversions.length === 0) {
setError("No Potential Trades Found");
}
if (releaseFunds) {
// @todo check if we need to release funds or if there are already enough funds to make our trade
await tokenConverter.releaseFundsForConversions(potentialConversions);
}

for (const t of potentialConversions) {
let amountOut = t.assetOut.balance;
Expand Down Expand Up @@ -255,24 +230,6 @@ export default function Convert({ options }: Props) {
<FullScreenBox flexDirection="column">
<Title />
{debug && <Options options={options} />}
{releaseFunds && (
<Box flexDirection="column" borderStyle="round" borderColor="#3396FF">
<Box flexDirection="row" marginLeft={1} justifyContent="space-between">
<Box flexDirection="column">
<Box flexDirection="row">
<Text bold color="white">
Release Funds Steps
</Text>
</Box>
<Box flexDirection="row">
<Text color="green">{releasedFunds.done ? "✔" : " "}</Text>
<Box marginRight={1} />
<Text>Release Funds</Text>
</Box>
</Box>
</Box>
</Box>
)}
<Box flexDirection="column" flexGrow={1}>
<Text bold backgroundColor="#3396FF">
Conversions
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/source/state/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ interface TradeError {
}

interface State {
releasedFunds: { done: boolean };
completed: (TradeSuccess | TradeError)[];
messages: Array<PotentialConversionsMessage | GetBestTradeMessage | ArbitrageMessage | ExecuteTradeMessage>;
}

export const defaultState = {
releasedFunds: { done: false },
trades: {},
completed: [],
messages: [],
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7013,7 +7013,7 @@ __metadata:
"@graphql-mesh/graphql": ^0.98.4
"@sindresorhus/tsconfig": ^3.0.1
"@types/react": ^18.2.55
"@venusprotocol/keeper-bots": 1.0.0-dev.3
"@venusprotocol/keeper-bots": 1.0.0-dev.4
"@venusprotocol/venus-protocol": ^9.1.0
ava: ^5.2.0
chalk: ^5.2.0
Expand Down Expand Up @@ -7171,7 +7171,7 @@ __metadata:
languageName: unknown
linkType: soft

"@venusprotocol/keeper-bots@1.0.0-dev.3, @venusprotocol/keeper-bots@workspace:packages/keeper-bots":
"@venusprotocol/keeper-bots@1.0.0-dev.4, @venusprotocol/keeper-bots@workspace:packages/keeper-bots":
version: 0.0.0-use.local
resolution: "@venusprotocol/keeper-bots@workspace:packages/keeper-bots"
dependencies:
Expand Down

0 comments on commit 64423be

Please sign in to comment.