This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
AP-818 Slippage support for investment calls #398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation of the solution
VaultActionData
struct for managing thelockMinTokensOut
andliqMinTokensOut
expectations respectivelydeposit
,redeem
,redeemAll
calls inIVault
deposit
andwithdraw
VaultActionData
struct defOpen questions:
As it stands, harvest accepts an array of accounts. To appropriately provide slippage tolerances we need an array for each leg for each account. Since we calculate the yield on-chain and then determine the amount we're going to harvest that way, we actually don't know exactly how much we're going to be trading for. Assuming we can estimate it accurately enough, we still need a lot of arguments to be pre-calculated and passed. For each account we need both a lock vault
minTokensOut[]
and a corresponding liquid array.If re-balancing is going to occur from locked -> liquid, we need to also pass in an expectation for the number of tokens expected on the incoming trade. Again, assuming we can precalculate this, we then need to pass a
minTokensOut
array for the liquid vault deposit leg.It's so many arrays that it starts making less sense for Harvest to be callable on multiple accounts. Additionally, I think that the on-chain yield calcs really throw a wrench into our ability to appropriately provide sane limits.
Instructions on making this work
yarn
oryarn install
to install npm dependencies