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

ApeCoinStake Strategy #79

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

Conversation

hottyage
Copy link

Screen Shot 2022-12-22 at 8 09 50 PM
New strategy for ApeStake APECOIN pool.

The workflow of this strategy is relatively simple. It just deposits APE to earn APE, and compounds the APE reward to the staking pool.

Test outputs at blockNumber = 16233370:

Impersonating...
0xf00dD244228F51547f0563e60bCa65a30FBF5f7f
0x91951fa186a77788197975ed58980221872a3352
Fetching Underlying at:  0x4d224452801ACEd8B2F0aebE155379bb5D594381
New Vault Deployed:  0xf7b8f914b9ef935526019F3eF9B177A6960ec772
Strategy Deployed:  0x48686897e53fe8c994592b7f9e250c09CaBE6E22
Strategy and vault added to Controller.
    Happy path
loop  0
old shareprice:  1000000000000000000
new shareprice:  1000000000000000000
growth:  1
instant APR: 0 %
instant APY: 0 %
loop  1
old shareprice:  1000000000000000000
new shareprice:  1000956813862045887
growth:  1.0009568138620457
instant APR: 94.99248022389843 %
instant APY: 158.23267589625755 %
loop  2
old shareprice:  1000956813862045887
new shareprice:  1001827243714661648
growth:  1.0008695978093773
instant APR: 86.33367051498257 %
instant APY: 136.86431592702712 %
loop  3
old shareprice:  1001827243714661648
new shareprice:  1002785315727509072
growth:  1.000956324574779
instant APR: 94.94390378406015 %
instant APY: 158.1075914921674 %
loop  4
old shareprice:  1002785315727509072
new shareprice:  1003744046907881996
growth:  1.0009560682284995
instant APR: 94.91845372542772 %
instant APY: 158.04208167678314 %
loop  5
old shareprice:  1003744046907881996
new shareprice:  1004616220042210066
growth:  1.000868919857622
instant APR: 86.26636346470634 %
instant APY: 136.70531898671996 %
loop  6
old shareprice:  1004616220042210066
new shareprice:  1005576209929021675
growth:  1.0009555787251487
instant APR: 94.86985583276602 %
instant APY: 157.91703415412135 %
loop  7
old shareprice:  1005576209929021675
new shareprice:  1006536859272825683
growth:  1.0009553222662972
instant APR: 94.84439459799025 %
instant APY: 157.85154382813113 %
loop  8
old shareprice:  1006536859272825683
new shareprice:  1007410776454247646
growth:  1.0008682416082142
instant APR: 86.19902686350508 %
instant APY: 136.54635874511274 %
loop  9
old shareprice:  1007410776454247646
new shareprice:  1008372685054047973
growth:  1.0009548325492268
instant APR: 94.79577548723587 %
instant APY: 157.72653384452684 %
vaultBalance:  10833332000000000000000000
earned!
Overall APR: 96.77598651665114 %
Overall APY: 162.86730382571452 %
earned!
      ✔ Farmer should earn money (25319ms)

}

function _liquidateReward() internal {
uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

We need additional logic to separate rewards from deposits, as underlying == rewardToken. See an example in the YEL strategy: https://github.com/harvest-finance/harvest-strategy/blob/master/contracts/strategies/yel/YelStrategy.sol#L136

Copy link
Author

Choose a reason for hiding this comment

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

I noticed this problem and handled it differently in doHardWork function. But this approach is more obvious.

Copy link
Author

Choose a reason for hiding this comment

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

I will update it

Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed this problem and handled it differently in doHardWork function. But this approach is more obvious.

But the problem is not resolved that way. When we have a balance in the rewardPool, and someone deposits into the vault, on doHardWork what happens is:

  • Funds from the vault get transferred to the strategy (+APE balance)
  • The strategy claims rewards from the rewardPool (+APE balance)
  • At liquidation, the APE balance is queried and notified for profit share. This balance now includes the new deposit.

Copy link
Author

Choose a reason for hiding this comment

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

Gotcha. Thanks for your clarification

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