FLASH SWAPPER

Deploying FLASH SWAPPER contract manually

If you need to deploy the Flash swapper contract manually you'll have to pass the other contracts hashes as parameters.

The following is the command necessary to deploy the Flash Swapper contract:

sudo casper-client put-deploy \
    --chain-name chain_name \
    --node-address http://$NODE_ADDRESS:7777/ \
    --secret-key path_to_secret_key.pem \
    --session-path path_to_wasm_file \
    --payment-amount 10000000000 \
    --session-arg="public_key:public_key='Public Key In Hex'" \
    --session-arg="uniswap_v2_factory:Key='Hash of factory Contract'" \
    --session-arg="wcspr:Key='Hash of WCSPR Contract'" \
    --session-arg="dai:Key='Hash of DAI Contract'" \
    --session-arg="contract_name:string='contract_name'"

You will need to deploy other contracts before deploying the Flash Swapper Contract, and pass these contracts hashes to the respective parameters above.

These contracts have already been deployed and their hashes are displayed in the table below:

Listed below are the command templates for manually deploying these contracts:

Factory

sudo casper-client put-deploy \
    --chain-name chain_name \
    --node-address http://$NODE_ADDRESS:7777/ \
    --secret-key path_to_secret_key.pem \
    --session-path path_to_wasm_file \
    --payment-amount 10000000000 \
    --session-arg="public_key:public_key='Public Key In Hex'" \
    --session-arg="fee_to_setter:Key='Hash of fee-to-setter Contract'" \
    --session-arg="contract_name:string='contract_name'"

Wcspr

sudo casper-client put-deploy \
    --chain-name chain_name \
    --node-address http://$NODE_ADDRESS:7777/ \
    --secret-key path_to_secret_key.pem \
    --session-path path_to_wasm_file \
    --payment-amount 10000000000 \
    --session-arg="public_key:public_key='Public Key In Hex'" \
    --session-arg="name:string='token-name'" \
    --session-arg="symbol:string='token-symbol'" \
    --session-arg="decimals:u8='unsigned integer value'" \
    --session-arg="contract_name:string='contract_name'"

Dai

sudo casper-client put-deploy \
    --chain-name chain_name \
    --node-address http://$NODE_ADDRESS:7777/ \
    --secret-key path_to_secret_key.pem \
    --session-path path_to_wasm_file \
    --payment-amount 10000000000 \
    --session-arg="public_key:public_key='Public Key In Hex'" \
    --session-arg="name:string='token-name'" \
    --session-arg="symbol:string='token-symbol'" \
    --session-arg="decimals:u8='unsigned integer value'" \
    --session-arg="contract_name:string='contract_name'"

Entry point methods

Flash Swapper's entry point methods are listed below:

start_swap

Starts swap.

Special Instructions: The user has to call this (start_swap) method first in order to call the uniswap_v2_call method. In turn,Start_swap will call 3 additional methods:

  • simple_flash_loan This method will be invoked if both tokens (token_borrow and token_pay) are the same.

  • simple_flash_swap This method will be invoked if both tokens (token_borrow and token_pay) are not the same. One of them must be equal to “Hash-0000000000000000000000000000000000000000000000000000000000000000”

  • triangular_flash_swap This method will be invoked if both tokens (token_borrow and token_pay) are not the same. The above methods will invoke the swap methods of Pair Contract by using the permissioned_pair_address,upon which the swap method will invoke the uniswap_v2_call method.

Parameters table:

This method returns nothing.

uniswap_v2_call

Calls the swap method of pair contract.

The sender must be a Flash Swapper Contract hash if user data contains a value.

Uniswap_v2_call must be called from a contract, as users cannot directly invoke this method.

Parameters table:

This method returns nothing.

Last updated