@paraswap/dex-lib 2.42.7 → 2.42.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +38 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/dex/simple-exchange.d.ts +3 -0
- package/build/dex/simple-exchange.js +18 -2
- package/build/dex/simple-exchange.js.map +1 -1
- package/package.json +1 -1
- package/src/dex/simple-exchange.ts +37 -3
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/abi/algebra/AlgebraPool.abi.json +0 -727
- package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
- package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
- package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
- package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
- package/build/abi/wBETH.json +0 -1527
- package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/build/abi/woo-fi/WooPP.abi.json +0 -548
- package/build/abi/woo-fi/Wooracle.abi.json +0 -260
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- package/build/dex/algebra/algebra-pool.d.ts +0 -114
- package/build/dex/algebra/algebra-pool.js +0 -448
- package/build/dex/algebra/algebra-pool.js.map +0 -1
- package/build/dex/balancer-v2/Gyro3Pool.d.ts +0 -43
- package/build/dex/balancer-v2/Gyro3Pool.js +0 -160
- package/build/dex/balancer-v2/Gyro3Pool.js.map +0 -1
- package/build/dex/balancer-v2/LinearMath.d.ts +0 -88
- package/build/dex/balancer-v2/LinearMath.js +0 -285
- package/build/dex/balancer-v2/LinearMath.js.map +0 -1
- package/build/dex/balancer-v2/LinearPool.d.ts +0 -81
- package/build/dex/balancer-v2/LinearPool.js +0 -444
- package/build/dex/balancer-v2/LinearPool.js.map +0 -1
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -90
- package/build/dex/balancer-v2/PhantomStablePool.js +0 -418
- package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
- package/build/dex/balancer-v2/StableMath.d.ts +0 -9
- package/build/dex/balancer-v2/StableMath.js +0 -272
- package/build/dex/balancer-v2/StableMath.js.map +0 -1
- package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -140
- package/build/dex/balancer-v2/balancer-v2-pool.js +0 -647
- package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +0 -33
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +0 -128
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +0 -34
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +0 -151
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +0 -1
- package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
- package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
- package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
- package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
- package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
- package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
- package/build/dex/lighter-v1/abi/erc20.json +0 -222
- package/build/dex/lighter-v1/abi/factory.json +0 -291
- package/build/dex/lighter-v1/abi/order_book.json +0 -594
- package/build/dex/lighter-v1/abi/order_book_helper.json +0 -176
- package/build/dex/lighter-v1/abi/router.json +0 -488
- package/build/dex/lighter-v1/config.d.ts +0 -4
- package/build/dex/lighter-v1/config.js +0 -17
- package/build/dex/lighter-v1/config.js.map +0 -1
- package/build/dex/lighter-v1/constants.d.ts +0 -2
- package/build/dex/lighter-v1/constants.js +0 -13
- package/build/dex/lighter-v1/constants.js.map +0 -1
- package/build/dex/lighter-v1/lighter-v1-pool.d.ts +0 -57
- package/build/dex/lighter-v1/lighter-v1-pool.js +0 -310
- package/build/dex/lighter-v1/lighter-v1-pool.js.map +0 -1
- package/build/dex/lighter-v1/lighter-v1.d.ts +0 -45
- package/build/dex/lighter-v1/lighter-v1.js +0 -331
- package/build/dex/lighter-v1/lighter-v1.js.map +0 -1
- package/build/dex/lighter-v1/types.d.ts +0 -40
- package/build/dex/lighter-v1/types.js +0 -3
- package/build/dex/lighter-v1/types.js.map +0 -1
- package/build/dex/pancakeswap-v3/types.d.ts +0 -14
- package/build/dex/pancakeswap-v3/types.js +0 -3
- package/build/dex/pancakeswap-v3/types.js.map +0 -1
- package/build/dex/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
- package/build/dex/quickswap/zyberswap-v3.js +0 -19
- package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
- package/build/dex/quickswap-v3.d.ts +0 -21
- package/build/dex/quickswap-v3.js +0 -40
- package/build/dex/quickswap-v3.js.map +0 -1
- package/build/dex/ramses-v2/config.d.ts +0 -4
- package/build/dex/ramses-v2/config.js +0 -28
- package/build/dex/ramses-v2/config.js.map +0 -1
- package/build/dex/ramses-v2/constants.d.ts +0 -28
- package/build/dex/ramses-v2/constants.js +0 -35
- package/build/dex/ramses-v2/constants.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
- package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
- package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
- package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
- package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
- package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
- package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
- package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
- package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/utils.js +0 -16
- package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
- package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
- package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
- package/build/dex/ramses-v2/ramses-v2.js +0 -690
- package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
- package/build/dex/ramses-v2/types.d.ts +0 -154
- package/build/dex/ramses-v2/types.js +0 -9
- package/build/dex/ramses-v2/types.js.map +0 -1
- package/build/dex/ramses-v2/utils.d.ts +0 -6
- package/build/dex/ramses-v2/utils.js +0 -71
- package/build/dex/ramses-v2/utils.js.map +0 -1
- package/build/dex/solidly/forks-override/fvm.d.ts +0 -20
- package/build/dex/solidly/forks-override/fvm.js +0 -42
- package/build/dex/solidly/forks-override/fvm.js.map +0 -1
- package/build/dex/sushiswap-v3/config.d.ts +0 -4
- package/build/dex/sushiswap-v3/config.js +0 -132
- package/build/dex/sushiswap-v3/config.js.map +0 -1
- package/build/dex/sushiswap-v3/constants.d.ts +0 -4
- package/build/dex/sushiswap-v3/constants.js +0 -32
- package/build/dex/sushiswap-v3/constants.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
- package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
- package/build/dex/sushiswap-v3/token.d.ts +0 -6
- package/build/dex/sushiswap-v3/token.js +0 -23
- package/build/dex/sushiswap-v3/token.js.map +0 -1
- package/build/dex/sushiswap-v3/types.d.ts +0 -15
- package/build/dex/sushiswap-v3/types.js +0 -18
- package/build/dex/sushiswap-v3/types.js.map +0 -1
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
- package/build/dex/woo-fi/config.d.ts +0 -4
- package/build/dex/woo-fi/config.js +0 -141
- package/build/dex/woo-fi/config.js.map +0 -1
- package/build/dex/woo-fi/constants.d.ts +0 -5
- package/build/dex/woo-fi/constants.js +0 -20
- package/build/dex/woo-fi/constants.js.map +0 -1
- package/build/dex/woo-fi/types.d.ts +0 -48
- package/build/dex/woo-fi/types.js +0 -3
- package/build/dex/woo-fi/types.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
- package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
- package/build/dex/woo-fi/woo-fi-math.js +0 -300
- package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi.d.ts +0 -65
- package/build/dex/woo-fi/woo-fi.js +0 -480
- package/build/dex/woo-fi/woo-fi.js.map +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
3
|
-
import { BasePool } from '../balancer-v2-pool';
|
|
4
|
-
import { SwapSide } from '../../../../constants';
|
|
5
|
-
import { callData, SubgraphPoolBase, PoolState } from '../../types';
|
|
6
|
-
import { StablePoolPairData } from '../stable/StablePool';
|
|
7
|
-
export declare type Gyro3PoolPairData = {
|
|
8
|
-
balances: BigNumber[];
|
|
9
|
-
indexIn: number;
|
|
10
|
-
indexOut: number;
|
|
11
|
-
swapFee: bigint;
|
|
12
|
-
balanceTertiary: BigNumber;
|
|
13
|
-
decimalsTertiary: number;
|
|
14
|
-
scalingFactors: bigint[];
|
|
15
|
-
root3Alpha: BigNumber;
|
|
16
|
-
};
|
|
17
|
-
export declare class Gyro3Pool extends BasePool {
|
|
18
|
-
vaultAddress: string;
|
|
19
|
-
vaultInterface: Interface;
|
|
20
|
-
poolInterface: Interface;
|
|
21
|
-
constructor(vaultAddress: string, vaultInterface: Interface);
|
|
22
|
-
parsePoolPairData(pool: SubgraphPoolBase, poolState: PoolState, tokenIn: string, tokenOut: string): Gyro3PoolPairData;
|
|
23
|
-
getSwapMaxAmount(poolPairData: Gyro3PoolPairData, side: SwapSide): bigint;
|
|
24
|
-
getOnChainCalls(pool: SubgraphPoolBase): callData[];
|
|
25
|
-
decodeOnChainCalls(pool: SubgraphPoolBase, data: {
|
|
26
|
-
success: boolean;
|
|
27
|
-
returnData: any;
|
|
28
|
-
}[], startIndex: number): [{
|
|
29
|
-
[address: string]: PoolState;
|
|
30
|
-
}, number];
|
|
31
|
-
onSell(amounts: bigint[], poolPairData: Gyro3PoolPairData): bigint[];
|
|
32
|
-
onBuy(amounts: bigint[], poolPairData: StablePoolPairData): bigint[];
|
|
33
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Gyro3Pool = void 0;
|
|
4
|
-
const abi_1 = require("@ethersproject/abi");
|
|
5
|
-
const bignumber_1 = require("@ethersproject/bignumber");
|
|
6
|
-
const balancer_v2_pool_1 = require("../balancer-v2-pool");
|
|
7
|
-
const constants_1 = require("../../../../constants");
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
const balancer_v2_math_1 = require("../../balancer-v2-math");
|
|
10
|
-
const sor_1 = require("@balancer-labs/sor");
|
|
11
|
-
// Swap Limit factor
|
|
12
|
-
const SWAP_LIMIT_FACTOR = BigInt('999999000000000000');
|
|
13
|
-
class Gyro3Pool extends balancer_v2_pool_1.BasePool {
|
|
14
|
-
constructor(vaultAddress, vaultInterface) {
|
|
15
|
-
super();
|
|
16
|
-
this.poolInterface = new abi_1.Interface([
|
|
17
|
-
'function getSwapFeePercentage() view returns (uint256)',
|
|
18
|
-
]);
|
|
19
|
-
this.vaultAddress = vaultAddress;
|
|
20
|
-
this.vaultInterface = vaultInterface;
|
|
21
|
-
}
|
|
22
|
-
parsePoolPairData(pool, poolState, tokenIn, tokenOut) {
|
|
23
|
-
// All values should be normalised to 18 decimals. e.g. 1USDC = 1e18 not 1e6
|
|
24
|
-
let indexIn = 0, indexOut = 0, indexTertiary = 0;
|
|
25
|
-
const scalingFactors = [];
|
|
26
|
-
const balances = pool.tokens.map((t, i) => {
|
|
27
|
-
if (t.address.toLowerCase() === tokenIn.toLowerCase())
|
|
28
|
-
indexIn = i;
|
|
29
|
-
else if (t.address.toLowerCase() === tokenOut.toLowerCase())
|
|
30
|
-
indexOut = i;
|
|
31
|
-
else
|
|
32
|
-
indexTertiary = i;
|
|
33
|
-
const scalingFactor = (0, utils_1.getTokenScalingFactor)(t.decimals);
|
|
34
|
-
scalingFactors.push(scalingFactor);
|
|
35
|
-
return bignumber_1.BigNumber.from(this._upscale(BigInt(poolState.tokens[t.address.toLowerCase()].balance), scalingFactor));
|
|
36
|
-
});
|
|
37
|
-
const balanceTertiary = balances[indexTertiary];
|
|
38
|
-
const decimalsTertiary = pool.tokens[indexTertiary].decimals;
|
|
39
|
-
const poolPairData = {
|
|
40
|
-
balances,
|
|
41
|
-
indexIn,
|
|
42
|
-
indexOut,
|
|
43
|
-
scalingFactors,
|
|
44
|
-
swapFee: poolState.swapFee,
|
|
45
|
-
balanceTertiary,
|
|
46
|
-
decimalsTertiary,
|
|
47
|
-
root3Alpha: (0, utils_1.safeParseFixed)(pool.root3Alpha, 18),
|
|
48
|
-
};
|
|
49
|
-
return poolPairData;
|
|
50
|
-
}
|
|
51
|
-
getSwapMaxAmount(poolPairData, side) {
|
|
52
|
-
if (side === constants_1.SwapSide.SELL) {
|
|
53
|
-
// Approximation - similar to traditional stable pools
|
|
54
|
-
return this._downscaleDown(balancer_v2_math_1.MathSol.mulDownFixed(poolPairData.balances[poolPairData.indexOut].toBigInt(), SWAP_LIMIT_FACTOR), poolPairData.scalingFactors[poolPairData.indexIn]);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Not currently supported
|
|
58
|
-
return BigInt(0);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/*
|
|
62
|
-
Helper function to construct onchain multicall data for Pool.
|
|
63
|
-
*/
|
|
64
|
-
getOnChainCalls(pool) {
|
|
65
|
-
const poolCallData = [
|
|
66
|
-
{
|
|
67
|
-
target: this.vaultAddress,
|
|
68
|
-
callData: this.vaultInterface.encodeFunctionData('getPoolTokens', [
|
|
69
|
-
pool.id,
|
|
70
|
-
]),
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
target: pool.address,
|
|
74
|
-
callData: this.poolInterface.encodeFunctionData('getSwapFeePercentage'),
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
return poolCallData;
|
|
78
|
-
}
|
|
79
|
-
/*
|
|
80
|
-
Helper function to decode multicall data for Pool.
|
|
81
|
-
data must contain returnData
|
|
82
|
-
startIndex is where to start in returnData. Allows this decode function to be called along with other pool types.
|
|
83
|
-
*/
|
|
84
|
-
decodeOnChainCalls(pool, data, startIndex) {
|
|
85
|
-
const pools = {};
|
|
86
|
-
const poolTokens = (0, utils_1.decodeThrowError)(this.vaultInterface, 'getPoolTokens', data[startIndex++], pool.address);
|
|
87
|
-
const swapFee = (0, utils_1.decodeThrowError)(this.poolInterface, 'getSwapFeePercentage', data[startIndex++], pool.address)[0];
|
|
88
|
-
const poolState = {
|
|
89
|
-
swapFee: BigInt(swapFee.toString()),
|
|
90
|
-
orderedTokens: poolTokens.tokens,
|
|
91
|
-
tokens: poolTokens.tokens.reduce((ptAcc, pt, j) => {
|
|
92
|
-
const tokenState = {
|
|
93
|
-
balance: BigInt(poolTokens.balances[j].toString()),
|
|
94
|
-
};
|
|
95
|
-
ptAcc[pt.toLowerCase()] = tokenState;
|
|
96
|
-
return ptAcc;
|
|
97
|
-
}, {}),
|
|
98
|
-
};
|
|
99
|
-
pools[pool.address] = poolState;
|
|
100
|
-
return [pools, startIndex];
|
|
101
|
-
}
|
|
102
|
-
onSell(amounts, poolPairData) {
|
|
103
|
-
try {
|
|
104
|
-
const invariant = sor_1.Gyro3Maths._calculateInvariant(poolPairData.balances, poolPairData.root3Alpha);
|
|
105
|
-
const virtualOffsetInOut = balancer_v2_math_1.MathSol.mulDownFixed(invariant.toBigInt(), poolPairData.root3Alpha.toBigInt());
|
|
106
|
-
const tokenAmountsInScaled = amounts.map(a => this._upscale(a, poolPairData.scalingFactors[poolPairData.indexIn]));
|
|
107
|
-
const tokenAmountsInWithFee = tokenAmountsInScaled.map(a => this._subtractSwapFeeAmount(a, poolPairData.swapFee));
|
|
108
|
-
const amountsOut = tokenAmountsInWithFee.map(amount => {
|
|
109
|
-
try {
|
|
110
|
-
const amountOut = sor_1.Gyro3Maths._calcOutGivenIn(poolPairData.balances[poolPairData.indexIn], poolPairData.balances[poolPairData.indexOut], bignumber_1.BigNumber.from(amount), bignumber_1.BigNumber.from(virtualOffsetInOut)).toBigInt();
|
|
111
|
-
return this._downscaleDown(amountOut, poolPairData.scalingFactors[poolPairData.indexOut]);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
return BigInt(0);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return amountsOut;
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
onBuy(amounts, poolPairData) {
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.Gyro3Pool = Gyro3Pool;
|
|
128
|
-
//# sourceMappingURL=Gyro3Pool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Gyro3Pool.js","sourceRoot":"","sources":["../../../../../src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAC/C,wDAAqD;AAErD,0DAA+C;AAC/C,qDAAiD;AACjD,uCAIqB;AAErB,6DAAiD;AACjD,4CAAgD;AAGhD,oBAAoB;AACpB,MAAM,iBAAiB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAcvD,MAAa,SAAU,SAAQ,2BAAQ;IAOrC,YAAY,YAAoB,EAAE,cAAyB;QACzD,KAAK,EAAE,CAAC;QALV,kBAAa,GAAG,IAAI,eAAS,CAAC;YAC5B,wDAAwD;SACzD,CAAC,CAAC;QAID,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,iBAAiB,CACf,IAAsB,EACt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M,UAAU,GAAa,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC9D,IAAI;oBACF,MAAM,SAAS,GAAG,gBAAU,CAAC,eAAe,CAC1C,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,EAC3C,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC5C,qBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EACtB,qBAAS,CAAC,IAAI,CAAC,kBAAkB,CAAC,CACnC,CAAC,QAAQ,EAAE,CAAC;oBACb,OAAO,IAAI,CAAC,cAAc,CACxB,SAAS,EACT,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CACnD,CAAC;iBACH;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IAED,KAAK,CAAC,OAAiB,EAAE,YAAgC;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAlLD,8BAkLC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
3
|
-
import { BasePool } from '../balancer-v2-pool';
|
|
4
|
-
import { SwapSide } from '../../../../constants';
|
|
5
|
-
import { callData, SubgraphPoolBase, PoolState } from '../../types';
|
|
6
|
-
import { DerivedGyroEParams, GyroEParams } from '@balancer-labs/sor';
|
|
7
|
-
import { StablePoolPairData } from '../stable/StablePool';
|
|
8
|
-
export declare type GyroEPoolPairData = {
|
|
9
|
-
balances: BigNumber[];
|
|
10
|
-
indexIn: number;
|
|
11
|
-
indexOut: number;
|
|
12
|
-
swapFee: bigint;
|
|
13
|
-
scalingFactors: bigint[];
|
|
14
|
-
tokenInIsToken0: boolean;
|
|
15
|
-
gyroEParams: GyroEParams;
|
|
16
|
-
derivedGyroEParams: DerivedGyroEParams;
|
|
17
|
-
};
|
|
18
|
-
export declare class GyroEPool extends BasePool {
|
|
19
|
-
vaultAddress: string;
|
|
20
|
-
vaultInterface: Interface;
|
|
21
|
-
poolInterface: Interface;
|
|
22
|
-
constructor(vaultAddress: string, vaultInterface: Interface);
|
|
23
|
-
parsePoolPairData(pool: SubgraphPoolBase, poolState: PoolState, tokenIn: string, tokenOut: string): GyroEPoolPairData;
|
|
24
|
-
getSwapMaxAmount(poolPairData: GyroEPoolPairData, side: SwapSide): bigint;
|
|
25
|
-
getOnChainCalls(pool: SubgraphPoolBase): callData[];
|
|
26
|
-
decodeOnChainCalls(pool: SubgraphPoolBase, data: {
|
|
27
|
-
success: boolean;
|
|
28
|
-
returnData: any;
|
|
29
|
-
}[], startIndex: number): [{
|
|
30
|
-
[address: string]: PoolState;
|
|
31
|
-
}, number];
|
|
32
|
-
onSell(amounts: bigint[], poolPairData: GyroEPoolPairData): bigint[];
|
|
33
|
-
onBuy(amounts: bigint[], poolPairData: StablePoolPairData): bigint[];
|
|
34
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GyroEPool = void 0;
|
|
4
|
-
const abi_1 = require("@ethersproject/abi");
|
|
5
|
-
const bignumber_1 = require("@ethersproject/bignumber");
|
|
6
|
-
const balancer_v2_pool_1 = require("../balancer-v2-pool");
|
|
7
|
-
const constants_1 = require("../../../../constants");
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
const balancer_v2_math_1 = require("../../balancer-v2-math");
|
|
10
|
-
const sor_1 = require("@balancer-labs/sor");
|
|
11
|
-
// Swap Limit factor
|
|
12
|
-
const SWAP_LIMIT_FACTOR = BigInt('999999000000000000');
|
|
13
|
-
class GyroEPool extends balancer_v2_pool_1.BasePool {
|
|
14
|
-
constructor(vaultAddress, vaultInterface) {
|
|
15
|
-
super();
|
|
16
|
-
this.poolInterface = new abi_1.Interface([
|
|
17
|
-
'function getSwapFeePercentage() view returns (uint256)',
|
|
18
|
-
]);
|
|
19
|
-
this.vaultAddress = vaultAddress;
|
|
20
|
-
this.vaultInterface = vaultInterface;
|
|
21
|
-
}
|
|
22
|
-
parsePoolPairData(pool, poolState, tokenIn, tokenOut) {
|
|
23
|
-
// All values should be normalised to 18 decimals. e.g. 1USDC = 1e18 not 1e6
|
|
24
|
-
let indexIn = 0, indexOut = 0;
|
|
25
|
-
const scalingFactors = [];
|
|
26
|
-
const balances = pool.tokens.map((t, i) => {
|
|
27
|
-
if (t.address.toLowerCase() === tokenIn.toLowerCase())
|
|
28
|
-
indexIn = i;
|
|
29
|
-
else if (t.address.toLowerCase() === tokenOut.toLowerCase())
|
|
30
|
-
indexOut = i;
|
|
31
|
-
const scalingFactor = (0, utils_1.getTokenScalingFactor)(t.decimals);
|
|
32
|
-
scalingFactors.push(scalingFactor);
|
|
33
|
-
return bignumber_1.BigNumber.from(this._upscale(BigInt(poolState.tokens[t.address.toLowerCase()].balance), scalingFactor));
|
|
34
|
-
});
|
|
35
|
-
const gyroEParams = {
|
|
36
|
-
alpha: (0, utils_1.safeParseFixed)(pool.alpha, 18),
|
|
37
|
-
beta: (0, utils_1.safeParseFixed)(pool.beta, 18),
|
|
38
|
-
c: (0, utils_1.safeParseFixed)(pool.c, 18),
|
|
39
|
-
s: (0, utils_1.safeParseFixed)(pool.s, 18),
|
|
40
|
-
lambda: (0, utils_1.safeParseFixed)(pool.lambda, 18),
|
|
41
|
-
};
|
|
42
|
-
const derivedGyroEParamsFromSubgraph = {
|
|
43
|
-
tauAlpha: {
|
|
44
|
-
x: (0, utils_1.safeParseFixed)(pool.tauAlphaX, 38),
|
|
45
|
-
y: (0, utils_1.safeParseFixed)(pool.tauAlphaY, 38),
|
|
46
|
-
},
|
|
47
|
-
tauBeta: {
|
|
48
|
-
x: (0, utils_1.safeParseFixed)(pool.tauBetaX, 38),
|
|
49
|
-
y: (0, utils_1.safeParseFixed)(pool.tauBetaY, 38),
|
|
50
|
-
},
|
|
51
|
-
u: (0, utils_1.safeParseFixed)(pool.u, 38),
|
|
52
|
-
v: (0, utils_1.safeParseFixed)(pool.v, 38),
|
|
53
|
-
w: (0, utils_1.safeParseFixed)(pool.w, 38),
|
|
54
|
-
z: (0, utils_1.safeParseFixed)(pool.z, 38),
|
|
55
|
-
dSq: (0, utils_1.safeParseFixed)(pool.dSq, 38),
|
|
56
|
-
};
|
|
57
|
-
const tokenInIsToken0 = indexIn === 0;
|
|
58
|
-
const poolPairData = {
|
|
59
|
-
balances,
|
|
60
|
-
indexIn,
|
|
61
|
-
indexOut,
|
|
62
|
-
scalingFactors,
|
|
63
|
-
swapFee: poolState.swapFee,
|
|
64
|
-
derivedGyroEParams: derivedGyroEParamsFromSubgraph,
|
|
65
|
-
gyroEParams: gyroEParams,
|
|
66
|
-
tokenInIsToken0,
|
|
67
|
-
};
|
|
68
|
-
return poolPairData;
|
|
69
|
-
}
|
|
70
|
-
getSwapMaxAmount(poolPairData, side) {
|
|
71
|
-
if (side === constants_1.SwapSide.SELL) {
|
|
72
|
-
// Approximation - similar to traditional stable pools
|
|
73
|
-
return this._downscaleDown(balancer_v2_math_1.MathSol.mulDownFixed(poolPairData.balances[poolPairData.indexOut].toBigInt(), SWAP_LIMIT_FACTOR), poolPairData.scalingFactors[poolPairData.indexIn]);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Not currently supported
|
|
77
|
-
return BigInt(0);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/*
|
|
81
|
-
Helper function to construct onchain multicall data for Pool.
|
|
82
|
-
*/
|
|
83
|
-
getOnChainCalls(pool) {
|
|
84
|
-
const poolCallData = [
|
|
85
|
-
{
|
|
86
|
-
target: this.vaultAddress,
|
|
87
|
-
callData: this.vaultInterface.encodeFunctionData('getPoolTokens', [
|
|
88
|
-
pool.id,
|
|
89
|
-
]),
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
target: pool.address,
|
|
93
|
-
callData: this.poolInterface.encodeFunctionData('getSwapFeePercentage'),
|
|
94
|
-
},
|
|
95
|
-
];
|
|
96
|
-
return poolCallData;
|
|
97
|
-
}
|
|
98
|
-
/*
|
|
99
|
-
Helper function to decode multicall data for Pool.
|
|
100
|
-
data must contain returnData
|
|
101
|
-
startIndex is where to start in returnData. Allows this decode function to be called along with other pool types.
|
|
102
|
-
*/
|
|
103
|
-
decodeOnChainCalls(pool, data, startIndex) {
|
|
104
|
-
const pools = {};
|
|
105
|
-
const poolTokens = (0, utils_1.decodeThrowError)(this.vaultInterface, 'getPoolTokens', data[startIndex++], pool.address);
|
|
106
|
-
const swapFee = (0, utils_1.decodeThrowError)(this.poolInterface, 'getSwapFeePercentage', data[startIndex++], pool.address)[0];
|
|
107
|
-
const poolState = {
|
|
108
|
-
swapFee: BigInt(swapFee.toString()),
|
|
109
|
-
orderedTokens: poolTokens.tokens,
|
|
110
|
-
tokens: poolTokens.tokens.reduce((ptAcc, pt, j) => {
|
|
111
|
-
const tokenState = {
|
|
112
|
-
balance: BigInt(poolTokens.balances[j].toString()),
|
|
113
|
-
};
|
|
114
|
-
ptAcc[pt.toLowerCase()] = tokenState;
|
|
115
|
-
return ptAcc;
|
|
116
|
-
}, {}),
|
|
117
|
-
};
|
|
118
|
-
pools[pool.address] = poolState;
|
|
119
|
-
return [pools, startIndex];
|
|
120
|
-
}
|
|
121
|
-
onSell(amounts, poolPairData) {
|
|
122
|
-
try {
|
|
123
|
-
const orderedNormalizedBalances = (0, sor_1.balancesFromTokenInOut)(poolPairData.balances[poolPairData.indexIn], poolPairData.balances[poolPairData.indexOut], poolPairData.tokenInIsToken0);
|
|
124
|
-
const [currentInvariant, invErr] = sor_1.GyroEMaths.calculateInvariantWithError(orderedNormalizedBalances, poolPairData.gyroEParams, poolPairData.derivedGyroEParams);
|
|
125
|
-
const invariant = {
|
|
126
|
-
x: currentInvariant.add(invErr.mul(2)),
|
|
127
|
-
y: currentInvariant,
|
|
128
|
-
};
|
|
129
|
-
const tokenAmountsInScaled = amounts.map(a => this._upscale(a, poolPairData.scalingFactors[poolPairData.indexIn]));
|
|
130
|
-
const tokenAmountsInWithFee = tokenAmountsInScaled.map(a => this._subtractSwapFeeAmount(a, poolPairData.swapFee));
|
|
131
|
-
const amountsOut = tokenAmountsInWithFee.map(amount => {
|
|
132
|
-
try {
|
|
133
|
-
const amountOut = sor_1.GyroEMaths.calcOutGivenIn(orderedNormalizedBalances, bignumber_1.BigNumber.from(amount), poolPairData.tokenInIsToken0, poolPairData.gyroEParams, poolPairData.derivedGyroEParams, invariant).toBigInt();
|
|
134
|
-
return this._downscaleDown(amountOut, poolPairData.scalingFactors[poolPairData.indexOut]);
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
return BigInt(0);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return amountsOut;
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
onBuy(amounts, poolPairData) {
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.GyroEPool = GyroEPool;
|
|
151
|
-
//# sourceMappingURL=GyroEPool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GyroEPool.js","sourceRoot":"","sources":["../../../../../src/dex/balancer-v2/pools/gyro/GyroEPool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAC/C,wDAAqD;AAErD,0DAA+C;AAC/C,qDAAiD;AACjD,uCAIqB;AAErB,6DAAiD;AACjD,4CAM4B;AAG5B,oBAAoB;AACpB,MAAM,iBAAiB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAcvD,MAAa,SAAU,SAAQ,2BAAQ;IAOrC,YAAY,YAAoB,EAAE,cAAyB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AC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CACpE,CAAC;YAEF,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACzD,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CACrD,CAAC;YAEF,MAAM,UAAU,GAAa,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC9D,IAAI;oBACF,MAAM,SAAS,GAAG,gBAAU,CAAC,cAAc,CACzC,yBAAyB,EACzB,qBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EACtB,YAAY,CAAC,eAAe,EAC5B,YAAY,CAAC,WAAW,EACxB,YAAY,CAAC,kBAAkB,EAC/B,SAAS,CACV,CAAC,QAAQ,EAAE,CAAC;oBACb,OAAO,IAAI,CAAC,cAAc,CACxB,SAAS,EACT,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CACnD,CAAC;iBACH;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IAED,KAAK,CAAC,OAAiB,EAAE,YAAgC;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA/MD,8BA+MC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Address } from '../../../types';
|
|
2
|
-
import { IDexHelper } from '../../../dex-helper';
|
|
3
|
-
import { ThreePool } from './3pool';
|
|
4
|
-
export declare const address: Address;
|
|
5
|
-
export declare class FRXETHPool extends ThreePool {
|
|
6
|
-
constructor(parentName: string, dexHelper: IDexHelper);
|
|
7
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FRXETHPool = exports.address = void 0;
|
|
7
|
-
const utils_1 = require("../../../utils");
|
|
8
|
-
const StableSwapFRXETH_json_1 = __importDefault(require("../../../abi/curve-v1/StableSwapFRXETH.json"));
|
|
9
|
-
const _3pool_1 = require("./3pool");
|
|
10
|
-
const pool = 'frxETH';
|
|
11
|
-
exports.address = '0xa1f8a6807c402e4a15ef4eba36528a3fed24e577'.toLowerCase();
|
|
12
|
-
const tokenAddress = '0xf43211935c781d5ca1a41d2041f397b8a7366c7a';
|
|
13
|
-
const N_COINS = 2;
|
|
14
|
-
const PRECISION_MUL = ['1', '1'].map(utils_1.bigNumberify);
|
|
15
|
-
const USE_LENDING = [false, false];
|
|
16
|
-
const COINS = [
|
|
17
|
-
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
18
|
-
'0x5e8422345238f34275888049021821e8e08caa1f',
|
|
19
|
-
];
|
|
20
|
-
const trackCoins = true;
|
|
21
|
-
class FRXETHPool extends _3pool_1.ThreePool {
|
|
22
|
-
constructor(parentName, dexHelper) {
|
|
23
|
-
super(parentName, dexHelper, pool, exports.address, tokenAddress, trackCoins, StableSwapFRXETH_json_1.default, N_COINS, PRECISION_MUL, USE_LENDING, COINS, 'FRXETHPool');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.FRXETHPool = FRXETHPool;
|
|
27
|
-
//# sourceMappingURL=frxETHpool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frxETHpool.js","sourceRoot":"","sources":["../../../../src/dex/curve-v1/pools/frxETHpool.ts"],"names":[],"mappings":";;;;;;AAEA,0CAA8C;AAC9C,wGAA2E;AAC3E,oCAAoC;AAEpC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACT,QAAA,OAAO,GAClB,4CAA4C,CAAC,WAAW,EAAE,CAAC;AAC7D,MAAM,YAAY,GAAY,4CAA4C,CAAC;AAC3E,MAAM,OAAO,GAAW,CAAC,CAAC;AAC1B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG;IACZ,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AACF,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAa,UAAW,SAAQ,kBAAS;IACvC,YAAY,UAAkB,EAAE,SAAqB;QACnD,KAAK,CACH,UAAU,EACV,SAAS,EACT,IAAI,EACJ,eAAO,EACP,YAAY,EACZ,UAAU,EACV,+BAAgB,EAChB,OAAO,EACP,aAAa,EACb,WAAW,EACX,KAAK,EACL,YAAY,CACb,CAAC;IACJ,CAAC;CACF;AAjBD,gCAiBC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Address, Log } from '../../../types';
|
|
2
|
-
import { IDexHelper } from '../../../dex-helper';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { CurvePool, PoolState } from './curve-pool';
|
|
5
|
-
import { DeepReadonly } from 'ts-essentials';
|
|
6
|
-
export declare const address: Address;
|
|
7
|
-
export declare class WBETHPool extends CurvePool {
|
|
8
|
-
isAdminBalancesSupported: boolean;
|
|
9
|
-
lastTransferredCoin?: Address;
|
|
10
|
-
constructor(parentName: string, dexHelper: IDexHelper, _pool?: string, _address?: string, _tokenAddress?: string, _trackCoins?: boolean, _abi?: any, _N_COINS?: number, _PRECISION_MUL?: BigNumber[], _USE_LENDING?: boolean[], _COINS?: string[], prefix?: string);
|
|
11
|
-
processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
12
|
-
handleExchangeRateUpdated(event: any, state: PoolState): PoolState;
|
|
13
|
-
handleCoinTransfer(event: any, state: PoolState, log: Log): PoolState;
|
|
14
|
-
handleRemoveLiquidityOne(event: any, state: PoolState, log: Log): PoolState;
|
|
15
|
-
handleNewFee(event: any, state: PoolState, log: Log): PoolState;
|
|
16
|
-
handleRemoveLiquidity(event: any, state: PoolState, log: Log): PoolState;
|
|
17
|
-
handleRemoveLiquidityImbalances(event: any, state: PoolState, log: Log): PoolState;
|
|
18
|
-
handleAddLiquidity(event: any, state: PoolState, log: Log): PoolState;
|
|
19
|
-
exchange(i: number, j: number, dx: BigNumber, state: PoolState): BigNumber;
|
|
20
|
-
private _balances;
|
|
21
|
-
get_dy(i: number, j: number, dx: BigNumber, state: Readonly<PoolState>): BigNumber;
|
|
22
|
-
_get_dy(i: number, j: number, dx: BigNumber, A: BigNumber, fee: BigNumber, balances: BigNumber[], rates: BigNumber[], usefee?: boolean): BigNumber;
|
|
23
|
-
protected _xp_mem(_rates: BigNumber[], _balances: BigNumber[]): BigNumber[];
|
|
24
|
-
_get_y(i: number, j: number, x: BigNumber, xp: BigNumber[], A: BigNumber): BigNumber;
|
|
25
|
-
remove_liquidity_one_coin(token_amount: BigNumber, token_supply: BigNumber, i: number, state: PoolState): BigNumber;
|
|
26
|
-
private _calc_withdraw_one_coin;
|
|
27
|
-
private get_y_D;
|
|
28
|
-
_get_D(xp: BigNumber[], amp: BigNumber): BigNumber;
|
|
29
|
-
}
|