diff --git a/Forc.lock b/Forc.lock index b6dcf63..8b02a2f 100644 --- a/Forc.lock +++ b/Forc.lock @@ -10,7 +10,7 @@ dependencies = [ [[package]] name = "core" -source = "path+from-root-8357A6DDC5F39D14" +source = "path+from-root-7053AAA90CC5E690" [[package]] name = "create_pool_and_add_liquidity_script" @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.65.2#66bb430395daf5b8f7205f7b9d8d008e2e812d54" +source = "git+https://github.com/fuellabs/sway?tag=v0.66.2#31486c0b47669612acb7c64d66ecb50aea281282" dependencies = ["core"] [[package]] diff --git a/fixtures/mira-amm/mira_amm_contract-abi.json b/fixtures/mira-amm/mira_amm_contract-abi.json index 19d4590..01436ee 100644 --- a/fixtures/mira-amm/mira_amm_contract-abi.json +++ b/fixtures/mira-amm/mira_amm_contract-abi.json @@ -1153,12 +1153,12 @@ { "name": "LP_FEE_VOLATILE", "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", - "offset": 62440 + "offset": 62416 }, { "name": "LP_FEE_STABLE", "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", - "offset": 62432 + "offset": 62408 } ] } \ No newline at end of file diff --git a/fixtures/mira-amm/mira_amm_contract.bin b/fixtures/mira-amm/mira_amm_contract.bin index 92330da..c661d25 100644 Binary files a/fixtures/mira-amm/mira_amm_contract.bin and b/fixtures/mira-amm/mira_amm_contract.bin differ diff --git a/libraries/math/src/pool_math.sw b/libraries/math/src/pool_math.sw index 8bb07d2..323c470 100644 --- a/libraries/math/src/pool_math.sw +++ b/libraries/math/src/pool_math.sw @@ -247,7 +247,7 @@ fn k( let _y: u256 = y * ONE_E_18 / pow_decimals_y; let _a: u256 = (_x * _y) / ONE_E_18; let _b: u256 = ((_x * _x) / ONE_E_18 + (_y * _y) / ONE_E_18); - return _a * _b / ONE_E_18; // x3y+y3x >= k + return _a * _b; // x3y+y3x >= k } else { return x * y; // xy >= k } @@ -255,7 +255,7 @@ fn k( // TODO: combine with `k` above? fn f(x_0: u256, y: u256) -> u256 { - x_0 * (y * y / ONE_E_18 * y / ONE_E_18) / ONE_E_18 + (x_0 * x_0 / ONE_E_18 * x_0 / ONE_E_18) * y / ONE_E_18 + x_0 * (y * y / ONE_E_18 * y / ONE_E_18) + (x_0 * x_0 / ONE_E_18 * x_0 / ONE_E_18) * y } fn d(x_0: u256, y: u256) -> u256 { @@ -269,10 +269,10 @@ fn get_y(x_0: u256, xy: u256, y: u256) -> u256 { let y_prev = y; let k = f(x_0, y); if k < xy { - let dy = (xy - k) * ONE_E_18 / d(x_0, y); + let dy = (xy - k) / d(x_0, y); y = y + dy; } else { - let dy = (k - xy) * ONE_E_18 / d(x_0, y); + let dy = (k - xy) / d(x_0, y); y = y - dy; } if y > y_prev {