Skip to content

Commit bfffd6c

Browse files
noahlitvinnoisekit
andauthored
stataUSDC for Base Mainnet (#260)
* init * progress * progress * progress * ready * seperate oracle files * remove package lock * fix collateral config for market * Remove unused extra setting * Fill `stataBasUSDC_address` setting from ratio oracle mock, avoid empty settings * Rename to `stataBasUSDC_address` to match original token symbol * draft test * tests pass * Fix for incorrect assets ratio oracle version * Reduce borrowed amount to 10 USDx * Remove pointless comments * Renaming * Bump versions --------- Co-authored-by: Noisekit <[email protected]> Co-authored-by: Noisekit <[email protected]>
1 parent 330987e commit bfffd6c

File tree

17 files changed

+417
-73
lines changed

17 files changed

+417
-73
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
const crypto = require('crypto');
2+
const assert = require('assert');
3+
const { ethers } = require('ethers');
4+
require('../../inspect');
5+
const log = require('debug')(`e2e:${require('path').basename(__filename, '.e2e.js')}`);
6+
7+
const { getEthBalance } = require('../../tasks/getEthBalance');
8+
const { setEthBalance } = require('../../tasks/setEthBalance');
9+
const { getCollateralBalance } = require('../../tasks/getCollateralBalance');
10+
const { getTokenBalance } = require('../../tasks/getTokenBalance');
11+
const { isCollateralApproved } = require('../../tasks/isCollateralApproved');
12+
const { approveCollateral } = require('../../tasks/approveCollateral');
13+
const { setTokenBalance } = require('../../tasks/setTokenBalance');
14+
const { syncTime } = require('../../tasks/syncTime');
15+
const { setConfigUint } = require('../../tasks/setConfigUint');
16+
const { getConfigUint } = require('../../tasks/getConfigUint');
17+
const { wrapCollateral } = require('../../tasks/wrapCollateral');
18+
const { unwrapCollateral } = require('../../tasks/unwrapCollateral');
19+
const { spotSell } = require('../../tasks/spotSell');
20+
const { spotBuy } = require('../../tasks/spotBuy');
21+
22+
describe(require('path').basename(__filename, '.e2e.js'), function () {
23+
const provider = new ethers.providers.JsonRpcProvider(
24+
process.env.RPC_URL || 'http://127.0.0.1:8545'
25+
);
26+
const wallet = ethers.Wallet.createRandom().connect(provider);
27+
const address = wallet.address;
28+
const privateKey = wallet.privateKey;
29+
30+
let snapshot;
31+
before('Create snapshot', async () => {
32+
snapshot = await provider.send('evm_snapshot', []);
33+
log('Create snapshot', { snapshot });
34+
});
35+
after('Restore snapshot', async () => {
36+
log('Restore snapshot', { snapshot });
37+
await provider.send('evm_revert', [snapshot]);
38+
});
39+
40+
it('should sync time of the fork', async () => {
41+
await syncTime();
42+
});
43+
44+
it('should disable withdrawal timeout', async () => {
45+
await setConfigUint({ key: 'accountTimeoutWithdraw', value: 0 });
46+
assert.equal(await getConfigUint('accountTimeoutWithdraw'), 0);
47+
});
48+
49+
it('should create new random wallet', async () => {
50+
log({ wallet: wallet.address, pk: wallet.privateKey });
51+
assert.ok(wallet.address);
52+
});
53+
54+
it('should set ETH balance to 100', async () => {
55+
assert.equal(await getEthBalance({ address }), 0, 'New wallet has 0 ETH balance');
56+
await setEthBalance({ address, balance: 100 });
57+
assert.equal(await getEthBalance({ address }), 100);
58+
});
59+
60+
it('should set stataBasUSDC balance to 1000', async () => {
61+
assert.equal(
62+
await getCollateralBalance({ address, symbol: 'stataBasUSDC' }),
63+
0,
64+
'New wallet has 0 stataBasUSDC balance'
65+
);
66+
await setTokenBalance({
67+
wallet,
68+
balance: 1000,
69+
tokenAddress: require('../../deployments/extras.json').stataBasUSDC_address,
70+
friendlyWhale: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
71+
});
72+
assert.equal(await getCollateralBalance({ address, symbol: 'stataBasUSDC' }), 1000);
73+
});
74+
75+
it('should approve stataBasUSDC spending for SpotMarket', async () => {
76+
assert.equal(
77+
await isCollateralApproved({
78+
address,
79+
symbol: 'stataBasUSDC',
80+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
81+
}),
82+
false,
83+
'New wallet has not allowed SpotMarket stataBasUSDC spending'
84+
);
85+
await approveCollateral({
86+
privateKey,
87+
symbol: 'stataBasUSDC',
88+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
89+
});
90+
assert.equal(
91+
await isCollateralApproved({
92+
address,
93+
symbol: 'stataBasUSDC',
94+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
95+
}),
96+
true
97+
);
98+
});
99+
100+
it('should wrap 1000 stataBasUSDC -> sStataUSDC', async () => {
101+
const synthBalance = await wrapCollateral({
102+
wallet,
103+
symbol: 'stataBasUSDC',
104+
synthAddress: require('../../deployments/extras.json').synth_stata_usdc_token_address,
105+
synthMarketId: require('../../deployments/extras.json').synth_stata_usdc_market_id,
106+
amount: 1000,
107+
});
108+
assert.equal(synthBalance, 1000);
109+
assert.equal(
110+
await getTokenBalance({
111+
walletAddress: address,
112+
tokenAddress: require('../../deployments/extras.json').synth_stata_usdc_token_address,
113+
}),
114+
1000
115+
);
116+
});
117+
118+
it('should swap 500 sStataUSDC -> snxUSD', async () => {
119+
assert.equal(await getCollateralBalance({ address, symbol: 'snxUSD' }), 0);
120+
await spotSell({
121+
wallet,
122+
marketId: require('../../deployments/extras.json').synth_stata_usdc_market_id,
123+
synthAmount: 500,
124+
minUsdAmount: 400,
125+
});
126+
assert.ok(
127+
(await getCollateralBalance({ address, symbol: 'snxUSD' })) >= 400,
128+
'snxUSD balance >= 400'
129+
);
130+
});
131+
132+
it('should approve snxUSD spending for SpotMarket', async () => {
133+
assert.equal(
134+
await isCollateralApproved({
135+
address,
136+
symbol: 'snxUSD',
137+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
138+
}),
139+
false,
140+
'New wallet has not allowed SpotMarket snxUSD spending'
141+
);
142+
await approveCollateral({
143+
privateKey,
144+
symbol: 'snxUSD',
145+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
146+
});
147+
assert.equal(
148+
await isCollateralApproved({
149+
address,
150+
symbol: 'snxUSD',
151+
spenderAddress: require('../../deployments/SpotMarketProxy.json').address,
152+
}),
153+
true
154+
);
155+
});
156+
157+
it('should swap 400 snxUSD -> sStataUSDC', async () => {
158+
await spotBuy({
159+
wallet,
160+
marketId: require('../../deployments/extras.json').synth_stata_usdc_market_id,
161+
usdAmount: 400,
162+
minAmountReceived: 300,
163+
});
164+
assert.ok(
165+
(await getTokenBalance({
166+
walletAddress: address,
167+
tokenAddress: require('../../deployments/extras.json').synth_stata_usdc_token_address,
168+
})) >=
169+
500 + 300,
170+
`sStataUSDC balance >= ${500 + 300}`
171+
);
172+
});
173+
174+
it('should unwrap 500 sStataUSDC -> stataBasUSDC', async () => {
175+
const synthBalance = await unwrapCollateral({
176+
wallet,
177+
symbol: 'stataBasUSDC',
178+
synthAddress: require('../../deployments/extras.json').synth_stata_usdc_token_address,
179+
synthMarketId: require('../../deployments/extras.json').synth_stata_usdc_market_id,
180+
amount: 500,
181+
});
182+
assert.ok(synthBalance < 500);
183+
assert.equal(await getCollateralBalance({ address, symbol: 'stataBasUSDC' }), 500);
184+
});
185+
});

omnibus-base-mainnet-andromeda.toml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
name = "synthetix-omnibus"
2-
version = "43"
2+
version = "44"
33
description = "Andromeda deployment"
44
preset = "andromeda"
55
include = [
6-
"tomls/core.toml", # Provision the core system
7-
"tomls/settings.toml", # Apply minimum liquidity ratio and withdrawal timeout
8-
"tomls/permissions.toml", # Allow deployer to create pools
9-
"tomls/permit-deniers.toml", # Add feature flag deniers to perps and core systems
10-
"tomls/pools/spartan-council.toml", # Create Spartan Council Pool
6+
"tomls/core.toml",
7+
"tomls/settings.toml",
8+
"tomls/permissions.toml",
9+
"tomls/permit-deniers.toml",
10+
"tomls/pools/spartan-council.toml",
1111
"tomls/markets/spot-factory.toml",
1212
"tomls/markets/perps-highcap-factory.toml",
1313
"tomls/markets/common/bigcap-settings.toml",
14-
"tomls/omnibus-base-mainnet-andromeda/spot/usdc.toml", # sUSDC spot market/wrapper
15-
"tomls/permit-all-perps-perpsHighcapSystem.toml", # Enable perps market
14+
"tomls/permit-all-perps-perpsHighcapSystem.toml",
1615
"tomls/permit-pdao-createMarket.toml",
1716
"tomls/omnibus-base-mainnet-andromeda/perps/referrers.toml",
1817
"tomls/omnibus-base-mainnet-andromeda/perps/global.toml",
19-
"tomls/omnibus-base-mainnet-andromeda/perps/perps-keeper-cost.toml", # Add gas oracle for keeper fees
18+
"tomls/omnibus-base-mainnet-andromeda/perps/perps-keeper-cost.toml",
2019
"tomls/omnibus-base-mainnet-andromeda/perps/feeCollector.toml",
21-
# Collaterals
22-
"tomls/omnibus-base-mainnet-andromeda/collaterals/susdc.toml",
23-
"tomls/collaterals/susdc.toml",
20+
21+
# USDC
22+
"tomls/omnibus-base-mainnet-andromeda/collaterals/sUSDC.toml",
23+
"tomls/omnibus-base-mainnet-andromeda/spot/USDC.toml",
24+
25+
# stataUSDC
26+
"tomls/omnibus-base-mainnet-andromeda/collaterals/sstataUSDC.toml",
27+
"tomls/omnibus-base-mainnet-andromeda/spot/stataUSDC.toml",
28+
"tomls/omnibus-base-mainnet-andromeda/oracles/stataUSDC-USDC.toml",
29+
2430
# BTC
2531
"tomls/omnibus-base-mainnet-andromeda/perps/btc-invokes.toml",
2632
"tomls/oracles/pyth-btc.toml",
@@ -380,6 +386,10 @@ args = [
380386
[setting.usdc_address]
381387
defaultValue = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
382388

389+
[setting.stataBasUSDC_address]
390+
defaultValue = "0x4EA71A20e655794051D1eE8b6e4A3269B13ccaCc"
391+
description = "https://basescan.org/token/0x4EA71A20e655794051D1eE8b6e4A3269B13ccaCc"
392+
383393
[setting.snx_address]
384394
defaultValue = "0x22e6966B799c4D5B13BE962E1D117b56327FDa66"
385395

omnibus-base-sepolia-andromeda.toml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
name = "synthetix-omnibus"
2-
version = "44"
2+
version = "45"
33
description = "Andromeda dev deployment"
44
preset = "andromeda"
55
include = [
6-
"tomls/core.toml", # Provision the core system
7-
"tomls/settings.toml", # Apply minimum liquidity ratio and withdrawal timeout
8-
"tomls/permissions.toml", # Allow deployer to create pools
9-
"tomls/permit-deniers.toml", # Add feature flag deniers to perps and core systems
10-
"tomls/pools/spartan-council.toml", # Create Spartan Council Pool
6+
"tomls/core.toml",
7+
"tomls/settings.toml",
8+
"tomls/permissions.toml",
9+
"tomls/permit-deniers.toml",
10+
"tomls/pools/spartan-council.toml",
1111
"tomls/markets/spot-factory.toml",
1212
"tomls/markets/perps-highcap-factory.toml",
13-
"tomls/markets/perps-lowcap-factory.toml", # DISABLED Second supermarket (Low MCap) # First supermarket (High MCap)
13+
"tomls/markets/perps-lowcap-factory.toml",
1414
"tomls/markets/common/bigcap-settings.toml",
15-
"tomls/omnibus-base-sepolia-andromeda/spot/usdc.toml", # sUSDC spot market/wrapper, mock for USDC
16-
"tomls/omnibus-base-sepolia-andromeda/spot/statausdc.toml", # sStataUSDC spot market/wrapper, mock for aUSDC/stataUSDC from erc-4626-to-assets-ratio-oracle
17-
"tomls/permit-all-perps-perpsHighcapSystem.toml", # Enable perps market
18-
"tomls/permit-revoke-all-perps-perpsLowcapSystem.toml", # Disable LowCaps perps market
15+
"tomls/permit-all-perps-perpsHighcapSystem.toml",
1916
"tomls/omnibus-base-sepolia-andromeda/perps/referrers.toml",
20-
"tomls/omnibus-base-sepolia-andromeda/perps/global.toml", # Global perps settings
21-
"tomls/omnibus-base-sepolia-andromeda/perps/perps-keeper-cost.toml", # Add gas oracle for keeper fees
22-
"tomls/oracles/statausdc-usdc.toml",
17+
"tomls/omnibus-base-sepolia-andromeda/perps/global.toml",
18+
"tomls/omnibus-base-sepolia-andromeda/perps/perps-keeper-cost.toml",
2319
"tomls/omnibus-base-sepolia-andromeda/perps/feeCollector.toml",
24-
# Collaterals
25-
"tomls/omnibus-base-sepolia-andromeda/collaterals/susdc.toml",
26-
"tomls/collaterals/susdc.toml",
27-
"tomls/omnibus-base-sepolia-andromeda/collaterals/sstatausdc.toml",
28-
"tomls/collaterals/sstatausdc.toml",
29-
# First super market for high mcap assets
20+
21+
# USDC
22+
"tomls/omnibus-base-sepolia-andromeda/collaterals/sUSDC.toml",
23+
"tomls/omnibus-base-sepolia-andromeda/spot/USDC.toml",
24+
25+
# stataUSDC
26+
"tomls/omnibus-base-sepolia-andromeda/collaterals/sstataUSDC.toml",
27+
"tomls/omnibus-base-sepolia-andromeda/spot/stataUSDC.toml",
28+
"tomls/omnibus-base-sepolia-andromeda/oracles/stataUSDC-USDC.toml",
29+
3030
# BTC
3131
"tomls/omnibus-base-sepolia-andromeda/perps/btc-invokes.toml",
3232
"tomls/oracles/pyth-btc.toml",
@@ -373,6 +373,10 @@ defaultValue = "1"
373373
[setting.pool_owner]
374374
defaultValue = "0x48914229deDd5A9922f44441ffCCfC2Cb7856Ee9"
375375

376+
[setting.stataBasUSDC_address]
377+
defaultValue = "<%= imports.erc_4626_to_assets_ratio_oracle.imports.statausdc_token_mock.contracts.Token.address %>"
378+
description = "We use the mock generated by erc-4626-to-assets-ratio-oracle package in statausdc-usdc.toml"
379+
376380
[invoke.setScPoolConfig]
377381
target = ["system.CoreProxy"]
378382
fromCall.func = "getPoolOwner"

tomls/collaterals/susdc.toml renamed to tomls/omnibus-base-mainnet-andromeda/collaterals/sUSDC.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
[setting.usdc_address]
1+
[setting.susdc_issuance_ratio]
2+
defaultValue = "<%= MaxUint256 %>"
3+
4+
[setting.susdc_liquidation_ratio]
5+
defaultValue = "<%= parseEther('1.005') %>"
6+
7+
[setting.susdc_liquidation_reward]
8+
defaultValue = "<%= parseEther('1') %>"
9+
10+
[setting.susdc_min_delegation]
11+
defaultValue = "<%= parseEther('100') %>"
212

313
[invoke.configure_susdc_collateral]
414
target = ["system.CoreProxy"]

tomls/collaterals/sstatausdc.toml renamed to tomls/omnibus-base-mainnet-andromeda/collaterals/sstataUSDC.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
[setting.stata_usdc_address]
1+
[setting.sstatausdc_issuance_ratio]
2+
defaultValue = "<%= MaxUint256 %>"
3+
4+
[setting.sstatausdc_liquidation_ratio]
5+
defaultValue = "<%= parseEther('1.1') %>"
6+
7+
[setting.sstatausdc_liquidation_reward]
8+
defaultValue = "<%= parseEther('1') %>"
9+
10+
[setting.sstatausdc_min_delegation]
11+
defaultValue = "<%= parseEther('100') %>"
212

313
[invoke.configure_sstatausdc_collateral]
414
target = ["system.CoreProxy"]

tomls/omnibus-base-mainnet-andromeda/collaterals/susdc.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

tomls/oracles/statausdc-usdc.toml renamed to tomls/omnibus-base-mainnet-andromeda/oracles/stataUSDC-USDC.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[clone.erc_4626_to_assets_ratio_oracle]
22
source = "erc-4626-to-assets-ratio-oracle:3.3.19"
3-
# var.vault = "<%= settings.stata_usdc_address %>" # On testnet, we provide no vault here and use the mocks deployed by this package
3+
target = "erc-4626-to-assets-ratio-oracle:3.3.19@stataBasUSDC_USDC"
4+
options.vault = "<%= settings.stataBasUSDC_address %>"
45

56
[invoke.register_erc_4626_to_assets_ratio_oracle_node]
67
target = ["system.oracle_manager.Proxy"]

0 commit comments

Comments
 (0)