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:

NameNetworkAccount info contract hashContract owner

Factory

Testnet

hash-13cc83616c3fb4e6ea22ead5e61eb6319d728783ed02eab51b1f442085e605a7

Casper Association

Wcspr

Testnet

hash-4f2d1b772147b9ce3706919fe0750af6964249b0931e2115045f97e1e135e80b

Casper Association

Dai

Testnet

hash-ffb8fa3073c7623484f76d79bc8baad110b24936b92d5ebc854d401895e88c95

Casper Association

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:

Parameter NameType

token_borrow

Key

amount

U256

token_pay

Key

user_data

String

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:

Parameter NameType

sender

Key

amount0

U256

amount1

U256

data

String

This method returns nothing.

Last updated