COPE trading pools are on-chain pools in which users can deposit COPE. User deposits is represented by a pool token, which automatically increase or decrease in value proportionally to the trading pool.
The trading pools are run on calls from COPE Leaderboard participants. These pools can open spot orders on Mango Markets with the deposited COPE as collateral.
Users can deposit COPE into the trading pool and will receive a number of pool tokens that is proportional to the net value of their deposit and net value of the trading pool.
For example, if a uses deposits 10 COPE value at $50 and the trading pool value is $50,000, their proportional deposit represents 0.1% of the total pool value. If the pool token supply is 5,000 the user will receive 0.1% * 5,000 = 5 pool tokens.
Users can at any time withdraw exchange pool tokens for deposited funds + ROI from the trading pool.
Withdraw of funds is instant, however because Mango markets enables margin trading, the trading pool will disable withdraws in case the account health falls below a certain level to protect itself from liquidations. If this happens, currently a manual re-adjust of open positions is necessary to improve account health, and users can continue to withdraw.
The trading pool program uses a number of PDAs to secure its operations.
- Trading authority PDA is used to interact with Mango markets.
- Minting authority PDA is used to mint new pool tokens.
The only available operations to the pool are opening / cancelling stop orders (prep coming in v2). Additionally there is no admin/privileged access to the trading pool that would enable anyone to withdraw the mango account funds or mint new pool tokens.
Some operations like withdrawing are computationally expensive, which requires us to find novels ways to deal with constraints of the Solana runtime. For this reason we are finding ways to chain instructions and contribute this back to Anchor.