@paraswap/dex-lib 3.8.31 → 3.8.32-inception.2
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/inception/inception-ratio-feed.json +239 -3
- package/build/dex/inception/config.d.ts +1 -2
- package/build/dex/inception/config.js +1 -4
- package/build/dex/inception/config.js.map +1 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -9
- package/build/dex/inception/inception-event-pool.js +1 -9
- package/build/dex/inception/inception-event-pool.js.map +1 -1
- package/build/dex/inception/inception.d.ts +1 -2
- package/build/dex/inception/inception.js +5 -2
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/index.js +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/stkgho/stkgho-pool.js +1 -1
- package/build/dex/stkgho/stkgho-pool.js.map +1 -1
- package/build/dex/stkgho/stkgho.js +5 -1
- package/build/dex/stkgho/stkgho.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/inception/inception-ineth-pool.json +1062 -0
- package/src/abi/inception/inception-ineth.json +609 -0
- package/src/abi/inception/inception-ratio-feed.json +329 -0
- package/src/abi/inception/inception-vault.json +991 -0
- package/src/abi/stkGHO.json +1131 -0
- package/src/dex/inception/config.ts +109 -0
- package/src/dex/inception/inception-e2e.test.ts +67 -0
- package/src/dex/inception/inception-event-pool.ts +60 -0
- package/src/dex/inception/inception-events.test.ts +67 -0
- package/src/dex/inception/inception-integration.test.ts +76 -0
- package/src/dex/inception/inception.ts +238 -0
- package/src/dex/inception/tokens.ts +37 -0
- package/src/dex/inception/types.ts +26 -0
- package/src/dex/inception/utils.ts +71 -0
- package/src/dex/index.ts +4 -0
- package/src/dex/stkgho/config.ts +14 -0
- package/src/dex/stkgho/stkgho-e2e.test.ts +77 -0
- package/src/dex/stkgho/stkgho-events.test.ts +79 -0
- package/src/dex/stkgho/stkgho-integration.test.ts +226 -0
- package/src/dex/stkgho/stkgho-pool.ts +111 -0
- package/src/dex/stkgho/stkgho.ts +221 -0
- package/src/dex/stkgho/types.ts +14 -0
- package/tests/constants-e2e.ts +110 -7
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
+
import {
|
|
3
|
+
Token,
|
|
4
|
+
Address,
|
|
5
|
+
ExchangePrices,
|
|
6
|
+
PoolPrices,
|
|
7
|
+
AdapterExchangeParam,
|
|
8
|
+
SimpleExchangeParam,
|
|
9
|
+
PoolLiquidity,
|
|
10
|
+
Logger,
|
|
11
|
+
NumberAsString,
|
|
12
|
+
DexExchangeParam,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
import { SwapSide, Network } from '../../constants';
|
|
15
|
+
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
16
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
17
|
+
import { IDex } from '../../dex/idex';
|
|
18
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
19
|
+
import { DexParams, PoolState, StkGHOData } from './types';
|
|
20
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
21
|
+
import { StkGHOConfig } from './config';
|
|
22
|
+
import { StkGHOEventPool } from './stkgho-pool';
|
|
23
|
+
import { Interface } from '@ethersproject/abi';
|
|
24
|
+
import StkGHO_ABI from '../../abi/stkGHO.json';
|
|
25
|
+
|
|
26
|
+
export class StkGHO extends SimpleExchange implements IDex<StkGHOData> {
|
|
27
|
+
static readonly stkGHOInterface = new Interface(StkGHO_ABI);
|
|
28
|
+
protected eventPool: StkGHOEventPool;
|
|
29
|
+
|
|
30
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
31
|
+
readonly needWrapNative = true;
|
|
32
|
+
|
|
33
|
+
protected config: DexParams;
|
|
34
|
+
|
|
35
|
+
readonly isFeeOnTransferSupported = false;
|
|
36
|
+
readonly exchangeRateUnit = 1_000_000_000_000_000_000n;
|
|
37
|
+
|
|
38
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
39
|
+
getDexKeysWithNetwork(StkGHOConfig);
|
|
40
|
+
|
|
41
|
+
logger: Logger;
|
|
42
|
+
|
|
43
|
+
constructor(
|
|
44
|
+
readonly network: Network,
|
|
45
|
+
readonly dexKey: string,
|
|
46
|
+
readonly dexHelper: IDexHelper,
|
|
47
|
+
) {
|
|
48
|
+
super(dexHelper, dexKey);
|
|
49
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
50
|
+
this.eventPool = new StkGHOEventPool(
|
|
51
|
+
dexKey,
|
|
52
|
+
dexKey,
|
|
53
|
+
network,
|
|
54
|
+
dexHelper,
|
|
55
|
+
this.logger,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const config = StkGHOConfig[dexKey][network];
|
|
59
|
+
this.config = {
|
|
60
|
+
stkGHO: config.stkGHO.toLowerCase(),
|
|
61
|
+
GHO: config.GHO.toLowerCase(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async initializePricing(blockNumber: number) {
|
|
66
|
+
const state = await this.eventPool.generateState(blockNumber);
|
|
67
|
+
|
|
68
|
+
this.eventPool.initialize(blockNumber, {
|
|
69
|
+
state,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getPoolIdentifiers(
|
|
78
|
+
srcToken: Token,
|
|
79
|
+
destToken: Token,
|
|
80
|
+
side: SwapSide,
|
|
81
|
+
blockNumber: number,
|
|
82
|
+
): Promise<string[]> {
|
|
83
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
84
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
srcTokenAddress === this.config.GHO &&
|
|
88
|
+
destTokenAddress === this.config.stkGHO
|
|
89
|
+
) {
|
|
90
|
+
return [`${this.dexKey}`];
|
|
91
|
+
} else {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async getPoolState(blockNumber: number): Promise<PoolState> {
|
|
97
|
+
const eventState = this.eventPool.getState(blockNumber);
|
|
98
|
+
if (eventState) return eventState;
|
|
99
|
+
const onChainState = await this.eventPool.generateState(blockNumber);
|
|
100
|
+
this.eventPool.setState(onChainState, blockNumber);
|
|
101
|
+
return onChainState;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async getPricesVolume(
|
|
105
|
+
srcToken: Token,
|
|
106
|
+
destToken: Token,
|
|
107
|
+
amounts: bigint[],
|
|
108
|
+
side: SwapSide,
|
|
109
|
+
blockNumber: number,
|
|
110
|
+
limitPools?: string[],
|
|
111
|
+
): Promise<null | ExchangePrices<StkGHOData>> {
|
|
112
|
+
if (side === SwapSide.BUY) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
117
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
118
|
+
|
|
119
|
+
if (
|
|
120
|
+
srcTokenAddress != this.config.GHO ||
|
|
121
|
+
destTokenAddress != this.config.stkGHO
|
|
122
|
+
) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const state = await this.getPoolState(blockNumber);
|
|
127
|
+
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
unit: state.exchangeRate,
|
|
131
|
+
prices: amounts.map(
|
|
132
|
+
amount => (state.exchangeRate * amount) / this.exchangeRateUnit,
|
|
133
|
+
),
|
|
134
|
+
data: {
|
|
135
|
+
exchange: this.dexKey,
|
|
136
|
+
},
|
|
137
|
+
poolAddresses: [this.config.stkGHO],
|
|
138
|
+
exchange: this.dexKey,
|
|
139
|
+
gasCost: 100_000,
|
|
140
|
+
poolIdentifier: `${this.dexKey}`,
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getCalldataGasCost(poolPrices: PoolPrices<StkGHOData>): number | number[] {
|
|
146
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getAdapterParam(
|
|
150
|
+
srcToken: string,
|
|
151
|
+
destToken: string,
|
|
152
|
+
srcAmount: string,
|
|
153
|
+
destAmount: string,
|
|
154
|
+
data: StkGHOData,
|
|
155
|
+
side: SwapSide,
|
|
156
|
+
): AdapterExchangeParam {
|
|
157
|
+
const { exchange } = data;
|
|
158
|
+
|
|
159
|
+
const payload = '';
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
targetExchange: exchange,
|
|
163
|
+
payload,
|
|
164
|
+
networkFee: '0',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async updatePoolState(): Promise<void> {}
|
|
169
|
+
|
|
170
|
+
async getDexParam(
|
|
171
|
+
srcToken: Address,
|
|
172
|
+
destToken: Address,
|
|
173
|
+
srcAmount: NumberAsString,
|
|
174
|
+
destAmount: NumberAsString,
|
|
175
|
+
recipient: Address,
|
|
176
|
+
data: StkGHOData,
|
|
177
|
+
side: SwapSide,
|
|
178
|
+
): Promise<DexExchangeParam> {
|
|
179
|
+
const exchangeData = StkGHO.stkGHOInterface.encodeFunctionData('stake', [
|
|
180
|
+
recipient,
|
|
181
|
+
srcAmount,
|
|
182
|
+
]);
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
needWrapNative: this.needWrapNative,
|
|
186
|
+
dexFuncHasRecipient: true,
|
|
187
|
+
exchangeData,
|
|
188
|
+
targetExchange: this.config.stkGHO,
|
|
189
|
+
returnAmountPos: undefined,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async getTopPoolsForToken(
|
|
194
|
+
tokenAddress: Address,
|
|
195
|
+
limit: number,
|
|
196
|
+
): Promise<PoolLiquidity[]> {
|
|
197
|
+
tokenAddress = tokenAddress.toLowerCase();
|
|
198
|
+
|
|
199
|
+
if (tokenAddress == this.config.GHO) {
|
|
200
|
+
return [
|
|
201
|
+
{
|
|
202
|
+
exchange: this.dexKey,
|
|
203
|
+
address: this.config.stkGHO,
|
|
204
|
+
connectorTokens: [
|
|
205
|
+
{
|
|
206
|
+
decimals: 18,
|
|
207
|
+
address: this.config.stkGHO,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
liquidityUSD: 1_000_000_000_000, // GHO to stkGHO supply is unlimited
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
} else {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
219
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
220
|
+
releaseResources(): AsyncOrSync<void> {}
|
|
221
|
+
}
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
_allowancesFn,
|
|
3
|
+
_balancesFn,
|
|
4
4
|
allowanceFn,
|
|
5
|
-
SmartToken,
|
|
6
|
-
balancesFn,
|
|
7
5
|
allowedFn,
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
balanceOfFn,
|
|
7
|
+
balancesFn,
|
|
8
|
+
SmartToken,
|
|
9
|
+
SmartTokenParams,
|
|
10
10
|
} from '../tests/smart-tokens';
|
|
11
11
|
import { Address } from '../src/types';
|
|
12
12
|
import { ETHER_ADDRESS, Network } from '../src/constants';
|
|
@@ -455,6 +455,10 @@ export const Tokens: {
|
|
|
455
455
|
address: '0x40d16fc0246ad3160ccc09b8d0d3a2cd28ae6c2f',
|
|
456
456
|
decimals: 18,
|
|
457
457
|
},
|
|
458
|
+
stkGHO: {
|
|
459
|
+
address: '0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d',
|
|
460
|
+
decimals: 18,
|
|
461
|
+
},
|
|
458
462
|
USDe: {
|
|
459
463
|
address: '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3',
|
|
460
464
|
decimals: 18,
|
|
@@ -499,6 +503,94 @@ export const Tokens: {
|
|
|
499
503
|
address: '0x23878914efe38d27c4d67ab83ed1b93a74d4086a',
|
|
500
504
|
decimals: 6,
|
|
501
505
|
},
|
|
506
|
+
instETH: {
|
|
507
|
+
address: '0x7FA768E035F956c41d6aeaa3Bd857e7E5141CAd5',
|
|
508
|
+
decimals: 18,
|
|
509
|
+
},
|
|
510
|
+
inrETH: {
|
|
511
|
+
address: '0x80d69e79258FE9D056c822461c4eb0B4ca8802E2',
|
|
512
|
+
decimals: 18,
|
|
513
|
+
},
|
|
514
|
+
inoETH: {
|
|
515
|
+
address: '0x9181f633e9b9f15a32d5e37094f4c93b333e0e92',
|
|
516
|
+
decimals: 18,
|
|
517
|
+
},
|
|
518
|
+
inosETH: {
|
|
519
|
+
address: '0xfD07fD5EBEa6F24888a397997E262179Bf494336',
|
|
520
|
+
decimals: 18,
|
|
521
|
+
},
|
|
522
|
+
inankrETH: {
|
|
523
|
+
address: '0xfa2629B9cF3998D52726994E0FcdB750224D8B9D',
|
|
524
|
+
decimals: 18,
|
|
525
|
+
},
|
|
526
|
+
incbETH: {
|
|
527
|
+
address: '0xbf19eead55a6b100667f04f8fbc5371e03e8ab2e',
|
|
528
|
+
decimals: 18,
|
|
529
|
+
},
|
|
530
|
+
inwbETH: {
|
|
531
|
+
address: '0xda9b11cd701e10c2ec1a284f80820edd128c5246',
|
|
532
|
+
decimals: 18,
|
|
533
|
+
},
|
|
534
|
+
inswETH: {
|
|
535
|
+
address: '0xc3ade5ace1bbb033ccae8177c12ecbfa16bd6a9d',
|
|
536
|
+
decimals: 18,
|
|
537
|
+
},
|
|
538
|
+
inETHx: {
|
|
539
|
+
address: '0x57a5a0567187ff4a8dcc1a9bba86155e355878f2',
|
|
540
|
+
decimals: 18,
|
|
541
|
+
},
|
|
542
|
+
insfrxETH: {
|
|
543
|
+
address: '0x668308d77be3533c909a692302cb4d135bf8041c',
|
|
544
|
+
decimals: 18,
|
|
545
|
+
},
|
|
546
|
+
inmETH: {
|
|
547
|
+
address: '0xeCf3672A6d2147E2A77f07069Fb48d8Cf6F6Fbf9',
|
|
548
|
+
decimals: 18,
|
|
549
|
+
},
|
|
550
|
+
inlsETH: {
|
|
551
|
+
address: '0x94b888e11a9e960a9c3b3528eb6ac807b27ca62e',
|
|
552
|
+
decimals: 18,
|
|
553
|
+
},
|
|
554
|
+
inETH: {
|
|
555
|
+
address: '0xf073bAC22DAb7FaF4a3Dd6c6189a70D54110525C',
|
|
556
|
+
decimals: 18,
|
|
557
|
+
},
|
|
558
|
+
rETH: {
|
|
559
|
+
address: '0xae78736Cd615f374D3085123A210448E74Fc6393',
|
|
560
|
+
decimals: 18,
|
|
561
|
+
},
|
|
562
|
+
oETH: {
|
|
563
|
+
address: '0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3',
|
|
564
|
+
decimals: 18,
|
|
565
|
+
},
|
|
566
|
+
osETH: {
|
|
567
|
+
address: '0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38',
|
|
568
|
+
decimals: 18,
|
|
569
|
+
},
|
|
570
|
+
cbETH: {
|
|
571
|
+
address: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704',
|
|
572
|
+
decimals: 18,
|
|
573
|
+
},
|
|
574
|
+
wbETH: {
|
|
575
|
+
address: '0xa2E3356610840701BDf5611a53974510Ae27E2e1',
|
|
576
|
+
decimals: 18,
|
|
577
|
+
},
|
|
578
|
+
ETHx: {
|
|
579
|
+
address: '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b',
|
|
580
|
+
decimals: 18,
|
|
581
|
+
},
|
|
582
|
+
sfrxETH: {
|
|
583
|
+
address: '0xac3E018457B222d93114458476f3E3416Abbe38F',
|
|
584
|
+
decimals: 18,
|
|
585
|
+
},
|
|
586
|
+
mETH: {
|
|
587
|
+
address: '0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa',
|
|
588
|
+
decimals: 18,
|
|
589
|
+
},
|
|
590
|
+
lsETH: {
|
|
591
|
+
address: '0x8c1BEd5b9a0928467c9B1341Da1D7BD5e10b6549',
|
|
592
|
+
decimals: 18,
|
|
593
|
+
},
|
|
502
594
|
rUSD: {
|
|
503
595
|
address: '0x65D72AA8DA931F047169112fcf34f52DbaAE7D18',
|
|
504
596
|
decimals: 18,
|
|
@@ -1518,7 +1610,7 @@ export const Holders: {
|
|
|
1518
1610
|
sDAI: '0x4C612E3B15b96Ff9A6faED838F8d07d479a8dD4c',
|
|
1519
1611
|
CVX: '0x0aCA67Fa70B142A3b9bF2eD89A81B40ff85dACdC',
|
|
1520
1612
|
MIM: '0xa046a8660e66d178ee07ec97c585eeb6aa18c26c',
|
|
1521
|
-
AnkETH: '
|
|
1613
|
+
AnkETH: '0xBB2d41AcfEA24A3A2aD4A6F95C3AcE1cC98c6ed6',
|
|
1522
1614
|
DAI: '0xd1668fb5f690c59ab4b0cabad0f8c1617895052b',
|
|
1523
1615
|
oldFRAX: '0x183d0dc5867c01bfb1dbbc41d6a9d3de6e044626',
|
|
1524
1616
|
newFRAX: '0x183d0dc5867c01bfb1dbbc41d6a9d3de6e044626',
|
|
@@ -1585,6 +1677,17 @@ export const Holders: {
|
|
|
1585
1677
|
stataUSDT: '0x6803364AceD5181877abC11E865FB27cB654a426',
|
|
1586
1678
|
aaveUSDT: '0x32c98a981Fe7C333Bd4e8E7630E8e0CF5ce20987',
|
|
1587
1679
|
weETH: '0x267ed5f71EE47D3E45Bb1569Aa37889a2d10f91e',
|
|
1680
|
+
rETH: '0x9985dF20D7e9103ECBCeb16a84956434B6f06ae8',
|
|
1681
|
+
oETH: '0xDcEe70654261AF21C44c093C300eD3Bb97b78192',
|
|
1682
|
+
osETH: '0xe080027Bd47353b5D1639772b4a75E9Ed3658A0d',
|
|
1683
|
+
cbETH: '0xd35faBF6Ec806f4D772617956A2058CdE086C6E0',
|
|
1684
|
+
wbETH: '0xc6C010287683FD3Db7865016e3e1D6468Dd73aA6',
|
|
1685
|
+
ETHx: '0x4F2083f5fBede34C2714aFfb3105539775f7FE64',
|
|
1686
|
+
sfrxETH: '0xC2545C68a71F6803264bdE885870fD72D361fB9E',
|
|
1687
|
+
mETH: '0xc3350595eD42EbE94556277bc77D257c76065291',
|
|
1688
|
+
lsETH: '0xAe60d8180437b5C34bB956822ac2710972584473',
|
|
1689
|
+
SWETH: '0xc585DF3a8C9ca0c614D023A812624bE36161502B',
|
|
1690
|
+
inankrETH: '0x310C8f5274F74258cDe1E5101b50A0502b884aC4',
|
|
1588
1691
|
rUSD: '0xEC2eda1C4F981E468ABF62424a10B69B738b498E',
|
|
1589
1692
|
arUSD: '0xeFc24206053a452e2299BF3b8f964512b041Db4C',
|
|
1590
1693
|
},
|