Skip to content

Commit

Permalink
final(ly) last configuration of legacy market (#279)
Browse files Browse the repository at this point in the history
* final(ly) last configuration of legacy market

this is the one to put it on mainnet!

* Update omnibus-mainnet.toml

Co-authored-by: Noisekit <[email protected]>

* Update omnibus-mainnet.toml

Co-authored-by: Noisekit <[email protected]>

* add staked eth oracle address

* add legacy market test for mainnetq

* fix configs

* prettify

* add missing `package`

* mainnet fixes

* update sepolia to use fake tokens

---------

Co-authored-by: Noisekit <[email protected]>
  • Loading branch information
dbeal-eth and noisekit authored Jul 8, 2024
1 parent 9bb2869 commit d778190
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,10 @@ workflows:
chain-id: 42161
provider-url: https://arbitrum-mainnet.infura.io/v3/$INFURA_API_KEY

- fork-test-new:
- fork-test:
name: test-sepolia
toml: omnibus-sepolia.toml
package: "synthetix-omnibus:latest"
preset: "main"
chain-id: 11155111
provider-url: https://sepolia.infura.io/v3/$INFURA_API_KEY
Expand Down
90 changes: 90 additions & 0 deletions e2e/tests/omnibus-mainnet.toml/LegacyMarket.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
const assert = require('assert');
const { getLpPosition } = require('../../tasks/getLpPosition');
const { getAccountCollateral } = require('../../tasks/getAccountCollateral');
const { ethers } = require('ethers');
const { syncTime } = require('../../tasks/syncTime');
const { contractWrite } = require('../../tasks/contractWrite');

const log = require('debug')(`e2e:${require('path').basename(__filename, '.js')}`);

describe(require('path').basename(__filename, '.e2e.js'), function () {
const provider = new ethers.providers.JsonRpcProvider(
process.env.RPC_URL || 'http://127.0.0.1:8545'
);

const LegacyMarketProxy = new ethers.Contract(
require('../../deployments/LegacyMarketProxy.json').address,
require('../../deployments/LegacyMarketProxy.json').abi,
provider
);

const V2x = new ethers.Contract(
require('../../deployments/V2x.json').address,
require('../../deployments/V2x.json').abi,
provider
);

let snapshot;
before('Create snapshot', async () => {
snapshot = await provider.send('evm_snapshot', []);
log('Create snapshot', { snapshot });
});

after('Restore snapshot', async () => {
log('Restore snapshot', { snapshot });
await provider.send('evm_revert', [snapshot]);
});

it('should sync time of the fork', async () => {
await syncTime();
});

it('should migrate account', async () => {
const accountId = 80800;
const walletAddress = '0x99F4176EE457afedFfCB1839c7aB7A030a5e4A92'; // pdao address (for now)
const snxBalance = parseFloat(ethers.utils.formatEther(await V2x.balanceOf(walletAddress)));
const debt = parseFloat(
ethers.utils.formatEther(
await V2x.debtBalanceOf(walletAddress, ethers.utils.formatBytes32String('sUSD'))
)
);
log({ snxBalance, debt });

const owner = await LegacyMarketProxy.owner();
await provider.send('anvil_impersonateAccount', [owner]);
const wallet = provider.getSigner(owner);

log('migrate account', { walletAddress, accountId });

await contractWrite({
wallet,
contract: 'LegacyMarketProxy',
func: 'migrateOnBehalf',
args: [walletAddress, accountId],
});
await provider.send('anvil_stopImpersonatingAccount', [owner]);

log('should have nothing left on v2x');
assert.equal(parseFloat(ethers.utils.formatEther(await V2x.balanceOf(walletAddress))), 0);
assert.equal(
parseFloat(
ethers.utils.formatEther(
await V2x.debtBalanceOf(walletAddress, ethers.utils.formatBytes32String('sUSD'))
)
),
0
);

log('the account should have the same debt as before');
const newDebt = (await getLpPosition({ accountId, poolId: 1, symbol: 'SNX' })).debt;
log({ newDebt });
assert.deepEqual(newDebt, debt);

log('the account should have the same collaterals as before');
const accountInfo = await getAccountCollateral({ accountId, symbol: 'SNX' });
log({ accountInfo });
assert.deepEqual(accountInfo.totalAssigned, accountInfo.totalDeposited);
// here we just assert that we have more than enough deposited. calculating the actual amount expected would required reading into reward escrow and doing some complicated stuff to figure out already vested amounts and etc.
assert(accountInfo.totalDeposited - accountInfo.totalLocked >= snxBalance);
});
});
83 changes: 76 additions & 7 deletions omnibus-mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,33 @@ include = [
"tomls/ccip-mainnet.toml",
"tomls/core.toml",
"tomls/permissions.toml",
"tomls/oracles/wsteth.toml",
"tomls/oracles/susde.toml",
"tomls/oracles/snx.toml",
"tomls/collaterals/wsteth.toml",
"tomls/collaterals/susde.toml",
"tomls/collaterals/snx.toml",
# "tomls/oracles/eth.toml",
# "tomls/collaterals/weth.toml",
"tomls/markets/legacy.toml",
"tomls/markets/spot-factory.toml",
"tomls/markets/spot/usde.toml",
"tomls/pools/spartan-council.toml",
"tomls/permit-all-transferCrossChain.toml",
]

[setting.snx_package]
defaultValue = "synthetix:3.3.5"
defaultValue = "synthetix:3.3.18"

[setting.spot_market_package]
defaultValue = "synthetix-spot-market:3.3.5"
defaultValue = "synthetix-spot-market:3.3.15"

[setting.perps_market_package]
defaultValue = "synthetix-perps-market:3.3.5"
defaultValue = "synthetix-perps-market:3.3.19"

[setting.legacy_market_package]
defaultValue = "synthetix-legacy-market:3.3.5"

[setting.susde_package]
defaultValue = 'susde-token'

[setting.owner]
defaultValue = "0x6E1613B5c68B4Cf2A58400D8019a97849A678139"
Expand All @@ -33,7 +44,16 @@ defaultValue = "0x33303637343430323300000000000000000000000000000000000000000000
defaultValue = "snax"

[setting.snx_address]
defaultValue = "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f"
defaultValue = "<%= imports.legacyMarket.imports.v2x.contracts.ProxySynthetix.address %>"

[setting.wsteth_aggregator_address]
defaultValue = "0xCfE54B5cD566aB89272946F602D76Ea879CAb4a8"

[setting.susde_aggregator_address]
defaultValue = "0xFF3BC18cCBd5999CE63E788A1c250a88626aD099"

[setting.usde_aggregator_address]
defaultValue = "0xa569d910839Ae8865Da8F8e70FfFb0cBA869F961"

[setting.snx_aggregator_address]
defaultValue = "0xDC3EA94CD0AC27d9A86C180091e7f78C683d3699"
Expand All @@ -51,7 +71,10 @@ defaultValue = "2000000000000000000"
defaultValue = "86400"

[setting.deployer]
defaultValue = "0x302d2451d9f47620374B54c521423Bf0403916A2"
defaultValue = "0xEde8a407913A874Dd7e3d5B731AFcA135D30375E"

[setting.pdao]
defaultValue = "0xEb3107117FEAd7de89Cd14D463D340A2E6917769"

[setting.sc_pool_id]
defaultValue = "1"
Expand All @@ -64,3 +87,49 @@ defaultValue = "0xE561d5E02207fb5eB32cca20a699E0d8919a1476"

[setting.ccip_token_pool]
defaultValue = "0x057152DB365B47851B0A0bd431644b8eE21fE1b4"

[setting.synthUsdeAsyncFixedFee]
defaultValue = "0"

[setting.synthUsdeSkewScale]
defaultValue = "0"

[setting.synth_usde_max_market_collateral]
defaultValue = "<%= parseEther('100000000') %>"

[setting.pyth_price_verification_address]
defaultValue = "0x4305FB66699C3B2702D4d05CF36551390A4c69C6"

[setting.pythFeedUrl]
defaultValue = "https://api.synthetix.io/pyth-mainnet/api/get_vaa_ccip?data={data}"

[setting.pythUsdeFeedId]
defaultValue = "0x6ec879b1e9963de5ee97e9c8710b742d6228252a5e2ca12d4ae81d7fe5ee8c5d"

# we want to enable the spot market wrapper for usde
[import.usde]
source = "usde-token"

[invoke.SpotMarketProxy_setWrapper_usde]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_usde_market_id %>"]
func = "setWrapper"
args = [
"<%= extras.synth_usde_market_id %>",
"<%= imports.usde.contracts.Token.address %>",
"<%= settings.synth_usde_max_market_collateral %>",
]

[invoke.setScPoolConfig]
target = ["system.CoreProxy"]
fromCall.func = "getPoolOwner"
fromCall.args = ["<%= settings.sc_pool_id %>"]
func = "setPoolConfiguration"
args = [
"<%= settings.sc_pool_id %>",
[
{ marketId = "<%= imports.legacyMarket.settings.marketId %>", weightD18 = 99, maxDebtShareValueD18 = "<%= parseEther('1') %>" },
{ marketId = "<%= settings.synth_usde_market_id %>", weightD18 = 1, maxDebtShareValueD18 = "<%= parseEther('1') %>" },
],
]
52 changes: 37 additions & 15 deletions omnibus-sepolia.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "synthetix-omnibus"
version = "1"
version = "2"
description = "Includes the full synthetix system with configurations applied"
include = [
"tomls/settings.toml",
"tomls/ccip-testnet.toml",
"tomls/core.toml",
"tomls/permissions.toml",
"tomls/oracles/pyth-wsteth.toml",
"tomls/oracles/pyth-susde.toml",
"tomls/oracles/pyth-snx.toml",
"tomls/oracles/wsteth.toml",
"tomls/oracles/susde.toml",
"tomls/oracles/snx.toml",
"tomls/collaterals/wsteth.toml",
"tomls/collaterals/susde.toml",
"tomls/collaterals/snx.toml",
Expand All @@ -25,17 +25,23 @@ include = [
defaultValue = "snaxtest"

[setting.snx_package]
defaultValue = "synthetix:3.3.15"
defaultValue = "synthetix:3.3.18"

[setting.spot_market_package]
defaultValue = "synthetix-spot-market:3.3.15"

[setting.legacy_market_package]
defaultValue = "synthetix-legacy-market:3.3.4"
defaultValue = "synthetix-legacy-market:3.3.5"

# the susde token doesn't appear to be deployed on sepolia
[setting.susde_package]
defaultValue = "usde-token"
defaultValue = "fake-susde-token"

depends = ["clone.susde_deploy"]

[setting.wsteth_package]
defaultValue = "fake-wsteth-token"

depends = ["clone.wsteth_deploy"]

[setting.owner]
defaultValue = "0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9"
Expand All @@ -44,16 +50,14 @@ defaultValue = "0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9"
defaultValue = "<%= imports.legacyMarket.imports.v2x.contracts.ProxySynthetix.address %>"

[setting.wsteth_aggregator_address]
# NOTE: below aggregator is actually plain ETH
defaultValue = "0x694AA1769357215DE4FAC081bf1f309aDC325306"
defaultValue = "0xaaabb530434B0EeAAc9A42E25dbC6A22D7bE218E"

[setting.susde_aggregator_address]
# NOTE: below aggregator is actually USDC
defaultValue = "0xA2F78ab2355fe2f984D808B5CeE7FD0A93D5270E"
defaultValue = "0x6f7be09227d98Ce1Df812d5Bc745c0c775507E92"

[setting.usde_aggregator_address]
# NOTE: below aggregator is actually USDC
defaultValue = "0xA2F78ab2355fe2f984D808B5CeE7FD0A93D5270E"
defaultValue = "0x55ec7c3ed0d7CB5DF4d3d8bfEd2ecaf28b4638fb"

[setting.snx_aggregator_address]
defaultValue = "0xc0F82A46033b8BdBA4Bb0B0e28Bc2006F64355bC"
Expand Down Expand Up @@ -104,8 +108,26 @@ defaultValue = "0xDd24F84d36BF92C65F92307595335bdFab5Bbd21"
defaultValue = "<%= parseEther('100000000') %>"

# we want to enable the spot market wrapper for usde
[import.usde]
source = "usde-token"
[clone.usde]
source = "mintable-token:2.0"
target = "fake-usde-token"
options.name = "Ethena USD (fake)"
options.symbol = "USDe"
options.owner = "<%= settings.deployer %>"

[clone.susde_deploy]
source = "mintable-token:2.0"
target = "fake-susde-token"
options.name = "Ethena Staked USD (fake)"
options.symbol = "sUSDe"
options.owner = "<%= settings.deployer %>"

[clone.wsteth_deploy]
source = "mintable-token:2.0"
target = "fake-wsteth-token"
options.name = "Lido Wrapped Staked ETH (fake)"
options.symbol = "WstETH"
options.owner = "<%= settings.deployer %>"

[invoke.SpotMarketProxy_setWrapper_usde]
target = ["spotFactory.SpotMarketProxy"]
Expand Down

0 comments on commit d778190

Please sign in to comment.