Market Maker Integration
Off-chain pricing is Native's biggest strength. We collaborate with diverse liquidity sources to provide the best pricing. This document outlines the technical setup to integrate as market maker.
Overview
Native's architecture is built upon three essential components: pricer, signer, and pool, within a secure liquidity network, enabling secure off-chain pricing.
The pricer ensures accurate price provision for order requests.
The signer safeguards order data for on-chain transactions.
The pool executes on-chain swaps using self-custody treasury.
When users request pricing on Native, Native's backend navigates various liquidity sources to discover the best price. Upon user confirmation to execute a swap, the market maker is engaged to acquire the final price, securely endorsed by the assigned signer. Signer gives market makers an additional layer to validate an order and control of the transaction can be executed by the pool smart contract.
Endpoints for pricer and signer
Native relies on API connections to the market makers to achieve off-chain pricing. HTTPS protocol and authentication are required for all the endpoints. Native supports authentication methods including API key and HMAC-SHA256. All endpoints should return JSON data and appropriate status codes.
In general, 3 API endpoints are required to integrate as a market maker with Native.
orderbook for Native to estimate the price for different order sizes
firm-quote for Native to obtain price from market maker given the requested token and amount
sign-quote for market maker to validate and sign the order to be executed on-chain
Authentication (optional)
By default, Native will pass the api_key
in the header of every request for you to authenticate that the request is coming from Native. You can get the api_key
by reaching out to the Native team.
Furthermore, Native allows for a flexible authentication method. If you have a different authentication method, reach out to our team so we can build a specialized interface for you.
Orderbook Endpoint
This endpoint is queried regularly to estimate the available liquidity and quote for different order sizes.
Params
chainId
Chain ID of the network. In integer. eg: 1 for Ethereum, 56 for BSC.
Response
The orderbook is "non-cumulative" in manner.
Firm quote Endpoint
This endpoint provides amount of token out the market maker will quote given the requested token and token amount. The parameters will be encoded to url when Native send this request to the market maker. Params
sellerTokenAmount
The token input amount of the order. In wei.
chainId
Chain ID of the network. In integer. eg: 1 for Ethereum, 56 for BSC.
sellerToken
The ERC20 token address will be sent to market maker.
buyerToken
The ERC20 token address will receive from market maker.
pool
Native pool contract address that will execute this order. Additional data for market maker to do validation or differential pricing.
seller
The address that will send seller token to market maker. (NativeRouter in most cases)
quoteId
Unique ID for this order request in UUID v5.
feeBps
For some order flows Native receives, the initiator (Aggregator) requests a fee. Native will just pass the fee param over to market makers (in bps). Market makers are supposed to factor the fee into the quote.
Native will work with market makers to coordinate the tracking and payment of fees, off-chain. Native will sign contracts with market makers, specifying how fees are set and paid. We will also provide data sources for market makers to monitor the fee owed.
Example
In this example, a user sells 10,000 USDC to market maker in exchange for USDT on Binance Smart Chain (BSC).
Response
In the response above, market maker returns 10,100 USDT for the order sent in the example.
Sign quote Endpoint
This endpoints provide amount of token out the market maker will quote given the requested token and token amount. The parameters will be encoded to url when Native send this request to the market maker. Params
nonce
ID to prevent transaction to be executed more than once. Incremental for each transaction by txOrigin and pool.
signer
Public address of the signer that will sign this order
seller
The address that will send seller token to market maker.
buyer
Native pool contract address that will execute this order.
sellerTokenAmount
The token input amount of the order. In wei.
buyerTokenAmount
The token output amount of the order. In wei. Can be modified by the signer to determine the final output amount.
sellerToken
The ERC20 token address will be sent to market maker.
buyerToken
The ERC20 token address will receive from market maker.
chainId
Chain ID of the network. In integer. eg: 1 for Ethereum, 56 for BSC.
deadlineTimestamp
The expiration time of the order, in block timestamp. Can be modified by the signer to determine the expiration time.
txOrigin
Address of the trader who initiated the order.
quoteId
Unique ID for this order request in UUID v5.
auth
The auth string received from get-quote. Can be used by the signer to verify the authenticity of the quote data. Signer and pricer can decide what auth protocol to use. Native just relay the auth string from pricer to signer.
Example body
In this example, a user requests to sign an order of 10,000 USDC to 10,100 USDT on Binance Smart Chain (BSC) to be transacted on market maker's Native pool (0xaaE854bdd940cf402d79e8051DC7E3390e32A3ac). The order have to be signed by the signer (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) to be successfully executed on-chain.
Order signing
Response
In the response above, market maker returns the signature generated and the corresponding order object to Native. With the signature customer can submit the transaction to execute the swap.
Pool Setup
Currently, Native User Interface does not support the creation of Market Maker Pool. However, you can reach out to the Native team so we can create the pool and transfer the ownership to you. You just need to provide this information:
Pool Name: The name you'd like to give your pool.
Chain and list of token addresses: The chain and the allowed tokens to be traded in the pool
Owner address: the owner of the pool where we will transfer the ownership to
Treasury address: the address where the fund is stored. Ideally, this should be the same as the owner address
Signer address: The key you'll use to sign quotes off-chain for your market maker. Put the public key (address) here and ensure the private key is stored securely. You'll need to be able to programmatically sign quotes with the private key later on (in the
signQuote
API).
To fund the market maker pool, you will need an External Account (EoA or Smart Contract) that needs to give token allowance to the pool. Note that this account address must be the same as the treasury address specified in the pool creation. With this method, you do not need to lock funds into a pool and still have access to all the assets.
Last updated