Skip to content

Latest commit

 

History

History
109 lines (79 loc) · 2.44 KB

remove-liquidity.md

File metadata and controls

109 lines (79 loc) · 2.44 KB

Remove Liquidity

A. Multiple Assets Out

Transactions

1. AssetTransfer:

Sender: user_address
Receiver: pool_address
Index: pool_token_asset_id
Amount: pool_token_asset_amount

2. AppCall:

Sender: user_address
Index: tinyman_amm_v2_app_id
OnComplete: NoOp
App Args: [“remove_liquidity”, min_asset_1_out, min_asset_2_out]
Foreign Assets: [asset_1_id, asset_2_id]
Accounts: [pool_address]
Fee: (3 * min_fee)

Side Effects

Local State Changes

  1. asset_1_reserves
  2. asset_2_reserves
  3. issued_pool_tokens
  4. asset_1_protocol_fees
  5. asset_2_protocol_fees
  6. asset_1_cumulative_price
  7. asset_2_cumulative_price
  8. cumulative_price_update_timestamp

Inner Transactions

1. AssetTransfer:

Sender: pool_address
Receiver: user_address
Index: asset_1_id
Amount: (See formula III.A)

2. AssetTransfer/Pay:

Sender: pool_address
Receiver: user_address
Index: asset_2_id
Amount: (See formula III.A)

B. Single Asset Out

Transactions

1. AssetTransfer:

Sender: user_address
Receiver: pool_address
Index: pool_token_asset_id
Amount: pool_token_asset_amount

2. AppCall:

Sender: user_address
Index: tinyman_amm_v2_app_id
OnComplete: NoOp
App Args: [“remove_liquidity”, min_asset_1_out, min_asset_2_out]
Foreign Assets: [output_asset_id]
Accounts: [pool_address]
Fee: (3 * min_fee)

Side Effects

Local State Changes

  1. asset_1_reserves
  2. asset_2_reserves
  3. issued_pool_tokens
  4. asset_1_protocol_fees
  5. asset_2_protocol_fees
  6. asset_1_cumulative_price
  7. asset_2_cumulative_price
  8. cumulative_price_update_timestamp

Logs

  1. input_asset_id
  2. input_amount
  3. swap_amount
  4. output_asset_id
  5. output_amount
  6. poolers_fee_amount
  7. protocol_fee_amount
  8. total_fee_amount

Inner Transactions

1. App Call (to increase op code budget):

It is for increasing the opcode (computational) budget which is required for internal swap calculations.

2. AssetTransfer/Pay:

Sender: pool_address
Receiver: user_address
Index: output_asset_id
Amount: (See formula III.B)