DolphinSwap LP Integration

This document aims to introduce the contract table structure of DolphinSwap, to make it easier to be integrated by 3rd parties.

Contract account

DolphinSwap contract:dolphinsswap

Check details on bloks:view

Basic Type

pooltoken

Parameter

Type

Comment

weight

uint32_t

Weight

symbol

extended_symbol

Token, includes contract, symbol and precision

reserve

asset

Token's total amount

Liquidity Pool

Statements

pool table is used to store all trading pairs, it is the core of the contract.

Table Structure

Table: pools

Scope: dolphinsswap

Parameter

Type

Comment

id

uint64_t

Liquidity Pool ID

code

symbol_code

LP token's name,for an example: DOPA

swap_fee

uint16_t

trading fee rate, need to divide by 10000

total_lptoken

uint64_t

total LP token amount

create_time

uint32_t

LP pool created time

last_update_time

uint32_t

last updated time

tokens

std::vector

trading pair list, includes 2 and more tokens

Request Demo:

curl -X POST -d '{"code":"dolphinsswap","scope":"dolphinsswap","table":"pools","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows

Lptoken Table

Statements

lptoken table is used to store users' LP

LP Naming Rules

Dolphin Swap LP Tokens all start with DOP, and then add the pool_id of the liquidity pool to convert to a 26 hexadecimal (letter). For example, the liquidity pool ID is 1, and the converted is DOPA. If it is 27, it corresponds to DOPAA, and so on. Code method for converting pool_id into lp code:

symbol_code id2lpcode(uint64_t id) {
    std::string code = "DOP";
    std::string s;
    while (id > 0) {
        uint32_t rem = id % 26;
        if (rem == 0) rem = 26;
        s += ('A' + rem - 1);
        id = (id - rem) / 26;
    }
    std::reverse(s.begin(), s.end());
    code += s;
    return symbol_code(code.c_str());
}

Table Structrue

Table: lptokens

Scope: LP token's name,like DOPA

Parameter

Type

Comment

owner

name

Liquidity Provider

token

uint64_t

LP token amount

Request Demo:

curl -X POST -d '{"code":"dolphinsswap","scope":"DOPA","table":"lptokens","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows

Deposit Table

Statements

The deposit table is used to store temporary market-making deposits. The user needs to recharge multiple assets for market-making. This table is used to temporarily record the user's single market-making deposit. The record will be automatically cleared after successful market making.

Table Structrue

Table: deposits

Scope: pool_id

Parameter

Type

Comment

owner

name

liquidity provider

quantities

std::vector

deposited token list

Request Demo:

curl -X POST -d '{"code":"dolphinsswap","scope":1,"table":"deposits","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows

Last updated