Skip to main content

Range

Handles all mathematical calculations in the protocol (swap, provide/remove liquidity), stores an array of bins and LP tokens held in the pool.

Interfaces

provide

Message from pool contract for liquidity provision.

PathMnemonicTypeDescription
opuint320xbe83bf33
query_iduint64query id
codemaybe_cellrange contract code
datamaybe_cellrange contract data
new_codesnew_codemaybe_cellnew code for range contract.
new_codesnew_lpmt_codemaybe_cellnew code for lp multitoken contract.
amount_xcoinstotal amount of token_x in provision
amount_ycoinstotal amount of token_y in provision
user_addressaddress
msg_1first_binint32first bin where provision starts.
msg_1tokensdictdictionary with coins for 4 bins of provision.
msg_1current_binint32active bin of provision.
msg_1price_storedintflag of further parsing (see below)

|price_stored=1|sqrt_price|uint256|initial provide price. Ignored if sqrt price already set.| |msg_1|reject_payload|maybe_cell|reject payload for liquidity provision. Sender recieves it with tokens refund.| |msg_1|forward_payload|maybe_cell|forward payload for liquidity provision. Sender recieves it with notify from lp multitoken contract.|

notify

Message from pool contract for notifing range contract about its neighbours.

PathMnemonicTypeDescription
opuint320x5295272c
query_iduint64query id
codemaybe_cellrange contract code
datamaybe_cellrange contract data
right?boolis message from next range to current
range_addressaddressaddress of previous or next range

swap

Message from pool contract for swap.

PathMnemonicTypeDescription
opuint320x2198e14d
query_iduint64query id
to_addressaddressreceiver address.
account?boolis trade account contract a receiver.
is_xboolfirst or second asset will be sent to the pool.
amountcoinsamount of asset for swap.
outcoinsamount of asset from swap.
exact_outcoinsexact out of tokens to recieve from swap.
partial_executionintflag of further parsing (see below)
partial_execution=0normal_slippagecoinsmin token out.
partial_execution=1slippageuint256last sqrt price of swap.
ref_cellmaybe_cellcell with referral address if present.
additional_datamaybe_celladditional data for swap. Now it is address of swap origin.
reject_payloadmaybe_cellreject payload for swap. Sender recieves it with tokens refund.
forward_payloadmaybe_cellforward payload for swap. Sender recieves it with swapped tokens.

swap_v2

Message from pool contract for swap.

PathMnemonicTypeDescription
opuint320xe8e0f806
query_iduint64query id
to_addressaddressreceiver address.
account?boolis trade account contract a receiver.
is_xboolfirst or second asset will be sent to the pool.
amountcoinsamount of asset for swap.
outcoinsamount of asset from swap.
exact_outcoinsexact out of tokens to recieve from swap.
partial_executionintflag of further parsing (see below)
partial_execution=0normal_slippagecoinsmin token out.
partial_execution=1slippageuint256last sqrt price of swap.
farming_datadistributed_x_amountcoinsamount of rewards distributed.
farming_datadistributed_y_amountcoinsamount of rewards distributed.
additional_datamaybe_celladditional data for swap. Now it is address of swap origin and referral address.
reject_payloadmaybe_cellreject payload for swap. Sender recieves it with tokens refund.
forward_payloadmaybe_cellforward payload for swap. Sender recieves it with swapped tokens.

continue_swap_v2

Message from itself for continuing swap.

PathMnemonicTypeDescription
opuint320x60e68ef4
query_iduint64query id
to_addressaddressreceiver address.
account?boolis trade account contract a receiver.
is_xboolfirst or second asset will be sent to the pool.
amountcoinsamount of asset for swap.
outcoinsamount of asset from swap.
exact_outcoinsexact out of tokens to recieve from swap.
partial_executionintflag of further parsing (see below)
partial_execution=0normal_slippagecoinsmin token out.
partial_execution=1slippageuint256last sqrt price of swap.
restprevious_timeuint64previous swap timestamp.
reststart_priceuint256initial price before swap started
restactual_feeuint16
restdistributed_x_amountcoinsamount of rewards distributed.
restdistributed_y_amountcoinsamount of rewards distributed.
additional_datamaybe_celladditional data for swap. Now it is address of swap origin.
reject_payloadmaybe_cellreject payload for swap. Sender recieves it with tokens refund.
forward_payloadmaybe_cellforward payload for swap. Sender recieves it with swapped tokens.

continue_provide

Message from itself for continuing liquidity provision.

PathMnemonicTypeDescription
opuint320x3685c9c1
query_iduint64query id
provide_token1coinsamount of token_x in provision
provide_token2coinsamount of token_y in provision
x_excesscoinsexcess of token_x to refund to user
y_excesscoinsexcess of token_y to refund to user
user_addressaddress
first_binint32first bin where provision starts.
bins_numuintamount of bins provided previously
tokensdictdictionary with coins for 4 bins of provision.
lp_tokens_to_mintdictdictionary with lp tokens to mint.
reject_payloadmaybe_cellreject payload for liquidity provision. Sender recieves it with tokens refund.
forward_payloadmaybe_cellforward payload for liquidity provision. Sender recieves it with notify from lp multitoken contract.

burn

Message from lp multitoken contract or itself for burning the liquidity.

PathMnemonicTypeDescription
opuint320x51597928
query_iduint64query id
user_addressaddress
pay_amount_xcoinstoken_x to pay to user
pay_amount_ycoinstoken_y to pay to user
first_binint32fist bin where burning starts.
tokens_to_burndictdictionary with lp tokens to mint.
forward_payloadmaybe_cellforward payload which is sent to the user address with withdrawn tokens.

burn_move

Message from lp multitoken contract or itself for burning and moving the liquidity.

PathMnemonicTypeDescription
opuint320x9550b59a
query_iduint64query id
user_addressaddress
pay_amount_xcoinstoken_x to pay to user
pay_amount_ycoinstoken_y to pay to user
first_binint32fist bin where burning starts.
tokens_to_burndictdictionary with lp tokens to mint.
first_bin_to_provideint32fist bin where provision starts.
tokens_to_providedictdictionary with coins for 4 bins of provision.
forward_payloadmaybe_cell

Get-methods

get_sqrt_price

Return

PathMnemonicTypeDescription
sqrt_pnumbercurrent sqrt price.

get_first_bin_number

Return

PathMnemonicTypeDescription
first_binnumberfirst bin of current range contract.

get_bin_step

Return

PathMnemonicTypeDescription
bin_stepnumberpool bin step basis point. Number between 0 and 10000.

get_lp_fee

Return

PathMnemonicTypeDescription
lp_feenumberlp fee rate. Number between 0 and 10000, where 10000 is 100% lp fee.

get_current_bin

Return

PathMnemonicTypeDescription
bin_numbernumberactive bin.

get_pool_addr

Return

PathMnemonicTypeDescription
pool_addraddresspool of range contract.

get_bins_dict

Return

PathMnemonicTypeDescription
liquidity_dictcelldictionary with liquidity for each bin

get_bins_dicts

Return

PathMnemonicTypeDescription
liquidity_dictcelldictionary with liquidity for each bin
lp_supply_dictcelldictionary with lp supply for each bin

get_lp_multitoken_wallet

Input

PathMnemonicTypeDescription
user_addressslicelp multitoken owner's address.

Return

PathMnemonicTypeDescription
lp_multitoken_addressslice

get_left_range

Return

PathMnemonicTypeDescription
range_addraddressprevious range address.

get_right_range

Return

PathMnemonicTypeDescription
range_addraddressnext range address.

get_bin

Input

PathMnemonicTypeDescription
bin_numbernumber

Return

PathMnemonicTypeDescription
liquidity_in_binnumbertotal liquidity in specific bin.

get_bin_lp

Input

PathMnemonicTypeDescription
bin_numbernumber

Return

PathMnemonicTypeDescription
lp_supply_in_binnumbersupply of lp tokens in specific bin.

get_price_bounds

Input

PathMnemonicTypeDescription
bin_numbernumber

Return

PathMnemonicTypeDescription
bin_start_pricenumberleft edge sqrt price of specific bin.
bin_end_pricenumberright edge sqrt price of specific bin.

get_collection_data

Return

PathMnemonicTypeDescription
zeronumber
content_datacell
pool_addressaddress

get_dynamic_fee

Return

PathMnemonicTypeDescription
dynamic_feenumber

get_get_dynamic_fee_by_timestamp

Input

PathMnemonicTypeDescription
timestampnumber

Return

PathMnemonicTypeDescription
dynamic_feenumber

get_dynamic_fees_info

Return

PathMnemonicTypeDescription
dynamic_feenumber
dynamic_fee_factornumber
previous_timenumber
time_filternumber
time_decaynumber

get_storage

Return

PathMnemonicTypeDescription
storagecellfull current storage of the contract.