Skip to content

Latest commit

 

History

History
79 lines (44 loc) · 3.97 KB

HOW-TO-USE-CONTRACT.md

File metadata and controls

79 lines (44 loc) · 3.97 KB

How to deploy and use Crossfader module

Prerequisite

  1. use CLI in contracts/crossfader
  2. Don't forget to remove [addresses] field in Move.toml before your deployment

Deploy module

aptos move create-resource-account-and-publish-package --seed 1235 --address-name ra_addr --named-addresses origin_account=[YOUR_ACCOUNT_ADDRESS]

  1. It creates a resource acccount with the given seed.
  2. It publishes package. When the package published, your account loses the control of resource account.
  3. init_module is called when it published

Reference)

Initialization before starting the service

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::init_vaults --type-args 0x1::aptos_coin::AptosCoin

It is another step for initializing the contract. It needs just to be called once in Crossfader. Every user uses the same module. It is totally safe because nobody has a control over the resource account module.

With the type args, Crossfader can be used for any coins!

Initialization for each user

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::initialize --type-args 0x1::aptos_coin::AptosCoin --args address:0x1223334444 u64:10000

It is called for each user. In a command line interface, don't forget to create the second account. Absolutely, users don't need to create it. Crossfader's server will create it and secure it with users' SSO auth :D

Deposit APT

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::deposit --type-args 0x1::aptos_coin::AptosCoin --args u64:100000

Direct withdrawal

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::request_withdraw --type-args 0x1::aptos_coin::AptosCoin --args address:0x12351131234 u64:5000

Withdrawal limitation is 10000, so you can use your 5000 APT only with your account signature.

2FA case

Withdrawal request

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::request_withdraw --type-args 0x1::aptos_coin::AptosCoin --args address:0x12351131234 u64:6000

Withdrawal sum exceeded the limit! You need another approval with Crossfader's safe 2FA.
Fyi, the sum is calculated among 1 day.

Withdrawal approval

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::deposit --type-args 0x1::aptos_coin::AptosCoin --args address:[YOUR ACCOUNT ADDRESS] address:0x12351131234 u64:6000 --profile [PROFILE]

The withdrawal request need to be approved from 2FA. In a test env, for getting signature of the second account(as a role of a server-side auth), you can use CLI options like --profile, --private-key, --private-key-file, --sender-account. Of course, in real Crossfader service, the only thing a user needs to do is SSO auth :D

Test Staking assets in your vault

This part is planned to be implemented.

Deploy sample defi service for testing

For testing, deploy SampleDefi like Crossfader.
In contracts/sample-defi,
aptos move create-resource-account-and-publish-package --seed 12333535 --address-name ra_addr --named-addresses origin_account=[YOUR_ACCOUNT_ADDRESS]

And then initialize it,
aptos move run --function-id 55790d1f3e8f4b0325f9d8b648952f982a95f2678706f500b4b18242b9c72d6a::sampledefi::init_coin_store --type-args 0x1::aptos_coin::AptosCoin

Staking

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::stake --type-args 0x1::aptos_coin::AptosCoin --args u64:6000

Unstaking

aptos move run --function-id 675340b1ccf7f77b888dbc13e70460eb95da791c8af2202230be4e6528559799::clank_draft::unstake --type-args 0x1::aptos_coin::AptosCoin --args u64:6000