function getShareOfPool(
address _tokenA,
address _tokenB,
uint _amountADesired,
uint _amountBDesired,
bool _owned
)external view returns (uint poolRatio)
// totalLiquidity의 경우 pairContract totalSupply()를 통해 획득
liquidity = Math.min((amount0*totalLiquidity) / _reserve0, (amount1*totalLiquidity) / _reserve1);
totalLiquidity = totalLiquidity+liquidity;
// 1만자리 연산을 위해..
uint _numerator = liquidity * (10 ** 5);
uint _quotient = ((_numerator / (totalLiquidity)) + 5) / 10;
if( liquidity > 0 )
return _quotient >= 10000 ? 10000 : _quotient;
else
return 0;
// 지분율 얻기(값에 의한)
await routerContract.getShareOfPool(
mockToken0Contract.address,
mockToken1Contract.address,
ethers.utils.parseEther("10.0"),
ethers.utils.parseEther("5.0"),
false
)
// 결과 (9.09%의 영향도)
BigNumber { value: "909" }
// 지분율 얻기(소유중인)
await routerContract..getShareOfPool(
mockToken0Contract.address,
mockToken1Contract.address,
0,
0,
true
)
// 결과 (100%의 영향도)
BigNumber { value: "10000" }