failed attempt to save even more gas in balanced pair by interpolating from a lookup table

This commit is contained in:
tim
2025-10-24 01:17:21 -04:00
parent 9796a4345f
commit dc7df27676
4 changed files with 328 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {ABDKMath64x64} from "../lib/abdk-libraries-solidity/ABDKMath64x64.sol";
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {NativeWrapper} from "../src/NativeWrapper.sol";
import {PartyPlanner} from "../src/PartyPlanner.sol";
@@ -66,23 +67,31 @@ library Deploy {
NativeWrapper wrapper,
bool _stable
) internal returns (PartyPool) {
return _stable && tokens_.length == 2 ?
new PartyPoolBalancedPair(
owner_,
name_,
symbol_,
tokens_,
bases_,
_kappa,
_swapFeePpm,
_flashFeePpm,
PROTOCOL_FEE_PPM,
PROTOCOL_FEE_RECEIVER,
wrapper,
new PartyPoolSwapImpl(wrapper),
new PartyPoolMintImpl(wrapper)
) :
new PartyPool(
if(_stable && tokens_.length == 2) {
PartyPoolBalancedPair pool = new PartyPoolBalancedPair(
owner_,
name_,
symbol_,
tokens_,
bases_,
_kappa,
_swapFeePpm,
_flashFeePpm,
PROTOCOL_FEE_PPM,
PROTOCOL_FEE_RECEIVER,
wrapper,
new PartyPoolSwapImpl(wrapper),
new PartyPoolMintImpl(wrapper)
);
pool.precompute(
ABDKMath64x64.divu(25,10_000), // ±25 bps
ABDKMath64x64.divu(10, 100), // taking up to 10% of the pool
20, // num Δ samples
20 // num α samples
);
return pool;
}
return new PartyPool(
owner_,
name_,
symbol_,