Search…
⌃K

# Equations

## Pools

$poolAssetValue= (assetTokenBalance*tokenPrice)/ (10 ** decimals)$
$poolValue = ∑positionValue(i)$
A pool's USD value is calculated by taking the sum of position values for each position the pool has. The position can be either an ERC20 token or an LP token.
$userPoolValue = userTokenBalance * poolTokenPrice$
$poolTokenPrice = poolValue/totalSupply$
A pool manager's available performance fee is calculated as follows:
$profit=max(0, currentTokenPrice-tokenPriceAtLastFeeMint)$
$feeRatio = performanceFee/10000$
$availableManagerFee = profit*totalSupply*feeRatio/currentTokenPrice$
Note that the performance fee is a percentage of the pool's profits, not the pool value.

## NFT Pool Token Distribution

$availableC1 = max(supplyCap * 0.05, 1)$
$availableC2 = max(supplyCap * 0.1, 2)$
$availableC3 = max(supplyCap * 0.2, 3)$
$availableC4 = supplyCap - availableC1 - availableC2 - availableC3$
An NFT pool's supply cap is determined by the pool manager when the pool is created, and can't be changed.

## Asset Prices

ERC20 asset price is calculated by getting the pre-determined optimal path for the asset and calling getAmountsOut() in Ubeswap's router.
The LP token price for a pair(token0, token1) is calculated as follows:
$r=sqrt(reserve0, reserve1)$
$p=sqrt(assetPrice0, assetPrice1)$
$price=2*r*p/totalSupply$
The reserves for an LP pair are retrieved from the Ubeswap Factory contract.