@paraswap/dex-lib 3.11.5 → 3.11.6
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/{inception/inception-ineth-pool.json → cables/CablesMainnetRFQ.json} +511 -490
- package/build/abi/fluid-dex/resolver.abi.json +731 -4
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/integral/pool.json +1041 -0
- package/build/abi/{wombat/pool.json → integral/relayer.json} +720 -473
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -23
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/cables/cables.d.ts +59 -0
- package/build/dex/cables/cables.js +599 -0
- package/build/dex/cables/cables.js.map +1 -0
- package/build/dex/cables/config.d.ts +4 -0
- package/build/dex/cables/config.js +15 -0
- package/build/dex/cables/config.js.map +1 -0
- package/build/dex/cables/constants.d.ts +20 -0
- package/build/dex/cables/constants.js +24 -0
- package/build/dex/cables/constants.js.map +1 -0
- package/build/dex/cables/rate-fetcher.d.ts +34 -0
- package/build/dex/cables/rate-fetcher.js +106 -0
- package/build/dex/cables/rate-fetcher.js.map +1 -0
- package/build/dex/cables/types.d.ts +113 -0
- package/build/dex/cables/types.js +19 -0
- package/build/dex/cables/types.js.map +1 -0
- package/build/dex/cables/validators.d.ts +5 -0
- package/build/dex/cables/validators.js +49 -0
- package/build/dex/cables/validators.js.map +1 -0
- package/build/dex/fluid-dex/config.js +1 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js +28 -1
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex.d.ts +19 -10
- package/build/dex/fluid-dex/fluid-dex.js +213 -55
- package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
- package/build/dex/fluid-dex/types.d.ts +22 -2
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +1 -2
- package/build/dex/jarvis.js +0 -58
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -45
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/stable-pool.js +8 -1
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -14
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
- package/build/dex/zerox/index.d.ts +26 -4
- package/build/dex/zerox/index.js +42 -50
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +0 -29
- package/build/dex/zerox/types.js +1 -8
- package/build/dex/zerox/types.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +8 -3
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/fluid-dex/resolver.abi.json +731 -4
- package/src/dex/fluid-dex/config.ts +1 -1
- package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +157 -6
- package/src/dex/fluid-dex/fluid-dex-events.test.ts +2 -4
- package/src/dex/fluid-dex/fluid-dex-integration.test.ts +69 -9
- package/src/dex/fluid-dex/fluid-dex-liquidity-proxy.ts +33 -0
- package/src/dex/fluid-dex/fluid-dex.ts +311 -89
- package/src/dex/fluid-dex/types.ts +25 -1
- package/src/executor/Executor03BytecodeBuilder.ts +10 -2
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/build/abi/inception/inception-ratio-feed.json +0 -329
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
- package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3-pool.d.ts +0 -76
- package/build/dex/balancer-v3/balancer-v3-pool.js +0 -383
- package/build/dex/balancer-v3/balancer-v3-pool.js.map +0 -1
- package/build/dex/balancer-v3/balancer-v3.d.ts +0 -57
- package/build/dex/balancer-v3/balancer-v3.js +0 -373
- package/build/dex/balancer-v3/balancer-v3.js.map +0 -1
- package/build/dex/balancer-v3/config.d.ts +0 -8
- package/build/dex/balancer-v3/config.js +0 -24
- package/build/dex/balancer-v3/config.js.map +0 -1
- package/build/dex/balancer-v3/getOnChainState.d.ts +0 -10
- package/build/dex/balancer-v3/getOnChainState.js +0 -158
- package/build/dex/balancer-v3/getOnChainState.js.map +0 -1
- package/build/dex/balancer-v3/getPoolsApi.d.ts +0 -2
- package/build/dex/balancer-v3/getPoolsApi.js +0 -81
- package/build/dex/balancer-v3/getPoolsApi.js.map +0 -1
- package/build/dex/balancer-v3/getTopPoolsApi.d.ts +0 -13
- package/build/dex/balancer-v3/getTopPoolsApi.js +0 -62
- package/build/dex/balancer-v3/getTopPoolsApi.js.map +0 -1
- package/build/dex/balancer-v3/types.d.ts +0 -63
- package/build/dex/balancer-v3/types.js +0 -3
- package/build/dex/balancer-v3/types.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -4
- package/build/dex/inception/config.js +0 -109
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -16
- package/build/dex/inception/inception-event-pool.js +0 -49
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -43
- package/build/dex/inception/inception.js +0 -180
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -7
- package/build/dex/inception/utils.js +0 -58
- package/build/dex/inception/utils.js.map +0 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
|
@@ -7,7 +7,7 @@ export const FluidDexConfig: DexConfigMap<DexParams> = {
|
|
|
7
7
|
[Network.MAINNET]: {
|
|
8
8
|
commonAddresses: {
|
|
9
9
|
liquidityProxy: '0x52aa899454998be5b000ad077a46bbe360f4e497',
|
|
10
|
-
resolver: '
|
|
10
|
+
resolver: '0x45f4ad57e300da55c33dea579a40fcee000d7b94',
|
|
11
11
|
dexFactory: '0x91716C4EDA1Fb55e84Bf8b4c7085f84285c19085',
|
|
12
12
|
},
|
|
13
13
|
},
|
|
@@ -3,7 +3,6 @@ import dotenv from 'dotenv';
|
|
|
3
3
|
dotenv.config();
|
|
4
4
|
|
|
5
5
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
6
|
-
|
|
7
6
|
import { testE2E } from '../../../tests/utils-e2e';
|
|
8
7
|
import {
|
|
9
8
|
Tokens,
|
|
@@ -12,6 +11,9 @@ import {
|
|
|
12
11
|
} from '../../../tests/constants-e2e';
|
|
13
12
|
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
14
13
|
import { generateConfig } from '../../config';
|
|
14
|
+
import { CollateralReserves, DebtReserves, DexLimits } from './types';
|
|
15
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
16
|
+
import { FluidDex } from './fluid-dex';
|
|
15
17
|
|
|
16
18
|
/*
|
|
17
19
|
README
|
|
@@ -66,10 +68,10 @@ function testForNetwork(
|
|
|
66
68
|
);
|
|
67
69
|
const tokens = Tokens[network];
|
|
68
70
|
const holders = Holders[network];
|
|
69
|
-
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
70
71
|
|
|
71
72
|
const sideToContractMethods = new Map([
|
|
72
73
|
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
74
|
+
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
|
|
73
75
|
]);
|
|
74
76
|
|
|
75
77
|
describe(`${network}`, () => {
|
|
@@ -83,7 +85,7 @@ function testForNetwork(
|
|
|
83
85
|
tokens[tokenBSymbol],
|
|
84
86
|
holders[tokenASymbol],
|
|
85
87
|
tokenBAmount,
|
|
86
|
-
|
|
88
|
+
side,
|
|
87
89
|
dexKey,
|
|
88
90
|
contractMethod as ContractMethod,
|
|
89
91
|
network,
|
|
@@ -96,7 +98,7 @@ function testForNetwork(
|
|
|
96
98
|
tokens[tokenASymbol],
|
|
97
99
|
holders[tokenBSymbol],
|
|
98
100
|
tokenBAmount,
|
|
99
|
-
|
|
101
|
+
side,
|
|
100
102
|
dexKey,
|
|
101
103
|
contractMethod as ContractMethod,
|
|
102
104
|
network,
|
|
@@ -137,8 +139,8 @@ describe('FluidDex E2E', () => {
|
|
|
137
139
|
const tokenASymbol: string = 'USDC';
|
|
138
140
|
const tokenBSymbol: string = 'USDT';
|
|
139
141
|
|
|
140
|
-
const tokenAAmount: string = '
|
|
141
|
-
const tokenBAmount: string = '
|
|
142
|
+
const tokenAAmount: string = '10000';
|
|
143
|
+
const tokenBAmount: string = '1000000';
|
|
142
144
|
|
|
143
145
|
testForNetwork(
|
|
144
146
|
network,
|
|
@@ -151,3 +153,152 @@ describe('FluidDex E2E', () => {
|
|
|
151
153
|
});
|
|
152
154
|
});
|
|
153
155
|
});
|
|
156
|
+
|
|
157
|
+
function NewColReservesOne(): CollateralReserves {
|
|
158
|
+
return {
|
|
159
|
+
token0RealReserves: BigInt(20000000006000000),
|
|
160
|
+
token1RealReserves: BigInt(20000000000500000),
|
|
161
|
+
token0ImaginaryReserves: BigInt(389736659726997981),
|
|
162
|
+
token1ImaginaryReserves: BigInt(389736659619871949),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function NewDebtReservesOne(): DebtReserves {
|
|
167
|
+
return {
|
|
168
|
+
token0Debt: BigInt(1e18),
|
|
169
|
+
token1Debt: BigInt(1e18),
|
|
170
|
+
token0RealReserves: BigInt(9486832995556050),
|
|
171
|
+
token1RealReserves: BigInt(9486832993079885),
|
|
172
|
+
token0ImaginaryReserves: BigInt(184868330099560759),
|
|
173
|
+
token1ImaginaryReserves: BigInt(184868330048879109),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const limitsTight: DexLimits = {
|
|
178
|
+
withdrawableToken0: {
|
|
179
|
+
available: 456740438880263n,
|
|
180
|
+
expandsTo: 711907234052361388866n,
|
|
181
|
+
expandsDuration: 600n,
|
|
182
|
+
},
|
|
183
|
+
withdrawableToken1: {
|
|
184
|
+
available: 825179383432029n,
|
|
185
|
+
expandsTo: 711907234052361388866n,
|
|
186
|
+
expandsDuration: 600n,
|
|
187
|
+
},
|
|
188
|
+
borrowableToken0: {
|
|
189
|
+
available: 941825058374170n,
|
|
190
|
+
expandsTo: 711907234052361388866n,
|
|
191
|
+
expandsDuration: 600n,
|
|
192
|
+
},
|
|
193
|
+
borrowableToken1: {
|
|
194
|
+
available: 941825058374170n,
|
|
195
|
+
expandsTo: 711907234052361388866n,
|
|
196
|
+
expandsDuration: 600n,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const limitsWide: DexLimits = {
|
|
201
|
+
withdrawableToken0: {
|
|
202
|
+
available: BigInt(34242332879776515083099999),
|
|
203
|
+
expandsTo: BigInt(34242332879776515083099999),
|
|
204
|
+
expandsDuration: 0n,
|
|
205
|
+
},
|
|
206
|
+
withdrawableToken1: {
|
|
207
|
+
available: BigInt(34242332879776515083099999),
|
|
208
|
+
expandsTo: BigInt(34242332879776515083099999),
|
|
209
|
+
expandsDuration: 22n,
|
|
210
|
+
},
|
|
211
|
+
borrowableToken0: {
|
|
212
|
+
available: BigInt(34242332879776515083099999),
|
|
213
|
+
expandsTo: BigInt(34242332879776515083099999),
|
|
214
|
+
expandsDuration: 0n,
|
|
215
|
+
},
|
|
216
|
+
borrowableToken1: {
|
|
217
|
+
available: BigInt(34242332879776515083099999),
|
|
218
|
+
expandsTo: BigInt(34242332879776515083099999),
|
|
219
|
+
expandsDuration: 308n,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const ErrInsufficientBorrowable = new Error('insufficient borrowable');
|
|
224
|
+
const ErrInsufficientMaxPrice = new Error('insufficient max price');
|
|
225
|
+
const ErrInsufficientReserve = new Error('insufficient reserve');
|
|
226
|
+
|
|
227
|
+
describe('TestPoolSimulator_SwapInLimits', () => {
|
|
228
|
+
const network = Network.MAINNET;
|
|
229
|
+
const dexHelper = new DummyDexHelper(network);
|
|
230
|
+
const dexKey = 'FluidDex';
|
|
231
|
+
const fluidDex = new FluidDex(network, dexKey, dexHelper);
|
|
232
|
+
|
|
233
|
+
it('when limits hit', () => {
|
|
234
|
+
let outAmt;
|
|
235
|
+
try {
|
|
236
|
+
outAmt = fluidDex.swapInAdjusted(
|
|
237
|
+
true,
|
|
238
|
+
BigInt(1e15),
|
|
239
|
+
NewColReservesOne(),
|
|
240
|
+
NewDebtReservesOne(),
|
|
241
|
+
100n,
|
|
242
|
+
18,
|
|
243
|
+
limitsTight,
|
|
244
|
+
Math.floor(Date.now() / 1000) - 10,
|
|
245
|
+
);
|
|
246
|
+
expect(outAmt).toEqual(0n);
|
|
247
|
+
} catch (err: any) {
|
|
248
|
+
expect(err.message).toEqual(ErrInsufficientBorrowable.message);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('when expanded', () => {
|
|
253
|
+
const outAmt = fluidDex.swapInAdjusted(
|
|
254
|
+
true,
|
|
255
|
+
BigInt(1e15),
|
|
256
|
+
NewColReservesOne(),
|
|
257
|
+
NewDebtReservesOne(),
|
|
258
|
+
100n,
|
|
259
|
+
18,
|
|
260
|
+
limitsTight,
|
|
261
|
+
Math.floor(Date.now() / 1000) - 6000,
|
|
262
|
+
);
|
|
263
|
+
console.log('outAmt: ', outAmt);
|
|
264
|
+
expect(outAmt?.toString()).toEqual('998262697204710');
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('when price diff hit', () => {
|
|
268
|
+
let outAmt;
|
|
269
|
+
try {
|
|
270
|
+
outAmt = fluidDex.swapInAdjusted(
|
|
271
|
+
true,
|
|
272
|
+
BigInt(3e16),
|
|
273
|
+
NewColReservesOne(),
|
|
274
|
+
NewDebtReservesOne(),
|
|
275
|
+
100n,
|
|
276
|
+
18,
|
|
277
|
+
limitsWide,
|
|
278
|
+
Math.floor(Date.now() / 1000) - 10,
|
|
279
|
+
);
|
|
280
|
+
expect(outAmt).toEqual(0n);
|
|
281
|
+
} catch (err: any) {
|
|
282
|
+
expect(err.message).toEqual(ErrInsufficientMaxPrice.message);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('when reserves limit is hit', () => {
|
|
287
|
+
let outAmt;
|
|
288
|
+
try {
|
|
289
|
+
outAmt = fluidDex.swapInAdjusted(
|
|
290
|
+
true,
|
|
291
|
+
BigInt(5e16),
|
|
292
|
+
NewColReservesOne(),
|
|
293
|
+
NewDebtReservesOne(),
|
|
294
|
+
100n,
|
|
295
|
+
18,
|
|
296
|
+
limitsWide,
|
|
297
|
+
Math.floor(Date.now() / 1000) - 10,
|
|
298
|
+
);
|
|
299
|
+
expect(outAmt).toEqual(0n);
|
|
300
|
+
} catch (err: any) {
|
|
301
|
+
expect(err.message).toEqual(ErrInsufficientReserve.message);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
@@ -38,9 +38,7 @@ describe('FluidDex EventPool Mainnet', function () {
|
|
|
38
38
|
const eventsToTest: Record<Address, EventMappings> = {
|
|
39
39
|
'0x52aa899454998be5b000ad077a46bbe360f4e497': {
|
|
40
40
|
LogOperate: [
|
|
41
|
-
|
|
42
|
-
21092142, 21092176, 21092187, 21092230, 21092286, 21092289, 21092295,
|
|
43
|
-
21092319, 21092352, 21092360, 21092368, 21092378, 21092383,
|
|
41
|
+
21190399, 21190405, 21190420, 21190452, 21190454, 21190465, 21190506,
|
|
44
42
|
],
|
|
45
43
|
},
|
|
46
44
|
};
|
|
@@ -86,7 +84,7 @@ describe('FluidDex EventPool Mainnet', function () {
|
|
|
86
84
|
|
|
87
85
|
const eventsToTest: Record<Address, EventMappings> = {
|
|
88
86
|
'0x91716C4EDA1Fb55e84Bf8b4c7085f84285c19085': {
|
|
89
|
-
LogDexDeployed: [
|
|
87
|
+
LogDexDeployed: [21199929],
|
|
90
88
|
},
|
|
91
89
|
};
|
|
92
90
|
|
|
@@ -46,7 +46,7 @@ function getReaderCalldata(
|
|
|
46
46
|
poolAddress,
|
|
47
47
|
pool!.token0.toLowerCase() === srcToken.toLowerCase() ? true : false,
|
|
48
48
|
amount,
|
|
49
|
-
|
|
49
|
+
0,
|
|
50
50
|
]),
|
|
51
51
|
}));
|
|
52
52
|
}
|
|
@@ -71,7 +71,7 @@ async function checkOnChainPricing(
|
|
|
71
71
|
dexHelper: DummyDexHelper,
|
|
72
72
|
srcToken: string,
|
|
73
73
|
) {
|
|
74
|
-
const resolverAddress = '
|
|
74
|
+
const resolverAddress = '0x45f4ad57e300da55c33dea579a40fcee000d7b94';
|
|
75
75
|
|
|
76
76
|
const readerIface = new Interface(ResolverABI);
|
|
77
77
|
|
|
@@ -197,7 +197,7 @@ describe('FluidDex', function () {
|
|
|
197
197
|
const tokenASymbol = 'wstETH';
|
|
198
198
|
const tokenBSymbol = 'ETH';
|
|
199
199
|
|
|
200
|
-
const
|
|
200
|
+
const amountsForSwap = [
|
|
201
201
|
0n,
|
|
202
202
|
1n * BI_POWS[18],
|
|
203
203
|
2n * BI_POWS[18],
|
|
@@ -220,12 +220,27 @@ describe('FluidDex', function () {
|
|
|
220
220
|
tokenASymbol,
|
|
221
221
|
tokenBSymbol,
|
|
222
222
|
SwapSide.SELL,
|
|
223
|
-
|
|
223
|
+
amountsForSwap,
|
|
224
224
|
'estimateSwapIn',
|
|
225
225
|
dexHelper,
|
|
226
226
|
);
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
+
it('wstETH -> ETH, getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
230
|
+
await testPricingOnNetwork(
|
|
231
|
+
fluidDex,
|
|
232
|
+
network,
|
|
233
|
+
dexKey,
|
|
234
|
+
blockNumber,
|
|
235
|
+
tokenASymbol,
|
|
236
|
+
tokenBSymbol,
|
|
237
|
+
SwapSide.BUY,
|
|
238
|
+
amountsForSwap,
|
|
239
|
+
'estimateSwapOut',
|
|
240
|
+
dexHelper,
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
229
244
|
it('ETH -> wstETH, getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
230
245
|
await testPricingOnNetwork(
|
|
231
246
|
fluidDex,
|
|
@@ -235,18 +250,33 @@ describe('FluidDex', function () {
|
|
|
235
250
|
tokenBSymbol,
|
|
236
251
|
tokenASymbol,
|
|
237
252
|
SwapSide.SELL,
|
|
238
|
-
|
|
253
|
+
amountsForSwap,
|
|
239
254
|
'estimateSwapIn',
|
|
240
255
|
dexHelper,
|
|
241
256
|
);
|
|
242
257
|
});
|
|
258
|
+
|
|
259
|
+
it('ETH -> wstETH, getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
260
|
+
await testPricingOnNetwork(
|
|
261
|
+
fluidDex,
|
|
262
|
+
network,
|
|
263
|
+
dexKey,
|
|
264
|
+
blockNumber,
|
|
265
|
+
tokenBSymbol,
|
|
266
|
+
tokenASymbol,
|
|
267
|
+
SwapSide.BUY,
|
|
268
|
+
amountsForSwap,
|
|
269
|
+
'estimateSwapOut',
|
|
270
|
+
dexHelper,
|
|
271
|
+
);
|
|
272
|
+
});
|
|
243
273
|
});
|
|
244
274
|
|
|
245
275
|
describe('USDC -> USDT', () => {
|
|
246
276
|
const tokenASymbol = 'USDC';
|
|
247
277
|
const tokenBSymbol = 'USDT';
|
|
248
278
|
|
|
249
|
-
const
|
|
279
|
+
const amountsForSwap = [
|
|
250
280
|
0n,
|
|
251
281
|
10n * BI_POWS[6],
|
|
252
282
|
20n * BI_POWS[6],
|
|
@@ -258,7 +288,7 @@ describe('FluidDex', function () {
|
|
|
258
288
|
80n * BI_POWS[6],
|
|
259
289
|
90n * BI_POWS[6],
|
|
260
290
|
100n * BI_POWS[6],
|
|
261
|
-
|
|
291
|
+
1000n * BI_POWS[6],
|
|
262
292
|
];
|
|
263
293
|
|
|
264
294
|
it('USDC -> USDT getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
@@ -270,12 +300,27 @@ describe('FluidDex', function () {
|
|
|
270
300
|
tokenASymbol,
|
|
271
301
|
tokenBSymbol,
|
|
272
302
|
SwapSide.SELL,
|
|
273
|
-
|
|
303
|
+
amountsForSwap,
|
|
274
304
|
'estimateSwapIn',
|
|
275
305
|
dexHelper,
|
|
276
306
|
);
|
|
277
307
|
});
|
|
278
308
|
|
|
309
|
+
it('USDC -> USDT getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
310
|
+
await testPricingOnNetwork(
|
|
311
|
+
fluidDex,
|
|
312
|
+
network,
|
|
313
|
+
dexKey,
|
|
314
|
+
blockNumber,
|
|
315
|
+
tokenASymbol,
|
|
316
|
+
tokenBSymbol,
|
|
317
|
+
SwapSide.BUY,
|
|
318
|
+
amountsForSwap,
|
|
319
|
+
'estimateSwapOut',
|
|
320
|
+
dexHelper,
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
|
|
279
324
|
it('USDT -> USDC getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
280
325
|
await testPricingOnNetwork(
|
|
281
326
|
fluidDex,
|
|
@@ -285,11 +330,26 @@ describe('FluidDex', function () {
|
|
|
285
330
|
tokenBSymbol,
|
|
286
331
|
tokenASymbol,
|
|
287
332
|
SwapSide.SELL,
|
|
288
|
-
|
|
333
|
+
amountsForSwap,
|
|
289
334
|
'estimateSwapIn',
|
|
290
335
|
dexHelper,
|
|
291
336
|
);
|
|
292
337
|
});
|
|
338
|
+
|
|
339
|
+
it('USDT -> USDC getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
340
|
+
await testPricingOnNetwork(
|
|
341
|
+
fluidDex,
|
|
342
|
+
network,
|
|
343
|
+
dexKey,
|
|
344
|
+
blockNumber,
|
|
345
|
+
tokenBSymbol,
|
|
346
|
+
tokenASymbol,
|
|
347
|
+
SwapSide.BUY,
|
|
348
|
+
amountsForSwap,
|
|
349
|
+
'estimateSwapOut',
|
|
350
|
+
dexHelper,
|
|
351
|
+
);
|
|
352
|
+
});
|
|
293
353
|
});
|
|
294
354
|
});
|
|
295
355
|
});
|
|
@@ -140,6 +140,7 @@ export class FluidDexLiquidityProxy extends StatefulEventSubscriber<FluidDexLiqu
|
|
|
140
140
|
feeHex,
|
|
141
141
|
collateralReservesHex,
|
|
142
142
|
debtReservesHex,
|
|
143
|
+
dexLimitsHex,
|
|
143
144
|
] = poolReserve;
|
|
144
145
|
|
|
145
146
|
const fee = Number(feeHex.toString());
|
|
@@ -160,6 +161,37 @@ export class FluidDexLiquidityProxy extends StatefulEventSubscriber<FluidDexLiqu
|
|
|
160
161
|
token1ImaginaryReserves: bigIntify(debtReservesHex[5]),
|
|
161
162
|
};
|
|
162
163
|
|
|
164
|
+
const withdrawableToken0 = {
|
|
165
|
+
available: bigIntify(dexLimitsHex[0][0]),
|
|
166
|
+
expandsTo: bigIntify(dexLimitsHex[0][1]),
|
|
167
|
+
expandsDuration: bigIntify(dexLimitsHex[0][2]),
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const withdrawableToken1 = {
|
|
171
|
+
available: bigIntify(dexLimitsHex[1][0]),
|
|
172
|
+
expandsTo: bigIntify(dexLimitsHex[1][1]),
|
|
173
|
+
expandsDuration: bigIntify(dexLimitsHex[1][2]),
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const borrowableToken0 = {
|
|
177
|
+
available: bigIntify(dexLimitsHex[2][0]),
|
|
178
|
+
expandsTo: bigIntify(dexLimitsHex[2][1]),
|
|
179
|
+
expandsDuration: bigIntify(dexLimitsHex[2][2]),
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const borrowableToken1 = {
|
|
183
|
+
available: bigIntify(dexLimitsHex[3][0]),
|
|
184
|
+
expandsTo: bigIntify(dexLimitsHex[3][1]),
|
|
185
|
+
expandsDuration: bigIntify(dexLimitsHex[3][2]),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const dexLimits = {
|
|
189
|
+
withdrawableToken0,
|
|
190
|
+
withdrawableToken1,
|
|
191
|
+
borrowableToken0,
|
|
192
|
+
borrowableToken1,
|
|
193
|
+
};
|
|
194
|
+
|
|
163
195
|
return {
|
|
164
196
|
pool,
|
|
165
197
|
token0,
|
|
@@ -167,6 +199,7 @@ export class FluidDexLiquidityProxy extends StatefulEventSubscriber<FluidDexLiqu
|
|
|
167
199
|
fee,
|
|
168
200
|
collateralReserves,
|
|
169
201
|
debtReserves,
|
|
202
|
+
dexLimits,
|
|
170
203
|
};
|
|
171
204
|
});
|
|
172
205
|
|