Skip to content

AMM Synch document #3832

@dobertRowneySr

Description

@dobertRowneySr

IBCO Joystream

somewhat at high level, to be shared with Bedeho and the Design team.

Assumptions

✅ means confirmed by Bedeho / Design team

  1. AMM can be started at any time, even when users/creator have already CRTs at their disposal (eg from a Sale) ✅
  2. Creator cannot mint or burn tokens in a discretionary way ✅
  3. Once AMM is shut down it cannot be re-started ✅
  4. Bonded tokens are minted into user account
  5. Unbonded token are burned
  6. Patronage is the only concurrent minting event
  7. Burn token is the only concurrent burning event
  8. JOYs from bonding are not given to the CRT issuer, just stored during the AMM lifetime
  9. Curve will be linear price(supply) = initial_price + sensitivity * supply, and sensitivity = 1 for now ✅. The correct amount of joy to be exchanged is obtained by integrating the price function from supply_before_bonding to supply_after_bonding when bonding (analogous when unbonding)
  10. AMM can be turned off only when JOY reserve amount equals 0
  11. Creator can set his initial allocation ✅
  12. Creator can unbond share of its own CRT, even when such amount is not backed by AMM reserve ✅
  13. AMM can be opened after sale ✅

User stories

Numerical values used are for sake of example, bonding and unbonding are theoretically inverse operations.
BC means bonding curve

User bonds with BC

Given

  • CRT Bondig Curve (identified by token_id = 1) supply value is supply = 1000
  • origin signed by user account sender
  • CRT 1 total supply is total_supply = 10,000
  • BC JOY reserve amount is 1,000,000

When

bond(origin, token_id = 1, crt_amount = 100) extrinsics executed with Ok(()) result

Then

  1. BC computes joy_amount that user is required to transfer:
    joy_amount = .5 * a * (1100^2 - 1000^2) + b * (1100 - 1000) = 105,100 using a,b = 1
  2. joy_amount = 105100 is transferred from sender into BC reserve_account
  3. crt_amount = 100 are minted into sender account
  4. BC supply value is set increased crt_amount and set to 1,100
  5. token_id total supply is also increased by crt_amount and set to 10,100
  6. reserve amount for BC increased by joy_amount and set to 1,105,100

User unbonds with BC

Given

  • CRT Bondig Curve (identified by token_id = 1) supply value is supply = 1,100
  • origin signed by user account sender
  • CRT 1 total supply is total_supply = 10,100
  • BC JOY reserve amount is 1,105,100

When

unbond(origin, token_id = 1, crt_amount = 100) extrinsics executed with Ok(()) result

Then

  1. BC computes joy_amount that BC is required to transfer back to the user:
    joy_amount = .5 * a * (1000^2 - 1100^2) + b * (1000 - 1100) = -105,100 using a,b = 1
  2. joy_amount = 105100 is transferred from BC reserve_account into sender account
  3. crt_amount = 100 are burned
  4. BC supply value is set decreased crt_amount and set to 1,100 - 100 = 1,000
  5. token_id total supply is also decreased by crt_amount and set to 10,100 - 100 = 10,000
  6. reserve amount for BC decreased by joy_amount = 105,100 and set to 1,105,100 - 105,100 = 1,000,000

Creator Story

Creator starts AMM

Given

token_id is a existing valid creator token.

When

activate_amm(token_id, initial_price = 100, sensitivity = 1) called with Ok(()) result

Then

  1. CRT offering state is set to Bonding Curve (or `AMM')
  2. Bonding curve is set up with provided parameters initial_price and sensitivity
  3. reserve_account for the BC is set set to be a (sub)account of the project_token module

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions