Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Profit Pools Spec [WIP]

Felix Feng edited this page Oct 23, 2019 · 4 revisions

Taker Considerations

  • How to efficiently aggregate liquidity across the different pools (infinite loop problem)
  • It would suck if you have to approve to every single ProfitPool. Or need to send funds to every profit pool. It's a for loop of transfers
  • Initially, there can be a low variety of ProfitPool spreads for few markets (e.g. 1% and 0.5%)
  • However, there should be discovery of these markets. (Maybe only allow 20 basis point increments to limit queue size)
  • Should be cheap & easy to calculate / derive blended cost and single source of approvals for all pairs. Starting to think that the factory should own approvals all the state.
  • Oracle + Pair -> Spread (Usually oracles work only for a specific pair)

Properties

  • Use the price feed / oracle you trust (as long as ETH/token pair)
  • Tokenized and pooled positions of the same pair / spread
  • Activity-based yield with defined requirements

Risks

  • Oracle corruption
  • Market / Oracle lag time

Smart Contracts

  • ProfitPool: Smart contract with a defined token pair and spread requirements. Lower spreads should result in more activity. Higher spreads means lower activity
  • ProfitPoolFactory: Used to add ProfitPools of new spread requirements. Each profit pool factory is linked to a certain oracle. Arbitrary token pairs don't really matter

ProfitPoolFactory

Design

  • LinkedList to track spread tokens
  • Stores balances of ProfitPools
  • Serves as source of approval and transfers

State

  • oracle
  • tokenA
  • tokenB
  • spread -> address

State

ProfitPool.sol is ERC20

State

  • tokenA
  • tokenB
  • spread
  • AToBOracle

Functions

constructor(tokenA, tokenB, spread, oracleAddress)

Sets the above

deposit(uint256 quantity) payable external

Deposits the specified pool token quantities of the specified quantity and generates a token based on the contribution.

withdraw(uint256 quantity) payable external

Burns the representative token and withdraws the current available mix.

use(address token, uint256 quantity)

  • Calls an external function smart contract that retrieves the quantity of tokens
  • Validates that the required spread is made - based on the oraclePrice

tokenAQuantity() public view returns(uint256)

tokenBQuantity() public view returns(uint256)