Contract Specific Design
Utilizing the design pattern of Uniswap V2, the modular design is divided into the following modules, with events reserved for data aggregation in a subgraph or backend:
1. StrategyFactory:
a. Create Strategy (Create Pool): Users can create trading strategies (pools) and grant authorization to the fee management contract.
b. Invoke Cross-Chain Contract to Create Strategy and Initiate First Order: Users can call a cross-chain contract to create a strategy and initiate the first order, with a minimum of 1000 CUSD.
c. Strategy IBC Memo: The memo for a created strategy contains:
i. Pair ID for the trading pair (e.g., ETH:CUSD).
ii. Pair address: This corresponds to the pair contract for the trading strategy, and only memos with less liquidity sent to this contract will be recognized in the future.
2. StrategyPair:
a. Create Orders (Add Liquidity): Users can create orders and add liquidity to the strategy pair.
b. Request Liquidity Reduction: Users can request to reduce liquidity.
c. Withdraw Stablecoin: Allows users to withdraw stablecoin.
d. Update Fund Net Value: Consider precision issues, with precision tentatively set at 9 decimal places (1,000,000,000).
e. Invoke Cross-Chain Contract for Liquidity Addition (Cross-Chain Coin is Stablecoin): Users can add liquidity across different chains, with stablecoin as the cross-chain asset.
f. Invoke Cross-Chain Contract for Liquidity Reduction (Cross-Chain Coin is 0; Information is the Amount of LP Tokens to Cross Back): After calculating the specific quantity for cross-chain return in MarginX, users can call this function.
g. Aggregate the Quantities of LP Tokens for Cross-Chain Liquidity Addition and Reduction: After adding or reducing liquidity across chains, LP token quantities are aggregated.
i. Memo structure: {"amount":" amount "} => LP token quantity.
ii. After cross-chain actions, update the fund net value. MarginX ensures that the corresponding CUSD is placed in the appropriate pair contract before updating.
3. Action:
This module aggregates CoastDAO for batch operations.
Last updated