-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Compound approve to mapTokenToCToken #85
Comments
The reason we had to reset the allowance is that for some ERC20 tokens, like USDT, its allowance needs to be 0 before approving a new amount. So we want to make sure the adapter is future-prove. |
@maxweng should we not account for this in the other adapters if that is the case? Might be worth seeing how much gas a change like this saves, considering @kingjacob matra I can't imagine we want to support USDT ever 😂 Stake is super expensive right now so anything we can save is good to consider. |
yea, let's run the gas delta tests to see the difference between those scenarios. |
actually, I'm thinking if we really want to save gas for staking, we can make batch deposits to aave/compound, instead of doing it for each stake. it's the minting action that takes A LOT of gas. |
@maxweng I like that idea! I was also wondering if we could remove |
I guess we could have a check to see if it's a new user or if there're remaining rewards before calling the claim function. but that's only gonna save gas once for each new user but will add a bit extra cost to all others. so we may have to weigh our options here. |
and the reason batch deposit's not there yet is that we haven't found a good way to incentivize 3rd party to actually trigger the deposit for others. do you have any ideas for that? |
@maxweng For the claim I mean we should just have a second arguments |
Gotcha. we can add a claim toggle in that case. but I don't see that will have a big impact on the gas costs because the heavy lifting part is to calculate how much rewards the user accrues up till now, no matter if he claims right away or not. so the only gas cost could be reduced is that of the token transfer part. |
Is it possible to move the token approvals for the cToken into the
mapTokenToCToken
function?Can we remove the approvals in this function and instead to a max approval in
mapTokenToCoToken
similarly to how we do it in the Aave adapter functionmapTokenToAToken
?I checked the cToken mint code and I can't see that it resets the approval ever so feel like this should be possible. I believe this would save gas when users stake.
The text was updated successfully, but these errors were encountered: