Comment on page
Depositing Assets
ASK IS GAS NECESARY FOR DEPOSITING AND WITHDRAWING!!!
In order to use Finterest, one needs to send the canister the underlying tokens. From there, Finterest 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 Finterest 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.).
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.
1. Pay Fee using instructions in #Practical Tx Fee Management for Developers and Users Practical Tx Fee Management for Developers and Users
getBlockDepositAccountIdAsText: () -> (text) query;
dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai getBlockDepositAccountIdAsText
dfx ledger --network ic transfer --memo 1 --amount 0.1 --fee 0.0001 4ee4eb645821d3960db2c81db0b0d5e3b01a2ba48207c958c603b70cc2f5c67b
depositIcp: (nat64) -> (DepositReceipt);
dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai depositIcp "(<your block number>)"
dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai depositIcp "(99837:nat64)"
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;
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"
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.
You then notify the Finterest 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
dfx canister --network ic call deposit_icp '(500_010_000)'
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.
getDepositIcrcAccount: () -> (Account) query;
getDepositIcrcAccount():async Icrc1.Account
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
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;})"
dfx canister --network ic call "$ICRC-CANISTER-ID" icrc1_balance_of '("$ACCOUNT")'
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")'
dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_icrc1 '(principal "mxzaz-hqaaa-aaaar-qaada-cai",50_000_010)'
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 Finterest). 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 Finterest.
dfx canister --network=ic call "$DIP-CANISTER-ID" approve "(principal "z4viz-kiaaa-aaaal-qbxmq-cai", "$AMOUNT")"
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)"
The approval amount should be "$DIP-TOKEN-FEE" + "$AMOUNT"
dfx canister --network=ic call --query "$DIP-CANISTER-ID" allowance "(principal \"owner-account-principal\", principal \"spender-account-principal\")"
note the first principal is your principal and the second is the Finterest 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")"
dfx canister call --network ic call z4viz-kiaaa-aaaal-qbxmq-cai deposit_dip '(principal "$DIP-CANISTER-ID","$DIP-TOKEN-FEE+AMOUNT")
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")'
Last modified 7mo ago