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

Perps sandbox extras #1901

Closed
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
File renamed without changes.
Empty file.
66 changes: 20 additions & 46 deletions sandboxes/perps/consumer.cannonfile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ defaultValue = "69"
[setting.test_user_perps_account_id]
defaultValue = "420"

[setting.another_user]
defaultValue = "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720" # PK 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
description = "Hardhat/Anvil test account (9)"

#
#
#
Expand All @@ -27,73 +23,73 @@ description = "Hardhat/Anvil test account (9)"
#
#
[invoke.create_account]
target = ["perps_sandbox.core_sandbox.synthetix.CoreProxy"]
target = ["perps_sandbox.synthetix.CoreProxy"]
from = "<%= settings.test_user %>"
func = "createAccount(uint128)"
args = ["<%= settings.test_user_account_id %>"]
extra.test_user_account_id.event = "AccountCreated"
extra.test_user_account_id.arg = 0

[invoke.mint_10k_box]
target = ["perps_sandbox.core_sandbox.box_token.MintableToken"]
target = ["perps_sandbox.box_token.MintableToken"]
from = "<%= settings.test_user %>"
func = "mint"
args = ["<%= parseEther('10000') %>", "<%= settings.test_user %>"]

[invoke.approve_10k_box_for_CoreProxy_to_spend]
target = ["perps_sandbox.core_sandbox.box_token.MintableToken"]
target = ["perps_sandbox.box_token.MintableToken"]
from = "<%= settings.test_user %>"
func = "approve"
args = [
"<%= imports.perps_sandbox.imports.core_sandbox.imports.synthetix.contracts.CoreProxy.address %>",
"<%= imports.perps_sandbox.imports.synthetix.contracts.CoreProxy.address %>",
"<%= parseEther('10000') %>",
]
depends = ["invoke.mint_10k_box"]

[invoke.deposit_1k_box]
target = ["perps_sandbox.core_sandbox.synthetix.CoreProxy"]
target = ["perps_sandbox.synthetix.CoreProxy"]
from = "<%= settings.test_user %>"
func = "deposit"
args = [
"<%= extras.test_user_account_id %>",
"<%= imports.perps_sandbox.imports.core_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= imports.perps_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= parseEther('1000') %>",
]
depends = ["invoke.approve_10k_box_for_CoreProxy_to_spend"]

[invoke.delegate_900_box]
target = ["perps_sandbox.core_sandbox.synthetix.CoreProxy"]
target = ["perps_sandbox.synthetix.CoreProxy"]
from = "<%= settings.test_user %>"
func = "delegateCollateral"
args = [
# examples of how to debug internal values line by line
"<%= /*console.log(extras) ||*/ extras.test_user_account_id %>",
"<%= /*console.log(imports.perps_sandbox.extras) ||*/ imports.perps_sandbox.imports.core_sandbox.extras.spartan_council_pool_id %>",
"<%= /*console.log(imports.perps_sandbox.imports) ||*/ imports.perps_sandbox.imports.core_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= /* console.log(extras) || */ extras.test_user_account_id %>",
"<%= /* console.log(imports.perps_sandbox.extras) || */imports.perps_sandbox.extras.spartan_council_pool_id %>",
"<%= /* console.log(imports.perps_sandbox.imports) || */ imports.perps_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= parseEther('900') %>",
"<%= parseEther('1') %>",
]
depends = ["invoke.deposit_1k_box"]

[invoke.borrow_300_susd]
target = ["perps_sandbox.core_sandbox.synthetix.CoreProxy"]
target = ["perps_sandbox.synthetix.CoreProxy"]
from = "<%= settings.test_user %>"
func = "mintUsd"
args = [
"<%= extras.test_user_account_id %>",
"<%= imports.perps_sandbox.imports.core_sandbox.extras.spartan_council_pool_id %>",
"<%= imports.perps_sandbox.imports.core_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= imports.perps_sandbox.extras.spartan_council_pool_id %>",
"<%= imports.perps_sandbox.imports.box_token.contracts.MintableToken.address %>",
"<%= parseEther('300') %>",
]
depends = ["invoke.delegate_900_box"]

[invoke.withdraw_300_susd]
target = ["perps_sandbox.core_sandbox.synthetix.CoreProxy"]
target = ["perps_sandbox.synthetix.CoreProxy"]
from = "<%= settings.test_user %>"
func = "withdraw"
args = [
"<%= extras.test_user_account_id %>",
"<%= imports.perps_sandbox.imports.core_sandbox.imports.synthetix.contracts.USDProxy.address %>",
"<%= imports.perps_sandbox.imports.synthetix.contracts.USDProxy.address %>",
"<%= parseEther('300') %>",
]
depends = ["invoke.borrow_300_susd"]
Expand All @@ -115,43 +111,21 @@ extra.test_user_perps_account_id.arg = 0
# We want to ensure test user has some susd in their wallet to start interacting with perps market, so adding this dependency step
depends = ["invoke.withdraw_300_susd"]

[invoke.approve_100_susd_for_PerpsMarketProxy_to_spend]
target = ["perps_sandbox.core_sandbox.synthetix.USDProxy"]
[invoke.approve_300_susd_for_PerpsMarketProxy_to_spend]
target = ["perps_sandbox.synthetix.USDProxy"]
from = "<%= settings.test_user %>"
func = "approve"
args = [
"<%= imports.perps_sandbox.imports.perps_factory.contracts.PerpsMarketProxy.address %>",
"<%= parseEther('100') %>",
"<%= parseEther('300') %>",
]

[invoke.deposit_100_susd_to_perps]
[invoke.deposit_300_susd_to_perps]
target = ["perps_sandbox.perps_factory.PerpsMarketProxy"]
from = "<%= settings.test_user %>"
func = "modifyCollateral"
args = [
"<%= extras.test_user_perps_account_id %>",
0, # 0 is a special market id for sUSD
"<%= parseEther('100') %>",
"<%= parseEther('300') %>",
]

[invoke.commit_perps_eth_order]
target = ["perps_sandbox.perps_factory.PerpsMarketProxy"]
from = "<%= settings.test_user %>"
func = "commitOrder" # args below
depends = ["invoke.deposit_100_susd_to_perps"]

[[invoke.commit_perps_eth_order.args]]
marketId = "<%= imports.perps_sandbox.extras.perps_eth_market_id %>"
accountId = "<%= extras.test_user_perps_account_id %>"
sizeDelta = "<%= parseEther('1') %>"
settlementStrategyId = "0"
acceptablePrice = "<%= parseEther(String(1000 * 1.05)) %>" # 5% slippage
referrer = "<%= AddressZero %>"
trackingCode = "<%= HashZero %>"

[invoke.transfer_100_susd_to_another_user]
target = ["perps_sandbox.core_sandbox.synthetix.USDProxy"]
from = "<%= settings.test_user %>"
func = "transfer"
args = ["<%= settings.another_user %>", "<%= parseEther('100') %>"]
depends = ["invoke.withdraw_300_susd"]