Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
68d54df
initial Sonic Curve AMO deploy script
naddison36 Feb 11, 2025
8670942
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Feb 11, 2025
8819f3b
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Feb 11, 2025
8b2b94d
Set governor to zero address on Vault implementation contracts
naddison36 Feb 12, 2025
986abf8
Base OETH Vault to get full async withdrawal support
naddison36 Feb 12, 2025
20375e6
Moved support for multi AMOs up to the OETH Vault
naddison36 Feb 12, 2025
67d078a
FIxed address used in StrategyAddedToMintWhitelist and StrategyRemove…
naddison36 Feb 13, 2025
6a6cf97
Fixed Base unit tests
naddison36 Feb 13, 2025
163dbff
Generated latest contract diagrams
naddison36 Feb 13, 2025
397ce1d
WIP Sonic Curve AMO fork tests
naddison36 Feb 13, 2025
a9a3193
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Feb 14, 2025
3abade8
Fixed OETH Vault unit tests
naddison36 Feb 14, 2025
e6a7c4b
Changed logging in withConfirmation function
naddison36 Feb 14, 2025
07ee3c8
FIxed logging in findBalancesSlot
naddison36 Feb 14, 2025
f919c9f
Added upgrade of the OETH Vault so it can use multiple AMOs
naddison36 Feb 14, 2025
75949f4
Removed CRV and CVX from OUSD Harvester
naddison36 Feb 14, 2025
51cf551
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Feb 17, 2025
44f7fef
Added Harvester to Sonic
naddison36 Feb 17, 2025
a50dcf9
Base Curve AMO strategy withdrawAll with no assets
naddison36 Feb 17, 2025
1089129
Fixed Sonic unit tests
naddison36 Feb 17, 2025
17d6c9e
Fixed Base Curve AMO fork tests
naddison36 Feb 17, 2025
79874b8
Changed Curve AMO strategy to BUSL-1.1 license
naddison36 Feb 17, 2025
affda22
Upgrade Base Vault with Curve AMO strategy
naddison36 Feb 18, 2025
214bd77
Increase number for Mainnet deploy script
naddison36 Feb 18, 2025
d349629
Updated Sonic contract diagrams
naddison36 Feb 18, 2025
ecdedc8
Generated latest Dripper and Harvester diagrams
naddison36 Feb 18, 2025
666f36c
Updated Sonic contract diagram
naddison36 Feb 18, 2025
f2766ed
Updated Sonic contracts diagram
naddison36 Feb 18, 2025
e9e4887
Added withinRange Chai matcher
naddison36 Feb 24, 2025
c656828
Use Waffle's emit matcher for events
naddison36 Feb 24, 2025
557ee3b
Change emittedEvent matcher to use exist instead of undefined assertion
naddison36 Feb 24, 2025
5fbc481
Use new emittedEvent Chai matcher
naddison36 Feb 24, 2025
4f8839c
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Feb 24, 2025
2bcabd1
WIP SwapX AMO strategy
naddison36 Feb 19, 2025
85a2f9b
Added rebalancing functions
naddison36 Feb 20, 2025
a7e11bd
Added strategyValueChecker modifier to rebalance functions
naddison36 Feb 20, 2025
8efda4a
Added SwapX AMO deploy script
naddison36 Feb 20, 2025
8830c9c
Prettier
naddison36 Feb 20, 2025
d91f574
WIP creating the gauge in the deploy script
naddison36 Feb 25, 2025
7ea30af
Removed most of the logging
naddison36 Feb 25, 2025
0f1ff27
Started SwapX AMO fork tests
naddison36 Feb 25, 2025
a951e10
Update SwapX AMO fork tests
naddison36 Feb 26, 2025
1765d20
Merge remote-tracking branch 'origin/nicka/chai-matchers' into nicka/…
naddison36 Feb 26, 2025
ec174e9
More SwapX AMO fork tests
naddison36 Feb 26, 2025
9593982
Used snapData and assertChangedData in SwapX AMO fork tests
naddison36 Feb 26, 2025
7bbe228
Config of gauge
naddison36 Feb 26, 2025
0d78b3c
More fork tests
naddison36 Feb 26, 2025
767d598
More SwapX AMO fork tests
naddison36 Feb 27, 2025
e915cdb
Fixed _swapExactTokensForTokens swapping OS in
naddison36 Mar 3, 2025
1a09566
Minor SonicSwapXAMOStrategy changes
naddison36 Mar 3, 2025
e720766
More SwapX AMO fork tests
naddison36 Mar 3, 2025
5c6bb89
More SwapX AMO fork tests
naddison36 Mar 3, 2025
cb89556
More SwapX fork testing
naddison36 Mar 3, 2025
d84eab4
Gov actions to change OS Vault config
naddison36 Mar 4, 2025
75c0251
Changed the Sonic Vault buffer to 0.5%
naddison36 Mar 4, 2025
4ef572d
Fix Sonic unit tests
naddison36 Mar 4, 2025
555f22a
Prettier
naddison36 Mar 4, 2025
0b322f0
Ran Sonic 012 deployment
naddison36 Mar 4, 2025
4ad9ee1
Merge remote-tracking branch 'origin/master' into nicka/sonic-deploy-…
naddison36 Mar 4, 2025
6bbafeb
Prettier
naddison36 Mar 4, 2025
139c6c1
Fixed schedule Timelock
naddison36 Mar 4, 2025
bbcd808
Merge remote-tracking branch 'origin/master' into nicka/sonic-swapx-amo
naddison36 Mar 4, 2025
f94b862
Merge remote-tracking branch 'origin/nicka/sonic-deploy-012-vault-con…
naddison36 Mar 4, 2025
3841560
Fix fork tests
naddison36 Mar 4, 2025
ba7b9cd
Merge remote-tracking branch 'origin/master' into nicka/sonic-swapx-amo
naddison36 Mar 4, 2025
bbf8281
Updated deploy script number
naddison36 Mar 4, 2025
c674f1c
Check pool and gauge in the constructor
naddison36 Mar 4, 2025
a76a73e
Added amm param to amoStrat Hardhat task
naddison36 Mar 5, 2025
0fe013d
New checkBalance implementation for SwapX AMO
naddison36 Mar 5, 2025
1629ddd
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Mar 6, 2025
0ac28ca
Merge remote-tracking branch 'origin/nicka/sonic-curve-amo' into nick…
naddison36 Mar 6, 2025
485879f
Updated deploy script number
naddison36 Mar 6, 2025
2db02d1
Merge remote-tracking branch 'origin/nicka/sonic-curve-amo' into nick…
naddison36 Mar 6, 2025
264589c
Polish SwapX AMO strategy contract
naddison36 Mar 6, 2025
c19a5ce
Polish the SwapX AMO contract
naddison36 Mar 6, 2025
41e271a
Got fork tests working again
naddison36 Mar 6, 2025
66d2bb3
Improved SwapX AMO fork tests
naddison36 Mar 7, 2025
a0ec2bd
More SwapX AMO fork testing
naddison36 Mar 7, 2025
0cb258b
Changed _calcTokensToBurn in contract
naddison36 Mar 7, 2025
e081a43
Removed unnecessary line in withinRange matcher
naddison36 Mar 7, 2025
ee34c7f
Removed use of safeTransfer
naddison36 Mar 7, 2025
1813846
More SwapX AMO fork tests
naddison36 Mar 7, 2025
17dc926
More SwapX AMO fork tests
naddison36 Mar 7, 2025
e57f13e
Added SwapX AMO Strategy contracts to diagrams
naddison36 Mar 7, 2025
9ecd643
Added Slither ignore
naddison36 Mar 7, 2025
c138b89
Using safeTransfer for SwapX AMO
naddison36 Mar 7, 2025
280a70b
Swapped the deployment order of Curve AMO and SwapX AMO
naddison36 Mar 11, 2025
f901dcf
Added SWPx the Harvester in Sonic contract diagram
naddison36 Mar 11, 2025
b3ff532
Merge remote-tracking branch 'origin/master' into nicka/sonic-curve-amo
naddison36 Mar 11, 2025
83c5c81
Changed mainnet deploy number after merge with master
naddison36 Mar 11, 2025
c606558
Removed Sonic Curve AMO
naddison36 Mar 11, 2025
fec91b8
Merge remote-tracking branch 'origin/master' into nicka/sonic-swapx-amo
naddison36 Mar 11, 2025
9af2bc3
Removed Curve AMO from Sonic fixture
naddison36 Mar 11, 2025
031416d
Fixed Sonic fork tests
naddison36 Mar 11, 2025
70eb772
Merge remote-tracking branch 'origin/nicka/sonic-swapx-amo' into nick…
naddison36 Mar 11, 2025
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
3 changes: 3 additions & 0 deletions contracts/contracts/harvest/OETHHarvesterSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ contract OETHHarvesterSimple is Initializable, Strategizable {
////////////////////////////////////////////////////
constructor(address _wrappedNativeToken) {
wrappedNativeToken = _wrappedNativeToken;

// prevent implementation contract to be governed
_setGovernor(address(1));
}

/// @notice Initialize the contract
Expand Down
11 changes: 11 additions & 0 deletions contracts/contracts/harvest/OSonicHarvester.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { SuperOETHHarvester } from "./SuperOETHHarvester.sol";

contract OSonicHarvester is SuperOETHHarvester {
/// @param _wrappedNativeToken Address of the native Wrapped S (wS) token
constructor(address _wrappedNativeToken)
SuperOETHHarvester(_wrappedNativeToken)
{}
}
52 changes: 44 additions & 8 deletions contracts/contracts/harvest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Dripper

Used by OUSD on Mainnet.

### Hierarchy

![Dripper Hierarchy](../../docs/DripperHierarchy.svg)
Expand All @@ -14,22 +16,26 @@

![Dripper Storage](../../docs/DripperStorage.svg)

## OETH Dripper
## Fixed Rate Dripper

Used on Mainnet for OETH, Base and Sonic.

### Hierarchy

![OETH Dripper Hierarchy](../../docs/OETHDripperHierarchy.svg)
![Fixed Rate Dripper Hierarchy](../../docs/OETHFixedRateDripperHierarchy.svg)

### Squashed

![OETH Dripper Squashed](../../docs/OETHDripperSquashed.svg)
![Fixed Rate Dripper Squashed](../../docs/OETHFixedRateDripperSquashed.svg)

### Storage

![OETH Dripper Storage](../../docs/OETHDripperStorage.svg)
![Fixed Rate Dripper Storage](../../docs/OETHFixedRateDripperStorage.svg)

## Harvester

Used on Mainnet for OUSD.

### Hierarchy

![Harvester Hierarchy](../../docs/HarvesterHierarchy.svg)
Expand All @@ -42,16 +48,46 @@

![Harvester Storage](../../docs/HarvesterStorage.svg)

## OETH Harvester
## OETH Simple Harvester

Used on Mainnet for OETH.

### Hierarchy

![OETH Simple Harvester Hierarchy](../../docs/OETHHarvesterSimpleHierarchy.svg)

### Squashed

![OETH Simple Harvester Squashed](../../docs/OETHHarvesterSimpleSquashed.svg)

### Storage

![OETH Simple Harvester Storage](../../docs/OETHHarvesterSimpleStorage.svg)

## Base Harvester

### Hierarchy

![OETH Base Harvester Hierarchy](../../docs/OETHBaseHarvesterHierarchy.svg)

### Squashed

![OETH Base Harvester Squashed](../../docs/OETHBaseHarvesterSquashed.svg)

### Storage

![OETH Base Harvester Storage](../../docs/OETHBaseHarvesterStorage.svg)

## Sonic Harvester

### Hierarchy

![OETH Harvester Hierarchy](../../docs/OETHHarvesterHierarchy.svg)
![Sonic Harvester Hierarchy](../../docs/OSonicHarvesterHierarchy.svg)

### Squashed

![OETH Harvester Squashed](../../docs/OETHHarvesterSquashed.svg)
![Sonic Harvester Squashed](../../docs/OSonicHarvesterSquashed.svg)

### Storage

![OETH Harvester Storage](../../docs/OETHHarvesterStorage.svg)
![Sonic Harvester Storage](../../docs/OSonicHarvesterStorage.svg)
54 changes: 54 additions & 0 deletions contracts/contracts/interfaces/sonic/ISwapXGauge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IGauge {
function TOKEN() external view returns (address);

function balanceOf(address account) external view returns (uint256);

function claimFees() external returns (uint256 claimed0, uint256 claimed1);

function deposit(uint256 amount) external;

function depositAll() external;

function earned(address account) external view returns (uint256);

function getReward() external;

function getReward(address _user) external;

function isForPair() external view returns (bool);

function lastTimeRewardApplicable() external view returns (uint256);

function lastUpdateTime() external view returns (uint256);

function notifyRewardAmount(address token, uint256 reward) external;

function periodFinish() external view returns (uint256);

function rewardForDuration() external view returns (uint256);

function rewardPerToken() external view returns (uint256);

function rewardPerTokenStored() external view returns (uint256);

function rewardRate() external view returns (uint256);

function rewardToken() external view returns (address);

function rewards(address) external view returns (uint256);

function totalSupply() external view returns (uint256);

function userRewardPerTokenPaid(address) external view returns (uint256);

function withdraw(uint256 amount) external;

function withdrawAll() external;

function withdrawAllAndHarvest() external;

function withdrawExcess(address token, uint256 amount) external;
}
122 changes: 122 additions & 0 deletions contracts/contracts/interfaces/sonic/ISwapXPair.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IPair {
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);

event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(
address indexed sender,
uint256 amount0,
uint256 amount1,
address indexed to
);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Claim(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1
);

function metadata()
external
view
returns (
uint256 dec0,
uint256 dec1,
uint256 r0,
uint256 r1,
bool st,
address t0,
address t1
);

function claimFees() external returns (uint256, uint256);

function tokens() external view returns (address, address);

function token0() external view returns (address);

function token1() external view returns (address);

function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;

function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;

function burn(address to)
external
returns (uint256 amount0, uint256 amount1);

function mint(address to) external returns (uint256 liquidity);

function getReserves()
external
view
returns (
uint256 _reserve0,
uint256 _reserve1,
uint256 _blockTimestampLast
);

function getAmountOut(uint256, address) external view returns (uint256);

// ERC20 methods
function name() external view returns (string memory);

function symbol() external view returns (string memory);

function decimals() external view returns (uint8);

function totalSupply() external view returns (uint256);

function balanceOf(address) external view returns (uint256);

function transfer(address recipient, uint256 amount)
external
returns (bool);

function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);

function allowance(address owner, address spender)
external
view
returns (uint256);

function approve(address spender, uint256 value) external returns (bool);

function claimable0(address _user) external view returns (uint256);

function claimable1(address _user) external view returns (uint256);

function isStable() external view returns (bool);

function skim(address to) external;

function sync() external;
}
15 changes: 15 additions & 0 deletions contracts/contracts/interfaces/sonic/IVoterV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IVoterV3 {
/// @notice create a gauge
function createGauge(address _pool, uint256 _gaugeType)
external
returns (
address _gauge,
address _internal_bribe,
address _external_bribe
);

function gauges(address _pool) external view returns (address _gauge);
}
9 changes: 9 additions & 0 deletions contracts/contracts/interfaces/sonic/IWrappedSonic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
pragma solidity ^0.8.0;

interface IWrappedSonic {
event Deposit(address indexed account, uint256 value);
event Withdrawal(address indexed account, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);

function allowance(address owner, address spender)
external
view
Expand Down
16 changes: 15 additions & 1 deletion contracts/contracts/proxies/SonicProxies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ contract SonicStakingStrategyProxy is InitializeGovernedUpgradeabilityProxy {
}

/**
* @notice OSonicHarvesterProxy delegates calls to a OETHHarvesterSimple implementation
* @notice OSonicHarvesterProxy delegates calls to a OSonicHarvester implementation
*/
contract OSonicHarvesterProxy is InitializeGovernedUpgradeabilityProxy {

}

/**
* @notice SonicCurveAMOStrategyProxy delegates calls to a SonicCurveAMOStrategy implementation
*/
contract SonicCurveAMOStrategyProxy is InitializeGovernedUpgradeabilityProxy {

}

/**
* @notice SonicSwapXAMOStrategyProxy delegates calls to a SonicSwapXAMOStrategy implementation
*/
contract SonicSwapXAMOStrategyProxy is InitializeGovernedUpgradeabilityProxy {

}
15 changes: 11 additions & 4 deletions contracts/contracts/strategies/BaseCurveAMOStrategy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

/**
Expand Down Expand Up @@ -60,8 +60,8 @@ contract BaseCurveAMOStrategy is InitializableAbstractStrategy {
IChildLiquidityGaugeFactory public immutable gaugeFactory;

// Ordered list of pool assets
uint128 public constant oethCoinIndex = 1;
uint128 public constant wethCoinIndex = 0;
uint128 public immutable oethCoinIndex;
uint128 public immutable wethCoinIndex;

/**
* @notice Maximum slippage allowed for adding/removing liquidity from the Curve pool.
Expand Down Expand Up @@ -124,8 +124,13 @@ contract BaseCurveAMOStrategy is InitializableAbstractStrategy {
address _oeth,
address _weth,
address _gauge,
address _gaugeFactory
address _gaugeFactory,
uint128 _oethCoinIndex,
uint128 _wethCoinIndex
) InitializableAbstractStrategy(_baseConfig) {
oethCoinIndex = _oethCoinIndex;
wethCoinIndex = _wethCoinIndex;

lpToken = IERC20(_baseConfig.platformAddress);
curvePool = ICurveStableSwapNG(_baseConfig.platformAddress);

Expand Down Expand Up @@ -335,6 +340,8 @@ contract BaseCurveAMOStrategy is InitializableAbstractStrategy {
*/
function withdrawAll() external override onlyVaultOrGovernor nonReentrant {
uint256 gaugeTokens = gauge.balanceOf(address(this));
// Can not withdraw zero LP tokens from the gauge
if (gaugeTokens == 0) return;
_lpWithdraw(gaugeTokens);

// Withdraws are proportional to assets held by 3Pool
Expand Down
Loading
Loading