DEXToken
Search…
⌃K

Pool

This contract implements the core algorithm of Speculative AMM and on-chain liquidity management functionality.

Overview

DEXG Pools are used to deposit and withdraw liquidity on DEXG Exchange, serving as the counterparty to be traded against, slightly comparable to orders in an order-book on centralised exchanges.
The primary function of pools on DEXG Pool is to maintain the volatility factors used for the algorithmic functions of the sAMM to evaluate token-pricing.
Via the Factory contract, new token pools can be created.

Single-token pools

The sAMM implemented on DEXG Pool allows the usage of single-token pools, which obliges liquidity providers to only submit the token they hold to the pool. Each pool is backed by a corresponding WETH pool, which is used by the algorithmic pricing mechanism as well.
Users can buy tokens directly from the pool in exchange for WETH, filling the corresponding WETH pool. On a token to token swap, a corresponding amount of the backing WETH pool will be moved to the token pool that has been swapped out from the token pool that has been swapped in.

Implemented launch pools

The following token pools have been implemented upon the launch of DEXG Exchange.
New pools are created by the community governance. For a description on how to do so, please refer to governance.

Providing pool liquidity

Providing liquidity on DEXG Pool is a straight forward process. Users which hold a token that has an active DEXG Pool contract can navigate to the corresponding pool on DEXG Exchange.
After approving the contract (1), the token can be deposited to the pool (2). In return, the liquidity provider will get DEXG-LP tokens. The DEXG-LP tokens will are minted by the pool on providing liquidity and burned on withdrawing liquidity from the pool. Withdrawing works in the same manner by navigating to 'Remove' (3).

API

Functions

Controller and View Functions

initialize

function initialize(
address _token0,
uint _Ct,
uint _Nt,
uint price
)
Initializes the staking pool which should be invoked by the DEXToken factory contract.

getToken

getToken()
returns (address)
A pool contains one token. Returns the token smart contract address.

Speculative AMM

initialize

initialize(
address _token0,
address _token1,
uint _Pt
)

mean

mean()

getLastUpdateTime

getLastUpdateTime()

getCirculatingSupply

getCirculatingSupply()

getUserbase

getUserbase()

getPrice

getPrice()

updateAMM

updateAMM()

getSpotPrice

getSpotPrice(
uint _Ct,
uint _Nt
)

getToken

getToken()

Pool Management

getPoolBalance

getPoolBalance()

getTotalLiquidity

getTotalLiquidity()

liquidityOf

liquidityOf(
address account
)
returns (uint)
Returns user's pool liquidity.

liquiditySharesOf

liquiditySharesOf(
address account
)

liquidityTokenToAmount

liquidityTokenToAmount(
uint token
)

liquidityFromAmount

liquidityFromAmount(
uint amount
)

deposit

deposit(
uint amount
)
Deposit an amount to the pool.

withdraw

withdraw(
uint amount
)
Withdraw an amount from the pool.

Trading Functions

swapExactETHForTokens

function swapExactETHForTokens(
uint amountIn,
uint minAmountOut,
uint maxPrice,
uint deadline
)

swapExactTokensForETH

function swapExactTokensForETH(
uint amountIn,
uint minAmountOut,
uint minPrice,
uint deadline
)