# API Explanation
## The relevant accounts
* Contract Account : danchorsmart
* Token Account : danchortoken
## Issue USN
transfer Tokens to danchorsmart , memo format is : "`issue:rate`"
```
cleos transfer testuseraaaa danchorsmart "100 EOS" "issue:15000"
```
## Query user debt positions
Check to see collateral id:
```
cleos get table danchorsmart danchorsmart collaterals
{
"rows": [{
"id": 1,
"contract": "eosio.token",
"sym": "4,EOS",
"status": 1,
"clear_rate": 12500,
"forfeit": 500,
"interest": 400,
"min_rate": 15000,
"last_price": 630180000,
"min_amount": "1.0000 EOS",
"max_amount": "10000000.0000 EOS",
"balance": "496252.9035 EOS",
"total_balance": "3708299.7951 EOS"
},{
"id": 2,
"contract": "btc.ptokens",
"sym": "8,PBTC",
"status": 1,
"clear_rate": 13000,
"forfeit": 500,
"interest": 400,
"min_rate": 15000,
"last_price": "3560823000000",
"min_amount": "0.00010000 PBTC",
"max_amount": "1000.00000000 PBTC",
"balance": "0.05000000 PBTC",
"total_balance": "0.05000000 PBTC"
}
],
"more": false
}
```
Query the user's debt warehouse record of a certain collateral
table name: danchorsmart, scope: collateral id, key: user name
```
cleos get table -L testuseraaaa -U testuseraaaa danchorsmart 1 debts
```
## By reducing the charge rate to issue new USN
Check to see collateral id
call the `adjust` action of Contract : [user,collateral id,rate,whether to generate usn]
```
cleos push action danchorsmart adjust '["testuseraaaa", 15000, true]' -p testuseraaaa
```
## Repay USN and withdraw EOS
Check to see collateral id
transfer USN to danchorsmart, memo format is: "`repay:collateral id:rate`"
```
cleos transfer -c danchortoken testuseraaaa danchorsmart "11.0000 USN" "repay:1:15000"
```
## Only Repay USN
Check to see collateral id
transfer USN to danchorsmart, memo format is: "`repay:collateral id:0`"
```
cleos transfer -c danchortoken testuseraaaa danchorsmart "11.0000 USN" "repay:1:0"
```
## Repay USN and withdraw EOS (Pay interest with collateral tokens)
Check to see collateral id
transfer USN to danchorsmart, memo format is: "`repay2:collateral id:rate`"
```
cleos transfer -c danchortoken testuseraaaa danchorsmart "11.0000 USN" "repay2:1:15000"
```
## Only Repay USN (Pay interest with collateral tokens)
Check to see collateral id
transfer USN to danchorsmart, memo format is: "`repay2:collateral id:0`"
```
cleos transfer -c danchortoken testuseraaaa danchorsmart "11.0000 USN" "repay2:1:0"
```
## Deposit
transfer EOS to danchorsmart, memo format is: "`deposit`"
```
cleos transfer testuseraaaa danchorsmart "100 EOS" "deposit"
```
## Withdraw EOS
call the `withdraw` action of Contract :
```
cleos push action danchorsmart withdraw '["testuseraaaa", "11.0000 EOS"]' -p testuseraaaa
```
## Bid
Check to see if there is an auction:
```
cleos get table danchorsmart danchorsmart auctions
{
"rows": [{
"aid": 1,
"collateral_id": 1,
"user": "testuseraaaa",
"price": 55063,
"pledge": "200.0000 EOS",
"issue": "327.9066 USN",
"remain_pledge": "169.9345 EOS",
"remain_issue": "327.9066 USN",
"create_time": "2021-05-28T07:56:00"
},,{
"aid": 2,
"collateral_id": 2,
"user": "testuserbbbb",
"price": 105063,
"pledge": "100.000000 BOX",
"issue": "500.9300 USN",
"remain_pledge": "60.950900 BOX",
"remain_issue": "245.9300 USN",
"create_time": "2021-05-28T07:56:00"
}
],
"more": false
}
```
If has any auction, You can buy it at a discount of 2%~10%
transfer USN to danchorsmart, memo format is: "`bid:collateral id:aid`"
```
cleos transfer -c danchortoken testuseraaaa danchorsmart "100 USN" "bid:1:2"
```
評論
0 條評論
請登入寫評論。