fixed-b
This commit is contained in:
@@ -53,6 +53,18 @@ contract NativeTest is Test {
|
||||
uint256 constant INIT_BAL = 1_000_000; // initial token units for each token
|
||||
uint256 constant BASE = 1; // use base=1 so internal amounts correspond to raw integers
|
||||
|
||||
// Compute fixed b for a pool initialized with numTokens tokens, each deposited with INIT_BAL (BASE == 1).
|
||||
function _computeFixedB(uint256 numTokens) internal view returns (int128) {
|
||||
int128 S = ABDKMath64x64.fromUInt(numTokens * INIT_BAL);
|
||||
int128 one = ABDKMath64x64.fromInt(1);
|
||||
int128 nMinus1 = ABDKMath64x64.fromUInt(numTokens - 1);
|
||||
int128 numerator = one.sub(targetSlippage.mul(nMinus1));
|
||||
int128 denominator = one.add(targetSlippage);
|
||||
int128 E = numerator.div(denominator);
|
||||
int128 y = ABDKMath64x64.ln(E).neg().div(tradeFrac);
|
||||
return S.div(y);
|
||||
}
|
||||
|
||||
function setUp() public {
|
||||
alice = address(0xA11ce);
|
||||
bob = address(0xB0b);
|
||||
@@ -93,8 +105,8 @@ contract NativeTest is Test {
|
||||
// Deploy pool with a small fee (0.1%)
|
||||
uint256 feePpm = 1000;
|
||||
|
||||
int128 kappa = LMSRStabilized.computeKappaFromSlippage(tokens.length, tradeFrac, targetSlippage);
|
||||
pool = Deploy.newPartyPool(address(this), "LP", "LP", tokens, bases, kappa, feePpm, feePpm, weth, false);
|
||||
int128 bFixed = _computeFixedB(tokens.length);
|
||||
pool = Deploy.newPartyPool(address(this), "LP", "LP", tokens, bases, bFixed, feePpm, feePpm, weth, false);
|
||||
|
||||
// Transfer initial deposit amounts into pool
|
||||
token0.transfer(address(pool), INIT_BAL);
|
||||
|
||||
Reference in New Issue
Block a user