@paraswap/dex-lib 4.0.3-Cables.0 → 4.0.3
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 +53 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
- package/build/abi/inception/inception-ratio-feed.json +329 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
- package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
- package/build/abi/usual-m-usd0/usualCollateralDao.abi.json +681 -0
- package/build/abi/usual-m-wrapped-m/usualM.abi.json +509 -0
- package/build/abi/{integral/relayer.json → wombat/pool.json} +474 -721
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +23 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/tokens-avalanche.json +44 -0
- package/build/dex/aave-v2/tokens-mainnet.json +188 -0
- package/build/dex/aave-v2/tokens-polygon.json +44 -0
- package/build/dex/algebra/algebra.js +2 -31
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +1 -0
- package/build/dex/bebop/bebop.js +1 -1
- package/build/dex/bebop/bebop.js.map +1 -1
- package/build/dex/cables/cables.d.ts +0 -1
- package/build/dex/cables/cables.js +88 -145
- package/build/dex/cables/cables.js.map +1 -1
- package/build/dex/cables/constants.js +1 -1
- package/build/dex/cables/constants.js.map +1 -1
- package/build/dex/cables/rate-fetcher.d.ts +0 -1
- package/build/dex/cables/rate-fetcher.js +10 -30
- package/build/dex/cables/rate-fetcher.js.map +1 -1
- package/build/dex/cables/types.d.ts +15 -16
- package/build/dex/cables/types.js +5 -2
- package/build/dex/cables/types.js.map +1 -1
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/inception/config.d.ts +4 -0
- package/build/dex/inception/config.js +109 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +16 -0
- package/build/dex/inception/inception-event-pool.js +49 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/inception/inception.d.ts +43 -0
- package/build/dex/inception/inception.js +180 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +7 -0
- package/build/dex/inception/utils.js +58 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/index.js +0 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/jarvis.d.ts +2 -1
- package/build/dex/jarvis.js +58 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +185 -0
- package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
- package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +45 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
- package/build/dex/stable-pool.js +1 -8
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +14 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
- package/build/dex/usual/types.d.ts +13 -0
- package/build/dex/usual/types.js +3 -0
- package/build/dex/usual/types.js.map +1 -0
- package/build/dex/usual/usual-bond.d.ts +18 -0
- package/build/dex/usual/usual-bond.js +52 -0
- package/build/dex/usual/usual-bond.js.map +1 -0
- package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
- package/build/dex/usual/usual-m-smart-m.js +50 -0
- package/build/dex/usual/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual/usual-m-usd0.d.ts +17 -0
- package/build/dex/usual/usual-m-usd0.js +51 -0
- package/build/dex/usual/usual-m-usd0.js.map +1 -0
- package/build/dex/usual/usual-m-wrapped-m.d.ts +17 -0
- package/build/dex/usual/usual-m-wrapped-m.js +50 -0
- package/build/dex/usual/usual-m-wrapped-m.js.map +1 -0
- package/build/dex/usual/usual.d.ts +27 -0
- package/build/dex/usual/usual.js +125 -0
- package/build/dex/usual/usual.js.map +1 -0
- package/build/dex/usual-m-smart-m/config.d.ts +3 -0
- package/build/dex/usual-m-smart-m/config.js +13 -0
- package/build/dex/usual-m-smart-m/config.js.map +1 -0
- package/build/dex/usual-m-smart-m/types.d.ts +7 -0
- package/build/dex/usual-m-smart-m/types.js +3 -0
- package/build/dex/usual-m-smart-m/types.js.map +1 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual-m-usd0/config.d.ts +3 -0
- package/build/dex/usual-m-usd0/config.js +14 -0
- package/build/dex/usual-m-usd0/config.js.map +1 -0
- package/build/dex/usual-m-usd0/types.d.ts +8 -0
- package/build/dex/usual-m-usd0/types.js +3 -0
- package/build/dex/usual-m-usd0/types.js.map +1 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
- package/build/dex/zerox/index.d.ts +4 -26
- package/build/dex/zerox/index.js +50 -42
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +29 -0
- package/build/dex/zerox/types.js +8 -1
- package/build/dex/zerox/types.js.map +1 -1
- package/build/executor/Executor01BytecodeBuilder.js +6 -11
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +6 -11
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +6 -11
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/lib/pub-sub.d.ts +35 -0
- package/build/lib/pub-sub.js +106 -0
- package/build/lib/pub-sub.js.map +1 -0
- package/build/types.d.ts +0 -1
- package/package.json +1 -1
- package/src/dex/algebra/algebra.ts +9 -48
- package/src/dex/bebop/bebop.ts +1 -1
- package/src/dex/dexalot/dexalot.ts +0 -1
- package/src/dex/index.ts +0 -2
- package/src/executor/Executor01BytecodeBuilder.ts +11 -15
- package/src/executor/Executor02BytecodeBuilder.ts +9 -13
- package/src/executor/Executor03BytecodeBuilder.ts +9 -16
- package/src/types.ts +0 -1
- package/tests/constants-e2e.ts +2 -2
- 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/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.d.ts +0 -41
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/src/abi/cables/CablesMainnetRFQ.json +0 -1083
- package/src/dex/cables/cables-e2e.test.ts +0 -207
- package/src/dex/cables/cables-integration.test.ts +0 -391
- package/src/dex/cables/cables.ts +0 -1006
- package/src/dex/cables/config.ts +0 -13
- package/src/dex/cables/constants.ts +0 -35
- package/src/dex/cables/rate-fetcher.ts +0 -219
- package/src/dex/cables/types.ts +0 -130
- package/src/dex/cables/validators.test.ts +0 -151
- package/src/dex/cables/validators.ts +0 -61
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import NodeCache from 'node-cache';
|
|
2
|
+
import { Network } from '../constants';
|
|
3
|
+
import { IDexHelper } from '../dex-helper';
|
|
4
|
+
type JsonPubSubMsg = {
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
data: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
type SetPubSubMsg = string[];
|
|
9
|
+
export declare class JsonPubSub {
|
|
10
|
+
private dexHelper;
|
|
11
|
+
private dexKey;
|
|
12
|
+
channel: string;
|
|
13
|
+
network: Network;
|
|
14
|
+
localCache: NodeCache;
|
|
15
|
+
constructor(dexHelper: IDexHelper, dexKey: string, channel: string);
|
|
16
|
+
initialize(): void;
|
|
17
|
+
subscribe(): void;
|
|
18
|
+
publish(data: Record<string, unknown>, ttl: number): void;
|
|
19
|
+
handleSubscription(json: JsonPubSubMsg): void;
|
|
20
|
+
getAndCache<T>(key: string): Promise<T | null>;
|
|
21
|
+
}
|
|
22
|
+
export declare class SetPubSub {
|
|
23
|
+
private dexHelper;
|
|
24
|
+
private dexKey;
|
|
25
|
+
channel: string;
|
|
26
|
+
network: Network;
|
|
27
|
+
set: Set<string>;
|
|
28
|
+
constructor(dexHelper: IDexHelper, dexKey: string, channel: string);
|
|
29
|
+
initialize(key: string): Promise<void>;
|
|
30
|
+
subscribe(): void;
|
|
31
|
+
publish(set: SetPubSubMsg): void;
|
|
32
|
+
handleSubscription(set: SetPubSubMsg): void;
|
|
33
|
+
has(key: string): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
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.SetPubSub = exports.JsonPubSub = void 0;
|
|
7
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
|
+
class JsonPubSub {
|
|
9
|
+
dexHelper;
|
|
10
|
+
dexKey;
|
|
11
|
+
channel;
|
|
12
|
+
network;
|
|
13
|
+
localCache = new node_cache_1.default();
|
|
14
|
+
constructor(dexHelper, dexKey, channel) {
|
|
15
|
+
this.dexHelper = dexHelper;
|
|
16
|
+
this.dexKey = dexKey;
|
|
17
|
+
this.network = this.dexHelper.config.data.network;
|
|
18
|
+
this.channel = `${this.network}_${this.dexKey}_${channel}`;
|
|
19
|
+
}
|
|
20
|
+
initialize() {
|
|
21
|
+
this.subscribe();
|
|
22
|
+
}
|
|
23
|
+
subscribe() {
|
|
24
|
+
this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
|
|
25
|
+
const decodedMsg = JSON.parse(msg);
|
|
26
|
+
this.handleSubscription(decodedMsg);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
publish(data, ttl) {
|
|
30
|
+
const expiresAt = Math.round(Date.now() / 1000) + ttl;
|
|
31
|
+
this.dexHelper.cache.publish(this.channel, JSON.stringify({ expiresAt, data }));
|
|
32
|
+
}
|
|
33
|
+
handleSubscription(json) {
|
|
34
|
+
const { expiresAt, data } = json;
|
|
35
|
+
const now = Math.round(Date.now() / 1000);
|
|
36
|
+
// calculating ttl as message might come with the delay
|
|
37
|
+
const ttl = expiresAt - now;
|
|
38
|
+
const keys = Object.keys(data);
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
this.localCache.set(key, data[key], ttl);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async getAndCache(key) {
|
|
44
|
+
const localValue = this.localCache.get(key);
|
|
45
|
+
if (localValue) {
|
|
46
|
+
return localValue;
|
|
47
|
+
}
|
|
48
|
+
const [value, ttl] = await Promise.all([
|
|
49
|
+
this.dexHelper.cache.get(this.dexKey, this.network, key),
|
|
50
|
+
this.dexHelper.cache.ttl(this.dexKey, this.network, key),
|
|
51
|
+
]);
|
|
52
|
+
if (value) {
|
|
53
|
+
// setting ttl same as in cache
|
|
54
|
+
// TODO-ps: check if ttl is not null
|
|
55
|
+
const parsedValue = JSON.parse(value);
|
|
56
|
+
this.localCache.set(key, parsedValue, Number(ttl));
|
|
57
|
+
return parsedValue;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.JsonPubSub = JsonPubSub;
|
|
63
|
+
class SetPubSub {
|
|
64
|
+
dexHelper;
|
|
65
|
+
dexKey;
|
|
66
|
+
channel;
|
|
67
|
+
network;
|
|
68
|
+
set = new Set();
|
|
69
|
+
constructor(dexHelper, dexKey, channel) {
|
|
70
|
+
this.dexHelper = dexHelper;
|
|
71
|
+
this.dexKey = dexKey;
|
|
72
|
+
this.network = this.dexHelper.config.data.network;
|
|
73
|
+
this.channel = `${this.network}_${this.dexKey}_${channel}`;
|
|
74
|
+
}
|
|
75
|
+
async initialize(key) {
|
|
76
|
+
// as there's no lazy load, we need to initialize the set
|
|
77
|
+
const initSet = await this.dexHelper.cache.smembers(key);
|
|
78
|
+
for (const member of initSet) {
|
|
79
|
+
this.set.add(member);
|
|
80
|
+
}
|
|
81
|
+
this.subscribe();
|
|
82
|
+
}
|
|
83
|
+
subscribe() {
|
|
84
|
+
this.dexHelper.cache.subscribe(this.channel, (_, msg) => {
|
|
85
|
+
const decodedMsg = JSON.parse(msg);
|
|
86
|
+
this.handleSubscription(decodedMsg);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
publish(set) {
|
|
90
|
+
// as there's no lazy load, also store locally
|
|
91
|
+
for (const key of set) {
|
|
92
|
+
this.set.add(key);
|
|
93
|
+
}
|
|
94
|
+
this.dexHelper.cache.publish(this.channel, JSON.stringify(set));
|
|
95
|
+
}
|
|
96
|
+
handleSubscription(set) {
|
|
97
|
+
for (const key of set) {
|
|
98
|
+
this.set.add(key);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async has(key) {
|
|
102
|
+
return this.set.has(key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.SetPubSub = SetPubSub;
|
|
106
|
+
//# sourceMappingURL=pub-sub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub-sub.js","sourceRoot":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CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,kBAAkB,CAAC,GAAiB;QAClC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF;AAhDD,8BAgDC"}
|
package/build/types.d.ts
CHANGED
|
@@ -148,7 +148,6 @@ export type DexExchangeParam = {
|
|
|
148
148
|
swappedAmountNotPresentInExchangeData?: boolean;
|
|
149
149
|
preSwapUnwrapCalldata?: string;
|
|
150
150
|
returnAmountPos: number | undefined;
|
|
151
|
-
insertFromAmountPos?: number;
|
|
152
151
|
permit2Approval?: boolean;
|
|
153
152
|
};
|
|
154
153
|
export type DexExchangeParamWithBooleanNeedWrapNative = DexExchangeParam & {
|
package/package.json
CHANGED
|
@@ -69,10 +69,6 @@ const ALGEBRA_TICK_BASE_OVERHEAD = 75_000;
|
|
|
69
69
|
const ALGEBRA_POOL_SEARCH_OVERHEAD = 10_000;
|
|
70
70
|
const ALGEBRA_QUOTE_GASLIMIT = 2_000_000;
|
|
71
71
|
|
|
72
|
-
const MAX_STALE_STATE_BLOCK_AGE = {
|
|
73
|
-
[Network.ZKEVM]: 150, // approximately 3min
|
|
74
|
-
};
|
|
75
|
-
|
|
76
72
|
type IAlgebraEventPool =
|
|
77
73
|
| AlgebraEventPoolV1_1
|
|
78
74
|
| AlgebraEventPoolV1_9
|
|
@@ -240,20 +236,6 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
240
236
|
|
|
241
237
|
if (pool) {
|
|
242
238
|
if (!pool.initFailed) {
|
|
243
|
-
if (this.network !== Network.ZKEVM) return pool;
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
pool.getStaleState() === null ||
|
|
247
|
-
(pool.getState(blockNumber) === null &&
|
|
248
|
-
blockNumber - pool.getStateBlockNumber() >
|
|
249
|
-
MAX_STALE_STATE_BLOCK_AGE[this.network])
|
|
250
|
-
) {
|
|
251
|
-
/* reload state, on zkEVM this would most likely timeout during request life
|
|
252
|
-
* but would allow to rely on staleState for couple of min for next requests
|
|
253
|
-
*/
|
|
254
|
-
await pool.initialize(blockNumber, { forceRegenerate: true });
|
|
255
|
-
}
|
|
256
|
-
|
|
257
239
|
return pool;
|
|
258
240
|
} else {
|
|
259
241
|
// if init failed then prefer to early return pool with empty state to fallback to rpc call
|
|
@@ -615,37 +597,16 @@ export class Algebra extends SimpleExchange implements IDex<AlgebraData> {
|
|
|
615
597
|
let state = pool.getState(blockNumber);
|
|
616
598
|
|
|
617
599
|
if (state === null) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
`${_srcAddress}_${_destAddress}_${pool.name}_${
|
|
627
|
-
pool.poolAddress
|
|
628
|
-
} state fallback to latest early enough state. Current blockNumber=${blockNumber}, stateBlockNumber=${pool.getStateBlockNumber()}`,
|
|
629
|
-
);
|
|
630
|
-
state = pool.getStaleState();
|
|
631
|
-
} else {
|
|
632
|
-
this.logger.warn(
|
|
633
|
-
`${_srcAddress}_${_destAddress}_${pool.name}_${pool.poolAddress} state is unhealthy, cannot compute price (no fallback on this chain)`,
|
|
634
|
-
);
|
|
635
|
-
return null; // never fallback as takes more time
|
|
636
|
-
}
|
|
637
|
-
} else {
|
|
638
|
-
const rpcPrice = await this.getPricingFromRpc(
|
|
639
|
-
_srcToken,
|
|
640
|
-
_destToken,
|
|
641
|
-
amounts,
|
|
642
|
-
side,
|
|
643
|
-
pool,
|
|
644
|
-
transferFees,
|
|
645
|
-
);
|
|
600
|
+
const rpcPrice = await this.getPricingFromRpc(
|
|
601
|
+
_srcToken,
|
|
602
|
+
_destToken,
|
|
603
|
+
amounts,
|
|
604
|
+
side,
|
|
605
|
+
pool,
|
|
606
|
+
transferFees,
|
|
607
|
+
);
|
|
646
608
|
|
|
647
|
-
|
|
648
|
-
}
|
|
609
|
+
return rpcPrice;
|
|
649
610
|
}
|
|
650
611
|
|
|
651
612
|
if (!state) return null;
|
package/src/dex/bebop/bebop.ts
CHANGED
|
@@ -723,7 +723,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
|
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
if (side
|
|
726
|
+
if (side == SwapSide.SELL) {
|
|
727
727
|
const requiredAmount = BigInt(optimalSwapExchange.destAmount);
|
|
728
728
|
const quoteAmount = BigInt(
|
|
729
729
|
response.buyTokens[utils.getAddress(destToken.address)].amount,
|
|
@@ -593,7 +593,6 @@ export class Dexalot extends SimpleExchange implements IDex<DexalotData> {
|
|
|
593
593
|
.multipliedBy(10000)
|
|
594
594
|
.toFixed(0)
|
|
595
595
|
: options.slippageFactor.minus(1).multipliedBy(10000).toFixed(0);
|
|
596
|
-
|
|
597
596
|
const rfqParams = {
|
|
598
597
|
makerAsset: ethers.utils.getAddress(makerToken.address),
|
|
599
598
|
takerAsset: ethers.utils.getAddress(takerToken.address),
|
package/src/dex/index.ts
CHANGED
|
@@ -96,7 +96,6 @@ import { StkGHO } from './stkgho/stkgho';
|
|
|
96
96
|
import { BalancerV3 } from './balancer-v3/balancer-v3';
|
|
97
97
|
import { balancerV3Merge } from './balancer-v3/optimizer';
|
|
98
98
|
import { SkyConverter } from './sky-converter/sky-converter';
|
|
99
|
-
import { Cables } from './cables/cables';
|
|
100
99
|
import { Stader } from './stader/stader';
|
|
101
100
|
|
|
102
101
|
const LegacyDexes = [
|
|
@@ -188,7 +187,6 @@ const Dexes = [
|
|
|
188
187
|
UsualBond,
|
|
189
188
|
StkGHO,
|
|
190
189
|
SkyConverter,
|
|
191
|
-
Cables,
|
|
192
190
|
FluidDex,
|
|
193
191
|
];
|
|
194
192
|
|
|
@@ -379,21 +379,17 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
379
379
|
|
|
380
380
|
let fromAmountPos = 0;
|
|
381
381
|
if (insertFromAmount) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
fromAmountPos =
|
|
395
|
-
(fromAmountIndex !== -1 ? fromAmountIndex : exchangeData.length) / 2;
|
|
396
|
-
}
|
|
382
|
+
const fromAmount = ethers.utils.defaultAbiCoder.encode(
|
|
383
|
+
['uint256'],
|
|
384
|
+
[swap.swapExchanges[swapExchangeIndex].srcAmount],
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
const fromAmountIndex = exchangeData
|
|
388
|
+
.replace('0x', '')
|
|
389
|
+
.indexOf(fromAmount.replace('0x', ''));
|
|
390
|
+
|
|
391
|
+
fromAmountPos =
|
|
392
|
+
(fromAmountIndex !== -1 ? fromAmountIndex : exchangeData.length) / 2;
|
|
397
393
|
}
|
|
398
394
|
|
|
399
395
|
return this.buildCallData(
|
|
@@ -335,20 +335,16 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
335
335
|
|
|
336
336
|
let fromAmountPos = 0;
|
|
337
337
|
if (insertFromAmount) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
);
|
|
345
|
-
const fromAmountIndex = exchangeData
|
|
346
|
-
.replace('0x', '')
|
|
347
|
-
.indexOf(fromAmount.replace('0x', ''));
|
|
338
|
+
const fromAmount = ethers.utils.defaultAbiCoder.encode(
|
|
339
|
+
['uint256'],
|
|
340
|
+
[swapExchange.srcAmount],
|
|
341
|
+
);
|
|
342
|
+
const fromAmountIndex = exchangeData
|
|
343
|
+
.replace('0x', '')
|
|
344
|
+
.indexOf(fromAmount.replace('0x', ''));
|
|
348
345
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
346
|
+
fromAmountPos =
|
|
347
|
+
(fromAmountIndex !== -1 ? fromAmountIndex : exchangeData.length) / 2;
|
|
352
348
|
}
|
|
353
349
|
|
|
354
350
|
return this.buildCallData(
|
|
@@ -331,31 +331,24 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder<
|
|
|
331
331
|
let fromAmountPos = 0;
|
|
332
332
|
let toAmountPos = 0;
|
|
333
333
|
if (insertAmount) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
['uint256'],
|
|
339
|
-
[swap.swapExchanges[swapExchangeIndex].srcAmount],
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
const fromAmountIndex = exchangeData
|
|
343
|
-
.replace('0x', '')
|
|
344
|
-
.indexOf(fromAmount.replace('0x', ''));
|
|
345
|
-
|
|
346
|
-
fromAmountPos =
|
|
347
|
-
(fromAmountIndex !== -1 ? fromAmountIndex : exchangeData.length) / 2;
|
|
348
|
-
}
|
|
349
|
-
|
|
334
|
+
const fromAmount = ethers.utils.defaultAbiCoder.encode(
|
|
335
|
+
['uint256'],
|
|
336
|
+
[swap.swapExchanges[swapExchangeIndex].srcAmount],
|
|
337
|
+
);
|
|
350
338
|
const toAmount = ethers.utils.defaultAbiCoder.encode(
|
|
351
339
|
['uint256'],
|
|
352
340
|
[swap.swapExchanges[swapExchangeIndex].destAmount],
|
|
353
341
|
);
|
|
354
342
|
|
|
343
|
+
const fromAmountIndex = exchangeData
|
|
344
|
+
.replace('0x', '')
|
|
345
|
+
.indexOf(fromAmount.replace('0x', ''));
|
|
355
346
|
const toAmountIndex = exchangeData
|
|
356
347
|
.replace('0x', '')
|
|
357
348
|
.indexOf(toAmount.replace('0x', ''));
|
|
358
349
|
|
|
350
|
+
fromAmountPos =
|
|
351
|
+
(fromAmountIndex !== -1 ? fromAmountIndex : exchangeData.length) / 2;
|
|
359
352
|
toAmountPos =
|
|
360
353
|
(toAmountIndex !== -1 ? toAmountIndex : exchangeData.length) / 2;
|
|
361
354
|
}
|
package/src/types.ts
CHANGED
package/tests/constants-e2e.ts
CHANGED
|
@@ -1900,7 +1900,7 @@ export const Holders: {
|
|
|
1900
1900
|
BETS: '0x8cc2284c90d05578633418f9cde104f402375a65',
|
|
1901
1901
|
HATCHY: '0x14ec295ec8def851ec6e2959df872dd24e422631',
|
|
1902
1902
|
USDCe: '0x3a2434c698f8d79af1f5a9e43013157ca8b11a66',
|
|
1903
|
-
USDC: '
|
|
1903
|
+
USDC: '0xcc2da711D621A4491b338CAC88B9C0954db3e75B',
|
|
1904
1904
|
USDTe: '0x84d34f4f83a87596cd3fb6887cff8f17bf5a7b83',
|
|
1905
1905
|
WETHe: '0x9bdB521a97E95177BF252C253E256A60C3e14447',
|
|
1906
1906
|
POPS: '0x5268c2331658cb0b2858cfa9db27d8f22f5434bc',
|
|
@@ -1916,7 +1916,7 @@ export const Holders: {
|
|
|
1916
1916
|
TSD: '0x691A89db352B72dDb249bFe16503494eC0D920A4',
|
|
1917
1917
|
THO: '0xc40d16c47394a506d451475c8a7c46c1175c1da1',
|
|
1918
1918
|
aAvaUSDT: '0x50B1Ba98Cf117c9682048D56628B294ebbAA4ec2',
|
|
1919
|
-
USDT: '
|
|
1919
|
+
USDT: '0x0d0707963952f2fba59dd06f2b425ace40b492fe',
|
|
1920
1920
|
aAvaWAVAX: '0x1B18Df70863636AEe4BfBAb6F7C70ceBCA9bA404',
|
|
1921
1921
|
oldFRAX: '0x4e3376018add04ebe4c46bf6f924ddec8c67aa7b',
|
|
1922
1922
|
newFRAX: '0x4e3376018add04ebe4c46bf6f924ddec8c67aa7b',
|
package/.idea/aws.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeProfile" value="profile:default" />
|
|
5
|
-
<option name="activeRegion" value="us-east-1" />
|
|
6
|
-
<option name="recentlyUsedProfiles">
|
|
7
|
-
<list>
|
|
8
|
-
<option value="profile:default" />
|
|
9
|
-
</list>
|
|
10
|
-
</option>
|
|
11
|
-
<option name="recentlyUsedRegions">
|
|
12
|
-
<list>
|
|
13
|
-
<option value="us-east-1" />
|
|
14
|
-
</list>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<ScalaCodeStyleSettings>
|
|
4
|
-
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
|
5
|
-
</ScalaCodeStyleSettings>
|
|
6
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
7
|
-
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
|
8
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
9
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
10
|
-
</TypeScriptCodeStyleSettings>
|
|
11
|
-
<codeStyleSettings language="TypeScript">
|
|
12
|
-
<indentOptions>
|
|
13
|
-
<option name="INDENT_SIZE" value="2" />
|
|
14
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
15
|
-
<option name="TAB_SIZE" value="2" />
|
|
16
|
-
</indentOptions>
|
|
17
|
-
</codeStyleSettings>
|
|
18
|
-
</code_scheme>
|
|
19
|
-
</component>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/.idea/prettier.xml
DELETED