description |
---|
Reference for Core V3 + Perps V3 on Base |
{% hint style="info" %}
- See deployment-info.md {% endhint %}
Andromeda is the combination of
- Core V3
- Perps V3
- USDC as collateral
The Spot Market is included, but only to be used as a mechanism to exchange the assets brought by traders and LPs (USDC) for the internal accounting tokens (sUSDC and sUSD).
- Unique to Andromeda Base is the use of a USDC wrapper, enabling USDC to appear to be used as collateral for LPs, and as margin as perp traders.
- Underneath, USDC is wrapped and or traded into sUSDC for LP collateral (and collecting fees), and sUSD as perp margin
- The full configuration of Base Goerli can be seen on Cannon
- See #andromeda-on-base-goerli for Addresses and ABIs
- Configuration explained:
- this is the part that deploys sUSDC (a USDC synth) and creates the spot market
- USDC <--> sUSDC can be wrapped/unwrapped on the spot market
- sUSD <--> sUSDC can be bought/sold on the spot market
- No fee on these, all atomic so can be composed with multicalls
- Coming: Andromeda Base Sandbox, but in the meant time see Cannon config
{% embed url="https://usecannon.com/packages/synthetix-omnibus/latest/84531-andromeda" %} Base Goerli Andromeda {% endembed %}
{% hint style="info" %} The Andromeda Release is configured to use oracle contracts which comply with ERC-7412. Use the client library when building off-chain integrations like UIs and bots. {% endhint %}
LPs can arrive with USDC to provide liquidity (LP). The contracts or integrators need to:
- Wrap USDC to sUSDC on the Spot Market
- Function:
SpotMarketProxy.wrap(marketId, wrapAmount, amountReceived)
- Example:
wrap(1, 1000000000000000000, 1000000000000000000)
- Function:
- Deposit sUSDC to Pool
- Delegate sUSDC to Market
When withdrawing, initial collateral plus any fees can be withdrawn, then unwrapped from sUSDC to USDC.
Integrators can create a seamless trading experience using USDC by utilizing the wrapper and spot market. Since USDC-sUSDC
and sUSDC-sUSD
exchanges are both 1:1 swaps, integrators can easily prepare a multicall to "zap" between USDC in their wallet and their account margin.
Integrators can directly deposit and withdraw USDC by preparing a multicall to execute in a single transaction. These transactions interact with the SpotMarketProxy
to wrap and swap USDC for sUSD. Use marketId = 1
for sUSDC
. Matching values like wrapAmount
and amountReceived
in the transactions will guarantee this 1:1 swap.
All transactions should be prepared as a multicall and sent to the TrustedMulticallForwarder
contracts using aggregate3Value
.
An account must meet the following requirements to execute USDC transfers between their wallet and a perps account.
Deposit:
- Holds an account NFT for perps. See creating an account.
- Approve
SpotMarketProxy
to transfer USDC - Approve
SpotMarketProxy
to transfer sUSDC - Approve
PerpsMarketProxy
to transfer sUSD
Withdraw:
- Account NFT has some withdrawable margin
- Approve
SpotMarketProxy
to transfer sUSD - Approve
SpotMarketProxy
to transfer sUSDC
Deposit perp margin
USDC -> sUSDC
- Wrap USDC on the spot market- Function:
SpotMarketProxy.wrap(marketId, wrapAmount, amountReceived)
- Example:
wrap(1, 1000000000000000000, 1000000000000000000)
- Function:
sUSDC -> sUSD
- Sell sUSDC for sUSD on the spot market- Function:
SpotMarketProxy.sell(marketId, synthAmount, minUsdAmount, referrer)
- Example:
sell(1, 1000000000000000000, 1000000000000000000, 0x0000000000000000000000000000000000000000)
- Function:
- Deposit sUSD
- Function:
PerpsMarketProxy.modifyCollateral(accountId, synthMarketId, amountDelta)
- Example:
modifyCollateral(12345, 0, 1000000000000000000)
- Function:
Withdraw perp margin
- Withdraw sUSD
- Function:
PerpsMarketProxy.modifyCollateral(accountId, synthMarketId, amountDelta)
- Example:
modifyCollateral(12345, 0, -1000000000000000000)
- Function:
sUSD -> sUSDC
- Buy sUSDC on the spot market- Function:
SpotMarketProxy.buy(marketId, usdAmount, minAmountReceived, referrer)
- Example:
buy(1, 1000000000000000000, 1000000000000000000, 0x0000000000000000000000000000000000000000)
- Function:
sUSDC -> USDC
- Unwrap sUSDC on the spot market- Function:
SpotMarketProxy.unwrap(marketId, unwrapAmount, minAmountReceived)
- Example:
unwrap(1, 1000000000000000000, 1000000000000000000)
- Function:
Sample Margin Transactions
- Perp order settlement and liquidation keepers are running on Goerli, and you can run your own perps-v3-keeper.md
- Base Goerli keeper for order settlement and liquidation
- Base Goerli Perp trades