@paraswap/dex-lib 2.33.4-balancer-v2-multihop.2 → 2.34.0
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/build/abi/algebra/AlgebraPool.abi.json +727 -0
- package/build/config.js +27 -0
- package/build/config.js.map +1 -1
- package/build/dex/algebra/algebra-pool-v1_1.d.ts +16 -2
- package/build/dex/algebra/algebra-pool-v1_1.js +166 -4
- package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
- package/build/dex/algebra/algebra-pool.d.ts +46 -0
- package/build/dex/algebra/algebra-pool.js +336 -0
- package/build/dex/algebra/algebra-pool.js.map +1 -0
- package/build/dex/algebra/algebra.js +9 -7
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +1 -0
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/types.d.ts +3 -2
- package/build/dex/algebra/utils.d.ts +3 -1
- package/build/dex/algebra/utils.js +59 -1
- package/build/dex/algebra/utils.js.map +1 -1
- package/build/dex/balancer-v2/optimizer.d.ts +0 -1
- package/build/dex/balancer-v2/optimizer.js +21 -29
- package/build/dex/balancer-v2/optimizer.js.map +1 -1
- package/build/dex/solidly/forks-override/velodromeV2.js +4 -1
- package/build/dex/solidly/forks-override/velodromeV2.js.map +1 -1
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.js +7 -1
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/lib/decoders.d.ts +3 -0
- package/build/lib/decoders.js +9 -1
- package/build/lib/decoders.js.map +1 -1
- package/build/stateful-event-subscriber.d.ts +1 -0
- package/build/stateful-event-subscriber.js +6 -0
- package/build/stateful-event-subscriber.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/src/config.ts +30 -0
- package/src/dex/algebra/algebra-integration.test.ts +122 -0
- package/src/dex/algebra/algebra-pool-v1_1.ts +259 -8
- package/src/dex/algebra/algebra.ts +9 -6
- package/src/dex/algebra/config.ts +1 -0
- package/src/dex/algebra/types.ts +3 -2
- package/src/dex/algebra/utils.ts +83 -2
- package/src/dex/balancer-v2/optimizer.ts +23 -38
- package/src/dex/solidly/forks-override/velodromeV2.ts +4 -2
- package/src/dex/uniswap-v2/nomiswap-v2.ts +2 -1
- package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +6 -8
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +52 -47
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +1 -9
- package/src/dex/uniswap-v3/uniswap-v3.ts +7 -1
- package/src/lib/decoders.ts +13 -0
- package/src/stateful-event-subscriber.ts +8 -0
- package/build/abi/api3-proxy.json +0 -46
- package/build/abi/api3-server-v1.json +0 -463
- package/build/abi/quick-perps/fast-price-events.json +0 -70
- package/build/abi/quick-perps/fast-price-feed.json +0 -741
- package/build/abi/quick-perps/reader.json +0 -313
- package/build/abi/quick-perps/vault-price-feed.json +0 -323
- package/build/abi/quick-perps/vault.json +0 -1953
- package/build/abi/quickPerps/fast-price-events.json +0 -70
- package/build/abi/quickPerps/fast-price-feed.json +0 -748
- package/build/abi/quickPerps/reader.json +0 -313
- package/build/abi/quickPerps/vault-price-feed.json +0 -477
- package/build/abi/quickPerps/vault.json +0 -1953
- 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/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/balancer-v2/LinearMath.d.ts +0 -19
- package/build/dex/balancer-v2/LinearMath.js +0 -179
- package/build/dex/balancer-v2/LinearMath.js.map +0 -1
- package/build/dex/balancer-v2/LinearPool.d.ts +0 -47
- package/build/dex/balancer-v2/LinearPool.js +0 -324
- package/build/dex/balancer-v2/LinearPool.js.map +0 -1
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -47
- package/build/dex/balancer-v2/PhantomStablePool.js +0 -294
- 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 -75
- package/build/dex/balancer-v2/balancer-v2-pool.js +0 -417
- package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
- package/build/dex/quick-perps/config.d.ts +0 -11
- package/build/dex/quick-perps/config.js +0 -27
- package/build/dex/quick-perps/config.js.map +0 -1
- package/build/dex/quick-perps/fast-price-feed.d.ts +0 -26
- package/build/dex/quick-perps/fast-price-feed.js +0 -176
- package/build/dex/quick-perps/fast-price-feed.js.map +0 -1
- package/build/dex/quick-perps/pool.d.ts +0 -21
- package/build/dex/quick-perps/pool.js +0 -210
- package/build/dex/quick-perps/pool.js.map +0 -1
- package/build/dex/quick-perps/quick-perps.d.ts +0 -52
- package/build/dex/quick-perps/quick-perps.js +0 -205
- package/build/dex/quick-perps/quick-perps.js.map +0 -1
- package/build/dex/quick-perps/types.d.ts +0 -98
- package/build/dex/quick-perps/types.js +0 -3
- package/build/dex/quick-perps/types.js.map +0 -1
- package/build/dex/quick-perps/usdq.d.ts +0 -15
- package/build/dex/quick-perps/usdq.js +0 -61
- package/build/dex/quick-perps/usdq.js.map +0 -1
- package/build/dex/quick-perps/vault-price-feed.d.ts +0 -43
- package/build/dex/quick-perps/vault-price-feed.js +0 -194
- package/build/dex/quick-perps/vault-price-feed.js.map +0 -1
- package/build/dex/quick-perps/vault-utils.d.ts +0 -8
- package/build/dex/quick-perps/vault-utils.js +0 -41
- package/build/dex/quick-perps/vault-utils.js.map +0 -1
- package/build/dex/quick-perps/vault.d.ts +0 -46
- package/build/dex/quick-perps/vault.js +0 -166
- package/build/dex/quick-perps/vault.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/test-dex/config.d.ts +0 -4
- package/build/dex/test-dex/config.js +0 -15
- package/build/dex/test-dex/config.js.map +0 -1
- package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
- package/build/dex/test-dex/test-dex-pool.js +0 -63
- package/build/dex/test-dex/test-dex-pool.js.map +0 -1
- package/build/dex/test-dex/test-dex.d.ts +0 -37
- package/build/dex/test-dex/test-dex.js +0 -126
- package/build/dex/test-dex/test-dex.js.map +0 -1
- package/build/dex/test-dex/types.d.ts +0 -6
- package/build/dex/test-dex/types.js +0 -3
- package/build/dex/test-dex/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
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
- package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
- package/build/lib/api3-feed.d.ts +0 -26
- package/build/lib/api3-feed.js +0 -82
- package/build/lib/api3-feed.js.map +0 -1
- package/src/dex/balancer-v2/balancer-v2-optimizer.test.ts +0 -226
|
@@ -113,7 +113,6 @@ function testForNetwork(
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
describe('UniswapV3 E2E', () => {
|
|
116
|
-
|
|
117
116
|
describe('UniswapV3', () => {
|
|
118
117
|
const dexKey = 'UniswapV3';
|
|
119
118
|
|
|
@@ -790,32 +789,33 @@ describe('UniswapV3 E2E', () => {
|
|
|
790
789
|
],
|
|
791
790
|
]);
|
|
792
791
|
|
|
793
|
-
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
|
|
794
|
-
[
|
|
795
|
-
{
|
|
796
|
-
name: 'USDC',
|
|
797
|
-
sellAmount: '100000000000000000000',
|
|
798
|
-
buyAmount: '100000000000000000000',
|
|
799
|
-
},
|
|
800
|
-
{
|
|
801
|
-
name: 'USDT',
|
|
802
|
-
sellAmount: '100000000000000000000',
|
|
803
|
-
buyAmount: '100000000000000000000',
|
|
804
|
-
},
|
|
805
|
-
],
|
|
792
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
|
|
806
793
|
[
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
794
|
+
[
|
|
795
|
+
{
|
|
796
|
+
name: 'USDC',
|
|
797
|
+
sellAmount: '100000000000000000000',
|
|
798
|
+
buyAmount: '100000000000000000000',
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
name: 'USDT',
|
|
802
|
+
sellAmount: '100000000000000000000',
|
|
803
|
+
buyAmount: '100000000000000000000',
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
[
|
|
807
|
+
{
|
|
808
|
+
name: 'BNB',
|
|
809
|
+
sellAmount: '1000000000000000000',
|
|
810
|
+
buyAmount: '10000000000000000000',
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: 'USDT',
|
|
814
|
+
sellAmount: '1000000000000000000000',
|
|
815
|
+
buyAmount: '20000000000000000',
|
|
816
|
+
},
|
|
817
|
+
],
|
|
818
|
+
];
|
|
819
819
|
|
|
820
820
|
sideToContractMethods.forEach((contractMethods, side) =>
|
|
821
821
|
describe(`${side}`, () => {
|
|
@@ -909,28 +909,33 @@ describe('UniswapV3 E2E', () => {
|
|
|
909
909
|
],
|
|
910
910
|
]);
|
|
911
911
|
|
|
912
|
-
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
|
|
913
|
-
[
|
|
914
|
-
{
|
|
915
|
-
name: 'FTM',
|
|
916
|
-
sellAmount: '100000000000000000',
|
|
917
|
-
buyAmount: '100000000',
|
|
918
|
-
},
|
|
919
|
-
{
|
|
920
|
-
name: 'USDC',
|
|
921
|
-
sellAmount: '100000000',
|
|
922
|
-
buyAmount: '100000000000000000',
|
|
923
|
-
},
|
|
924
|
-
],
|
|
912
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] =
|
|
925
913
|
[
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
914
|
+
[
|
|
915
|
+
{
|
|
916
|
+
name: 'FTM',
|
|
917
|
+
sellAmount: '100000000000000000',
|
|
918
|
+
buyAmount: '100000000',
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
name: 'USDC',
|
|
922
|
+
sellAmount: '100000000',
|
|
923
|
+
buyAmount: '100000000000000000',
|
|
924
|
+
},
|
|
925
|
+
],
|
|
926
|
+
[
|
|
927
|
+
{
|
|
928
|
+
name: 'WFTM',
|
|
929
|
+
sellAmount: '100000000000000',
|
|
930
|
+
buyAmount: '1000000000000000',
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
name: 'WETH',
|
|
934
|
+
sellAmount: '1000000000000000',
|
|
935
|
+
buyAmount: '100000000000000',
|
|
936
|
+
},
|
|
937
|
+
],
|
|
938
|
+
];
|
|
934
939
|
|
|
935
940
|
sideToContractMethods.forEach((contractMethods, side) =>
|
|
936
941
|
describe(`${side}`, () => {
|
|
@@ -629,15 +629,10 @@ describe('ChronosV3', () => {
|
|
|
629
629
|
beforeEach(async () => {
|
|
630
630
|
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
631
631
|
uniswapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
632
|
-
uniswapV3Mainnet = new UniswapV3(
|
|
633
|
-
Network.ARBITRUM,
|
|
634
|
-
dexKey,
|
|
635
|
-
dexHelper,
|
|
636
|
-
);
|
|
632
|
+
uniswapV3Mainnet = new UniswapV3(Network.ARBITRUM, dexKey, dexHelper);
|
|
637
633
|
});
|
|
638
634
|
|
|
639
635
|
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
640
|
-
|
|
641
636
|
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
642
637
|
|
|
643
638
|
const pools = await uniswapV3.getPoolIdentifiers(
|
|
@@ -687,7 +682,6 @@ describe('ChronosV3', () => {
|
|
|
687
682
|
});
|
|
688
683
|
|
|
689
684
|
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
690
|
-
|
|
691
685
|
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
692
686
|
|
|
693
687
|
const pools = await uniswapV3.getPoolIdentifiers(
|
|
@@ -964,7 +958,5 @@ describe('SushiSwapV3', () => {
|
|
|
964
958
|
|
|
965
959
|
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
966
960
|
});
|
|
967
|
-
|
|
968
961
|
});
|
|
969
962
|
});
|
|
970
|
-
|
|
@@ -91,7 +91,13 @@ export class UniswapV3
|
|
|
91
91
|
|
|
92
92
|
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
93
93
|
getDexKeysWithNetwork(
|
|
94
|
-
_.pick(UniswapV3Config, [
|
|
94
|
+
_.pick(UniswapV3Config, [
|
|
95
|
+
'UniswapV3',
|
|
96
|
+
'SushiSwapV3',
|
|
97
|
+
'QuickSwapV3.1',
|
|
98
|
+
'RamsesV2',
|
|
99
|
+
'ChronosV3',
|
|
100
|
+
]),
|
|
95
101
|
);
|
|
96
102
|
|
|
97
103
|
logger: Logger;
|
package/src/lib/decoders.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Result } from '@ethersproject/abi';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { BigNumber as EthersBigNumber } from 'ethers';
|
|
3
4
|
import { BytesLike, defaultAbiCoder } from 'ethers/lib/utils';
|
|
4
5
|
import _, { parseInt } from 'lodash';
|
|
5
6
|
import { BN_0 } from '../bignumber-constants';
|
|
@@ -50,6 +51,18 @@ export const uint256ToBigInt = (
|
|
|
50
51
|
return generalDecoder(result, ['uint256'], 0n, value => value[0].toBigInt());
|
|
51
52
|
};
|
|
52
53
|
|
|
54
|
+
export const uint128ToBigNumber = (
|
|
55
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
56
|
+
): EthersBigNumber => {
|
|
57
|
+
return generalDecoder(result, ['uint128'], 0n, value => value[0]);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const int24ToNumber = (
|
|
61
|
+
result: MultiResult<BytesLike> | BytesLike,
|
|
62
|
+
): number => {
|
|
63
|
+
return generalDecoder(result, ['int24'], 0n, value => value[0]);
|
|
64
|
+
};
|
|
65
|
+
|
|
53
66
|
export const uint256ArrayDecode = (
|
|
54
67
|
result: MultiResult<BytesLike> | BytesLike,
|
|
55
68
|
): bigint => {
|
|
@@ -18,6 +18,7 @@ type StateCache<State> = {
|
|
|
18
18
|
export type InitializeStateOptions<State> = {
|
|
19
19
|
state?: DeepReadonly<State>;
|
|
20
20
|
initCallback?: (state: DeepReadonly<State>) => void;
|
|
21
|
+
forceRegenerate?: boolean;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export abstract class StatefulEventSubscriber<State>
|
|
@@ -89,6 +90,13 @@ export abstract class StatefulEventSubscriber<State>
|
|
|
89
90
|
let masterBn: undefined | number = undefined;
|
|
90
91
|
if (options && options.state) {
|
|
91
92
|
this.setState(options.state, blockNumber);
|
|
93
|
+
} else if (options && options.forceRegenerate) {
|
|
94
|
+
// ZkEVM forces to always regenerate state when it is old
|
|
95
|
+
this.logger.debug(
|
|
96
|
+
`${this.parentName}: ${this.name}: forced to regenerate state`,
|
|
97
|
+
);
|
|
98
|
+
const state = await this.generateState(blockNumber);
|
|
99
|
+
this.setState(state, blockNumber);
|
|
92
100
|
} else {
|
|
93
101
|
if (this.dexHelper.config.isSlave && this.masterPoolNeeded) {
|
|
94
102
|
let stateAsString = await this.dexHelper.cache.hget(
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [],
|
|
4
|
-
"name": "api3ServerV1",
|
|
5
|
-
"outputs": [
|
|
6
|
-
{
|
|
7
|
-
"internalType": "address",
|
|
8
|
-
"name": "",
|
|
9
|
-
"type": "address"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"stateMutability": "view",
|
|
13
|
-
"type": "function"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"inputs": [],
|
|
17
|
-
"name": "dataFeedId",
|
|
18
|
-
"outputs": [
|
|
19
|
-
{
|
|
20
|
-
"internalType": "bytes32",
|
|
21
|
-
"name": "",
|
|
22
|
-
"type": "bytes32"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"stateMutability": "view",
|
|
26
|
-
"type": "function"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"inputs": [],
|
|
30
|
-
"name": "read",
|
|
31
|
-
"outputs": [
|
|
32
|
-
{
|
|
33
|
-
"internalType": "int224",
|
|
34
|
-
"name": "value",
|
|
35
|
-
"type": "int224"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"internalType": "uint32",
|
|
39
|
-
"name": "timestamp",
|
|
40
|
-
"type": "uint32"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"stateMutability": "view",
|
|
44
|
-
"type": "function"
|
|
45
|
-
}
|
|
46
|
-
]
|