Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
063d8b2
initial commit of the native staking strategy
sparrowDom Apr 4, 2024
6e8332b
fix text
sparrowDom Apr 4, 2024
b933f22
add some more functionality
sparrowDom Apr 10, 2024
0a43d14
finish up the fuse interval test, update deploy script
sparrowDom Apr 11, 2024
d31fe30
some natspec and refactoring
sparrowDom Apr 11, 2024
03c544c
add some more accounting logic
sparrowDom Apr 11, 2024
9aa0d73
finish up accounting and add tests for it
sparrowDom Apr 12, 2024
e99f86c
add some comments
sparrowDom Apr 15, 2024
52ba11e
add tests for manually fixing accounting
sparrowDom Apr 15, 2024
e656ecb
lint and prettier
sparrowDom Apr 15, 2024
fe113a5
undo file delete
sparrowDom Apr 15, 2024
71ad71f
implement the collect rewards function and add tests for it
sparrowDom Apr 16, 2024
2c448bb
implement and test checkBalance
sparrowDom Apr 16, 2024
5d5e9cb
add functions to register and exit/remove the ssv validator
sparrowDom Apr 18, 2024
121c7f7
Native staking updates (#2023)
naddison36 Apr 22, 2024
8a64dc8
Native staking changes (#2024)
naddison36 Apr 23, 2024
8419fc7
Native staking changes and unit tests (#2029)
naddison36 Apr 25, 2024
87c5254
allow for WETH to send ETH to the contract
sparrowDom Apr 26, 2024
1d66508
shorten error message
sparrowDom Apr 26, 2024
00ec878
fix depositing bug
sparrowDom Apr 27, 2024
ec4933b
Holesky deploy (#2026)
sparrowDom Apr 29, 2024
6179cb1
manuallyFixAccounting changes (#2034)
naddison36 Apr 29, 2024
da6a7b5
fix fork tests
sparrowDom Apr 29, 2024
fd17ec9
Merge branch 'master' into sparrowDom/nativeStaking
sparrowDom May 6, 2024
8f7d3d5
prettier
sparrowDom May 6, 2024
967fe49
fix unit test
sparrowDom May 6, 2024
1af324d
mainnet native staking fork tests (#2037)
naddison36 May 7, 2024
ce2ec63
fix unit tests
sparrowDom May 6, 2024
fe12d23
fix global hooks filter
sparrowDom May 7, 2024
c61c9bb
add github workflow
sparrowDom May 7, 2024
7e2e640
another workflow fix
sparrowDom May 7, 2024
af8ea03
another workflow fix
sparrowDom May 7, 2024
32480dd
fix holesky tests
sparrowDom May 7, 2024
0fb09ea
remove the .only
sparrowDom May 7, 2024
c7175bb
prettier
sparrowDom May 7, 2024
69abd8f
Sparrow dom/native staking defender action (#2051)
sparrowDom May 9, 2024
2f7a9cd
Fix fork tests (#2050)
naddison36 May 9, 2024
0623a47
add payable to fee accumulator (#2053)
sparrowDom May 9, 2024
f268742
fix linter
naddison36 May 9, 2024
20d29a1
Fix balancer fork test
naddison36 May 10, 2024
2a93df2
Merge remote-tracking branch 'origin/master' into sparrowDom/nativeSt…
naddison36 May 10, 2024
b898801
Fixed resolveContract for none proxied contracts
naddison36 May 10, 2024
25170aa
simplified woethCcipZapperFixture
naddison36 May 10, 2024
e1ff728
Regenerated latest contract diagrams
naddison36 May 10, 2024
c09cd46
Resolved Slither divide-before-multiply warning
naddison36 May 10, 2024
9d83e97
Native staking deployment to reduceQueueTime
naddison36 May 10, 2024
7eb135b
Fixed fork test harvesting CRV rewards
naddison36 May 10, 2024
579a93c
gas optimisation
sparrowDom May 10, 2024
4c864ca
Merge remote-tracking branch 'origin/master' into sparrowDom/nativeSt…
naddison36 May 10, 2024
e7b96e9
make verification automatic
sparrowDom May 10, 2024
8a53f3e
removed wethToVault from manuallyFixAccounting
naddison36 May 10, 2024
98a193a
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into s…
naddison36 May 10, 2024
905abf9
native staking strategy redeployed
sparrowDom May 10, 2024
fc48427
adjust the comment
sparrowDom May 10, 2024
4b51655
add rate limit to calling manually fix accounting (#2057)
sparrowDom May 13, 2024
657b064
Correct deployName in Native Staking deploy script
naddison36 May 13, 2024
769018a
Fix linter
naddison36 May 13, 2024
b98e9de
Remove approveAssets on Swapper contract in 095_ogn_buyback script as…
naddison36 May 13, 2024
622a3b4
Fix Holesky fork tests
naddison36 May 13, 2024
c25745d
Fix mainnet fork tests
naddison36 May 13, 2024
4ca3136
skip deploy 095_ogn_buyback for now
naddison36 May 13, 2024
37c9d0a
fix some Slither errors
naddison36 May 13, 2024
193af2f
Fix Slither warnings
naddison36 May 13, 2024
6d5034a
Upgrade the CI to use node.js 20.x
naddison36 May 13, 2024
848d578
Fix CI
naddison36 May 13, 2024
79d5058
Fix CI
naddison36 May 13, 2024
7b7ac39
Upgrade to node.js 20
naddison36 May 13, 2024
6b2be67
Still upgrade the buyback contracts but not approveAssets on the swapper
naddison36 May 13, 2024
5f2f8f6
Upgrade actions so they don't use node.js 16
naddison36 May 13, 2024
6baed9b
attempt to fix holesky fork run
sparrowDom May 13, 2024
9ce05e1
Generated latest contract diagram
naddison36 May 13, 2024
8c052d8
fix codecov upload
naddison36 May 13, 2024
3687fbe
Fix OETH process diagram for native staking
naddison36 May 13, 2024
6df4f5f
add a withdrawal event when withdrawing WETH to vault (#2059)
sparrowDom May 13, 2024
614b11e
Regenerated latest native staking diagram
naddison36 May 13, 2024
21d5569
Merge remote-tracking branch 'origin/master' into sparrowDom/nativeSt…
naddison36 May 13, 2024
8be6f90
Changed vault mint to call to Dripper.collect
naddison36 May 15, 2024
c8288b7
Added more vault mint fork tests
naddison36 May 16, 2024
63a11f7
first implementation of the withdrawal queue
naddison36 May 16, 2024
abe0e9c
Fix Slither
naddison36 May 16, 2024
cfe6a81
add a util contract that is able to recalculate a valid deposit data …
sparrowDom May 16, 2024
3a35b55
Slither fixes
naddison36 May 17, 2024
28ae453
Fix linter
naddison36 May 17, 2024
ad492cc
Updated contract diagram
naddison36 May 17, 2024
4872259
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 May 20, 2024
c491131
Merge remote-tracking branch 'origin/master' into sparrowDom/nativeSt…
naddison36 May 22, 2024
e8c15b5
Prettier native staking test
naddison36 May 22, 2024
acad4b9
Renamed native staking deploy script
naddison36 May 22, 2024
638bf30
Fix event values (#2060)
sparrowDom May 22, 2024
b4e9c3f
Deploy latest Native Staking Strategy to Holesky (#2073)
naddison36 May 22, 2024
77d7b07
Deploy native staking Proxy via Relayer (#2066)
sparrowDom May 22, 2024
4c25093
Setup basic defender action (#2072)
sparrowDom May 22, 2024
c4456b9
Output more contract details in 097 deploy script
naddison36 May 23, 2024
c1922b6
Added claimWithdrawals to OETHVaultCore
naddison36 May 23, 2024
e5ebf29
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 May 23, 2024
0643034
prettier
naddison36 May 23, 2024
a50f2d2
Add getting WETH from Dripper on mints over rebaseThreshold
naddison36 May 23, 2024
82b4fd1
Restricted OETH's depositToStrategy to only deposit WETH
naddison36 May 23, 2024
10b95df
Fixed unit tests
naddison36 May 23, 2024
f27966b
Suppress Slither
naddison36 May 23, 2024
112dd37
Changed ssv util getClusterInfo to use the SSV API instead of the ssv…
naddison36 May 23, 2024
f3e9d35
Fix Native Staking fork tests
naddison36 May 24, 2024
4e9e24f
Fix Native Staking fork tests
naddison36 May 24, 2024
8cf9a25
Changed ssv util getClusterInfo to use the SSV API instead of the ssv…
naddison36 May 24, 2024
fc09bed
Prettier
naddison36 May 24, 2024
bb3b7e6
ValidatorRegistrator.stakeEth gas improvement when multiple validators
naddison36 May 24, 2024
e163cff
Corrected stakeEth call in OETH processes diagram
naddison36 May 24, 2024
cdb36ef
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 May 24, 2024
9d302ec
Fixes to withdrawal queue
naddison36 May 24, 2024
ef1c325
Add more withdrawal queue unit tests
naddison36 May 24, 2024
267d045
More withdrawal queue unit tests
naddison36 May 24, 2024
beb9170
Fixed adjusting the vault value for the withdrawal queue
naddison36 May 24, 2024
10259ce
Add more withdrawal queue tests
naddison36 May 24, 2024
dd7632d
Implemented withdrawAll in MockStrategy
naddison36 May 24, 2024
84d9a7f
Fixed bug in claimWithdrawals
naddison36 May 24, 2024
bb8577f
Complete code coverage of OETH Vault unit tests
naddison36 May 24, 2024
e853081
Added fork test for registering a validator twice
naddison36 May 27, 2024
12bba64
Stake funds with confirmations for front-running protection of Beacon…
sparrowDom May 28, 2024
5632653
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 May 28, 2024
0a0e9da
Updated Buyback value flow for OETH
naddison36 May 28, 2024
93b3cdf
Updated Native staking process diagram
naddison36 May 29, 2024
003fcdb
Updated OETH Vault diagrams
naddison36 May 29, 2024
9295fe7
Add process for pausing the Native Staking Strategy
naddison36 May 29, 2024
8748170
Merge remote-tracking branch 'origin/master' into sparrowDom/nativeSt…
naddison36 May 29, 2024
270a3f6
Removed the redundant condition in the fuse interval check (#2082)
naddison36 Jun 2, 2024
706da2e
OZ - Native Staking - M-01 All Addresses Are Registered Validators by…
naddison36 Jun 2, 2024
71adea7
OZ - Native Staking - N-07 Lack of Indexed Event Parameters (#2083)
naddison36 Jun 2, 2024
8f8118d
Deployed new Native Staking Strategy
naddison36 Jun 2, 2024
d398042
generated latest NativeStakingSSVStrategy docs
naddison36 Jun 2, 2024
b6c2219
P2P API changes (#2084)
naddison36 Jun 2, 2024
81b9359
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 Jun 2, 2024
49439ec
Hardhat tasks for Native Staking (#2085)
naddison36 Jun 3, 2024
8e75f24
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 Jun 3, 2024
2081919
bumped the deploy script number
naddison36 Jun 3, 2024
6ecf222
Cap the validators a Native Staking Strategy can hold (#2087)
naddison36 Jun 3, 2024
c807e8d
don't format Defender Action code in dist folder
naddison36 Jun 4, 2024
8ab4317
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 Jun 4, 2024
7f54c94
Deployed latest NativeStakingSSVStrategy contract to Holesky
naddison36 Jun 4, 2024
c4f2a30
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
naddison36 Jun 4, 2024
2c90f9f
Fix deployment file
shahthepro Jun 28, 2024
35c4848
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 3, 2024
7849b81
Merge remote-tracking branch 'origin/nicka/oeth-arm' into nicka/oeth-arm
naddison36 Jul 3, 2024
d8b0fea
updated deploy number for OETH withdrawal queue
naddison36 Jul 3, 2024
a2dada1
Fixed unit tests
naddison36 Jul 3, 2024
532e9b9
Remove stETH from Vault in OETH Withdrawal Queue deployment is not al…
naddison36 Jul 3, 2024
2075e66
Skipping OETH Vault collateral swaps
naddison36 Jul 3, 2024
4ecffac
Skipping OETH whale redeem in fork tests
naddison36 Jul 3, 2024
f2c278b
Fixed spelling in comments of VaultStorage
naddison36 Jul 3, 2024
8f46a2b
Fail CI if any mainnet fork tests fail
naddison36 Jul 3, 2024
2f90d78
Continue with fork tests if any fail but still fail the CI job
naddison36 Jul 3, 2024
bafeff1
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 3, 2024
faf9521
increment deploy script number
naddison36 Jul 3, 2024
8094ddd
restore Github Actions config
naddison36 Jul 3, 2024
e811fc7
Updated OETHVaultCore comments
naddison36 Jul 4, 2024
0cd7ac2
Upgraded OETH Vault on Holesky to include the withdrawal queue
naddison36 Jul 4, 2024
ba3c28c
Added Vault requestWithdrawal andclaimWithdrawal Hardhat tasks
naddison36 Jul 4, 2024
39d9a86
OETHVaultCore Natspec updates
naddison36 Jul 4, 2024
4e3a58d
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 5, 2024
99f17e5
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 10, 2024
f8d4974
Add 30 minute time delay between request and claim from the OETH With…
clement-ux Jul 12, 2024
b277f36
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 12, 2024
937a084
fix: test expectRevert with new error message
clement-ux Jul 12, 2024
ae24a1f
Merge remote-tracking branch 'origin/nicka/oeth-arm' into nicka/oeth-arm
naddison36 Jul 12, 2024
b07ce57
Fixed unit tests
naddison36 Jul 12, 2024
bdeb1de
Remove stETH and rETH asset from OETH Vault
naddison36 Jul 14, 2024
25f1b53
Skip legacy strategy tests
naddison36 Jul 14, 2024
3049eff
Skiped legacy Oracle prices
naddison36 Jul 14, 2024
3c9c9ec
Skipped Aura price tests
naddison36 Jul 14, 2024
14746bb
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 14, 2024
b7a6a10
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 14, 2024
dc58a1c
Remove rETH as an asset from the Vault
naddison36 Jul 15, 2024
5815778
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 15, 2024
c607bc7
Added call to cacheWETHAssetIndex after stETH is removed from the Vault
naddison36 Jul 15, 2024
33a5678
Updated vault storage diagrams
naddison36 Jul 15, 2024
cbd6764
Added second native staking strategy as the default for WETH
naddison36 Jul 15, 2024
f93f6ab
Add solvency check. (#2131)
clement-ux Jul 15, 2024
d3de400
Fixed claim Natspec now the delay is in place
naddison36 Jul 16, 2024
ecc2773
Changed console debug in assertUpgradeIsSafe to use logger
naddison36 Jul 16, 2024
74875cd
Updated Natspec
naddison36 Jul 16, 2024
5c2ab55
Assert totalValue in withdrawal queue unit tests
naddison36 Jul 16, 2024
cccc048
Merge remote-tracking branch 'origin/nicka/oeth-arm' into nicka/oeth-arm
naddison36 Jul 16, 2024
6ba210a
Fixed prettier
naddison36 Jul 16, 2024
52b2fe3
Asset vault checkBalance of WETH to OETH Vault unit tests
naddison36 Jul 16, 2024
f9e9fdd
_checkBalance and _totalValue on OETH Vault to protect against insolv…
naddison36 Jul 16, 2024
e85f4fb
Override _totalValueInVault in OETH Vault
naddison36 Jul 16, 2024
8c77769
Removed super._totalValue call
naddison36 Jul 16, 2024
6eda2ed
Fix AMO fork tests
naddison36 Jul 16, 2024
1ab9752
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 16, 2024
28e3ead
Generated latest OETH Vault diagrams
naddison36 Jul 16, 2024
e86fa11
Don't account for WETH reserved for withdrawal during allocation (#2138)
shahthepro Jul 16, 2024
0f383e0
WIP more unit tests
naddison36 Jul 16, 2024
e66dc12
Added more unit tests
naddison36 Jul 16, 2024
d67d1bf
Merge remote-tracking branch 'origin/nicka/oeth-arm' into nicka/oeth-arm
naddison36 Jul 16, 2024
61ead28
Added more withdrawal unit tests
naddison36 Jul 16, 2024
b0cd078
Fix skipped test
shahthepro Jul 16, 2024
5ac4175
Add extra test to OETH ARM. (#2139)
clement-ux Jul 17, 2024
5b61c2b
fix: reduce delay period between request and claim to 10min. (#2140)
clement-ux Jul 17, 2024
975c3c6
Refactor OETH Vault's `_allocate()` (#2141)
naddison36 Jul 17, 2024
5422808
Add extra test for OETH Withdraw Queue (#2142)
clement-ux Jul 17, 2024
839bde2
Override allocate on OETH Vault so _addWithdrawalQueueLiquidity is no…
naddison36 Jul 18, 2024
5d29d45
Skip waiting for confirmation on Tenderly testnets
shahthepro Jul 18, 2024
bb5a82a
Fix unit tests
shahthepro Jul 18, 2024
8bd687b
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 22, 2024
9135275
Add snapVault hardhat task
naddison36 Jul 25, 2024
cc6f2f3
Updated insolvency unit tests
naddison36 Jul 26, 2024
133ddcb
Added more insolvency unit tests
naddison36 Jul 26, 2024
fb765e1
Fix _totalValue so it handles when vault value is less than the outst…
naddison36 Jul 26, 2024
f3053f2
Added SafeCast to unit128
naddison36 Jul 26, 2024
22b8b2b
Reject redeems and withdrawals if no available assets due to insolvency
naddison36 Jul 26, 2024
e59268f
Redeem to no longer try and get liquidity from the default strategy i…
naddison36 Jul 26, 2024
74afa41
Simplify _wethAvailable
naddison36 Jul 26, 2024
dc46164
refactor of _claimWithdrawal
naddison36 Jul 26, 2024
4f5a57d
Generated latest OETHVaultCore diagram
naddison36 Jul 26, 2024
193ad6d
Fix Slither
naddison36 Jul 26, 2024
f4de2e6
Updated the other _wethAvailable function
naddison36 Jul 26, 2024
b9d5e00
Set Vault buffer to 0.2%
naddison36 Jul 26, 2024
acf271d
Swapped order in deploy script
naddison36 Jul 26, 2024
5978d6d
Simplify _totalValue logic
naddison36 Jul 29, 2024
6b26be9
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 29, 2024
faa060a
Moved the burn of OETH lower in the request withdrawal
naddison36 Jul 29, 2024
d16970d
Added reentrant protection to addWithdrawalQueueLiquidity
naddison36 Jul 29, 2024
b6a2fbb
Refactor _addWithdrawalQueueLiquidity
naddison36 Jul 29, 2024
0ad9592
Added vault buffer to snapVault Hardhat task
naddison36 Jul 29, 2024
eca6ffa
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 29, 2024
f15891d
fix: change `CLAIM_DELAY` visibility to `public`.
clement-ux Jul 29, 2024
365f2e0
Added SafeCast to uint128
naddison36 Jul 29, 2024
38a4b40
Refactor of _wethAvailable to use explicit returns
naddison36 Jul 29, 2024
380c3b5
Revert OETH swapCollateral now only WETH
naddison36 Jul 30, 2024
9c32a73
Generated latest OETH Vault diagrams
naddison36 Jul 30, 2024
008c8e3
Generated latest OSDU Vault diagrams
naddison36 Jul 30, 2024
2181617
Generated Dripper and Harvester diagrams
naddison36 Jul 30, 2024
1a659bc
Fix linter
naddison36 Jul 30, 2024
f9a89d3
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 30, 2024
9c78cce
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Jul 31, 2024
231459a
Fix vault storage slots
naddison36 Jul 31, 2024
d36241b
Generate new vault diagrams
naddison36 Jul 31, 2024
afba028
Fixed slither issues in VaultStorage
naddison36 Jul 31, 2024
1647eca
Skip Flux strategy fork tests as DAI market is 100% utilized which is…
naddison36 Jul 31, 2024
08536cf
Move DripperChanged event with other withdrawal queue events
naddison36 Jul 31, 2024
a5b2f70
Deployed the latest OETHVault to Holesky
naddison36 Jul 31, 2024
486cf25
Fixed Available in snapVault Hardhat task
naddison36 Jul 31, 2024
8f89126
Fixed _wethAvailable on OETHVaultAdmin to match OETHVaultCore
naddison36 Jul 31, 2024
8c25150
Fix js linter
naddison36 Jul 31, 2024
0324e41
Merge remote-tracking branch 'origin/master' into nicka/oeth-arm
naddison36 Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions contracts/contracts/interfaces/IDripper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IDripper {
/// @notice How much funds have dripped out already and are currently
// available to be sent to the vault.
/// @return The amount that would be sent if a collect was called
function availableFunds() external view returns (uint256);

/// @notice Collect all dripped funds and send to vault.
/// Recalculate new drip rate.
function collect() external;

/// @notice Collect all dripped funds, send to vault, recalculate new drip
/// rate, and rebase mToken.
function collectAndRebase() external;

/// @notice Change the drip duration. Governor only.
/// @param _durationSeconds the number of seconds to drip out the entire
/// balance over if no collects were called during that time.
function setDripDuration(uint256 _durationSeconds) external;

/// @dev Transfer out ERC20 tokens held by the contract. Governor only.
/// @param _asset ERC20 token address
/// @param _amount amount to transfer
function transferToken(address _asset, uint256 _amount) external;
}
40 changes: 40 additions & 0 deletions contracts/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ interface IVault {
);
event StrategyAddedToMintWhitelist(address indexed strategy);
event StrategyRemovedFromMintWhitelist(address indexed strategy);
event DripperChanged(address indexed _dripper);
event WithdrawalRequested(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount,
uint256 _queued
);
event WithdrawalClaimed(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount
);
event WithdrawalClaimable(uint256 _claimable, uint256 _newClaimable);

// Governable.sol
function transferGovernance(address _newGovernor) external;
Expand Down Expand Up @@ -205,6 +218,8 @@ interface IVault {

function netOusdMintedForStrategy() external view returns (int256);

function setDripper(address _dripper) external;

function weth() external view returns (address);

function cacheWETHAssetIndex() external;
Expand All @@ -225,4 +240,29 @@ interface IVault {
external
view
returns (bool);

// These are OETH specific functions
function addWithdrawalQueueLiquidity() external;

function requestWithdrawal(uint256 _amount)
external
returns (uint256 requestId, uint256 queued);

function claimWithdrawal(uint256 requestId)
external
returns (uint256 amount);

function claimWithdrawals(uint256[] memory requestIds)
external
returns (uint256[] memory amounts, uint256 totalAmount);

function withdrawalQueueMetadata()
external
view
returns (VaultStorage.WithdrawalQueueMetadata memory);

function withdrawalRequests(uint256 requestId)
external
view
returns (VaultStorage.WithdrawalRequest memory);
}
13 changes: 12 additions & 1 deletion contracts/contracts/mocks/MockStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract MockStrategy {
address[] public assets;

address public withdrawAllAsset;
address public withdrawAllRecipient;

constructor() {}

function deposit(address asset, uint256 amount) external {}
Expand All @@ -21,7 +24,10 @@ contract MockStrategy {
}

function withdrawAll() external {
require(false, "Not implemented");
IERC20(withdrawAllAsset).transfer(
withdrawAllRecipient,
IERC20(withdrawAllAsset).balanceOf(address(this))
);
}

function checkBalance(address asset)
Expand All @@ -45,4 +51,9 @@ contract MockStrategy {
{
return new address[](0);
}

function setWithdrawAll(address asset, address recipient) external {
withdrawAllAsset = asset;
withdrawAllRecipient = recipient;
}
}
93 changes: 93 additions & 0 deletions contracts/contracts/vault/OETHVaultAdmin.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,105 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { IStrategy } from "../interfaces/IStrategy.sol";
import { IVault } from "../interfaces/IVault.sol";
import { VaultAdmin } from "./VaultAdmin.sol";

/**
* @title OETH VaultAdmin Contract
* @author Origin Protocol Inc
*/
contract OETHVaultAdmin is VaultAdmin {
using SafeERC20 for IERC20;

address public immutable weth;

constructor(address _weth) {
weth = _weth;
}

/// @dev Simplified version of the deposit function as WETH is the only supported asset.
function _depositToStrategy(
address _strategyToAddress,
address[] calldata _assets,
uint256[] calldata _amounts
) internal override {
require(
strategies[_strategyToAddress].isSupported,
"Invalid to Strategy"
);
require(
_assets.length == 1 && _amounts.length == 1 && _assets[0] == weth,
"Only WETH is supported"
);

// Check the there is enough WETH to transfer once the WETH reserved for the withdrawal queue is accounted for
require(_amounts[0] <= _wethAvailable(), "Not enough WETH available");

// Send required amount of funds to the strategy
IERC20(weth).safeTransfer(_strategyToAddress, _amounts[0]);

// Deposit all the funds that have been sent to the strategy
IStrategy(_strategyToAddress).depositAll();
}

function _withdrawFromStrategy(
address _recipient,
address _strategyFromAddress,
address[] calldata _assets,
uint256[] calldata _amounts
) internal override {
super._withdrawFromStrategy(
_recipient,
_strategyFromAddress,
_assets,
_amounts
);

IVault(address(this)).addWithdrawalQueueLiquidity();
}

function _withdrawAllFromStrategy(address _strategyAddr) internal override {
super._withdrawAllFromStrategy(_strategyAddr);

IVault(address(this)).addWithdrawalQueueLiquidity();
}

function _withdrawAllFromStrategies() internal override {
super._withdrawAllFromStrategies();

IVault(address(this)).addWithdrawalQueueLiquidity();
}

/// @dev Calculate how much WETH in the vault is not reserved for the withdrawal queue.
// That is, it is available to be redeemed or deposited into a strategy.
function _wethAvailable() internal view returns (uint256 wethAvailable) {
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;

// The amount of WETH that is still to be claimed in the withdrawal queue
uint256 outstandingWithdrawals = queue.queued - queue.claimed;

// The amount of sitting in WETH in the vault
uint256 wethBalance = IERC20(weth).balanceOf(address(this));

// If there is not enough WETH in the vault to cover the outstanding withdrawals
if (wethBalance <= outstandingWithdrawals) {
return 0;
}

return wethBalance - outstandingWithdrawals;
}

function _swapCollateral(
address,
address,
uint256,
uint256,
bytes calldata
) internal pure override returns (uint256) {
revert("Collateral swap not supported");
}
}
Loading