@paraswap/dex-lib 3.8.30 → 3.8.32
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/AaveV1_lending_pool.json +27 -0
- package/build/abi/Aave_GSM.json +751 -0
- package/build/abi/aave-gsm/Aave_GSM.json +751 -0
- package/build/abi/aave-gsm/IFeeStrategy.json +78 -0
- package/build/abi/inception/inception-ineth-pool.json +1062 -0
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +93 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/platypus/asset.json +490 -0
- package/build/abi/platypus/avax-pool.json +820 -0
- package/build/abi/platypus/oracle.json +119 -0
- package/build/abi/platypus/pool.json +677 -0
- package/build/abi/smardex/all/smardex-router.json +648 -0
- package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
- package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
- package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
- package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
- package/build/abi/stkGHO.json +1131 -0
- package/build/abi/swaap-v1/pool.json +1346 -0
- package/build/abi/usual-bond/usd0pp.abi.json +867 -0
- package/build/dex/aave-gsm/aave-gsm-pool.d.ts +28 -0
- package/build/dex/aave-gsm/aave-gsm-pool.js +117 -0
- package/build/dex/aave-gsm/aave-gsm-pool.js.map +1 -0
- package/build/dex/aave-gsm/aave-gsm.d.ts +43 -0
- package/build/dex/aave-gsm/aave-gsm.js +306 -0
- package/build/dex/aave-gsm/aave-gsm.js.map +1 -0
- package/build/dex/aave-gsm/config.d.ts +3 -0
- package/build/dex/aave-gsm/config.js +17 -0
- package/build/dex/aave-gsm/config.js.map +1 -0
- package/build/dex/aave-gsm/types.d.ts +18 -0
- package/build/dex/aave-gsm/types.js +3 -0
- package/build/dex/aave-gsm/types.js.map +1 -0
- package/build/dex/aave-v1/aave-v1.d.ts +34 -0
- package/build/dex/aave-v1/aave-v1.js +180 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -0
- package/build/dex/aave-v1/config.d.ts +11 -0
- package/build/dex/aave-v1/config.js +20 -0
- package/build/dex/aave-v1/config.js.map +1 -0
- package/build/dex/aave-v1/tokens-mainnet.json +134 -0
- package/build/dex/aave-v1/tokens.d.ts +3 -0
- package/build/dex/aave-v1/tokens.js +50 -0
- package/build/dex/aave-v1/tokens.js.map +1 -0
- package/build/dex/aave-v1/types.d.ts +12 -0
- package/build/dex/aave-v1/types.js +3 -0
- package/build/dex/aave-v1/types.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +5 -0
- package/build/dex/inception/config.js +112 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +25 -0
- package/build/dex/inception/inception-event-pool.js +57 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/inception/inception-native.d.ts +43 -0
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +44 -0
- package/build/dex/inception/inception.js +177 -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 +4 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/platypus/asset.d.ts +14 -0
- package/build/dex/platypus/asset.js +97 -0
- package/build/dex/platypus/asset.js.map +1 -0
- package/build/dex/platypus/config.d.ts +11 -0
- package/build/dex/platypus/config.js +69 -0
- package/build/dex/platypus/config.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +63 -0
- package/build/dex/platypus/platypus.js +473 -0
- package/build/dex/platypus/platypus.js.map +1 -0
- package/build/dex/platypus/pool-avax.d.ts +8 -0
- package/build/dex/platypus/pool-avax.js +54 -0
- package/build/dex/platypus/pool-avax.js.map +1 -0
- package/build/dex/platypus/pool-base.d.ts +19 -0
- package/build/dex/platypus/pool-base.js +86 -0
- package/build/dex/platypus/pool-base.js.map +1 -0
- package/build/dex/platypus/pool-pure.d.ts +8 -0
- package/build/dex/platypus/pool-pure.js +37 -0
- package/build/dex/platypus/pool-pure.js.map +1 -0
- package/build/dex/platypus/pool-subscriber.d.ts +14 -0
- package/build/dex/platypus/pool-subscriber.js +167 -0
- package/build/dex/platypus/pool-subscriber.js.map +1 -0
- package/build/dex/platypus/pool.d.ts +8 -0
- package/build/dex/platypus/pool.js +58 -0
- package/build/dex/platypus/pool.js.map +1 -0
- package/build/dex/platypus/types.d.ts +92 -0
- package/build/dex/platypus/types.js +10 -0
- package/build/dex/platypus/types.js.map +1 -0
- package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
- package/build/dex/quickswap/spiritswap-v3.js +19 -0
- package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
- package/build/dex/smardex/config.d.ts +4 -0
- package/build/dex/smardex/config.js +64 -0
- package/build/dex/smardex/config.js.map +1 -0
- package/build/dex/smardex/constants.d.ts +18 -0
- package/build/dex/smardex/constants.js +33 -0
- package/build/dex/smardex/constants.js.map +1 -0
- package/build/dex/smardex/sdk/constants.d.ts +6 -0
- package/build/dex/smardex/sdk/constants.js +13 -0
- package/build/dex/smardex/sdk/constants.js.map +1 -0
- package/build/dex/smardex/sdk/core.d.ts +113 -0
- package/build/dex/smardex/sdk/core.js +499 -0
- package/build/dex/smardex/sdk/core.js.map +1 -0
- package/build/dex/smardex/sdk/errors.d.ts +15 -0
- package/build/dex/smardex/sdk/errors.js +22 -0
- package/build/dex/smardex/sdk/errors.js.map +1 -0
- package/build/dex/smardex/sdk/types.d.ts +62 -0
- package/build/dex/smardex/sdk/types.js +3 -0
- package/build/dex/smardex/sdk/types.js.map +1 -0
- package/build/dex/smardex/sdk/utils.d.ts +44 -0
- package/build/dex/smardex/sdk/utils.js +133 -0
- package/build/dex/smardex/sdk/utils.js.map +1 -0
- package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
- package/build/dex/smardex/smardex-event-pool.js +119 -0
- package/build/dex/smardex/smardex-event-pool.js.map +1 -0
- package/build/dex/smardex/smardex.d.ts +65 -0
- package/build/dex/smardex/smardex.js +519 -0
- package/build/dex/smardex/smardex.js.map +1 -0
- package/build/dex/smardex/types.d.ts +55 -0
- package/build/dex/smardex/types.js +3 -0
- package/build/dex/smardex/types.js.map +1 -0
- package/build/dex/solidly/forks-override/cone.d.ts +22 -0
- package/build/dex/solidly/forks-override/cone.js +53 -0
- package/build/dex/solidly/forks-override/cone.js.map +1 -0
- package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
- package/build/dex/solidly/forks-override/solisnek.js +15 -0
- package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
- package/build/dex/stkgho/config.d.ts +3 -0
- package/build/dex/stkgho/config.js +14 -0
- package/build/dex/stkgho/config.js.map +1 -0
- package/build/dex/stkgho/stkgho-pool.d.ts +41 -0
- package/build/dex/stkgho/stkgho-pool.js +81 -0
- package/build/dex/stkgho/stkgho-pool.js.map +1 -0
- package/build/dex/stkgho/stkgho.d.ts +41 -0
- package/build/dex/stkgho/stkgho.js +163 -0
- package/build/dex/stkgho/stkgho.js.map +1 -0
- package/build/dex/stkgho/types.d.ts +11 -0
- package/build/dex/stkgho/types.js +3 -0
- package/build/dex/stkgho/types.js.map +1 -0
- package/build/dex/swaap-v1/config.d.ts +17 -0
- package/build/dex/swaap-v1/config.js +56 -0
- package/build/dex/swaap-v1/config.js.map +1 -0
- package/build/dex/swaap-v1/constants.d.ts +6 -0
- package/build/dex/swaap-v1/constants.js +17 -0
- package/build/dex/swaap-v1/constants.js.map +1 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
- package/build/dex/swaap-v1/libraries/Const.js +26 -0
- package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
- package/build/dex/swaap-v1/libraries/Num.js +167 -0
- package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
- package/build/dex/swaap-v1/libraries/Struct.js +3 -0
- package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +62 -0
- package/build/dex/swaap-v1/swaap-v1.js +379 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
- package/build/dex/swaap-v1/types.d.ts +106 -0
- package/build/dex/swaap-v1/types.js +9 -0
- package/build/dex/swaap-v1/types.js.map +1 -0
- package/build/dex/usual-bond/config.d.ts +3 -0
- package/build/dex/usual-bond/config.js +13 -0
- package/build/dex/usual-bond/config.js.map +1 -0
- package/build/dex/usual-bond/types.d.ts +7 -0
- package/build/dex/usual-bond/types.js +3 -0
- package/build/dex/usual-bond/types.js.map +1 -0
- package/build/dex/usual-bond/usual-bond.d.ts +35 -0
- package/build/dex/usual-bond/usual-bond.js +162 -0
- package/build/dex/usual-bond/usual-bond.js.map +1 -0
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/package.json +2 -3
- package/src/abi/aave-gsm/Aave_GSM.json +751 -0
- package/src/abi/aave-gsm/IFeeStrategy.json +78 -0
- package/src/abi/stkGHO.json +1131 -0
- package/src/dex/aave-gsm/aave-gsm-e2e.test.ts +109 -0
- package/src/dex/aave-gsm/aave-gsm-events.test.ts +79 -0
- package/src/dex/aave-gsm/aave-gsm-integration.test.ts +522 -0
- package/src/dex/aave-gsm/aave-gsm-pool.ts +178 -0
- package/src/dex/aave-gsm/aave-gsm.ts +410 -0
- package/src/dex/aave-gsm/config.ts +16 -0
- package/src/dex/aave-gsm/types.ts +23 -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 +4 -0
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -12
- package/.idea/vcs.xml +0 -6
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { testE2E } from '../../../tests/utils-e2e';
|
|
6
|
+
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
7
|
+
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
8
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
9
|
+
import { generateConfig } from '../../config';
|
|
10
|
+
|
|
11
|
+
function testForNetwork(
|
|
12
|
+
network: Network,
|
|
13
|
+
dexKey: string,
|
|
14
|
+
tokenASymbol: string,
|
|
15
|
+
tokenBSymbol: string,
|
|
16
|
+
tokenAAmount: string,
|
|
17
|
+
tokenBAmount: string,
|
|
18
|
+
) {
|
|
19
|
+
const provider = new StaticJsonRpcProvider(
|
|
20
|
+
generateConfig(network).privateHttpProvider,
|
|
21
|
+
network,
|
|
22
|
+
);
|
|
23
|
+
const tokens = Tokens[network];
|
|
24
|
+
const holders = Holders[network];
|
|
25
|
+
|
|
26
|
+
const sideToContractMethods = new Map([
|
|
27
|
+
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
28
|
+
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
describe(`${network}`, () => {
|
|
32
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
33
|
+
describe(`${side}`, () => {
|
|
34
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
35
|
+
describe(`${contractMethod}`, () => {
|
|
36
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
37
|
+
await testE2E(
|
|
38
|
+
tokens[tokenASymbol],
|
|
39
|
+
tokens[tokenBSymbol],
|
|
40
|
+
holders[tokenASymbol],
|
|
41
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
42
|
+
side,
|
|
43
|
+
dexKey,
|
|
44
|
+
contractMethod,
|
|
45
|
+
network,
|
|
46
|
+
provider,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe('StkGHO E2E', () => {
|
|
57
|
+
const dexKey = 'StkGHO';
|
|
58
|
+
|
|
59
|
+
describe('Mainnet', () => {
|
|
60
|
+
const network = Network.MAINNET;
|
|
61
|
+
|
|
62
|
+
const tokenASymbol: string = 'GHO';
|
|
63
|
+
const tokenBSymbol: string = 'stkGHO';
|
|
64
|
+
|
|
65
|
+
const tokenAAmount: string = '1000000000000000000';
|
|
66
|
+
const tokenBAmount: string = '1000000000000000000';
|
|
67
|
+
|
|
68
|
+
testForNetwork(
|
|
69
|
+
network,
|
|
70
|
+
dexKey,
|
|
71
|
+
tokenASymbol,
|
|
72
|
+
tokenBSymbol,
|
|
73
|
+
tokenAAmount,
|
|
74
|
+
tokenBAmount,
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { StkGHOEventPool } from './stkgho-pool';
|
|
6
|
+
import { Network } from '../../constants';
|
|
7
|
+
import { Address } from '../../types';
|
|
8
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
9
|
+
import { testEventSubscriber } from '../../../tests/utils-events';
|
|
10
|
+
import { PoolState } from './types';
|
|
11
|
+
import { StkGHOConfig } from './config';
|
|
12
|
+
|
|
13
|
+
jest.setTimeout(50 * 1000);
|
|
14
|
+
|
|
15
|
+
async function fetchPoolState(
|
|
16
|
+
stkGHOPool: StkGHOEventPool,
|
|
17
|
+
blockNumber: number,
|
|
18
|
+
poolAddress: string,
|
|
19
|
+
): Promise<PoolState> {
|
|
20
|
+
const eventState = stkGHOPool.getState(blockNumber);
|
|
21
|
+
if (eventState) return eventState;
|
|
22
|
+
const onChainState = await stkGHOPool.generateState(blockNumber);
|
|
23
|
+
stkGHOPool.setState(onChainState, blockNumber);
|
|
24
|
+
return onChainState;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// eventName -> blockNumbers
|
|
28
|
+
type EventMappings = Record<string, number[]>;
|
|
29
|
+
|
|
30
|
+
describe('StkGHO EventPool Mainnet', function () {
|
|
31
|
+
const dexKey = 'StkGHO';
|
|
32
|
+
const network = Network.MAINNET;
|
|
33
|
+
const dexHelper = new DummyDexHelper(network);
|
|
34
|
+
const logger = dexHelper.getLogger(dexKey);
|
|
35
|
+
let stkGHOPool: StkGHOEventPool;
|
|
36
|
+
|
|
37
|
+
// poolAddress -> EventMappings
|
|
38
|
+
const eventsToTest: Record<Address, EventMappings> = {
|
|
39
|
+
[StkGHOConfig[dexKey][network].stkGHO]: {
|
|
40
|
+
ExchangeRateChanged: [], // haven't been emitted yet
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
beforeEach(async () => {
|
|
45
|
+
stkGHOPool = new StkGHOEventPool(
|
|
46
|
+
dexKey,
|
|
47
|
+
dexKey,
|
|
48
|
+
network,
|
|
49
|
+
dexHelper,
|
|
50
|
+
logger,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Object.entries(eventsToTest).forEach(
|
|
55
|
+
([poolAddress, events]: [string, EventMappings]) => {
|
|
56
|
+
describe(`Events for ${poolAddress}`, () => {
|
|
57
|
+
Object.entries(events).forEach(
|
|
58
|
+
([eventName, blockNumbers]: [string, number[]]) => {
|
|
59
|
+
describe(`${eventName}`, () => {
|
|
60
|
+
blockNumbers.forEach((blockNumber: number) => {
|
|
61
|
+
it(`State after ${blockNumber}`, async function () {
|
|
62
|
+
await testEventSubscriber(
|
|
63
|
+
stkGHOPool,
|
|
64
|
+
stkGHOPool.addressesSubscribed,
|
|
65
|
+
(_blockNumber: number) =>
|
|
66
|
+
fetchPoolState(stkGHOPool, _blockNumber, poolAddress),
|
|
67
|
+
blockNumber,
|
|
68
|
+
`${dexKey}_${poolAddress}`,
|
|
69
|
+
dexHelper.provider,
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { StkGHO } from './stkgho';
|
|
10
|
+
import {
|
|
11
|
+
checkPoolPrices,
|
|
12
|
+
checkPoolsLiquidity,
|
|
13
|
+
checkConstantPoolPrices,
|
|
14
|
+
} from '../../../tests/utils';
|
|
15
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
|
+
import StkGHO_ABI from '../../abi/stkGHO.json';
|
|
17
|
+
|
|
18
|
+
function getReaderCalldata(
|
|
19
|
+
exchangeAddress: string,
|
|
20
|
+
readerIface: Interface,
|
|
21
|
+
amounts: bigint[],
|
|
22
|
+
funcName: string,
|
|
23
|
+
) {
|
|
24
|
+
return amounts.map(amount => ({
|
|
25
|
+
target: exchangeAddress,
|
|
26
|
+
callData: readerIface.encodeFunctionData(funcName, [amount]),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function decodeReaderResult(
|
|
31
|
+
results: Result,
|
|
32
|
+
readerIface: Interface,
|
|
33
|
+
funcName: string,
|
|
34
|
+
) {
|
|
35
|
+
return results.map(result => {
|
|
36
|
+
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
37
|
+
return BigInt(parsed[0]._hex);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function checkOnChainPricing(
|
|
42
|
+
stkGHO: StkGHO,
|
|
43
|
+
funcName: string,
|
|
44
|
+
blockNumber: number,
|
|
45
|
+
prices: bigint[],
|
|
46
|
+
amounts: bigint[],
|
|
47
|
+
) {
|
|
48
|
+
const exchangeAddress = '0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d';
|
|
49
|
+
const readerIface = new Interface(StkGHO_ABI);
|
|
50
|
+
|
|
51
|
+
const readerCallData = getReaderCalldata(
|
|
52
|
+
exchangeAddress,
|
|
53
|
+
readerIface,
|
|
54
|
+
amounts.slice(1),
|
|
55
|
+
funcName,
|
|
56
|
+
);
|
|
57
|
+
const readerResult = (
|
|
58
|
+
await stkGHO.dexHelper.multiContract.methods
|
|
59
|
+
.aggregate(readerCallData)
|
|
60
|
+
.call({}, blockNumber)
|
|
61
|
+
).returnData;
|
|
62
|
+
|
|
63
|
+
const expectedPrices = [0n].concat(
|
|
64
|
+
decodeReaderResult(readerResult, readerIface, funcName),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
expect(prices).toEqual(expectedPrices);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function testPricingOnNetwork(
|
|
71
|
+
stkGHO: StkGHO,
|
|
72
|
+
network: Network,
|
|
73
|
+
dexKey: string,
|
|
74
|
+
blockNumber: number,
|
|
75
|
+
srcTokenSymbol: string,
|
|
76
|
+
destTokenSymbol: string,
|
|
77
|
+
side: SwapSide,
|
|
78
|
+
amounts: bigint[],
|
|
79
|
+
funcNameToCheck: string,
|
|
80
|
+
) {
|
|
81
|
+
const networkTokens = Tokens[network];
|
|
82
|
+
|
|
83
|
+
const pools = await stkGHO.getPoolIdentifiers(
|
|
84
|
+
networkTokens[srcTokenSymbol],
|
|
85
|
+
networkTokens[destTokenSymbol],
|
|
86
|
+
side,
|
|
87
|
+
blockNumber,
|
|
88
|
+
);
|
|
89
|
+
console.log(
|
|
90
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
91
|
+
pools,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
95
|
+
|
|
96
|
+
const poolPrices = await stkGHO.getPricesVolume(
|
|
97
|
+
networkTokens[srcTokenSymbol],
|
|
98
|
+
networkTokens[destTokenSymbol],
|
|
99
|
+
amounts,
|
|
100
|
+
side,
|
|
101
|
+
blockNumber,
|
|
102
|
+
pools,
|
|
103
|
+
);
|
|
104
|
+
console.log(
|
|
105
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
106
|
+
poolPrices,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(poolPrices).not.toBeNull();
|
|
110
|
+
if (stkGHO.hasConstantPriceLargeAmounts) {
|
|
111
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
112
|
+
} else {
|
|
113
|
+
checkPoolPrices(poolPrices!, amounts, side, dexKey);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await checkOnChainPricing(
|
|
117
|
+
stkGHO,
|
|
118
|
+
funcNameToCheck,
|
|
119
|
+
blockNumber,
|
|
120
|
+
poolPrices![0].prices,
|
|
121
|
+
amounts,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
describe('StkGHO', function () {
|
|
126
|
+
const dexKey = 'StkGHO';
|
|
127
|
+
let blockNumber: number;
|
|
128
|
+
let stkGHO: StkGHO;
|
|
129
|
+
|
|
130
|
+
describe('Mainnet', () => {
|
|
131
|
+
const network = Network.MAINNET;
|
|
132
|
+
const dexHelper = new DummyDexHelper(network);
|
|
133
|
+
|
|
134
|
+
const tokens = Tokens[network];
|
|
135
|
+
|
|
136
|
+
// Don't forget to update relevant tokens in constant-e2e.ts
|
|
137
|
+
const srcTokenSymbol = 'GHO';
|
|
138
|
+
const destTokenSymbol = 'stkGHO';
|
|
139
|
+
|
|
140
|
+
const amountsForSell = [
|
|
141
|
+
0n,
|
|
142
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
143
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
144
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
145
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
146
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
147
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
148
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
149
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
150
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
151
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const amountsForBuy = [
|
|
155
|
+
0n,
|
|
156
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
157
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
158
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
159
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
160
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
161
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
162
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
163
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
164
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
165
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
beforeAll(async () => {
|
|
169
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
170
|
+
stkGHO = new StkGHO(network, dexKey, dexHelper);
|
|
171
|
+
if (stkGHO.initializePricing) {
|
|
172
|
+
await stkGHO.initializePricing(blockNumber);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
177
|
+
await testPricingOnNetwork(
|
|
178
|
+
stkGHO,
|
|
179
|
+
network,
|
|
180
|
+
dexKey,
|
|
181
|
+
blockNumber,
|
|
182
|
+
srcTokenSymbol,
|
|
183
|
+
destTokenSymbol,
|
|
184
|
+
SwapSide.SELL,
|
|
185
|
+
amountsForSell,
|
|
186
|
+
'previewStake',
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
191
|
+
await testPricingOnNetwork(
|
|
192
|
+
stkGHO,
|
|
193
|
+
network,
|
|
194
|
+
dexKey,
|
|
195
|
+
blockNumber,
|
|
196
|
+
srcTokenSymbol,
|
|
197
|
+
destTokenSymbol,
|
|
198
|
+
SwapSide.BUY,
|
|
199
|
+
amountsForBuy,
|
|
200
|
+
'previewStake',
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('getTopPoolsForToken', async function () {
|
|
205
|
+
// We have to check without calling initializePricing, because
|
|
206
|
+
// pool-tracker is not calling that function
|
|
207
|
+
const newStkGHO = new StkGHO(network, dexKey, dexHelper);
|
|
208
|
+
if (newStkGHO.updatePoolState) {
|
|
209
|
+
await newStkGHO.updatePoolState();
|
|
210
|
+
}
|
|
211
|
+
const poolLiquidity = await newStkGHO.getTopPoolsForToken(
|
|
212
|
+
tokens[srcTokenSymbol].address,
|
|
213
|
+
10,
|
|
214
|
+
);
|
|
215
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
216
|
+
|
|
217
|
+
if (!newStkGHO.hasConstantPriceLargeAmounts) {
|
|
218
|
+
checkPoolsLiquidity(
|
|
219
|
+
poolLiquidity,
|
|
220
|
+
Tokens[network][srcTokenSymbol].address,
|
|
221
|
+
dexKey,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { Log, Logger } from '../../types';
|
|
4
|
+
import { catchParseLogError } from '../../utils';
|
|
5
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
7
|
+
import { PoolState } from './types';
|
|
8
|
+
import StkGHO_ABI from '../../abi/stkGHO.json';
|
|
9
|
+
import { StkGHOConfig } from './config';
|
|
10
|
+
import { uint256ToBigInt } from '../../lib/decoders';
|
|
11
|
+
|
|
12
|
+
export class StkGHOEventPool extends StatefulEventSubscriber<PoolState> {
|
|
13
|
+
handlers: {
|
|
14
|
+
[event: string]: (
|
|
15
|
+
event: any,
|
|
16
|
+
state: DeepReadonly<PoolState>,
|
|
17
|
+
log: Readonly<Log>,
|
|
18
|
+
) => DeepReadonly<PoolState> | null;
|
|
19
|
+
} = {};
|
|
20
|
+
|
|
21
|
+
logDecoder: (log: Log) => any;
|
|
22
|
+
|
|
23
|
+
addressesSubscribed: string[];
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
readonly poolName: string,
|
|
27
|
+
readonly parentName: string,
|
|
28
|
+
protected network: number,
|
|
29
|
+
protected dexHelper: IDexHelper,
|
|
30
|
+
logger: Logger,
|
|
31
|
+
protected stkGHOIface = new Interface(StkGHO_ABI),
|
|
32
|
+
) {
|
|
33
|
+
super(parentName, poolName, dexHelper, logger);
|
|
34
|
+
|
|
35
|
+
this.logDecoder = (log: Log) => this.stkGHOIface.parseLog(log);
|
|
36
|
+
this.addressesSubscribed = [StkGHOConfig[parentName][network].stkGHO];
|
|
37
|
+
|
|
38
|
+
this.handlers['ExchangeRateChanged'] =
|
|
39
|
+
this.handleExchangeRateChanged.bind(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getIdentifier(): string {
|
|
43
|
+
return `${this.parentName}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The function is called every time any of the subscribed
|
|
48
|
+
* addresses release log. The function accepts the current
|
|
49
|
+
* state, updates the state according to the log, and returns
|
|
50
|
+
* the updated state.
|
|
51
|
+
* @param state - Current state of event subscriber
|
|
52
|
+
* @param log - Log released by one of the subscribed addresses
|
|
53
|
+
* @returns Updates state of the event subscriber after the log
|
|
54
|
+
*/
|
|
55
|
+
protected processLog(
|
|
56
|
+
state: DeepReadonly<PoolState>,
|
|
57
|
+
log: Readonly<Log>,
|
|
58
|
+
): DeepReadonly<PoolState> | null {
|
|
59
|
+
try {
|
|
60
|
+
const event = this.logDecoder(log);
|
|
61
|
+
if (event.name in this.handlers) {
|
|
62
|
+
return this.handlers[event.name](event, state, log);
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
catchParseLogError(e, this.logger);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The function generates state using on-chain calls. This
|
|
73
|
+
* function is called to regenerate state if the event based
|
|
74
|
+
* system fails to fetch events and the local state is no
|
|
75
|
+
* more correct.
|
|
76
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
77
|
+
* should be generated
|
|
78
|
+
* @returns state of the event subscriber at blocknumber
|
|
79
|
+
*/
|
|
80
|
+
async generateState(blockNumber: number): Promise<DeepReadonly<PoolState>> {
|
|
81
|
+
const callData = [
|
|
82
|
+
{
|
|
83
|
+
target: this.addressesSubscribed[0],
|
|
84
|
+
callData: this.stkGHOIface.encodeFunctionData('getExchangeRate', []),
|
|
85
|
+
decodeFunction: uint256ToBigInt,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const res = await this.dexHelper.multiWrapper.tryAggregate<bigint>(
|
|
90
|
+
true,
|
|
91
|
+
callData,
|
|
92
|
+
blockNumber,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const result = {
|
|
96
|
+
exchangeRate: res[0].returnData,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
handleExchangeRateChanged(
|
|
103
|
+
event: any,
|
|
104
|
+
state: DeepReadonly<PoolState>,
|
|
105
|
+
log: Readonly<Log>,
|
|
106
|
+
): DeepReadonly<PoolState> | null {
|
|
107
|
+
return {
|
|
108
|
+
exchangeRate: BigInt(event.args.exchangeRate),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -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
|
+
}
|