Skip to content

Latest commit

 

History

History
100 lines (86 loc) · 2.76 KB

tip-127.md

File metadata and controls

100 lines (86 loc) · 2.76 KB
tip:127
title: Support Tron-DEX based on system contracts
author: sean liu <liu.sean@tron.network> 
discussions to: https://github.com/tronprotocol/TIPs/issues/127
status: Final
type: Standards Track
category: core
created: 2020-08-10

Simple Summary

This TIP provides system contracts for the market in java-tron.

Abstract

This TIP provides system contracts to support the exchange of token, including TRX and TRC-10. The main features include an online order table and online matching.

Motivation

Security, transparency, and efficiency have always been at the core of DEX, but exchanges in the form of smart contracts often rely on offline matchmaking systems. In addition, the higher costs also lead to users avoiding frequent transactions as much as possible, reducing the overall transaction volume.

Specification

Only two system contracts are added, which is convenient and simple to use.

Create new order:

rpc MarketSellAsset (MarketSellAssetContract) returns (TransactionExtention) {}

message MarketSellAssetContract {
    bytes owner_address = 1;
    bytes sell_token_id = 2;
    int64 sell_token_quantity = 3;
    bytes buy_token_id = 4;
    int64 buy_token_quantity = 5;
}

Parameter:
owner_address:Owner address,default hexString 
sell_token_id:sell token id,default hexString     
sell_token_quantity:sell token quantity           
buy_token_id:buy token id,default hexString         
buy_token_quantity:buy token quantity, min to receive

Cancel an exist order:

rpc MarketCancelOrder (MarketCancelOrderContract) returns (TransactionExtention) {}

message MarketCancelOrderContract {
    bytes owner_address = 1;
    bytes order_id = 2;
}
Parameter:
owner_address:Owner address,default hexString 
order_id:order id

A set of query interfaces is also provided.Like, Get all trading pairs:

rpc GetMarketPairList (EmptyMessage) returns (MarketOrderPairList) {  }

Get all order prices for the trading pair:

rpc GetMarketPriceByPair (MarketOrderPair) returns (MarketOrderList) {

Get all orders for the trading pair:

rpc GetMarketOrderListByPair (MarketOrderPair) returns (MarketOrderList) {};

Get order by orderId:

rpc GetMarketOrderById (BytesMessage) returns (MarketOrder) {}

Get all orders for the account:

rpc GetMarketOrderByAccount (BytesMessage) returns (MarketOrderList) {};

Get orderId from transactionInfo

message Transaction{
...
repeated MarketOrderDetail orderDetails = 26;
}

message MarketOrderDetail {
  bytes makerOrderId = 1;
  bytes takerOrderId = 2;
  int64 fillSellQuantity = 3;
  int64 fillBuyQuantity = 4;
}
Parameter:
makerOrderId: exist order id
takerOrderId: current order id
fillSellQuantity: sell quantity in this matching
fillBuyQuantity: buy quantity in this matching