Conversation
|
@juliangruber I've added bunch of tests to validate functionality of the code. Do you think it would make sense to split it into a separate PR? |
| sender: config.account.address, | ||
| }) | ||
|
|
||
| if (!sushiswapRouterAddress && config.chainId === 314) { |
There was a problem hiding this comment.
is it not fatal if this happens on testnet?
There was a problem hiding this comment.
It's not since there is no calibration deployment for sushiswap and so do not perform swaps there.
However, should we leave the mainnet bot running even if we're not able to find the router?
lib/auction.js
Outdated
| ? publicClient.estimateGas({ | ||
| account: walletAddress, | ||
| to: swapTx.to, | ||
| data: swapTx.data, | ||
| value: swapTx.value, | ||
| }) | ||
| : Promise.resolve(0n), |
There was a problem hiding this comment.
I don't think this will work because the simulation would fail without USDFC in the wallet.
There was a problem hiding this comment.
It does, but only when we set simulate param to true which also throws an error if we don't actually have tokens.
There was a problem hiding this comment.
I've fixed swap gas estimation in afd0e27
Quote HTTP API returns gasSpent property which can be multiplied with the gas price to get an approximate gas requirements for the swap.
dismissed as Julian has unassigned himself.
|
@wjmelements would you be able to give this another pass? |
| const swapAmountOut = BigInt(quote.assumedAmountOut) | ||
| const totalGasCost = bidGasCost + swapGasCost | ||
| const totalCost = auctionPrice + totalGasCost | ||
| const isProfitable = swapAmountOut >= totalCost |
There was a problem hiding this comment.
the quote was for amount in that includes existingUsdfcBalance, so this is effectively selling any prior balance at a huge discount
There was a problem hiding this comment.
Kudos for catching this. Should be fixed in cc572a0 . Now we should get quote for the bid amount only, but swap the whole USDFC amount back to FIL. Now, that doesn't mean that the bot will be profitable, but that's not the goal here.
Closes #6