Cope trading pools are programs that execute orders on Mango Markets using the user deposited COPE as collateral, the program automatically re-invests profits into the COPE collateral pool.
Each trading pool has a unique PDA for holding assets, and a trading authority that can execute orders.
Users deposited stake is represented with a pool token mechanism, whose value increases in proportion to COPE in the trading pool. Users can withdraw funds from the pool based on the exchange rate between the pool token and COPE.
Orders in a trade pool can be creaded by a trading authority, representing a wallet address that is recorded in the trading pool.
The trading authority is analogous to a "trader" or an entity executing an arbitrary trading strategy.
When trading the program based in an order executes a trade on Mango Markets using COPE as collateral, when a position is closed the profits are converted into COPE and added to the collateral pool. This increases the value of pool tokens held by the users and further decreses the supply on COPE on the market (is there enought liquidity for this?). Inversly on bad trades COPE from the collateral pool can be sold to cover the borrowd assest on MM.
Depositing and Withdrawing
When users deposit COPE into the pool, they receive pool tokens, with which they can later withdraw the deposited COPE + their ROI.
Withdrawing can only be done during periods when trading is disabled, as the amount of COPE in the pool, can affect open positions.
The idea behind pool tokens is that the ROI is inherit in the exchange rate between COPE and the pool token.
Amount of pool tokens are minted as:
- - Amount of pool tokens received after the deposit
- - Amount of COPE deposited
- - Total number of pool tokens
- - Total amount of COPE in the pool
- - Amount of COPE to withdraw
- - Amount of returned pool tokens
When depositing, new pool tokens are minted. The pool controls the mint for its own pool token.
When withdrawing the pool tokens are exchanged for COPE and burned by the pool, this way the exchange rate is not affected.