On this page

latest contributor to this doc

Last Edit:

@gcharang↗

Pegs

The Pegs Antara Module is in the final stages of production. The specifics of the implementation are also subject to change. Please reach out to the Komodo team for consultation before attempting to use this module in a production environment.

The Pegs Antara Module is a mechanism for creating a decentralized stablecoin.

A stablecoin is a cryptocurrency that has a financial value that is "pegged" to another asset. Stablecoins can be used in a Smart Chain environment to allow users to buy, sell, and trade with on-chain assets that mimic off-chain prices.

For example, a stablecoin can be pegged to a common fiat currency, such as USD or EUR. The stablecoin can also mimic stocks, external cryptocurrencies, and other assets, so long as reliable price-data can be accessed through an online application programming interface (API).

The Pegs Antara Module requires interactivity with several additional Antara Modules, including the following:

  • The Gateways Module
    • This module acts as a bridge between the Smart Chain where Pegs is active and an external cryptocurrency
      • The external cryptocurrency must be based on the Bitcoin protocol
      • Typically, this external Smart Chain features a coin, such as KMD, that is tradeable in many venues across the cryptocurrency industry
    • On the external cryptocurrency blockchain, a user sends cryptocurrency coins to a multisignature address that is controlled by the Gateways Module, which locks the coins against further spending for the duration of the usage of the Pegs Module
    • On the Pegs-related Smart Chain, the Gateways Module then issues to the user tokens that represent the value of the user's locked funds
  • The Tokens Module
    • This module provides the functionality necessary to manage a cryptocurrency-based token system in coordination with the Gateways Module
    • These tokens represent the (now locked) value of the external Bitcoin-protocol or Komodo-protocol based cryptocurrency
    • These tokens can be spent and traded as actual cryptocurrency; the user who returns them to the Gateways Module at a later time will unlock and receive the associated external funds
  • The Oracles Module
    • This module uses an oraclefeed app to provide information to the Gateways Module about tokens a user deposits
  • The Prices Module
    • The Prices Module obtains data from a range of external sources (defined by a developer) and makes this information available on the Pegs Smart Chain
    • This module utilizes functionality from the Oracles Module to transfer the obtained data from the real world into the digital world
    • The Prices Module is responsible for tracking the value of an external asset (including assets external to the Komodo ecosystem) for on-chain price mimicry
    • Data from the Prices module becomes available for Smart Chain activity after a twenty-four hour delay

There are several technical elements involved in the Pegs Antara Module that collaborate to create a stablecoin.

The first aspect relies on three different Antara Modules: Gateways, Tokens, and Oracles.

On any cryptocurrency blockchain that is built on the Bitcoin protocol, such as KMD, users send funds to a multisignature address that is controlled by the Komodo-based Gateways Module that is active on this chain. The Gateways Module locks these funds against further spending at this time.

Once the funds are locked, the three modules together automatically make available to the user an equivalent number of tokens on the Pegs-related Smart Chain. These tokens represent the locked funds on a 1:1 ratio at the satoshi level (each token represents one satoshi of the external coin).

As these tokens are 1:1 representations of the locked funds, the value of these tokens does not change in respect to the associated funds. However, the cryptocurrency represented may not have a stable value.

The second aspect relies on the Prices Antara Module.

Before the user can exchange their tokens for a stablecoin, the Smart Chain must be able to determine the stablecoin's projected market value (such as the market value of USD).

Using data provided by a wide range of online application programming interfaces (APIs), which can be manually determined by a developer, these two modules create a stable rate of exchange between the user's tokens and the pegged stablecoin.

With these two elements (the user's tokens and a rate of exchange) the Pegs Antara Module is now able to offer a stablecoin.

The user sends their tokens (such as tokenized KMD) to the Pegs Module, which locks the tokens against further spending for the duration of Pegs usage.

Once the funds are locked, the Pegs Module creates native coins on the Pegs-related Smart Chain and issues these new coins to the user. The exchange rate between the user's deposited tokens and the native Smart Chain coins is determined by the data-driven rate of exchange.

The user may only withdraw up to 80% of the current financial value of the locked external cryptocurrency funds. The other 20% is held as a collateralized loan, available to assist in maintaining the stablecoin's value, if necessary.

In this manner, the native Smart Chain coins become the intended stablecoin.

As time progresses, the difference in price between the user's tokenized cryptocurrency and the stablecoin will change. Consider for example that the user is using KMD as the deposited cryptocurrency to access a stablecoin that mimics the USD fiat currency. The stablecoin in this example is named USDK.

The rules of liquidation found below are applicable only when the "global-debt ratio" β€” the ratio of all user deposits and debts at current prices on the Smart Chain β€” is higher than 60%.

If the global-debt ratio is lower than 60%, no accounts are in danger of liquidation, regardless of their individual debt ratio.

If the value of KMD increases relative to USD, the user may withdraw additional USDK coins from their Pegs account, until the total withdrawn USDK amount is again equal to 80% of the total value of the deposited KMD tokens.

On the other hand, if the value of KMD decreases relative to USD, the remaining amount of KMD tokens in the user’s account are subject to liquidation.

There are two stages to account liquidation: "yellow zone" and "red zone."

The yellow zone applies to accounts where the user has withdrawn a value of USDK (also called "debt") that, due to price volatility, now exceeds the 80% withdrawal limit, but is not yet at a level of 90%.

In this circumstance, a third-party user on the Pegs-related Smart Chain may deposit USDK coins on behalf of the indebted user's acccount, and receive the equivalent value of KMD tokens. These tokens are withdrawn from the indebted user's account.

The USDK coins are burned, thus preserving the ratio of withdrawn USDK coins in sync with the global total value of KMD tokens deposited on the Pegs-related Smart Chain.

Should the debt of a user's account surpass the 90% threshold, the account enters the red zone.

Here, a third-party user can gain an immediate 5% rate of return by sending USDK coins to the Pegs Module to liquidate the indebted user's account. The third-party user must deposit USDK to cover the user's whole debt, valued at 90% of the indebted account's KMD tokens, according to current prices.

In return, the liquidating user receives 95% of the KMD tokens in the indebted user's account. These KMD tokens can be redeemed on the KMD chain and, if sold at the current price, provide a 5% profit.

The USDK coins sent by the liquidating user are burned.

The remaining indebted user's KMD tokens are donated to the Pegs Antara Module, where they continue to support the maintenance of a healthy backing coin vs stablecoin ratio (KMD:USDK). In case the account debt was exactly 90% at the moment of liquidation, the remaining will be 5%.

The liquidated user still holds their USDK coins and can exchange them for KMD tokens from another account that is in the yellow zone.

To prevent account liquiditation, when the user who created the account detects that their account is approaching the 90% debt-ratio threshold, they have two options available.

The depositor can return an amount of USDK coins that satisfies 100% of the outstanding balance of their collateralized loan at current prices.

Alternatively, the depositor can deposit more tokenized KMD to their account at current prices until the user's debt/loan ratio is safely below the 80% threshold.

  • The Smart Chain creator creates an instance of the Pegs Antara Module, called a "Peg", using the pegscreate API method.
    • Once created, the creator adds this new Peg creation's transaction id called the pegstxid to the Smart Chain's launch parameters using the -earlytxid parameter
  • With the Peg active on the Smart Chain, a user locks tokenized external cryptocurrency to the Pegs Module using pegsfund
  • The user can withdraw up to 80% of the value of their locked tokens in the form of the Smart Chain's coins using pegsget
  • At anytime, the user can redeem the locked tokenized external cryptocurrency by repaying the Smart Chain's coins using pegsredeem
  • A user can retrieve the current information about their Pegs account using pegsaccountinfo
  • A user can retrieve all past actions related to their Pegs account using pegsaccounthistory
  • A user can retrieve current information about the Peg using pegsinfo
  • A user that has not yet created an account can exchange native coins of the Smart Chain for deposited tokens belonging to another user's account where the debt ratio is in the "yellow zone", 80% to 90%, using pegsexchange
  • A user can retrieve information about accounts that have a debt ratio in the "red zone", +90%, using pegsworstaccounts
  • A user can liquidate the "red zone" account of another user, receiving KMD tokens in return according to the current price, as well as a 5% additional profit, using pegsliquidate

The Antara Tutorials section features full walkthroughs for the Pegs Module.

Link to the user side of the Pegs Module Tutorial

Link to the creator side of the Pegs Module Tutorial

pegsaccounthistory pegstxid

The pegsaccounthistory method returns all the past actions related to the Pegs account of the user who executes the method.

The method relies on the pubkey address provided by the user when launching the daemon to determine the Pegs account for which the method will retrieve data.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg

NameTypeDescription
"result"(string)whether the command executed successfully
"name"(string)the name of the method
"account history"(array of json)an array containing json data that describe the past actions related to the user's Pegs account
"action"(string)the name of the past action
"amount"(number)the amount of satoshis involved
"accounttxid"(string)the transaction id of the action
"token"(string)the name of the token involved
"deposit"(number)the amount of initial satoshis deposited
"debt"(string)the total amount of debt after the associated action

Command:

./komodo-cli -ac_name=HELLOWORLD pegsaccounthistory a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7

pegsaccountinfo pegstxid

The pegsaccountinfo method returns the current information of the Pegs account belonging to the user who executes the method.

The method relies on the pubkey provided by the user when launching the daemon to determine the account for which the method will retrieve data.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg

NameTypeDescription
"result"(string)whether the command executed successfully
"name"(string)the name of the method
"account info"(array of json)an array containing json data that describe the user's Pegs account
"token"(string)the name of the token involved
"deposit"(number)the amount of initial satoshis deposited
"debt"(string)the total amount of current debt
"ratio"(string)the debt ratio based on the current price

Command:

./komodo-cli -ac_name=HELLOWORLD pegsaccountinfo a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7

pegsaddress [pubkey]

The pegsaddress method returns information about the Pegs module and associated addresses.

Optionally, if a pubkey is supplied, this method also returns the corresponding Pegs CC Address and balance.

NameTypeDescription
pubkey(string, optional)the pubkey of another user on the network

NameTypeDescription
"result"(string)whether the command executed successfully
"PegsCCAddress"(string)taking the contract's EVAL code as a modifier, this is the public address that corresponds to the contract's privkey
"PegsCCBalance"(number)the amount of funds in the PegsCCAddress
"PegsNormalAddress"(string)the unmodified public address generated from the contract's privkey
"PegsNormalBalance"(number)the amount of funds in the PegsNormalAddress
"PegsCCTokensAddress"(string)the public address where Tokens are locked in the Pegs module
"PubkeyCCaddress(Pegs)"(string)taking the module's EVAL code as a modifier, this is the Antara address from the pubkey supplied as an argument
"PubkeyCCbalance(Pegs)"(number)the amount of funds in the PubkeyCCaddress(Pegs)
"myCCAddress(Pegs)"(string)taking the module's EVAL code as a modifier, this is the Antara address from the pubkey of the user
"myCCbalance(Pegs)"(number)the amount of funds in the myCCAddress(Pegs)
"myaddress"(string)the public address of the pubkey used to launch the chain
"mybalance"(number)the amount of funds in the myaddress

Command:

./komodo-cli -ac_name=HELLOWORLD pegsaddress

Command:

./komodo-cli -ac_name=HELLOWORLD pegsaddress 0257e1074b542c47cd6f603e3d78400045df0781875f698138e92cb03055286634

pegscreate amount N bindtxid1 [bindtxid2 ...]

The pegscreate method creates an on-chain Peg, associating the value of the Smart Chain's pegged stablecoin with the value of a foreign asset.

The creation of this peg requires a tokenized backing cryptocurrency. Any cryptocurrency that is based on the Bitcoin protocol can fulfill this role, including BTC and KMD. There can be more than one such supporting cryptocurrency on any stablecoin Smart Chain.

The amount parameter is the number of coins to be added to the Pegs Module from the available balance in the wallet of the user who is creating the peg. Often, this is the same user who created the Smart Chain, and therefore this balance can be extracted from the Smart Chain's premined coins. The coins will be used for the transaction fees that the Pegs Module performs through automated behavior. The coins are also used for markers, which are transactions that send a very small amount of funds to a global address on the Pegs Module for record keeping purposes.

The N parameter is the number of gateways to associate with the Pegs module. Each cryptocurrency asset that backs the Peg's stablecoin needs a unique gateway.

The bindtxidN parameter is the bindtxid of a gateway used to tokenize external cryptocurrencies.

The transction id of the pegscreate transaction is called the pegstxid.

Once the pegstxid transaction is confirmed, the Smart Chain daemon should be stopped and started again with the parameter -earlytxid=pegstxid added to the launch command. This ensures that it is the only Peg active on the Smart Chain.

The -earlytxid parameter can be added to the launch parameters only before the 100th block.

For more information, see the following linked tutorial.

Link to the creator side of the Pegs Module Tutorial

NameTypeDescription
amount(number)the number of coins to be added
N(number)the number of gateways to associate with the Pegs module
bindtxid1(string)the bindtxid of a gateway used to tokenize external cryptocurrencies
[bindtxid2 ...](strings, optional)same as above; used when more than one external cryptocurrency backs the Peg

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegscreate 100000 1 0b5716554e523aa4678112a8ac3d15039e0aae6f4812b9d4c631cc9cfbf48786

Broadcast the hex:

Command:

./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 0400008085202f890197c74ae1999260bb3c7342dd25f3f68a0991d4b50a40f4a6e37838b6e3ca112e02000000484730440220466a45514b5eb24a3a14886dbca204997db498e1509928700a3e0ac63645be3402204164ce5c8f8eb82785158b1f79000721be4db45bb3726fb8043fb089aa19886601ffffffff669ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc9ce7764817000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc2f96465cc2480000232102d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b47567ac0000000000000000256a23ee43018687f4fb9ccc31c6d4b912486fae0a9e03153daca8128167a43a524e5516570b000000005f0100000000000000000000000000

The above string is the pegstxid that represents the Peg.

pegsexchange pegstxid tokenid amount

The pegsexchange method exchanges native coins for deposited tokens. This method is intended for users that do not have a Pegs account associated with the pubkey used to launch their daemon.

Users that have an account may use the pegsreedem method to exchange coins for tokens.

To supply the user that executes the method with tokens, this method sends the user's coins to pay the debt of another user whose account is in the "yellow zone" (a debt ratio between 80% and 90% based on current prices). This improves the debt ratio of the indebted user, thus forestalling liquidation of the indebted user's account.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg
tokenid(string)the tokenid of the tokenized cryptocurrency backing the peg
amount(amount)the amount of coins to exchange

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegsexchange a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7 1a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf1 0.01

pegsfund pegstxid tokenid amount

The pegsfund method allows a user to lock the given amount of a tokenized cryptocurrency in the Pegs module. The action of locking the tokenized cryptocurrency creates a Pegs account for this user.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg
tokenid(string)the tokenid of the tokenized cryptocurrency backing the peg
amount(amount)the amount of the tokenized cryptocurrency to be locked in the Pegs account

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegsfund a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7 1a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf1 0.01

Broadcast the hex:

Command:

./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 0400008085202f89024c386ef60103e74f339867bd7c38b7f187ceee842b8e57ab9a42a16b0721be23040000007b4c79a276a072a26ba067a565802103c75c1de29a35e41606363b430c08be1c2dd93cf7a468229a082cc79c7b77eece8140213fbd380d7905f770709725fe462e5f0a731eca4e56435c4b2f7c96d5b6201433e7c780d313795ddf9ae1d0b689b4f950af6e0e07dd9bcbc293b46f2a349ef4a100af038001eea10001ffffffff9c29a09fb0f1f178ed83e7064297a3d0ba892d9b0eb6b9f0b04c3622203f8be3000000007b4c79a276a072a26ba067a56580210217a6aa6c0fe017f9e469c3c00de5b3aa164ca410e632d1c04169fd7040e20e0681409a7fa29976f948038b77573fb1103836340ebbcdfbbba8dc852186be1666811c034adf2ec9d9515eb58f14df81925f46fb152b2964e8f392b70bafdfe3a8af83a100af038001f2a10001ffffffff051027000000000000302ea22c8020e39343ebe1b40dcc747d145f140983b38f230dcf7963f2b58051265c765f2efa81031210008203000401cc1027000000000000302ea22c8020d77058bfd93eebe366e1c82fc1475690fd290214ed43b8c9dd25374077b35cbe81031210008203000401cc40420f0000000000302ea22c802002bc3497bdabeac3d0c40ac845fa105685724d1b70c84bd6c5cef2ff4c353e7881032214008203000401cc3cdf993b00000000302ea22c802039452b774825750cd9390c3f05c96e486ecf2f21779466efbcd214220a7f288a8103120c008203000401cc0000000000000000c86a4cc5f2741a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf102210217a6aa6c0fe017f9e469c3c00de5b3aa164ca410e632d1c04169fd7040e20e062103c75c1de29a35e41606363b430c08be1c2dd93cf7a468229a082cc79c7b77eece175cee46f7711371604618bcb04458f01c829527a012f459da3c21ff44ee34dbc89e53a9210217a6aa6c0fe017f9e469c3c00de5b3aa164ca410e632d1c04169fd7040e20e0640420f000000000040420f0000000000000000000000000000000000a79900000000000000000000000000

The above string is the accounttxid of the user.

pegsget pegstxid tokenid amount

The pegsget method allows a user to withdraw (also called "assume a debt") in native coins up to 80% of the value of the locked tokens (also called "collateral") in their account.

The exchange of value from tokens to native coins is calculated according to the current price data available on the Smart Chain at the time of the transaction.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg
tokenid(string)the tokenid of the tokenized cryptocurrency backing the peg
amount(amount)the amount of the native coins to receive from the Pegs module

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegsget a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7 1a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf1 0.001

pegsinfo pegstxid

The pegsinfo method returns the current information about the indicated pegstxid Peg.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg

NameTypeDescription
"result"(string)whether the command executed successfully
"name"(string)the name of the method
"info"(json array)the current information about the given Peg
"token"(string)the name of the token
"total deposit"(amount)the total number of tokens deposited
"total debt"(amount)the total number of satoshis of the native coin withdrawn
"total ratio"(string)the total debt ratio for the above token based on the current price
"global ratio"(string)the global debt ratio for all tokens backing the Peg, based on the current prices

Command:

./komodo-cli -ac_name=HELLOWORLD pegsinfo a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7

pegsliquidate pegstxid tokenid accounttxid

The pegsliquidate method allows a user to liquidate the account of another user if their debt ratio is in "red zone" (greater than 90%) for the given tokenid token.

In return, the liquidating user can receive an immediate profit of 5%, in tokens, taken from the liquidated user's remaining balance.

Any remaining value in the liquidated user's account is immediately distributed to the Pegs Antara Module for global stablecoin price and supply management.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg
tokenid(string)the tokenid of the tokenized cryptocurrency backing the peg
accounttxid(string)the accounttxid of another user whose account is in the "red zone"

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegsliquidate a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7 1a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf1 298cfa125e1a38a7aa2a8da8282b017a45cd0c1dc70935712692c00abf48ba3f

pegsredeem pegstxid tokenid

The pegsredeem method allows a user to withdraw their deposited tokenized cryptocurrency by repaying their entire debt.

The user provides payment in the native coin of the Smart Chain.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg
tokenid(string)the tokenid of the tokenized cryptocurrency backing the peg

NameTypeDescription
"hex"(string)the hex value to be broadcast
"result"(string)whether the command executed successfully

Command:

./komodo-cli -ac_name=HELLOWORLD pegsredeem a9539ec8db34ee44ff213cda59f412a02795821cf05844b0bc184660711371f7 1a459712f1e79a544efdf55cfb3e111c5df3300a4da4d16cb3b963bbb50aebf1

pegsworstaccounts pegstxid

The pegsworstaccounts method returns the information on the accounts that currently can be liquidated. An account can be liquidated if the account holder's total debt balance exceeds 90% of the account value.

NameTypeDescription
pegstxid(string)the transaction id returned previously by the pegscreate method at the creation of the on-chain Peg