-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rocket Pool Vault #18
base: main
Are you sure you want to change the base?
Conversation
i might've put the interfaces into the wrong folder so lmk if there's a better location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also create a new folder in interfaces. call it vaults or something and put the interfaces related to vaults in there.
@@ -0,0 +1,15 @@ | |||
pragma solidity 0.8.0; | |||
|
|||
// SPDX-License-Identifier: GPL-3.0-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goes above pragma solidity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
interface RocketDepositPoolInterface { | ||
function getBalance() external view returns (uint256); | ||
function getExcessBalance() external view returns (uint256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line in between each function. Keep same style as other interface files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -0,0 +1,17 @@ | |||
pragma solidity 0.8.0; | |||
|
|||
// SPDX-License-Identifier: GPL-3.0-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above pragma solidity
|
||
interface RocketTokenRETHInterface is IERC20 { | ||
function getEthValue(uint256 _rethAmount) external view returns (uint256); | ||
function getRethValue(uint256 _ethAmount) external view returns (uint256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new lines
contracts/vaults/RocketPoolVault.sol
Outdated
|
||
contract RocketVault is BaseVault { | ||
|
||
RocketDepositPoolInterface depositPool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments to explain what these variables are
contracts/vaults/RocketPoolVault.sol
Outdated
RocketTokenRETHInterface rETH; | ||
|
||
constructor (address _diamond, address _rETHAddress, address _depositPool) BaseVault(_diamond) { | ||
depositPool = RocketDepositPoolInterface(_depositPool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at the docs, you should only store the RocketStorageInterface address, and use it to get the current addresses of the rocketdepositpool and rockettokenreth
contracts/vaults/RocketPoolVault.sol
Outdated
} | ||
|
||
function getAmountETH(uint256 lpTokenAmount) external view override returns (uint256) { | ||
return rETH.getEthValue(lpTokenAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a limit to how much could be withdrawn. I think to avoid having bids that can't be covered (not enough excess ETH in the pool to withdraw), we should make a check that takes this in consideration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
should we also add a check for depositing (if the rocket vault is not accepting more ETH) and 24 hr check after depositing?
I believe rocket already has these checks in place, but wondering if we need them on our side too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need to add checks for depositing. If it does revert I don't think it's a big deal. Mainly on the withdraw we want to avoid reverting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the check for the withdraw limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm
@@ -0,0 +1,9 @@ | |||
// SPDX-License-Identifier: GPL-3.0-only | |||
pragma solidity 0.8.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong solidity version (should be ^0.8.0)
|
||
interface RocketStorageInterface { | ||
|
||
// Getters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
@@ -0,0 +1,9 @@ | |||
// SPDX-License-Identifier: GPL-3.0-only | |||
pragma solidity 0.8.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong solidity version
@@ -0,0 +1,14 @@ | |||
// SPDX-License-Identifier: GPL-3.0-only | |||
pragma solidity 0.8.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong solidity version
contracts/vaults/RocketPoolVault.sol
Outdated
} | ||
|
||
function getAmountETH(uint256 lpTokenAmount) external view override returns (uint256) { | ||
return rETH.getEthValue(lpTokenAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need to add checks for depositing. If it does revert I don't think it's a big deal. Mainly on the withdraw we want to avoid reverting.
contracts/vaults/RocketPoolVault.sol
Outdated
} | ||
|
||
function getAmountETH(uint256 lpTokenAmount) external view override returns (uint256) { | ||
return rETH.getEthValue(lpTokenAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the check for the withdraw limit?
contracts/vaults/RocketPoolVault.sol
Outdated
} | ||
|
||
function getAmountETH(uint256 lpTokenAmount) external view override returns (uint256) { | ||
return rETH.getEthValue(lpTokenAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm
contracts/vaults/RocketPoolVault.sol
Outdated
address rethAddress = rocketStorage.getAddress(keccak256(abi.encodePacked("contract.address", "rocketETHToken"))); | ||
RocketTokenRETHInterface rETH = RocketTokenRETHInterface(rethAddress); | ||
|
||
// check that rocketVault has enough ETH to handle withdrawal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check should be in the getAmountEth function. Reason is because we use this function when checking if a bid is valid (enough eth in vaults to cover bid). With this change we will not be displaying bids if rocket pool limits the withdrawal amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea makes sense. I'll move the check to getAmountEth
The withdraw
function in vaultAccountingFacet doesn't call getAmountEth
though. If a user wants to withdraw from the vault, I'm guessing its ok that it reverts too? Since we only want to avoid reverting when a bid is actually accepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the check to getAmountEth. I currently have it as an if statement where if rocket vault doesn't have enough eth to match the eth amount result, it returns the rocket vault balance. This may mess up the userETHBalance
function in VaultAccountingFacet though.
If I have a require(rocketVault.balance >= ethAmount, "not enough ETH to withdraw")
, I'm assuming it would revert sometimes. Wondering what you think is the best way to go about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The userETHBalance
function calls the vault's getAmountETH
function, so this should be good.
Also need to add tests for this. Would probably be similar to how we test the vaults in the old repo. Mainnet fork for the rocket pool testing. I'll get the testing started with the empty vault. |
contracts/vaults/RocketPoolVault.sol
Outdated
uint256 ethAmount = rETH.getEthValue(lpTokenAmount); | ||
|
||
// check if rocket vault has enough to withdraw, if not return rocket vault balance | ||
if (rocketVault.balance >= ethAmount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should call the contract's balanceOf function. https://github.com/rocket-pool/rocketpool/blob/master/contracts/contract/RocketVault.sol#L39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
contracts/vaults/RocketPoolVault.sol
Outdated
address rethAddress = rocketStorage.getAddress(keccak256(abi.encodePacked("contract.address", "rocketETHToken"))); | ||
RocketTokenRETHInterface rETH = RocketTokenRETHInterface(rethAddress); | ||
|
||
// check that rocketVault has enough ETH to handle withdrawal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The userETHBalance
function calls the vault's getAmountETH
function, so this should be good.
@@ -12,9 +12,10 @@ interface IVault { | |||
/** | |||
* @dev Deposits LP token directly into vault | |||
* | |||
* @param user The user depositing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params are not in order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Also you didn't run prettier. You should set it up so it automatically applies when saving. |
…ukuNFT/fuku-nft-diamond into feat/rocket-delegate-mechanism
Rocket Pool Delegate
@@ -0,0 +1,16 @@ | |||
pragma solidity ^0.8.0; | |||
|
|||
// SPDX-License-Identifier: GPL-3.0-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goes above pragma solidity
pragma solidity ^0.8.0; | ||
|
||
// SPDX-License-Identifier: GPL-3.0-only | ||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import {IERC20} from ...
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | ||
|
||
interface RocketVaultInterface { | ||
function balanceOf(string memory _networkContractName) external view returns (uint256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New lines in between each function
hardhat.config.js
Outdated
hardhat: { | ||
forking: { | ||
url: MAINNET_URL, | ||
enabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this false by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged main so this should be fixed
hardhat.config.js
Outdated
|
||
module.exports = { | ||
networks: { | ||
hardhat: { | ||
forking: { | ||
url: MAINNET_URL, | ||
enabled: true, | ||
// enabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't comment out, set enabled to false
@@ -152,7 +152,7 @@ contract BidMarketFacet is IBidMarket { | |||
// update user balance | |||
vs.userVaultBalances[bidInfo.bidder][bidInfo.bidInput.vault] -= bidLPTokenAmount; | |||
// withdraw funds from vault | |||
uint256 ethReturned = vault.withdraw(bidLPTokenAmount, payable(this)); | |||
uint256 ethReturned = vault.withdraw(bidLPTokenAmount, payable(this), abi.encode(bidInfo.bidder)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use vaultlibutils for optional data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're encoding the bidder's address instead of msg.sender here. how would I go about adding this to the vaultLibUtils?
@@ -156,7 +156,7 @@ contract OptionMarketFacet is IOptionMarket, IERC721Receiver { | |||
// update user balance | |||
vs.userVaultBalances[option.bidder][option.optionInput.bidInput.vault] -= premiumLPTokenAmount; | |||
// withdraw the premium from bidder's vault | |||
uint256 ethReturned = vault.withdraw(premiumLPTokenAmount, payable(this)); | |||
uint256 ethReturned = vault.withdraw(premiumLPTokenAmount, payable(this), abi.encode(option.bidder)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use vaultlibutils for optional data
@@ -244,7 +244,11 @@ contract OptionMarketFacet is IOptionMarket, IERC721Receiver { | |||
// update user balance | |||
vs.userVaultBalances[option.bidder][option.optionInput.bidInput.vault] -= strikeLPTokenAmount; | |||
// withdraw the strike amount from bidder's vault | |||
uint256 ethReturned = vault.withdraw(strikeLPTokenAmount, payable(oms.acceptedOptions[optionId].seller)); | |||
uint256 ethReturned = vault.withdraw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use vaultlibutils for optional data
pending issues: