Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

stevieraykatz
Copy link
Contributor

@stevieraykatz stevieraykatz commented Oct 3, 2023

Explanation of the solution

  • Added two new arrays to the VaultActionData struct for managing the lockMinTokensOut and liqMinTokensOut expectations respectively
  • Added an array as an arg to the respective deposit, redeem, redeemAll calls in IVault
  • Added an array to the strategy endpoints for consumption on deposit and withdraw
  • Modified associated helpers, utils and defaults to reflect new VaultActionData struct def
  • Adjusted tests as needed to support and expect the new structs

Open questions:

  1. 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.

  2. 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

  • run yarn or yarn install to install npm dependencies

@linear
Copy link

linear bot commented Oct 3, 2023

AP-818 Add token slippage array to VaultActionData and invest/redeem flows

Add an array to the VaultActionData to accept token slippage tolerances for the underlying Strategy token trade path.

Add this array to each Vault and Strategy interfaces for the deposit/redeem calls.

We expect that this will be empty for the Flux strategy so this shouldn't affect the launch of the Flux strategy or its scope.

@stevieraykatz stevieraykatz self-assigned this Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant