Flash Swap

Transactions

1. AppCall:

Sender: user_address Index: tinyman_amm_v2_app_id OnComplete: NoOp App Args: [“flash_swap”, index_diff, asset_1_amount, asset_2_amount] Foreign Assets: [asset_1_id, asset_2_id] Accounts: [pool_address] Fee: (3 * min_fee)

2. AppCall (Group Index: index of flash swap call + index diff specified in the arguments):

Sender: user_address Index: tinyman_amm_v2_app_id OnComplete: NoOp App Args: [“verifiy_flash_swap”, index_diff] Foreign Assets: [asset_1_id, asset_2_id] Accounts: [pool_address] Fee: min_fee

Side Effects

  1. Flash Swap

Local State Changes

  1. lock

  2. asset_1_cumulative_price

  3. asset_2_cumulative_price

  4. cumulative_price_update_timestamp

Logs

To able to share data between app calls, these logs are added:

  1. asset_1_balance_after_transfer

  2. asset_2_balance_after_transfer

Inner Transactions

1. AssetTransfer (If asset 1 amount is not 0):

Sender: pool_address Receiver: user_address Index: asset_1_id Amount: asset_1_amount

2. AssetTransfer/Pay (If asset 2 amount is not 0):

Sender: pool_address Receiver: user_address Index: asset_2_id Amount: asset_2_amount

2. Verify Flash Swap

Local State Changes

  1. lock

  2. asset_1_reserves

  3. asset_2_reserves

  4. asset_1_protocol_fees

  5. asset_2_protocol_fees

Logs

  1. asset_1_output_amount

  2. asset_1_input_amount

  3. asset_1_poolers_fee_amount

  4. asset_1_protocol_fee_amount

  5. asset_1_total_fee_amount

  6. asset_2_output_amount

  7. asset_2_input_amount

  8. asset_2_poolers_fee_amount

  9. asset_2_protocol_fee_amount

  10. asset_2_total_fee_amount

Last updated