Equations

Pools

poolAssetValue=(assetTokenBalancetokenPrice)/(10decimals)poolAssetValue= (assetTokenBalance*tokenPrice)/ (10 ** decimals)
poolValue=positionValue(i)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=userTokenBalancepoolTokenPriceuserPoolValue = userTokenBalance * poolTokenPrice
poolTokenPrice=poolValue/totalSupplypoolTokenPrice = poolValue/totalSupply

A pool manager's available performance fee is calculated as follows:

profit=max(0,currentTokenPricetokenPriceAtLastFeeMint)profit=max(0, currentTokenPrice-tokenPriceAtLastFeeMint)
feeRatio=performanceFee/10000feeRatio = performanceFee/10000
availableManagerFee=profittotalSupplyfeeRatio/currentTokenPriceavailableManagerFee = 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(supplyCap0.05,1)availableC1 = max(supplyCap * 0.05, 1)
availableC2=max(supplyCap0.1,2)availableC2 = max(supplyCap * 0.1, 2)
availableC3=max(supplyCap0.2,3)availableC3 = max(supplyCap * 0.2, 3)
availableC4=supplyCapavailableC1availableC2availableC3availableC4 = 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)r=sqrt(reserve0, reserve1)
p=sqrt(assetPrice0,assetPrice1)p=sqrt(assetPrice0, assetPrice1)
price=2rp/totalSupplyprice=2*r*p/totalSupply

The reserves for an LP pair are retrieved from the Ubeswap Factory contract.

Last updated