Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 4.1 KB

indexing.md

File metadata and controls

58 lines (44 loc) · 4.1 KB

General Rules

  • Inscriptions must have a MIME Type of "text/plain" or "application/json". To check this, split the mime type from ";" and check the first part without strip/trim etc.
  • Inscription must be a valid JSON (not JSON5). Trailing commas make the function invalid.
  • Leading or trailing whitespace characters, tabs, or line breaks are allowed and will be removed/truncated.
  • JSON must have "p", "op" fields where "p" in ["brc20-module", "brc20-swap"], "op" in ["deploy", "withdraw", "approve", "conditional-approve", "commit"]
  • All field names in JSON must be in lowercase.
  • All numeric values use the BRC20-defined 18-digit precision format, but calculations involving multiplication/division/square root require converting to large integers according to each ticker's valid precision.

Module-Specific Rules

  • The module storage address is the serialized ID of the inscription, and the index suffix "0" byte must be removed.
  • In deploy inscriptions, the source field value must be in lowercase.
  • In deploy inscriptions, the init object's all keys and values must be strings.
  • In deploy inscriptions, the init object must contain fields: gas_tick, gas_to, fee_to, sequencer.
  • In deploy inscriptions, the swap_fee_rate is optional, defaulting to 0; precision is 3 decimal places.
  • Using transfer to send the balance to the module address before the module is deployed is not considered as a deposit for this module, and the balance will not be returned. It is a non-standard burn.
  • For a module that has enabled withdrawal, if the balance is withdrawn directly to the burn address, the withdrawal will be successful and burned.
  • For a module that has enabled withdrawal, if the balance is withdrawn directly to a module address, it is not considered a deposit for this module and will not be returned. It is a non-standard burn.

Commit Rules

  • When inscribe a commit, it must be inscribed by the sequencer address.
  • Commit can inscribe in any order, but the module must have been deployed before commit.
  • When inscribing commit, gas_price must have a valid precision matching gas_tick, and can be 0.
  • When inscribing commit, all involved tickers must have been deployed.
  • When inscribing commit, it is necessary to verify that all user signatures are legal.

Commit Sending Rules

  • After sending a commit, the receiver must be the module address.
  • When sending a commit, the first commit's parent must be empty, and subsequent commits' parents cannot be empty.
  • When sending a commit, the parent inscription mentioned in the commit must have been sent before.
  • After sending and confirming a commit, it is not supported to replace it by specifying the same parent again.
  • After sending a commit, all included user authorization functions will be executed.

LP Token Rules

  • The parameters "tick0/tick1" and "tick1/tick0" are equivalent.
  • LP token precision is 18 decimal places.
  • Slippage precision is 3 decimal places.
  • Numeric field types are generally strings, but the ts timestamp field is an exception.

Ticker Rules

  • Currently, tickers only support 4 characters in length, with more to be supported in the next phase (see supplement).
  • Address field values currently only support p2wpkh and p2tr, with more to be supported in the next phase (see supplement).

Future Updates

When releasing, specify a height update protocol and make the following changes:

  • Support all address types, using lowercase pkscript format, and bip322 requires supporting signatures for all address types.
  • To support non-4 character tickers, function parameters are token0/token1, and it is necessary to pass 2 clear parameters to transmit token0 and token1.
  • Directly close the conditional-approve inscription function and no longer track individual inscription's repetitive transfer events.
  • Trading pairs' internal storage will no longer use token0/token1 to describe.
  • Send will no longer support sending LP tokens, and an additional sendLP function will be added to send LP tokens.
  • Gas fee calculation will no longer use the exact byte count in {} functions, but simply charge according to the number of functions.