update yearn vault to v2#47
Conversation
| uint256 expiry; | ||
|
|
||
| // uninitialized state | ||
| if (closeParams.currentOption <= address(1)) { |
There was a problem hiding this comment.
I changed this recently, needs to be if (closeParams.currentOption == address(0)) {
| import {RibbonVault} from "./base/RibbonVault.sol"; | ||
| import {IRibbonThetaVault} from "../../interfaces/IRibbonThetaVault.sol"; | ||
|
|
||
| contract RibbonDeltaYearnVault is RibbonVault, OptionsDeltaYearnVaultStorage { |
There was a problem hiding this comment.
Since the Delta vaults don't deal with yvUSDC, why do we need to have a Yearn implementation?
There was a problem hiding this comment.
I was thinking buying options whilst keeping the reserves in yvUSDC so your net loss every week is smaller. But I guess not worth.
| address _oTokenFactory, | ||
| address _gammaController, | ||
| address _marginPool, | ||
| address _gnosisEasyAuction |
There was a problem hiding this comment.
We're missing passing the Yearn registry
There was a problem hiding this comment.
in v1, we had it in constructor because the asset parameter was there. but the asset parameter is now in initialize, so I pass it in there. yearnRegistry is only used once to get the collateral token, so I don't think it is necessary to pass it in constructor, hold it as a constant, and then reference it in initialize. Just pass it into initialize
There was a problem hiding this comment.
| } | ||
|
|
||
| if (vaultFee > 0) { | ||
| transferAsset(payable(feeRecipient), vaultFee); |
There was a problem hiding this comment.
Following this function here, just confirming that we're going to collect fees in yvUSDC?
There was a problem hiding this comment.
I think it's fine to collect fees in yvUSDC btw, if it simplifies things
There was a problem hiding this comment.
I changed it to be yvUSDC
| require(newOption != address(0), "!nextOption"); | ||
|
|
||
| // Wrap entire `asset` balance to `collateralToken` balance | ||
| _wrapToYieldToken(); |
There was a problem hiding this comment.
Is it possible to move this to the bottom of the function? We're following the check-effect-interaction pattern so we should do interactions that involve asset transfers last.
| */ | ||
| function burnRemainingOTokens() external onlyOwner nonReentrant { | ||
| // Wrap entire `asset` balance to `collateralToken` balance | ||
| _wrapToYieldToken(); |
There was a problem hiding this comment.
| returns (uint256 withdrawAmount) | ||
| { | ||
| function _withdrawYieldAndBaseToken( | ||
| address payable recipient, |
There was a problem hiding this comment.
We don't need payable since it's converted under the hood
| /* | ||
| Upgrades the vault to point to the latest yearn vault for the asset token | ||
| */ | ||
| function upgradeYearnVault() external onlyOwner { |
There was a problem hiding this comment.
this should be called in between commitAndClose() and rollToNextOption(). only time we have all the collateral back in the vault
| GAMMA_CONTROLLER, | ||
| MARGIN_POOL, | ||
| newOption, | ||
| wdiv( |
There was a problem hiding this comment.
We can try removing DSMath entirely as an import by copy pasting the wdiv/wmul functions into the contract, see if that helps with the size
| import {ShareMath} from "../../libraries/ShareMath.sol"; | ||
| import {RibbonVault} from "./base/RibbonVault.sol"; | ||
|
|
||
| contract RibbonThetaYearnVault is RibbonVault, OptionsThetaYearnVaultStorage { |
There was a problem hiding this comment.
We can remove OptionsThetaYearnVaultStorage since it's already inherited by RibbonVault?
There was a problem hiding this comment.
good catch. originally made sense because we had theta / delta vaults so they diverged in whats needed for storage, but we have deleted delta
| event NewOptionStrikeSelected(uint256 strikePrice, uint256 delta); | ||
|
|
||
| event PremiumDiscountSet( | ||
| uint256 premiumDiscount, | ||
| uint256 newPremiumDiscount | ||
| ); | ||
|
|
||
| event AuctionDurationSet( | ||
| uint256 auctionDuration, | ||
| uint256 newAuctionDuration | ||
| ); |
There was a problem hiding this comment.
We can remove these events imo
| import {ShareMath} from "../../libraries/ShareMath.sol"; | ||
| import {RibbonVault} from "./base/RibbonVault.sol"; | ||
|
|
||
| contract RibbonThetaVault is RibbonVault, OptionsThetaVaultStorage { |
There was a problem hiding this comment.
There was a problem hiding this comment.
we cannot do this because theta vaults inherit OptionsThetaVaultStorageV1 and delta vaults inherit OptionsDeltaVaultStorageV1.
both with different storage variables.
ribbon vault inherits OptionsVaultStorage which is the commonality between the two vaults
| uint256 performanceFee, | ||
| uint256 vaultFee, | ||
| uint256 round |
There was a problem hiding this comment.
I must have missed this before, we should replace the vaultFee for managementFee
There was a problem hiding this comment.
I actually added managementFee as well.
vaultFee is how much we actually made that week which is worth passing in
There was a problem hiding this comment.
The dev can just do performanceFee + managementFee = vaultFee so it's redundant?
| feeRecipient, | ||
| vaultFee | ||
| ); | ||
| emit CollectVaultFees(performanceFee, vaultFee, vaultState.round); |
There was a problem hiding this comment.
Refer to https://github.com/ribbon-finance/ribbon-v2/pull/47/files#r676746116
emit CollectVaultFees(performanceFee, managementFee, vaultState.round);
de0e7c2 to
b811b96
Compare
7b4d3f8 to
34757eb
Compare
|
|
||
| before(async function () { | ||
| // Reset block | ||
| await network.provider.request({ |
There was a problem hiding this comment.
Is there some way to avoid doing hardhat_reset? Calling reset breaks the test coverage tool.
Alternatively, we can use this solution to fork the state.
| assert.isAtMost(receipt.gasUsed.toNumber(), 1045000); | ||
| // console.log("commitAndClose", receipt.gasUsed.toNumber()); | ||
| }); | ||
| }); |
| premium = GnosisAuction.getOTokenPremium( | ||
| otokenAddress, | ||
| optionsPremiumPricer, | ||
| premiumDiscount | ||
| ); |
There was a problem hiding this comment.
Needs to account for the fact that the put contracts are collateralized with yvUSDC
| (uint256 lockedBalance, uint256 newPricePerShare, uint256 mintShares) = | ||
| VaultLifecycleYearn.rollover( | ||
| totalSupply(), | ||
| totalBalance(), |
There was a problem hiding this comment.
I think we're meant to pass in the collateralToken.balanceOf(address(this)) (yvUSDC balance) instead of totalBalance() (USDC balance)
This is likely why it's throwing off the calculation in VaultLifecycleYearn.createShort
Pull Request Test Coverage Report for Build 1094642468
💛 - Coveralls |
| gasLimits: { | ||
| depositWorstCase: 151608, | ||
| depositBestCase: 130594, | ||
| depositBestCase: 130681, |
There was a problem hiding this comment.
Follow up PR after this, let's gas golf the deposit flow for ThetaYearnVault
No description provided.