Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 1.6 KB

flash-loan.md

File metadata and controls

73 lines (54 loc) · 1.6 KB

Flash Loan

Transactions

1. AppCall:

Sender: user_address
Index: tinyman_amm_v2_app_id
OnComplete: NoOp
App Args: [“flash_loan”, 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 loan call + index diff specified in the arguments):

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

Side Effects

1. Flash Loan

Local State Changes

  1. asset_1_cumulative_price
  2. asset_2_cumulative_price
  3. cumulative_price_update_timestamp

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 Loan

Local State Changes

  1. asset_1_reserves
  2. asset_2_reserves
  3. asset_1_protocol_fees
  4. asset_2_protocol_fees

Logs

  1. asset_1_output_amount
  2. asset_1_input_amount
  3. asset_1_donation_amount
  4. asset_1_poolers_fee_amount
  5. asset_1_protocol_fee_amount
  6. asset_1_total_fee_amount
  7. asset_2_output_amount
  8. asset_2_input_amount
  9. asset_2_donation_amount
  10. asset_2_poolers_fee_amount
  11. asset_2_protocol_fee_amount
  12. asset_2_total_fee_amount