Depositing Assets

ASK IS GAS NECESARY FOR DEPOSITING AND WITHDRAWING!!!

In order to use Finny, one needs to send the canister the underlying tokens. From there, Finny gives you a protocol balance which we describe as your canister balance.

Similar to how centralize exchanges have individual balances built into their applications before trading, the Finny canister works using the same principal. Once the canister balances are recorded you may transact on the protocol as you like. (i.e. minting fTokens, repaying borrows, etc.).

🏦Depositing ICP

There are two ways to deposit ICP, one in which you check blocks and submitting the block number for a minted balance and another in which you send to a subaccount and clear it to the finrisk main deposit account. For the first method, if you lose the block before letting the canister know you will have to scan every block on the icp chain for your transaction. For the second method, you don't have to worry about this but you will have to input an extra 0.0001 ICP for the subaccount to the main deposit account.

🏦Method 1: Depositing with blocks

2. Get the Finrisk Canister ID

- View Finrisk Canister ID Candid Notation

getBlockDepositAccountIdAsText: () -> (text) query;

- View Finrisk Canister ID with dfx

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai getBlockDepositAccountIdAsText

3. Send ICP to the Finrisk Canister

dfx ledger --network ic transfer  --memo 1 --amount 0.1 --fee 0.0001 4ee4eb645821d3960db2c81db0b0d5e3b01a2ba48207c958c603b70cc2f5c67b

4. Once the Block Confirmation is Received, Notify the Central Canister by Passing in the Block Number

- Notify Canister Candid Notation

depositIcp: (nat64) -> (DepositReceipt);

- Notify Canister with dfx

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai depositIcp "(<your block number>)"

- A Concrete Example with dfx

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai depositIcp "(99837:nat64)"

🏦Method 2 Depositing Using a Subaccount

2. Get your Subaccount Deposit Account ID

- Getting Deposit Subaccount Candid Notation

The specific getDepositAccountIdAsXXX will depend on whether you use the ledger from dfx or through calling the ledger canister through code.

getDepositAccountIdAsText: () -> (text) query;
getDepositAccountIdAsBlob: () -> (blob) query;

3. Send to Subaccount

- Send ICP to Subaccount using dfx

Using the deposit account id from step 2:

NOTE: The transfer from the subaccount to the default account requires a 0.0001 ICP fee on top of the --fee flag fee. I.E. If you want 5 ICP to show up in your book, you need to input 5.0001 as below

dfx ledger --network ic transfer --amount 5.0001 --fee 0.0001 --memo 1 "$SUBACCOUNTID"

- A Concrete Example using dfx

dfx ledger --network ic transfer --amount 5.0001 --fee 0.0001 4ee4eb645821d3960db2c81db0b0d5e3b01a2ba48207c958c603b70cc2f5c67b

4. (Optional) If you want to view your deposit go to https://dashboard.internetcomputer.org/ and plug in that deposit account to the search bar.

5. Notify Fintrest Canister of Deposit

- Notify Canister Candid Notation

You then notify the Finny canister that you have sent ICP to your subaccount. It will then clear this balance sending it to the main canister's default account and mint you ICP on the canister book balance.

deposit_icp: (nat64) -> (DepositReceipt);

NOTE AGAIN: The transfer from the subaccount to the default account requires a 10_000 ICP fee on top of the --fee flag fee. I.E. If you want 500_000_000 ICP to show up in your book, you need to 5_000_100_00 as below

- Notify Canister using dfx

dfx canister --network ic call deposit_icp '(500_010_000)'

6. See #view-token-balance to view your account balances in the canister

🏦Deposit ICRC-1

Depositing ICRC-1 is only done via the Subaccount method for now. Most ICRC-1 canisters do not yet have archived blocks. Please only deposit the assets in the #assets. If you deposit anything else can't help you, well we probably can but we don't have the time.

2. Get the Deposit Subaccount

- Getting the Deposit Subaccount Candid Notation

getDepositIcrcAccount: () -> (Account) query;

- Getting the Deposit Subaccount with dfx

getDepositIcrcAccount():async Icrc1.Account

3. Send tokens to the ICRC-1 Subaccount

- Sending Tokens Using dfx

dfx canister --network ic call "$ICRC-CANISTER-ID" icrc1_transfer "((record { from_subaccount = null; to = "$ACCOUNT"; amount = "$AMOUNT"; fee = "$FEE"; memo = null; created_at_time = null;})"

HEADS UP: The transfer from the subaccount to the default account requires an additional unit of icrc fee on top of the fee flag. I.E. If you want 5 ckbtc to show up in your book, and the fee is 10 you need to amount needs to = 500_000_010 on top of the --fee = 10 fee flag.

Replace the "$ACCOUNT" above with the result you received in step 2

- Concrete dfx Example using ckBtc's canister ID

dfx canister --network ic call mxzaz-hqaaa-aaaar-qaada-cai icrc1_transfer "((record { from_subaccount = null; to = record {owner = principal "fggox-qyaaa-aaaah-abkbq-cai";subaccount = opt blob "T\8et\ba\a4\016\d3\13\15\f3\9f\ca\f5C#\d5dJ\b8\e5\c5\e9,ser)/\1f\c6\a2";},; amount = 5.00001; fee = 0.00001; memo = null; created_at_time = null;})"

4. (Optional) View Subaccount balance

dfx canister --network ic call "$ICRC-CANISTER-ID" icrc1_balance_of '("$ACCOUNT")'

5. Notfy the Canister of your Deposit

deposit_icrc1: (Token, nat) -> (DepositReceipt);
type Token = principal 

NOTE AGAIN: The transfer from the subaccount to the default account frequires an additional unit of icrc fee on top of the fee flag. I.E. If you want 50_000_000 ckbtc to show up in your book, and the fee is 10 you need enter in 50_000_010 for "$AMOUNT"

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_icrc1 '("$ICRC-CANISTER-ID","$AMOUNT")'

- Concrete example using dfx

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_icrc1 '(principal "mxzaz-hqaaa-aaaar-qaada-cai",50_000_010)'

6. See #view-token-balance to view your account balances in the canister

🏦Deposit DIP20

Depositing DIP20 tokens into the protocol requires one to approve the canister to use a certain amount of tokens. This is done by calling the 'approve()' method of DIP20 asset you want to deposit (if its supported by Finny). Please only deposit the assets in the token-list. If you deposit anything else can't help you, well we probably can but we don't have the time.

The following function must be called in our protocol and pass the token ID of the asset as stored in Finny.

2. Approve Balance you Want to Send

- Using dfx

dfx canister --network=ic call "$DIP-CANISTER-ID" approve "(principal "z4viz-kiaaa-aaaal-qbxmq-cai", "$AMOUNT")"

- A Concrete Example Using dfx

Please put in the exact amount you want to transfer unlike previous tokens. I.E. if you want 1_000 in your book approve 1_000. Note, upon transfer, your own balance will lose an additional "$DIP-TOKEN-FEE" But you do not need to specify it on approve.

dfx canister --network=ic call aanaa-xaaaa-aaaah-aaeiq-cai approve "(principal "z4viz-kiaaa-aaaal-qbxmq-cai", 1_000:nat)"

3. (Optional) View Approval Amount

The approval amount should be "$DIP-TOKEN-FEE" + "$AMOUNT"

- Using dfx

dfx canister --network=ic call --query "$DIP-CANISTER-ID" allowance "(principal \"owner-account-principal\", principal \"spender-account-principal\")"

-A Concrete Example Using dfx

note the first principal is your principal and the second is the Finny canister's

dfx canister --network=ic call --query aanaa-xaaaa-aaaah-aaeiq-cai allowance "(principal "e72ak-uu5s4-t3uba-ldsg5-yx7du-cn5t4-cvqoc-fkgoz-akjmp-3bljs-3qe", principal "z4viz-kiaaa-aaaal-qbxmq-cai")"

4. Notify the Finny Canister to Transfer from your Wallet to the Canister.

- Using dfx

dfx canister call --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_dip '(principal "$DIP-CANISTER-ID","$DIP-TOKEN-FEE+AMOUNT")

- A Concrete Example Using dfx

NOTE: For the amount you want in your book add a fee to the parameter for this function. I.E. if you want 1_000 minted and the fee is 2_000_000_000, put in 2_000_001_000

dfx canister call --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_dip '(principal "aanaa-xaaaa-aaaah-aaeiq-cai",2_000_001_000")'

5. See #view-token-balance to view your account balances in the canister

Last updated