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

sccp-388-susds #649

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion omnibus-base-mainnet-andromeda.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ include = [
"tomls/omnibus-base-mainnet-andromeda/collaterals/cbeth.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/wsteth.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/weth.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/susds.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-usdc.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-stata-usdc.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-susds.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-cbbtc.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-cbeth.toml",
"tomls/omnibus-base-mainnet-andromeda/collaterals/synth-wsteth.toml",
Expand All @@ -34,6 +36,7 @@ include = [
"tomls/omnibus-base-mainnet-andromeda/spot/cbeth.toml",
"tomls/omnibus-base-mainnet-andromeda/spot/wsteth.toml",
"tomls/omnibus-base-mainnet-andromeda/spot/weth.toml",
"tomls/omnibus-base-mainnet-andromeda/spot/susds.toml",

# Perps Liquidation rewards
"tomls/omnibus-base-mainnet-andromeda/rewards/snx_rewards_for_sc_pool.toml",
Expand All @@ -44,6 +47,7 @@ include = [
"tomls/omnibus-base-mainnet-andromeda/rewards/sweth_perps_liquidations_rewards.toml",
"tomls/omnibus-base-mainnet-andromeda/rewards/susdc_perps_liquidations_rewards.toml",
"tomls/omnibus-base-mainnet-andromeda/rewards/stata_usdc_perps_liquidations_rewards.toml",
"tomls/omnibus-base-mainnet-andromeda/rewards/susds_perps_liquidations_rewards.toml",

# stataUSDC
"tomls/omnibus-base-mainnet-andromeda/oracles/stataUSDC-USDC.toml",
Expand Down Expand Up @@ -158,6 +162,7 @@ include = [
"tomls/omnibus-base-mainnet-andromeda/oracles/pyth-xrp.toml",
"tomls/omnibus-base-mainnet-andromeda/oracles/pyth-yfi.toml",
"tomls/omnibus-base-mainnet-andromeda/oracles/pyth-zro.toml",
"tomls/omnibus-base-mainnet-andromeda/oracles/pyth-susds.toml",

#
# Perps
Expand All @@ -171,6 +176,7 @@ include = [
"tomls/omnibus-base-mainnet-andromeda/perps/collaterals/weth.toml",
"tomls/omnibus-base-mainnet-andromeda/perps/collaterals/usdc.toml",
"tomls/omnibus-base-mainnet-andromeda/perps/collaterals/stata-usdc.toml",
"tomls/omnibus-base-mainnet-andromeda/perps/collaterals/susds.toml",

# Perps Settings
"tomls/omnibus-base-mainnet-andromeda/perps/global.toml",
Expand Down Expand Up @@ -373,6 +379,7 @@ snx_address = "0x22e6966B799c4D5B13BE962E1D117b56327FDa66"
usdc_address = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
weth_address = "0x4200000000000000000000000000000000000006"
wsteth_address = "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"
susds_address = "0x5875eEE11Cf8398102FdAd704C9E96607675467a"

[setting.pyth_feed_url]
defaultValue = "https://api.synthetix.io/pyth-mainnet/api/get_vaa_ccip?data={data}"
Expand Down Expand Up @@ -428,7 +435,7 @@ pyth_feed_id_ethfi = "0xb27578a9654246cb0a2950842b92330e9ace141c52b63829cc72d5c4
pyth_feed_id_fartcoin = "0x58cd29ef0e714c5affc44f269b2c1899a52da4169d7acc147b9da692e6953608"
pyth_feed_id_fil = "0x150ac9b959aee0051e4091f0ef5216d941f590e1c5e7f91cf7635b5c11628c0e"
pyth_feed_id_flow = "0x2fb245b9a84554a0f15aa123cbb5f64cd263b59e9a87d80148cbffab50c69f30"
pyth_feed_id_ftm = "0xf490b178d0c85683b7a0f2388b40af2e6f7c90cbe0f96b31f315f08d0e5a2d6d" # replaced with Sonic feed as ftm is 1:1 redeemable to sonic
pyth_feed_id_ftm = "0xf490b178d0c85683b7a0f2388b40af2e6f7c90cbe0f96b31f315f08d0e5a2d6d" # replaced with Sonic feed as ftm is 1:1 redeemable to sonic
pyth_feed_id_fxs = "0x735f591e4fed988cd38df74d8fcedecf2fe8d9111664e0fd500db9aa78b316b1"
pyth_feed_id_gala = "0x0781209c28fda797616212b7f94d77af3a01f3e94a5d421760aef020cf2bcb51"
pyth_feed_id_gmx = "0xb962539d0fcb272a494d65ea56f94851c2bcf8823935da05bd628916e2e9edbf"
Expand Down Expand Up @@ -496,3 +503,5 @@ pyth_feed_id_xlm = "0xb7a8eba68a997cd0210c2e1e4ee811ad2d174b3611c22d9ebf16f4cb7e
pyth_feed_id_xrp = "0xec5d399846a9209f3fe5881d70aae9268c94339ff9817e8d18ff19fa05eea1c8"
pyth_feed_id_yfi = "0x425f4b198ab2504936886c1e93511bb6720fbcf2045a4f3c0723bb213846022f"
pyth_feed_id_zro = "0x3bd860bea28bf982fa06bcf358118064bb114086cc03993bd76197eaab0b8018"
pyth_feed_id_susds_usds_rr = "0x6968a8641208463d17ae3b9cfa0e4841a7aa7a5d54122b9f692b84fe9ce3409f"
pyth_feed_id_usds_usd = "0x77f0971af11cc8bac224917275c1bf55f2319ed5c654a1ca955c82fa2d297ea1"
31 changes: 31 additions & 0 deletions tomls/omnibus-base-mainnet-andromeda/collaterals/susds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[var.susds_synth_config]
susds_issuance_ratio = "<%= parseEther('10') %>"
susds_liquidation_ratio = "<%= parseEther('1.5') %>"
susds_liquidation_reward = "<%= parseEther('0.0001') %>"
susds_min_delegation = "<%= parseEther('0.1') %>"
susds_max_collateral_limit = "<%= parseEther(String(2_000_000)) %>"

[invoke.CoreProxy_configureCollateral_susds]
target = ["system.CoreProxy"]
fromCall.func = "owner"
func = "configureCollateral" # "args" see below in the multiline block

[[invoke.CoreProxy_configureCollateral_susds.args]]
tokenAddress = "<%= settings.susds_address %>"
oracleNodeId = "<%= extras.susds_oracle_id %>"
issuanceRatioD18 = "<%= settings.susds_issuance_ratio %>"
liquidationRatioD18 = "<%= settings.susds_liquidation_ratio %>"
liquidationRewardD18 = "<%= settings.susds_liquidation_reward %>"
minDelegationD18 = "<%= settings.susds_min_delegation %>"
depositingEnabled = false

[invoke.CoreProxy_setPoolCollateralConfiguration_susds]
target = ["system.CoreProxy"]
fromCall.func = "getPoolOwner"
fromCall.args = ["<%= settings.spartan_council_pool_id_setting %>"]
func = "setPoolCollateralConfiguration"
args = [
"<%= settings.spartan_council_pool_id_setting %>",
"<%= settings.susds_address %>",
{ collateralLimitD18 = "<%= settings.susds_max_collateral_limit %>", issuanceRatioD18 = 0 },
]
19 changes: 19 additions & 0 deletions tomls/omnibus-base-mainnet-andromeda/collaterals/synth-susds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[var.susds_synth_config]
susds_issuance_ratio = "<%= parseEther('2') %>"
susds_liquidation_ratio = "<%= parseEther('1.1') %>"
susds_liquidation_reward = "<%= parseEther('0.0001') %>"
susds_min_delegation = "<%= parseEther('0.1') %>"

[invoke.configure_susds_collateral]
target = ["system.CoreProxy"]
fromCall.func = "owner"
func = "configureCollateral" # "args" see below in the multiline block

[[invoke.configure_susds_collateral.args]]
tokenAddress = "<%= extras.synth_susds_token_address %>"
oracleNodeId = "<%= extras.susds_oracle_id %>"
issuanceRatioD18 = "<%= settings.susds_issuance_ratio %>"
liquidationRatioD18 = "<%= settings.susds_liquidation_ratio %>"
liquidationRewardD18 = "<%= settings.susds_liquidation_reward %>"
minDelegationD18 = "<%= settings.susds_min_delegation %>"
depositingEnabled = false
105 changes: 105 additions & 0 deletions tomls/omnibus-base-mainnet-andromeda/oracles/pyth-susds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# This registers a staleness node that looks to Pyth for a fresh enough price, or otherwise reverts with an ERC-7412 compatible error
# Latest Pyth Price
################################################################
# First step is registering the susds-usds redemption based feed
################################################################

[invoke.registerPythSusdsUsdsRrOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
5, # 5 = pyth aggregator type
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'bool'], [settings.pyth_price_verification_address, settings.pyth_feed_id_susds_usds_rr, false]) %>",
[
],
]
extra.susds_usds_rr_pyth_oracle_id.event = "NodeRegistered"
extra.susds_usds_rr_pyth_oracle_id.arg = 0

# Pyth Off-chain Lookup
[invoke.registerLookupSusdsUsdsRrOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
9, # 9 = PythOffchainLookupNode
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'uint256'], [imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address, settings.pyth_feed_id_susds_usds_rr, settings.default_staleness_tolerance]) %>",
[
],
]
extra.susds_usds_rr_lookup_oracle_id.event = "NodeRegistered"
extra.susds_usds_rr_lookup_oracle_id.arg = 0

# Staleness Node
[invoke.registerSusdsUsdsRrOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
7, # 7 = staleness circuit breaker
"<%= defaultAbiCoder.encode(['uint256'], [settings.default_staleness_tolerance]) %>",
[
"<%= extras.susds_usds_rr_pyth_oracle_id %>",
"<%= extras.susds_usds_rr_lookup_oracle_id %>",
],
]
extra.susds_usds_oracle_id.event = "NodeRegistered"
extra.susds_usds_oracle_id.arg = 0

################################################################
# Second step is registering the usds-usd market price
################################################################

[invoke.registerPythUsdsUsdOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
5, # 5 = pyth aggregator type
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'bool'], [settings.pyth_price_verification_address, settings.pyth_feed_id_usds_usd, false]) %>",
[
],
]
extra.usds_usd_pyth_oracle_id.event = "NodeRegistered"
extra.usds_usd_pyth_oracle_id.arg = 0

# Pyth Off-chain Lookup
[invoke.registerLookupUsdsUsdOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
9, # 9 = PythOffchainLookupNode
"<%= defaultAbiCoder.encode(['address', 'bytes32', 'uint256'], [imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address, settings.pyth_feed_id_usds_usd, settings.default_staleness_tolerance]) %>",
[
],
]
extra.usds_usd_lookup_oracle_id.event = "NodeRegistered"
extra.usds_usd_lookup_oracle_id.arg = 0

# Staleness Node
[invoke.registerUsdsUsdOracleNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
7, # 7 = staleness circuit breaker
"<%= defaultAbiCoder.encode(['uint256'], [settings.default_staleness_tolerance]) %>",
[
"<%= extras.usds_usd_pyth_oracle_id %>",
"<%= extras.usds_usd_lookup_oracle_id %>",
],
]
extra.usds_usd_oracle_id.event = "NodeRegistered"
extra.usds_usd_oracle_id.arg = 0

# Third step combine susds/usds * usds/usd to get back the susds/usd redemption based price

[invoke.registerSusdsNode]
target = ["system.oracle_manager.Proxy"]
func = "registerNode"
args = [
# 1 = reducer node
1,
# 1 parameters: 1 operation = 7 for mul decimal
"<%= defaultAbiCoder.encode(['uint256'], [7]) %>",
# 2 parent: 1 is the eth txn price node id, 2 is the eth oracle node id
["<%= extras.susds_usds_oracle_id %>", "<%= extras.usds_usd_oracle_id %>"],
]
extra.susds_oracle_id.event = "NodeRegistered"
extra.susds_oracle_id.arg = 0
27 changes: 27 additions & 0 deletions tomls/omnibus-base-mainnet-andromeda/perps/collaterals/susds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[var.perps_collateral_synth_susds_settings]
synth_susds_upper_limit_discount = "<%= parseEther('0.010') %>"
synth_susds_lower_limit_discount = "<%= parseEther('0.0101') %>"
synth_susds_discount_scalar = "<%= parseEther('1') %>"

[invoke.PerpsMarketProxy_setCollateralConfiguration_synth_susds]
target = ["perpsFactory.PerpsMarketProxy"]
fromCall.func = "owner"
func = "setCollateralConfiguration"
args = [
"<%= extras.synth_susds_market_id %>",
"<%= settings.synth_susds_max_collateral_amount %>",
"<%= settings.synth_susds_upper_limit_discount %>",
"<%= settings.synth_susds_lower_limit_discount %>",
"<%= settings.synth_susds_discount_scalar %>",
]

[invoke.CoreProxy_configureMaximumMarketCollateral_Perps_synth_susds]
target = ["system.CoreProxy"]
fromCall.func = "owner"
fromCall.args = []
func = "configureMaximumMarketCollateral"
args = [
"<%= imports.perpsFactory.extras.superMarketId %>",
"<%= extras.synth_susds_token_address %>",
"<%= settings.synth_susds_max_collateral_amount %>",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[provision.RewardsDistributor_susds_liquidation_rewards]
source = "synthetix-rewards-dist-ext:3.6.0"
target = "synthetix-rewards-dist-ext:3.6.0@perps-susds"
options.salt = "<%= settings.salt %>-perps-susds"
options.rewardManager = "<%= imports.system.contracts.CoreProxy.address %>"
options.poolId = "<%= settings.spartan_council_pool_id_setting %>"
options.payoutToken = "<%= extras.synth_susds_token_address %>"
options.payoutTokenDecimals = "18"
options.name = "Perps Savings USDS Liquidation Rewards"
options.authorizedDistributor = "<%= imports.perpsFactory.contracts.PerpsMarketProxy.address %>"

[invoke.PerpsMarketProxy_registerDistributor_synth_susds_liquidations]
target = ["perpsFactory.PerpsMarketProxy"]
fromCall.func = "owner"
func = "registerDistributor"
args = [
"<%= extras.synth_susds_token_address %>",
"<%= imports.RewardsDistributor_susds_liquidation_rewards.contracts.RewardsDistributorExternal.address %>",
"<%= extras.synth_susds_market_id %>",
[
"<%= extras.synth_usdc_token_address %>",
"<%= settings.synth_stata_usdc_token_address %>",
],
]

[invoke.CoreProxy_registerRewardsDistributor_susds_liquidation_rewards_for_SpartanCouncilPool_usdc_lp]
target = ["system.CoreProxy"]
fromCall.func = "getPoolOwner"
fromCall.args = ["<%= settings.spartan_council_pool_id_setting %>"]
func = "registerRewardsDistributor"
args = [
"<%= settings.spartan_council_pool_id_setting %>",
"<%= extras.synth_usdc_token_address %>",
"<%= imports.RewardsDistributor_susds_liquidation_rewards.contracts.RewardsDistributorExternal.address %>",
]

[invoke.CoreProxy_registerRewardsDistributor_susds_liquidation_rewards_for_SpartanCouncilPool_stata_usdc_lp]
target = ["system.CoreProxy"]
fromCall.func = "getPoolOwner"
fromCall.args = ["<%= settings.spartan_council_pool_id_setting %>"]
func = "registerRewardsDistributor"
args = [
"<%= settings.spartan_council_pool_id_setting %>",
"<%= settings.synth_stata_usdc_token_address %>",
"<%= imports.RewardsDistributor_susds_liquidation_rewards.contracts.RewardsDistributorExternal.address %>",
]
92 changes: 92 additions & 0 deletions tomls/omnibus-base-mainnet-andromeda/spot/susds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[var.susds_spot_settings]
synth_susds_max_collateral_amount = "<%= parseEther(String(2_000_0000)) %>"
synth_susds_skew_scale = "<%= 1 %>"

[invoke.SpotMarketProxy_createSynth_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "owner"
func = "createSynth"
args = ["Synthetic Savings USDS", "sUSDS", "<%= settings.owner %>"]
extra.synth_susds_market_id.event = "SynthRegistered"
extra.synth_susds_market_id.arg = 0
extra.synth_susds_token_address.event = "SynthRegistered"
extra.synth_susds_token_address.arg = 1

[invoke.SpotMarketProxy_updatePriceData_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "updatePriceData"
args = [
"<%= extras.synth_susds_market_id %>",
"<%= extras.susds_oracle_id %>",
"<%= extras.susds_oracle_id %>",
"<%= settings.strict_staleness_tolerance %>",
]

[invoke.CoreProxy_configureMaximumMarketCollateral_susds]
target = ["system.CoreProxy"]
fromCall.func = "owner"
fromCall.args = []
func = "configureMaximumMarketCollateral"
args = [
"<%= extras.synth_susds_market_id %>",
"<%= settings.susds_address %>",
"<%= settings.synth_susds_max_collateral_amount %>",
]

[invoke.SpotMarketProxy_setMarketSkewScale_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "setMarketSkewScale"
args = ["<%= extras.synth_susds_market_id %>", "<%= settings.synth_susds_skew_scale %>"]

[invoke.SpotMarketProxy_setWrapper_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "setWrapper"
args = [
"<%= extras.synth_susds_market_id %>",
"<%= settings.susds_address %>",
"<%= settings.synth_susds_max_collateral_amount %>",
]

# NOTE set disabled = true to addSettlementStrategy call before initial mainnet deployment
[invoke.SpotMarketProxy_addSettlementStrategy_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "addSettlementStrategy"
args = [
"<%= extras.synth_susds_market_id %>",
{ strategyType = "1", settlementDelay = "0", settlementWindowDuration = "1", priceVerificationContract = "0x0000000000000000000000000000000000000000", feedId = "0x0000000000000000000000000000000000000000000000000000000000000000", url = "", settlementReward = 0, minimumUsdExchangeAmount = "0", maxRoundingLoss = "1", priceDeviationTolerance = "0", disabled = false },
]
extra.synth_susds_settlement_strategy_id.event = "SettlementStrategyAdded"
extra.synth_susds_settlement_strategy_id.arg = 1

[invoke.SpotMarketProxy_setSettlementStrategy_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "setSettlementStrategy"
args = [
"<%= extras.synth_susds_market_id %>",
"<%= extras.synth_susds_settlement_strategy_id %>",
{ strategyType = "1", settlementDelay = "<%= settings.settlement_delay %>", settlementWindowDuration = "<%= settings.settlement_window_duration %>", priceVerificationContract = "<%= imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address %>", feedId = "<%= settings.susds_oracle_id %>", url = "<%= settings.pyth_feed_url %>", settlementReward = "<%= settings.settlement_reward %>", minimumUsdExchangeAmount = "<%= settings.settlement_minimum_usd_exchange_amount %>", maxRoundingLoss = "<%= settings.settlement_max_rounding_loss %>", priceDeviationTolerance = "<%= settings.price_deviation_tolerance %>", disabled = true },
]

[invoke.SpotMarketProxy_setAtomicFixedFee_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "setAtomicFixedFee"
args = ["<%= extras.synth_susds_market_id %>", "<%= parseEther(String(0.3)) %>"]

[invoke.SpotMarketProxy_setCollateralLeverage_susds]
target = ["spotFactory.SpotMarketProxy"]
fromCall.func = "getMarketOwner"
fromCall.args = ["<%= extras.synth_susds_market_id %>"]
func = "setCollateralLeverage"
args = ["<%= extras.synth_susds_market_id %>", "<%= parseEther('10') %>"]