Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 11 additions & 12 deletions contracts/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ interface IVault {
) external;

// VaultCore.sol

/// @notice Deprecated: use `mint(uint256 _amount)` instead.
function mint(
address _asset,
uint256 _amount,
Expand All @@ -137,17 +139,6 @@ interface IVault {

function checkBalance(address _asset) external view returns (uint256);

/// @notice Deprecated: use calculateRedeemOutput
function calculateRedeemOutputs(uint256 _amount)
external
view
returns (uint256[] memory);

function calculateRedeemOutput(uint256 _amount)
external
view
returns (uint256);

function getAssetCount() external view returns (uint256);

function getAllAssets() external view returns (address[] memory);
Expand All @@ -156,13 +147,20 @@ interface IVault {

function getAllStrategies() external view returns (address[] memory);

/// @notice Deprecated.
function strategies(address _addr)
external
view
returns (VaultStorage.Strategy memory);

/// @notice Deprecated: use `asset()` instead.
function isSupportedAsset(address _asset) external view returns (bool);

function dripper() external view returns (address);

function asset() external view returns (address);

function oToken() external view returns (address);

function initialize(address) external;

function addWithdrawalQueueLiquidity() external;
Expand Down Expand Up @@ -216,6 +214,7 @@ interface IVault {

function previewYield() external view returns (uint256 yield);

/// @notice Deprecated: user `asset()` instead.
function weth() external view returns (address);

// slither-disable-end constable-states
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ contract OETHSupernovaAMOStrategy is StableSwapAMMStrategy {
/**
* @param _baseConfig The `platformAddress` is the address of the Supernova OETH/WETH pool.
* The `vaultAddress` is the address of the OETH Vault.
* @param _oeth Address of the OETH token.
* @param _weth Address of the WETH token.
* @param _gauge Address of the Supernova gauge for the pool.
*/
constructor(
BaseStrategyConfig memory _baseConfig,
address _oeth,
address _weth,
address _gauge
) StableSwapAMMStrategy(_baseConfig, _oeth, _weth, _gauge) {}
constructor(BaseStrategyConfig memory _baseConfig, address _gauge)
StableSwapAMMStrategy(_baseConfig, _gauge)
{}
}
19 changes: 19 additions & 0 deletions contracts/contracts/strategies/algebra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Diagrams

## OETH Supernova AMO Strategy

### Hierarchy

![OETH Supernova AMO Strategy Hierarchy](../../../docs/OETHSupernovaAMOStrategyHierarchy.svg)

### Interactions

![OETH Supernova AMO Strategy Interactions](../../../docs/OETHSupernovaAMOStrategyInteractions.svg)

### Squashed

![OETH Supernova AMO Strategy Squashed](../../../docs/OETHSupernovaAMOStrategySquashed.svg)

### Storage

![OETH Supernova AMO Strategy Storage](../../../docs/OETHSupernovaAMOStrategyStorage.svg)
30 changes: 15 additions & 15 deletions contracts/contracts/strategies/algebra/StableSwapAMMStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,19 @@ contract StableSwapAMMStrategy is InitializableAbstractStrategy {
/**
* @param _baseConfig The `platformAddress` is the address of the Algebra pool.
* The `vaultAddress` is the address of the Origin Sonic Vault.
* @param _oToken Address of the OToken.
* @param _asset Address of the asset token.
* @param _gauge Address of the Algebra gauge for the pool.
*/
constructor(
BaseStrategyConfig memory _baseConfig,
address _oToken,
address _asset,
address _gauge
) InitializableAbstractStrategy(_baseConfig) {
constructor(BaseStrategyConfig memory _baseConfig, address _gauge)
InitializableAbstractStrategy(_baseConfig)
{
// Read the oToken address from the Vault
address oTokenMem = IVault(_baseConfig.vaultAddress).oToken();
address assetMem = IVault(_baseConfig.vaultAddress).asset();

// Checked both tokens are to 18 decimals
require(
IBasicToken(_asset).decimals() == 18 &&
IBasicToken(_oToken).decimals() == 18,
IBasicToken(assetMem).decimals() == 18 &&
IBasicToken(oTokenMem).decimals() == 18,
"Incorrect token decimals"
);
// Check the Algebra pool is a Stable AMM (sAMM)
Expand All @@ -180,21 +179,22 @@ contract StableSwapAMMStrategy is InitializableAbstractStrategy {
IGauge(_gauge).TOKEN() == _baseConfig.platformAddress,
"Incorrect gauge"
);
oTokenPoolIndex = IPair(_baseConfig.platformAddress).token0() == _oToken
oTokenPoolIndex = IPair(_baseConfig.platformAddress).token0() ==
oTokenMem
? 0
: 1;
// Check the pool tokens are correct
require(
IPair(_baseConfig.platformAddress).token0() ==
(oTokenPoolIndex == 0 ? _oToken : _asset) &&
(oTokenPoolIndex == 0 ? oTokenMem : assetMem) &&
IPair(_baseConfig.platformAddress).token1() ==
(oTokenPoolIndex == 0 ? _asset : _oToken),
(oTokenPoolIndex == 0 ? assetMem : oTokenMem),
"Incorrect pool tokens"
);

// Set the immutable variables
oToken = _oToken;
asset = _asset;
oToken = oTokenMem;
asset = assetMem;
pool = _baseConfig.platformAddress;
gauge = _gauge;

Expand Down
11 changes: 3 additions & 8 deletions contracts/contracts/strategies/sonic/SonicSwapXAMOStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ contract SonicSwapXAMOStrategy is StableSwapAMMStrategy {
/**
* @param _baseConfig The `platformAddress` is the address of the SwapX pool.
* The `vaultAddress` is the address of the Origin Sonic Vault.
* @param _os Address of the OS token.
* @param _ws Address of the Wrapped S (wS) token.
* @param _gauge Address of the SwapX gauge for the pool.
*/
constructor(
BaseStrategyConfig memory _baseConfig,
address _os,
address _ws,
address _gauge
) StableSwapAMMStrategy(_baseConfig, _os, _ws, _gauge) {}
constructor(BaseStrategyConfig memory _baseConfig, address _gauge)
StableSwapAMMStrategy(_baseConfig, _gauge)
{}
}
32 changes: 3 additions & 29 deletions contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,16 +813,13 @@ const getPlumeContracts = async () => {
};

const deploySonicSwapXAMOStrategyImplementation = async () => {
const cOSonicProxy = await ethers.getContract("OSonicProxy");
const cOSonicVaultProxy = await ethers.getContract("OSonicVaultProxy");

// Deploy Sonic SwapX AMO Strategy implementation
const dSonicSwapXAMOStrategy = await deployWithConfirmation(
"SonicSwapXAMOStrategy",
[
[addresses.sonic.SwapXWSOS.pool, cOSonicVaultProxy.address],
cOSonicProxy.address,
addresses.sonic.wS,
addresses.sonic.SwapXWSOS.gauge,
]
);
Expand Down Expand Up @@ -869,22 +866,14 @@ const deploySonicSwapXAMOStrategyImplementationAndInitialize = async () => {
const deployOETHSupernovaAMOStrategyPoolAndGauge = async () => {
// Account authorized to call createPair on the factory contract
const pairBootstrapper = "0x7F8f2B6D0b0AaE8e95221Ce90B5C26B128C1Cb66";
const topkenHandlerWhitelister = "0xD09A1388F0CcE25DA97E8bBAbf5D083E25a5Fbc6";
const sPairBootstrapper = await impersonateAndFund(pairBootstrapper);
const sTokenHandlerWhitelister = await impersonateAndFund(
topkenHandlerWhitelister
);

const oeth = await ethers.getContract("OETHProxy");

const factoryABI = [
"function createPair(address tokenA, address tokenB, bool stable) external returns (address pair)",
"event PairCreated(address token0, address token1, bool stable, address pair, uint);",
];
const tokenHandlerABI = [
"function whitelistToken(address _token) external",
"function whitelistConnector(address _token) external",
];
const pairCreatedTopic =
"0xc4805696c66d7cf352fc1d6bb633ad5ee82f6cb577c453024b6e0eb8306c6fc9";

Expand All @@ -897,18 +886,14 @@ const deployOETHSupernovaAMOStrategyPoolAndGauge = async () => {
gaugeManagerAbi,
addresses.mainnet.supernovaGaugeManager
);
const tokenHandler = await ethers.getContractAt(
tokenHandlerABI,
await gaugeManager.tokenHandler()
);

const factory = await ethers.getContractAt(
factoryABI,
addresses.mainnet.supernovaPairFactory
);

let poolAddress;
log("Creating new OETH/WETH pair...");
console.log("Creating new OETH/WETH pair...");
const tx = await factory
.connect(sPairBootstrapper)
.createPair(oeth.address, addresses.mainnet.WETH, true);
Expand All @@ -923,14 +908,9 @@ const deployOETHSupernovaAMOStrategyPoolAndGauge = async () => {
);
console.log("Pair address:", pairAddress);

console.log("Whitelisting OETH token");
await tokenHandler
.connect(sTokenHandlerWhitelister)
.whitelistToken(oeth.address);

poolAddress = pairAddress;

log("Creating gauge for OETH/WETH...");
console.log("Creating gauge for OETH/WETH...");
const gaugeCreatedTopic = ethers.utils.id(
"GaugeCreated(address,address,address,address,address)"
);
Expand Down Expand Up @@ -959,19 +939,13 @@ const deployOETHSupernovaAMOStrategyImplementation = async (
const cOETHSupernovaAMOStrategyProxy = await ethers.getContract(
"OETHSupernovaAMOProxy"
);
const cOETHProxy = await ethers.getContract("OETHProxy");
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");

// Deploy OETH Supernova AMO Strategy implementation that will serve
// OETH Supernova AMO
const dSupernovaAMOStrategy = await deployWithConfirmation(
"OETHSupernovaAMOStrategy",
[
[poolAddress, cOETHVaultProxy.address],
cOETHProxy.address,
addresses.mainnet.WETH,
gaugeAddress,
]
[[poolAddress, cOETHVaultProxy.address], gaugeAddress]
);

const cOETHSupernovaAMOStrategy = await ethers.getContractAt(
Expand Down
75 changes: 75 additions & 0 deletions contracts/docs/OETHSupernovaAMOStrategyHierarchy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading