origin-dollar
origin-dollar copied to clipboard
Dust in ConvexEthMetaStrategy
When withdrawing funds, we should deposit the full balance of ETH to WETH. This way we don't leave any intermediate ETH in the contract, and also the next depositAll() will pick up the funds.
weth.deposit{ value: _amount }();
I'm not actually reproing bug here. Doesn't seem to actually leave dust.
from world import *
OETH_CONVEX_OETH_ETH_STRAT
'0x1827F9eA98E0bf96550b2FC20F7233277FcD7E63'
s = accounts.at(OETH_CONVEX_OETH_ETH_STRAT, force=True)
oeth_vault_admin.withdrawFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, [WETH], [10e18], {'from': STRATEGIST})
print(s.balance()) # zero
oeth_vault_admin.withdrawFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, [WETH], [27850153071752247653], {'from': STRATEGIST})
print(s.balance()) # zero
Our math on calculating how many LP tokens to withdraw is really good, at least a current pool tilt. Decided to fuzz it a little, and no dust leftover.
from world import *
OETH_CONVEX_OETH_ETH_STRAT
'0x1827F9eA98E0bf96550b2FC20F7233277FcD7E63'
s = accounts.at(OETH_CONVEX_OETH_ETH_STRAT, force=True)
for i in range(0,800):
amount = int(2e18*random.random())+int(100*random.random())
oeth_vault_admin.withdrawFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, [WETH], [amount], {'from': STRATEGIST})
print(s.balance(), amount)