-
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
Open
ez7212
wants to merge
74
commits into
main
Choose a base branch
from
feat/rocketvault
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
4cd4e20
add msg.sender to depositLpToken
ez7212 3f849f7
add user param to depositLpToken
ez7212 f0b50e4
add address param
ez7212 6a18b22
initial commit
ez7212 2e9152e
initial commit
ez7212 6edefca
inital commit
ez7212 d676eea
fix IVault directory
ez7212 f608078
new directory for vault interfaces
ez7212 f6d1280
import only RocketStorage and add withdrawal check
ez7212 210d35f
update solidity version
ez7212 962ae49
update solidity version and remove comment
ez7212 7543bac
move withdraw check to getAmountEth
ez7212 87920b3
rearrange params
ez7212 2f39bbd
change vault balance getter function
ez7212 4cca37b
initial commit
ez7212 609ce9a
add forking config
ez7212 03bd301
add rocket vault deployment
ez7212 dfa61c0
rocket test initial commit
ez7212 ba2a92d
fix comment
ez7212 d65f23d
Merge branch 'main' into feat/rocketvault
Oozyx 8d364a5
fix getAddress parameter
ez7212 9eeb1b7
all tests for rocket vault
ez7212 6aa821f
Merge branch 'feat/rocketvault' of https://github.com/FukuNFT/fuku-nf…
ez7212 4140092
set forking to true
ez7212 99a0629
Skip tests if not fork
Oozyx 0bec6bd
Network fork set to false
Oozyx 17c9df2
Remove vault coverage
Oozyx ff5bfdf
Add test variables
Oozyx 559aac6
Add feature info
Oozyx 63c5039
initial commit
ez7212 e3e9c51
initial commit
ez7212 cda310b
initial commit
ez7212 a0e3fe2
initial commit
ez7212 6b3a1bf
add _data param
ez7212 c50c92d
changed file name
ez7212 f2c79eb
removed
ez7212 4f8ca96
move BaseDelegate code here
ez7212 f753bf5
add _data param and make deposit/withdraw changes
ez7212 713f2aa
fix import and storage interface
ez7212 a9e7089
initial commit
ez7212 d6268e9
initial commit
ez7212 766d4d9
add comment
ez7212 f8082f6
change interface names
ez7212 2552e9f
fix param description and order
ez7212 6b9c84f
fix imports
ez7212 2c7d253
fix imports, param order, and add vault storage creation
ez7212 de0a184
remove initialize and ownable
ez7212 da6db33
add comment
ez7212 0934d39
add address encoding
ez7212 51ca073
change bytes32 param to address
ez7212 cbcbb49
change bytes32 to bytes
ez7212 756c841
add bytes param
ez7212 5c22445
add bytes param
ez7212 d86864f
add receive function
ez7212 1125200
add bytes decoder and getter for current implementation
ez7212 49dcc9b
import interface and change bytes to address
ez7212 538d306
add userData for tests to pass
ez7212 059e8c7
add userData for tests to pass
ez7212 81fee31
add delegate testing
ez7212 1ea26d2
more tests
ez7212 3ba4746
Refactor suggestions
Oozyx 418e5fb
remove unneeded functions
ez7212 d8ce179
change implementation functions to ownership
ez7212 090ec87
Merge branch 'feat/rocket-delegate-mechanism' of https://github.com/F…
ez7212 d4bac30
add getVaultOptionalData helper
ez7212 953ab23
multiple user withdraw tests
ez7212 2da5cac
minor changes
Oozyx 9d25759
rocket vault without creating new vault storage
ez7212 d1d78a9
upgrade rocket vault and ensure withdrawals work
ez7212 0c89801
Use fixture constant
Oozyx 0ca165f
change impersonate deposit amt
ez7212 c383576
Use RocketPoolVaultStorage interface
Oozyx beb594b
Remove text file
Oozyx 82ea2e4
Merge pull request #26 from FukuNFT/feat/rocket-delegate-mechanism
Oozyx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
skipFiles: ["vendor/", "test/", "interfaces/"], | ||
skipFiles: ["vendor/", "test/", "interfaces/", "vaults/"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0; | |
|
||
import { IOptionMarket } from "../interfaces/facets/IOptionMarket.sol"; | ||
import { ICryptoPunksMarket } from "../interfaces/ICryptoPunksMarket.sol"; | ||
import { IVault } from "../interfaces/IVault.sol"; | ||
import { IVault } from "../interfaces/vaults/IVault.sol"; | ||
import { LibStorage, OptionMarketStorage, VaultStorage, TokenAddressStorage } from "../libraries/LibStorage.sol"; | ||
import { LibVaultUtils } from "../libraries/LibVaultUtils.sol"; | ||
import { OptionDuration, OptionInputParams, OptionInfo } from "../FukuTypes.sol"; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. use vaultlibutils for optional data |
||
// another safety check to make sure enough ETH was withdrawn | ||
require(option.optionInput.premium <= ethReturned, "Didn't burn enough LP tokens"); | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. use vaultlibutils for optional data |
||
strikeLPTokenAmount, | ||
payable(oms.acceptedOptions[optionId].seller), | ||
abi.encode(option.bidder) | ||
); | ||
// another safety check to make sure enough ETH was withdrawn | ||
require(option.optionInput.bidInput.amount <= ethReturned, "Didn't burn enough LP tokens"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
interface IRocketDelegate { | ||
/** | ||
* @dev Deposits ETH and converts to vault's LP token | ||
* | ||
* @return The amount of LP tokens received from ETH deposit | ||
*/ | ||
function deposit() external payable returns (uint256); | ||
|
||
/** | ||
* @dev Deposits LP token directly into vault | ||
* | ||
* @param amount The amount of LP tokens to deposit | ||
* @param user The user depositing | ||
*/ | ||
function depositLpToken(uint256 amount, address user) external; | ||
|
||
/** | ||
* @dev Converts LP token and withdraws as ETH | ||
* | ||
* @param lpTokenAmount The amount of LP tokens to withdraw before converting | ||
* @param recipient The recipient of the converted ETH | ||
* @return The amount of ETH withdrawn | ||
*/ | ||
function withdraw(uint256 lpTokenAmount, address payable recipient) external returns (uint256); | ||
|
||
/** | ||
* @dev Withdraws LP token directly from vault | ||
* | ||
* @param lpTokenAmount The amount of LP tokens to withdraw | ||
* @param recipient The recipient of the LP tokens | ||
*/ | ||
function withdrawLpToken(uint256 lpTokenAmount, address recipient) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
interface IRocketDepositPool { | ||
function deposit() external payable; | ||
|
||
function getUserLastDepositBlock(address _address) external view returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
interface IRocketPoolVaultStorage { | ||
function setDelegateAddress(address user, address delegateAddress) external; | ||
|
||
function getDelegateAddress(address user) external view returns (address); | ||
|
||
function transferOwnership(address newOwner) external; | ||
|
||
function owner() external view returns (address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
interface IRocketStorage { | ||
function getAddress(bytes32 _key) external view returns (address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
interface IRocketTokenRETH is IERC20 { | ||
function getEthValue(uint256 _rethAmount) external view returns (uint256); | ||
|
||
function getRethValue(uint256 _ethAmount) external view returns (uint256); | ||
|
||
function mint(uint256 _ethAmount, address _to) external; | ||
|
||
function burn(uint256 _rethAmount) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
// SPDX-License-Identifier: GPL-3.0-only | ||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | ||
|
||
interface IRocketVault { | ||
function balanceOf(string memory _networkContractName) external view returns (uint256); | ||
|
||
function depositEther() external payable; | ||
|
||
function withdrawEther(uint256 _amount) external; | ||
|
||
function depositToken( | ||
string memory _networkContractName, | ||
IERC20 _tokenAddress, | ||
uint256 _amount | ||
) external; | ||
|
||
function withdrawToken( | ||
address _withdrawalAddress, | ||
IERC20 _tokenAddress, | ||
uint256 _amount | ||
) external; | ||
|
||
function balanceOfToken(string memory _networkContractName, IERC20 _tokenAddress) external view returns (uint256); | ||
|
||
function transferToken( | ||
string memory _networkContractName, | ||
IERC20 _tokenAddress, | ||
uint256 _amount | ||
) external; | ||
|
||
function burnToken(ERC20Burnable _tokenAddress, uint256 _amount) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?