Order book

The order book feature allows users can swap tickA to tickB. The liquidity providers can capture a 1% transaction fee for each trade.

Make Order

Key
SubKey
Required ?
Fixed Value
Description

p

Yes

“orc-20”

Protocol: it helps other systems identify and process ORC-20 operations

op

Yes

“order-make”

Operation: type of operation

params

tick1

Yes

Ticker: symbol of the token 1

params

tid1

Yes

Token ID: identifier of the token 1

params

amt1

Yes

Amount to make order: it states the amount of the token1 to make order

params

tick2

Yes

Ticker: symbol of the token 2

params

tid2

Yes

Token ID: identifier of the token 2

params

amt2

Yes

Amount to make order: it states the amount of the token2 to make order

params

er

Yes

Exchange Rate: How many token2 can be exchanged for 1 token1, This value can be a decimal. It cannot exceed the decimal places length of token2.

params

dl

Yes

Deadline: Order expiration time, the date must be after the effective date (block height).

params

fr

No

“100”

Fee Rate: The transaction fee rate that the taker needs to pay for each execution, expressed as an integer between 0 and 10000, with a denominator of 10000. This portion of the fee will be retained within the order. The actual fee rate in calculations is given by fr/10000.

params

oid

No

inscription ID

Order ID: identifier of the order, the inscription ID where the order is deployed. This field is unnecessary during deployment and, if provided, will be considered invalid. It should determined by the actual inscription number.

Example:

{
	"p": "orc-20",
	"op": "order-make",
	"params": {
		"tick1": "orc",		
		"tid1": "2504160",
		"amt1": "10000",
		"tick2": "orc",		
		"tid2": "2504160",
		"amt2": "10000",
		"er": "1",
		"dl": "1225476600"
	}
}
  1. Each order has a unique order ID, which is the Inscription ID created during order creation. When taking an order later, it is necessary to specify the order ID to confirm the intended interaction with the order. Please refrain from including this field during deployment, and even if included, it will be deemed invalid. The actual Inscription ID should be the primary reference.

  2. After the inscription for order creation (order-make) is minted, it does not take effect immediately. The user needs to transfer the inscription to themselves once for the event to take effect. After the transfer, the user's amt1 and amt2 need to be deducted from the total balance, and the balance is transferred to the order. If the user's available balance is insufficient during the transfer, the operation fails, and the inscription becomes inactive.

  3. Prior to the expiration or cancellation of the order, any user can freely trade with the order. They can exchange token1 for token2 or token2 for token1.

  4. The exchange rate indicates how many token2 can be exchanged for 1 token1. This value can be a decimal.

  5. The fee rate is fixed at 1%, meaning that for each exchange, the taker receives 99% of the output token, while the remaining 1% is retained as a fee.

  6. The deadline is in timestamp format. After this time, the order becomes invalid.

  7. The order creator can delete the order at any time by transferring the inscription to an address other than their own. After deletion, the amt1 and amt2 in the order are transferred to the user's available balance.

Take Order

Key
SubKey
Required ?
Fixed Value
Description

p

Yes

“orc-20”

Protocol: it helps other systems identify and process ORC-20 operations

op

Yes

“order-take”

Operation: type of operation

params

oids

Yes

Order IDs: list of orders you want to take. This is an array of order IDs, allowing multiple orders to be taken at one time

params

tick1

Yes

Ticker: symbol of the token out

params

tid1

Yes

Token ID: identifier of the token out

params

amt1

Yes

Amount to take order: it states the amount of the token out

params

tick2

Yes

Ticker: symbol of the token token in

params

tid2

Yes

Token ID: identifier of the token in

Example:

{
	"p": "orc-20",
	"op": "order-take",
	"params": {
		"oids": ["0000000", "0000001"],
		"tick1": "orc",
		"tid1": "2504160",
		"amt1": "100"
		"tick2": "orc",
		"tid2": "2504160",
	}
}
  1. After the inscription is minted, it does not take effect immediately. The inscription needs to be transferred once for it to become effective, and simultaneously, the inscription itself becomes invalid.

  2. If the user's available balance is insufficient during the transfer, the operation fails, and the inscription becomes invalid.

  3. When taking an order, transactions are conducted in the order of the OID array.

    a. If the first order cannot fulfill the exchange quantity of tokens, complete the entire exchange for that order and proceed to the second order.

    b. If, at any point, an order can fully exchange the quantity of tokens, the search for subsequent orders is discontinued.

  4. All orders must meet the following criteria: The tid1 and tid2 on the order must match the user-input tid1 and tid2, regardless of order (e.g., order tid1 = tid2 or order tid2 = tid1 are both valid).

  5. Orders need to be executed in sequence. If there is an invalid order during the execution process, the entire order-take will be invalidated.

  6. If a user wants to exchange tick1 for tick2, but the balance of tick2 in the order is insufficient during the transaction, the transaction will be invalid. This rule applies similarly to exchanging tick2 for tick1.

Last updated