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

IdleFinance Tranche Strategy #75

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

Conversation

hottyage
Copy link

New strategy for Idle Finance Tranche.
Screen Shot 2022-08-18 at 1 13 02 AM
Screen Shot 2022-08-18 at 1 12 16 AM

There are two types of tranches, Senior(AA) Tranche and Junior(BB) Tranche. Currently we only support the Senior Tranche since the Junior Tranche doesn't have any extra reward tokens.

The token flow of the invest process is:

  1. Deposit underlying token to the IdleCDO contract which will mint the AA token.
  2. Stake the AA token to the gauge to get the IDLE and the extra staking reward.

The deposit token of Lido - stETH tranche is stETH and the underlying token of the strategy is wstETH since the stETH is rebalancing token. So there wrap/unwrap process on invest/withdraw.

Test outputs at blockNumber = 15356073:

IdleTrances: stETH
Impersonating...
0xf00dD244228F51547f0563e60bCa65a30FBF5f7f
0x23237b849D0E6f392573EE6aE9e3B1256F058143
Fetching Underlying at:  0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0
New Vault Deployed:  0xA08DBD4515e15C512eb827dA146c1A8FEA907a4a
Strategy Deployed:  0xaAA7D0dDe838d4CB62f31edB5c5bbDdf918481A3
Strategy and vault added to Controller.
    Happy path
loop  0
old shareprice:  1000000000000000000
new shareprice:  999999999999999999
growth:  1
instant APR: 0 %
instant APY: 0 %
loop  1
old shareprice:  999999999999999999
new shareprice:  1000015568317980385
growth:  1.0000155683179803
instant APR: 1.5456226090871714 %
instant APY: 1.5575958999760164 %
loop  2
old shareprice:  1000015568317980385
new shareprice:  1000031135099713689
growth:  1.0000155665393884
instant APR: 1.5454460304793294 %
instant APY: 1.5574165787344718 %
loop  3
old shareprice:  1000031135099713689
new shareprice:  1000046917042288197
growth:  1.0000157814512176
instant APR: 1.566782476884452 %
instant APY: 1.5790867103647743 %
loop  4
old shareprice:  1000046917042288197
new shareprice:  1000062697038321801
growth:  1.0000157792557176
instant APR: 1.5665645076440526 %
instant APY: 1.5788653089385818 %
loop  5
old shareprice:  1000062697038321801
new shareprice:  1000078474964606034
growth:  1.000015776937117
instant APR: 1.5663343169720356 %
instant APY: 1.5786314941717894 %
loop  6
old shareprice:  1000078474964606034
new shareprice:  1000094250414536585
growth:  1.0000157742120497
instant APR: 1.5660637722921853 %
instant APY: 1.5783566907488833 %
loop  7
old shareprice:  1000094250414536585
new shareprice:  1000110023392464789
growth:  1.0000157714914586
instant APR: 1.5657936720091925 %
instant APY: 1.5780823394621057 %
loop  8
old shareprice:  1000110023392464789
new shareprice:  1000125793492085169
growth:  1.0000157683647313
instant APR: 1.5654832505207137 %
instant APY: 1.5777670332824512 %
loop  9
old shareprice:  1000125793492085169
new shareprice:  1000141561128499176
growth:  1.0000157656531976
instant APR: 1.5652140494585254 %
instant APY: 1.5774935969546267 %
vaultBalance:  5675850000000000000000
earned!
Overall APR: 1.561939641811396 %
Overall APY: 1.5741677326549075 %
earned!
      ✔ Farmer should earn money (31877ms)

Copy link
Contributor

@CryptJS13 CryptJS13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments. I think we need a better implementation for withdrawToVault. Withdrawing all is not the best solution.

_profitSharingNumerator: 300,
_profitSharingDenominator: 1000,
_sell: true,
_sellFloor: 1e18,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sellFloor is too high with WETH as rewardToken. It will now only liquidate if the total rewards are more than 1ETH. sellFloor could actually be set to 0, as we simulate profitability before running hardWork anyways.

IERC20(underlying()).safeTransfer(vault(), underlyingBalance);
}

function withdrawToVault(uint256 amount) external restricted {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to do a partial withdrawal? We do not want to withdraw all to vault if it is not necessary. The funds will sit idle in the vault until the next hardwork

Copy link
Contributor

@CryptJS13 CryptJS13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants