Skip to content

Exchange (Bancor)

The built-in on-chain exchange. Trading and the resulting price movements of a pair follow the Bancor protocol.

ExchangeCreate

Create a trading pair.

> exchangeCreate [OwnerAddress] first_token_id first_token_balance second_token_id second_token_balance
  • OwnerAddress (optional) — the address of the account which initiated the transaction. Default: the address of the login account.
  • first_token_id, first_token_balance — ID and amount of the first token.
  • second_token_id, second_token_balance — ID and amount of the second token. The ID is the ID of the issued TRC10 token. If it is TRX, the ID is _. The amount must be greater than 0, and less than 1,000,000,000,000,000.

Example:

> exchangeCreate 1000001 10000 _ 10000
    # Create trading pairs with the IDs of 1000001 and TRX, with amount 10000 for both.

GetExchange

Query exchange pair based on id (confirmed state).

> getExchange 1

ExchangeInject

Capital injection. When conducting a capital injection, depending on its quantity (quant), a proportion of each token in the trading pair will be withdrawn from the account and injected into the trading pair. Depending on the difference in the balance of the transaction, the same amount of money for the same token would vary.

> exchangeInject [OwnerAddress] exchange_id token_id quant
  • OwnerAddress (optional) — the address of the account which initiated the transaction. Default: the address of the login account.
  • exchange_id — the ID of the trading pair to be funded.
  • token_id, quant — tokenId and quantity (unit in base unit) of capital injection.

ExchangeTransaction

> exchangeTransaction [OwnerAddress] exchange_id token_id quant expected
  • OwnerAddress (optional) — the address of the account which initiated the transaction. Default: the address of the login account.
  • exchange_id — ID of the trading pair.
  • token_id, quant — the ID and quantity of tokens being exchanged, equivalent to selling.
  • expected — the minimum quantity of the other token you are willing to receive, in that token's base unit. It is a slippage floor, not a price: the chain computes the real output along the pair's bonding curve and rejects the transaction if it would come out below expected. It is denominated in a different token than quant, so the two are not comparable — expected is not required to be smaller than quant. It must be greater than 0.

Example:

> ExchangeTransaction 1 1000001 100 80

Sells 100 base units of token 1000001 into trading pair 1, and requires at least 80 base units of the pair's other token in return. If the curve would return less than 80 at that moment, the transaction fails and nothing is sold. The 80 is a floor on the amount received, not a price.

ExchangeWithdraw

Capital withdrawal. When conducting a capital withdrawal, depending on its quantity (quant), a proportion of each token in the transaction pair is withdrawn from the trading pair and injected into the account. Depending on the difference in the balance of the transaction, the same amount of money for the same token would vary.

> exchangeWithdraw [OwnerAddress] exchange_id token_id quant
  • OwnerAddress (optional) — the address of the account which initiated the transaction. Default: the address of the login account.
  • Exchange_id — the ID of the trading pair to be withdrawn.
  • Token_id, quant — tokenId and quantity (unit in base unit) of capital withdrawal.

Obtain information on trading pairs

  • ListExchanges — list trading pairs.
  • ListExchangesPaginated — list trading pairs by page.

See also

  • proposals — on-chain governance proposals
  • dex — the TRON-DEX order market
  • transfer-trc10 — issue the TRC10 assets being traded