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

NotionalV2 Strategy #72

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

Conversation

hottyage
Copy link

New strategy for Notional V2. We hold the nTokens and claim NOTE rewards and compound those rewards into more nTokens.
Screen Shot 2022-06-23 at 10 23 28 PM
The nTokens are liquidity share token, users provide liquidity to the Notional and get back the nTokens. More informations about nTokens here.

The reward token of this strategy is WETH. We swap the NOTE rewards to WETH and then swap WETH to the underlying of the nToken to mint more nToken.

Added the test outputs for ETH and DAI since the Notional receives native ETH instead of WETH.

Test outputs at blockNumber = 15003364:

  Notional: ETH
Impersonating...
0xf00dD244228F51547f0563e60bCa65a30FBF5f7f
0x39eea0258a5c3e3c5092b2f910371d124592a7fb
Fetching Underlying at:  0xabc07BF91469C5450D6941dD0770E6E6761B90d6
New Vault Deployed:  0x7F1857761b4A3a99ba52328a9E1288b2A6c929b6
Strategy Deployed:  0xaAA7D0dDe838d4CB62f31edB5c5bbDdf918481A3
Strategy and vault added to Controller.
    Happy path
loop  0
old shareprice:  100000000
new shareprice:  100000000
growth:  1
instant APR: 0 %
instant APY: 0 %
loop  1
eth balance 27355804912697405
old shareprice:  100000000
new shareprice:  100003799
growth:  1.00003799
instant APR: 3.771647200004295 %
instant APY: 3.8434741802752193 %
loop  2
eth balance 27353147436273982
old shareprice:  100003799
new shareprice:  100007598
growth:  1.0000379885568147
instant APR: 3.7715039205628464 %
instant APY: 3.8433254094036196 %
loop  3
eth balance 27351914482828085
old shareprice:  100007598
new shareprice:  100011397
growth:  1.000037987113739
instant APR: 3.771360652011424 %
instant APY: 3.843176650054647 %
loop  4
eth balance 27347832676324466
old shareprice:  100011397
new shareprice:  100015195
growth:  1.0000379756719127
instant APR: 3.7702247074888886 %
instant APY: 3.841997177723755 %
loop  5
eth balance 27345175531995508
old shareprice:  100015195
new shareprice:  100018993
growth:  1.0000379742298158
instant APR: 3.770081536110012 %
instant APY: 3.8418485211696662 %
loop  6
eth balance 27342518498452610
old shareprice:  100018993
new shareprice:  100022790
growth:  1.0000379627897273
instant APR: 3.7689457641304713 %
instant APY: 3.8406692430302147 %
loop  7
eth balance 27339861575741275
old shareprice:  100022790
new shareprice:  100026587
growth:  1.0000379613486086
instant APR: 3.768802689858006 %
instant APY: 3.8405206892007104 %
loop  8
eth balance 27337204763908576
old shareprice:  100026587
new shareprice:  100030384
growth:  1.0000379599075995
instant APR: 3.768659626475568 %
instant APY: 3.84037214687607 %
loop  9
eth balance 27334548061338238
old shareprice:  100030384
new shareprice:  100034180
growth:  1.000037948469737
instant APR: 3.767524075493024 %
instant APY: 3.839193114923334 %
vaultBalance:  3586192457724
eth balance 27332603193335447
earned!
Overall APR: 3.770327667166569 %
Overall APY: 3.8421040821236208 %
earned!
  Notional: DAI
Impersonating...
0xf00dD244228F51547f0563e60bCa65a30FBF5f7f
0x10bf1dcb5ab7860bab1c3320163c6dddf8dcc0e4
Fetching Underlying at:  0x6EbcE2453398af200c688C7c4eBD479171231818
New Vault Deployed:  0x7F1857761b4A3a99ba52328a9E1288b2A6c929b6
Strategy Deployed:  0xaAA7D0dDe838d4CB62f31edB5c5bbDdf918481A3
Strategy and vault added to Controller.
    Happy path
loop  0
old shareprice:  100000000
new shareprice:  100000000
growth:  1
instant APR: 0 %
instant APY: 0 %
loop  1
old shareprice:  100000000
new shareprice:  100003606
growth:  1.00003606
instant APR: 3.580036800000439 %
instant APY: 3.64470978860838 %
loop  2
old shareprice:  100003606
new shareprice:  100007201
growth:  1.0000359487036898
instant APR: 3.568987302326967 %
instant APY: 3.6332593227988985 %
loop  3
old shareprice:  100007201
new shareprice:  100010783
growth:  1.0000358174207875
instant APR: 3.5559535357839422 %
instant APY: 3.6197542039804853 %
loop  4
old shareprice:  100010783
new shareprice:  100014353
growth:  1.000035696150884
instant APR: 3.5439138597691766 %
instant APY: 3.6072806853365114 %
loop  5
old shareprice:  100014353
new shareprice:  100017910
growth:  1.0000355648953705
instant APR: 3.530882812382039 %
instant APY: 3.593781759287751 %
loop  6
old shareprice:  100017910
new shareprice:  100021456
growth:  1.0000354536502511
instant APR: 3.5198383969341043 %
instant APY: 3.5823421682784184 %
loop  7
old shareprice:  100021456
new shareprice:  100024989
growth:  1.0000353224212213
instant APR: 3.5068099788491116 %
instant APY: 3.568849205430391 %
loop  8
old shareprice:  100024989
new shareprice:  100028510
growth:  1.0000352012035711
instant APR: 3.49477549054324 %
instant APY: 3.556387169531483 %
loop  9
old shareprice:  100028510
new shareprice:  100032020
growth:  1.0000350899958421
instant APR: 3.4837347872055875 %
instant APY: 3.5449555399300614 %
vaultBalance:  100058886222629751
earned!
Overall APR: 3.526161349389618 %
Overall APY: 3.588891205456224 %
earned!
      ✔ Farmer should earn money (28077ms)

0x8eae010b847722fa95e85dfc0113c19f46531a85595a4a8aeb38cb97657d35c4;
bytes32 internal constant _NTOKEN_UNDERLYING = 0xca1ad68fb46e1d177e14769fefa6ec6792476f949c8cd88042b7f02ed2f5d2e2;

address public constant weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
Copy link

Choose a reason for hiding this comment

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

ise CAPITAL_CASE for contants

IERC20(_nTokenUnderlying).safeApprove(_rewardPool, underlyingBalance);
}

Types.BalanceAction memory action = Types.BalanceAction(
Copy link

Choose a reason for hiding this comment

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

better to use Type creations via JSON, make reviewer work a bit easy :)

IBVault.FundManagement memory funds;
funds.sender = address(this);
funds.fromInternalBalance = false;
funds.recipient = address(uint160(address(this)));
Copy link

Choose a reason for hiding this comment

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

is it necessary wrapping?

Copy link
Author

Choose a reason for hiding this comment

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

We need it to cast address to payable address.

address _underlying,
address _vault,
address _rewardPool, // always the notional proxy, could be constant,
address _bVault,
Copy link

Choose a reason for hiding this comment

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

you can make it static variable

}

function investedUnderlyingBalance() public view returns (uint256) {
uint256 underlyingBalance = IERC20(underlying()).balanceOf(address(this));
Copy link

Choose a reason for hiding this comment

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

inline please

address _vault,
address _rewardPool, // always the notional proxy, could be constant,
address _bVault,
bytes32 _note2wethpid,
Copy link

Choose a reason for hiding this comment

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

can be static for reduce gas usage

@CryptJS13 CryptJS13 mentioned this pull request Jul 11, 2022
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