# CommercioMint

The commerciomint module is the one that allows you to create Collateralized Debt Positions (CDPs) using your Commercio.network tokens (ucommercio) in order to get Commercio Cash Credits (uccc) in return.

A Collateralized Debt Position (CDP) is a core component of the Commercio Network blockchain whose purpose is to create Commercio Cash Credits (uccc) in exchange for Commercio Tokens (ucommercio) which it then holds in escrow until the borrowed Commercio Cash Credits are returned.

In simple words, opening a CDP allows you to exchange any amount of ucommercio to get half the amount of uccc. For example, if you open a CDP lending 100 ucommercio will result in you receiving 50 uccc.

# Transactions

# Open a CDP

# Transaction message

To open a new CDP you need to create and sign the following message:

{
  "type": "commercio/MsgOpenCdp",
  "value": {
    "deposited_amount": [
      {
        "amount": "<amount to be deposited>",
        "denom": "<token denom to be deposited>"
      }
    ],
    "depositor": "<user address>"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12

A maximum of 1 MsgOpenCdp messages can be sent in each transaction.

# Action type

If you want to list past transactions including this kind of message, you need to use the following message.action value:

openCdp
1

# Close a CDP

# Transaction message

To close a previously opened CDP you need to create and sign the following message:

{
  "type": "commercio/MsgCloseCdp",
  "value": {
    "signer": "<user address>",
    "timestamp": "<block height at which the CDP is being inserted into the chain>"
  }
}
1
2
3
4
5
6
7

# Action type

If you want to list past transactions including this kind of message, you need to use the following message.action value:

closeCdp
1

# Set CDP collateral rate

WARNING

This transaction type is accessible only to the government.
Trying to perform this transaction without being the government will result in an error.

# Transaction message

To set the CDP collateral rate you need to create and sign the following message:

{
  "type": "commercio/MsgSetCdpCollateralRate",
  "value": {
    "signer": "<user address>",
    "cdp_collateral_rate": "<floating-point collateral rate>"
  }
}
1
2
3
4
5
6
7

# Action type

If you want to list past transactions including this kind of message, you need to use the following message.action value:

setCdpCollateralRate
1

# Queries

# Reading all CDP opened by a user at a given timestamp

# CLI

cncli query commerciomint get-cdp [user-addr] [block-height]
1

# REST

Endpoint:

/commerciomint/cdps/${address}/${timestamp}
1

Parameters:

Parameter Description
address Address of the user for which to read the CDP
timestamp Timestamp of when the CDP request was made
# Example

Getting CDPs opened by did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke at timestamp 1570177686:

http://localhost:1317/commerciomint/cdps/did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke/1570177686
1

# Response

{
  "height": "0",
  "result": {
    "deposited_amount": [
      {
        "amount": "10000000",
        "denom": "ucommercio"
      }
    ],
    "liquidity_amount": {
      "amount": "500000",
      "denom": "uccc"
    },
    "owner": "did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke/1570177686",
    "timestamp": "1570177686"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# Reading all CDP opened by a user

# CLI

$ cncli query commerciomint get-cdps [user-addr]
1

# REST

Endpoint:

/commerciomint/cdps/${address}
1

Parameters:

Parameter Description
address Address of the user for which to read all the CDPs
# Example

Getting CDPs opened by did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke:

http://localhost:1317/commerciomint/cdps/did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke
1

# Response

{
  "height": "0",
  "result": [
    {
      "deposited_amount": [
        {
          "amount": "10000000",
          "denom": "ucommercio"
        }
      ],
      "liquidity_amount": {
        "denom": "uccc",
        "amount": "500000"
      },
      "owner": "did:com:15erw8aqttln5semks0vnqjy9yzrygzmjwh7vke/1570177686",
      "timestamp": "1570177686"
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# Reading the current CDP collateral rate

# CLI

cncli query commerciomint collateral-rate
1

# REST

Endpoint:

/commerciomint/collateral_rate
1
# Example

Getting the current CDP collateral rate:

http://localhost:1317/commerciomint/collateral_rate
1

# Response

{
  "height": "0",
  "result": "2.000000000000000000"
}
1
2
3
4