Skip to content
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

Deploy stargate #963

Merged
merged 13 commits into from
Oct 16, 2023
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
restore-keys: |
hardhat-network-fork-${{ runner.os }}-
hardhat-network-fork-
- run: npx hardhat test ./test/plugins/individual-collateral/cbeth/*.test.ts
- run: npx hardhat test ./test/plugins/individual-collateral/{stargate,cbeth}/*.test.ts
env:
NODE_OPTIONS: '--max-old-space-size=8192'
TS_NODE_SKIP_IGNORE: true
Expand Down
8 changes: 8 additions & 0 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface ITokens {
cbETH?: string
STG?: string
sUSDC?: string
sUSDbC?: string
pmckelvy1 marked this conversation as resolved.
Show resolved Hide resolved
sUSDT?: string
sETH?: string
MORPHO?: string
Expand Down Expand Up @@ -112,6 +113,7 @@ interface INetworkConfig {
COMET_REWARDS?: string
AAVE_V3_INCENTIVES_CONTROLLER?: string
AAVE_V3_POOL?: string
STARGATE_STAKING_CONTRACT?: string
}

export const networkConfig: { [key: string]: INetworkConfig } = {
Expand Down Expand Up @@ -218,6 +220,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
STARGATE_STAKING_CONTRACT: '0xB0D502E938ed5f4df2E681fE6E419ff29631d62b'
},
'1': {
name: 'mainnet',
Expand Down Expand Up @@ -313,6 +316,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
STARGATE_STAKING_CONTRACT: '0xB0D502E938ed5f4df2E681fE6E419ff29631d62b'
},
'3': {
name: 'tenderly',
Expand Down Expand Up @@ -408,6 +412,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
COMET_REWARDS: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
AAVE_V3_POOL: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
AAVE_V3_INCENTIVES_CONTROLLER: '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb',
STARGATE_STAKING_CONTRACT: '0xB0D502E938ed5f4df2E681fE6E419ff29631d62b'
},
'5': {
name: 'goerli',
Expand Down Expand Up @@ -510,6 +515,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
aBasUSDbC: '0x0a1d576f3eFeF75b330424287a95A366e8281D54',
aWETHv3: '0xD4a0e0b9149BCee3C920d2E00b5dE09138fd8bb7',
acbETHv3: '0xcf3D55c10DB69f28fD1A75Bd73f3D8A2d9c595ad',
sUSDbC: '0x4c80e24119cfb836cdf0a6b53dc23f04f7e652ca',
STG: '0xE3B53AF74a4BF62Ae5511055290838050bf764Df'
},
chainlinkFeeds: {
DAI: '0x591e79239a7d679378ec8c847e5038150364c78f', // 0.3%, 24hr
Expand All @@ -527,6 +534,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
COMET_REWARDS: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
AAVE_V3_POOL: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5',
AAVE_V3_INCENTIVES_CONTROLLER: '0xf9cc4F0D883F1a1eb2c253bdb46c254Ca51E1F44',
STARGATE_STAKING_CONTRACT: '0x06Eb48763f117c7Be887296CDcdfad2E4092739C'
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ contract StargateRewardableWrapper is RewardableERC20Wrapper {
address(pool_) != address(0),
"Invalid address"
);
require(address(stargate_) == address(stakingContract_.stargate()), "Wrong stargate");
try stakingContract_.stargate() returns (address stargateAddress) {
require(stargateAddress == address(stargate_), "Wrong stargate");
} catch {
// using LPStakingTime contract instead
require(stakingContract_.eToken() == address(stargate_), "Wrong stargate");
}

uint256 poolLength = stakingContract_.poolLength();
uint256 pid = type(uint256).max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface IStargateLPStaking {
function poolLength() external view returns (uint256);

function stargate() external view returns (IERC20);
function stargate() external view returns (address);
function eToken() external view returns (address);

// Info of each pool.
struct PoolInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ contract StargateLPStakingMock is IStargateLPStaking {
mapping(uint256 => mapping(address => uint256)) poolToUserBalance;

ERC20Mock public immutable stargateMock;
IERC20 public immutable stargate;
address public immutable stargate;
address public immutable eToken;

uint256 public totalAllocPoint = 0;

constructor(ERC20Mock stargateMock_) {
stargateMock = stargateMock_;
stargate = stargateMock_;
stargate = address(stargateMock_);
eToken = address(stargateMock_);
}

function poolLength() external view override returns (uint256) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
STAKING_CONTRACT,
SUSDC,
} from '../../../../test/plugins/individual-collateral/stargate/constants'
import { useEnv } from '#/utils/env'

async function main() {
// ==== Read Configuration ====
Expand Down Expand Up @@ -50,19 +51,31 @@ async function main() {

/******** Deploy Stargate USDC Wrapper **************************/

const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('StargatePoolWrapper')
const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('StargateRewardableWrapper')
let chainIdKey = useEnv('FORK_NETWORK', 'mainnet') == 'mainnet' ? '1' : '8453'
let USDC_NAME = 'USDC'
let name = 'Wrapped Stargate USDC'
let symbol = 'wSTG-USDC'
let sUSDC = networkConfig[chainIdKey].tokens.sUSDC

if (chainIdKey == '8453') {
USDC_NAME = 'USDbC'
name = 'Wrapped Stargate USDbC'
symbol = 'wSTG-USDbC'
sUSDC = networkConfig[chainIdKey].tokens.sUSDbC
}

const erc20 = await WrapperFactory.deploy(
'Wrapped Stargate USDC',
'wSTG-USDC',
networkConfig[chainId].tokens.STG,
STAKING_CONTRACT,
SUSDC
name,
symbol,
networkConfig[chainIdKey].tokens.STG,
networkConfig[chainIdKey].STARGATE_STAKING_CONTRACT,
sUSDC
)
await erc20.deployed()

console.log(
`Deployed Wrapper for Stargate USDC on ${hre.network.name} (${chainId}): ${erc20.address} `
`Deployed Wrapper for Stargate ${USDC_NAME} on ${hre.network.name} (${chainIdKey}): ${erc20.address} `
)

const StargateCollateralFactory: StargatePoolFiatCollateral__factory =
Expand All @@ -73,11 +86,11 @@ async function main() {
).deploy(
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDC!,
chainlinkFeed: networkConfig[chainIdKey].chainlinkFeeds.USDC!,
oracleError: fp('0.0025').toString(), // 0.25%,
erc20: erc20.address,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24h hr,
oracleTimeout: oracleTimeout(chainIdKey, '86400').toString(), // 24h hr,
targetName: hre.ethers.utils.formatBytes32String('USD'),
defaultThreshold: fp('0.0125').toString(), // 1.25%
delayUntilDefault: bn('86400').toString(), // 24h
Expand All @@ -88,7 +101,7 @@ async function main() {
await (await collateral.refresh()).wait()
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

console.log(`Deployed Stargate USDC to ${hre.network.name} (${chainId}): ${collateral.address}`)
console.log(`Deployed Stargate ${USDC_NAME} to ${hre.network.name} (${chainIdKey}): ${collateral.address}`)

assetCollDeployments.collateral.sUSDC = collateral.address
assetCollDeployments.erc20s.sUSDC = erc20.address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function main() {

/******** Deploy Stargate USDT Wrapper **************************/

const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('StargatePoolWrapper')
const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('StargateRewardableWrapper')

const erc20 = await WrapperFactory.deploy(
'Wrapped Stargate USDT',
Expand Down
Loading