@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,28 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { Log, Logger } from '../../types';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { PoolState } from './types';
|
|
7
|
+
export declare class AaveGsmEventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
|
+
readonly gsm: string;
|
|
9
|
+
readonly parentName: string;
|
|
10
|
+
protected network: number;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
protected aaveGsmIface: Interface;
|
|
13
|
+
protected feeStrategyIface: Interface;
|
|
14
|
+
protected PERCENT_FACTOR: bigint;
|
|
15
|
+
handlers: {
|
|
16
|
+
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => Promise<DeepReadonly<PoolState> | null>;
|
|
17
|
+
};
|
|
18
|
+
logDecoder: (log: Log) => any;
|
|
19
|
+
addressesSubscribed: string[];
|
|
20
|
+
constructor(gsm: string, parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, aaveGsmIface?: Interface, feeStrategyIface?: Interface, PERCENT_FACTOR?: bigint);
|
|
21
|
+
getIdentifier(): string;
|
|
22
|
+
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
|
|
23
|
+
getOnChainState(address: string, blockNumber?: number | string): Promise<PoolState>;
|
|
24
|
+
generateState(blockNumber?: number | string): Promise<DeepReadonly<PoolState>>;
|
|
25
|
+
handleFeeStrategyUpdated(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
|
|
26
|
+
handleSwapFreeze(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
|
|
27
|
+
handleSeized(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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.AaveGsmEventPool = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
10
|
+
const Aave_GSM_json_1 = __importDefault(require("../../abi/aave-gsm/Aave_GSM.json"));
|
|
11
|
+
const IFeeStrategy_json_1 = __importDefault(require("../../abi/aave-gsm/IFeeStrategy.json"));
|
|
12
|
+
const decoders_1 = require("../../lib/decoders");
|
|
13
|
+
class AaveGsmEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
14
|
+
constructor(gsm, parentName, network, dexHelper, logger, aaveGsmIface = new abi_1.Interface(Aave_GSM_json_1.default), feeStrategyIface = new abi_1.Interface(IFeeStrategy_json_1.default), PERCENT_FACTOR = 10000n) {
|
|
15
|
+
super(parentName, `${parentName}_${gsm}`, dexHelper, logger);
|
|
16
|
+
this.gsm = gsm;
|
|
17
|
+
this.parentName = parentName;
|
|
18
|
+
this.network = network;
|
|
19
|
+
this.dexHelper = dexHelper;
|
|
20
|
+
this.aaveGsmIface = aaveGsmIface;
|
|
21
|
+
this.feeStrategyIface = feeStrategyIface;
|
|
22
|
+
this.PERCENT_FACTOR = PERCENT_FACTOR;
|
|
23
|
+
this.handlers = {};
|
|
24
|
+
this.logDecoder = (log) => this.aaveGsmIface.parseLog(log);
|
|
25
|
+
this.addressesSubscribed = [gsm];
|
|
26
|
+
// Add handlers
|
|
27
|
+
this.handlers['FeeStrategyUpdated'] =
|
|
28
|
+
this.handleFeeStrategyUpdated.bind(this);
|
|
29
|
+
this.handlers['SwapFreeze'] = this.handleSwapFreeze.bind(this);
|
|
30
|
+
this.handlers['Seized'] = this.handleSeized.bind(this);
|
|
31
|
+
}
|
|
32
|
+
getIdentifier() {
|
|
33
|
+
return `${this.parentName}_${this.gsm}`;
|
|
34
|
+
}
|
|
35
|
+
async processLog(state, log) {
|
|
36
|
+
try {
|
|
37
|
+
const event = this.logDecoder(log);
|
|
38
|
+
if (event.name in this.handlers) {
|
|
39
|
+
return await this.handlers[event.name](event, state, log);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
async getOnChainState(address, blockNumber = 'latest') {
|
|
48
|
+
const callData = [
|
|
49
|
+
{
|
|
50
|
+
target: address,
|
|
51
|
+
callData: this.feeStrategyIface.encodeFunctionData('getBuyFee', [
|
|
52
|
+
this.PERCENT_FACTOR,
|
|
53
|
+
]),
|
|
54
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
target: address,
|
|
58
|
+
callData: this.feeStrategyIface.encodeFunctionData('getSellFee', [
|
|
59
|
+
this.PERCENT_FACTOR,
|
|
60
|
+
]),
|
|
61
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
target: this.gsm,
|
|
65
|
+
callData: this.aaveGsmIface.encodeFunctionData('getAvailableLiquidity', []),
|
|
66
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
target: this.gsm,
|
|
70
|
+
callData: this.aaveGsmIface.encodeFunctionData('getIsFrozen', []),
|
|
71
|
+
decodeFunction: decoders_1.booleanDecode,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
target: this.gsm,
|
|
75
|
+
callData: this.aaveGsmIface.encodeFunctionData('getIsSeized', []),
|
|
76
|
+
decodeFunction: decoders_1.booleanDecode,
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
const results = await this.dexHelper.multiWrapper.tryAggregate(true, callData, blockNumber);
|
|
80
|
+
return {
|
|
81
|
+
buyFee: results[0].returnData,
|
|
82
|
+
sellFee: results[1].returnData,
|
|
83
|
+
underlyingLiquidity: results[2].returnData,
|
|
84
|
+
isFrozen: results[3].returnData,
|
|
85
|
+
isSeized: results[4].returnData,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async generateState(blockNumber = 'latest') {
|
|
89
|
+
const callData = [
|
|
90
|
+
{
|
|
91
|
+
target: this.gsm,
|
|
92
|
+
callData: this.aaveGsmIface.encodeFunctionData('getFeeStrategy', []),
|
|
93
|
+
decodeFunction: decoders_1.addressDecode,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const feeStrategy = await this.dexHelper.multiWrapper.tryAggregate(true, callData, blockNumber);
|
|
97
|
+
const result = await this.getOnChainState(feeStrategy[0].returnData, blockNumber);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
async handleFeeStrategyUpdated(event, state, log) {
|
|
101
|
+
return await this.getOnChainState(event.args.newFeeStrategy);
|
|
102
|
+
}
|
|
103
|
+
async handleSwapFreeze(event, state, log) {
|
|
104
|
+
return {
|
|
105
|
+
...state,
|
|
106
|
+
isFrozen: event.args.enabled,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async handleSeized(event, state, log) {
|
|
110
|
+
return {
|
|
111
|
+
...state,
|
|
112
|
+
isSeized: true,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.AaveGsmEventPool = AaveGsmEventPool;
|
|
117
|
+
//# sourceMappingURL=aave-gsm-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave-gsm-pool.js","sourceRoot":"","sources":["../../../src/dex/aave-gsm/aave-gsm-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAG1E,qFAAuD;AACvD,6FAAoE;AACpE,iDAI4B;AAE5B,MAAa,gBAAiB,SAAQ,mDAAkC;IAatE,YACW,GAAW,EACX,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,eAAe,IAAI,eAAS,CAAC,uBAAO,CAAC,EACrC,mBAAmB,IAAI,eAAS,CAAC,2BAAgB,CAAC,EAClD,iBAAiB,MAAO;QAElC,KAAK,CAAC,UAAU,EAAE,GAAG,UAAU,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QATpD,QAAG,GAAH,GAAG,CAAQ;QACX,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,iBAAY,GAAZ,YAAY,CAAyB;QACrC,qBAAgB,GAAhB,gBAAgB,CAAkC;QAClD,mBAAc,GAAd,cAAc,CAAU;QApBpC,aAAQ,GAMJ,EAAE,CAAC;QAkBL,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ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,IAAI,CAAC,GAAG;gBAChB,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,EAAE,CAAC;gBACpE,cAAc,EAAE,wBAAa;aAC9B;SACF,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAChE,IAAI,EACJ,QAAQ,EACR,WAAW,CACZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CACvC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,EACzB,WAAW,CACZ,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC5B,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO;YACL,GAAG,KAAK;YACR,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO;SAC7B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO;YACL,GAAG,KAAK;YACR,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;CACF;AAlKD,4CAkKC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
|
|
2
|
+
import { SwapSide, Network } from '../../constants';
|
|
3
|
+
import { IDex } from '../../dex/idex';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
+
import { AaveGsmData, DexParams, PoolState } from './types';
|
|
6
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
7
|
+
import { Interface } from '@ethersproject/abi';
|
|
8
|
+
import { AaveGsmEventPool } from './aave-gsm-pool';
|
|
9
|
+
export declare class AaveGsm extends SimpleExchange implements IDex<AaveGsmData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
static readonly gsmInterface: Interface;
|
|
14
|
+
protected eventPools: Record<string, AaveGsmEventPool>;
|
|
15
|
+
protected config: DexParams;
|
|
16
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
17
|
+
readonly needWrapNative = false;
|
|
18
|
+
readonly isFeeOnTransferSupported = false;
|
|
19
|
+
static dexKeysWithNetwork: {
|
|
20
|
+
key: string;
|
|
21
|
+
networks: Network[];
|
|
22
|
+
}[];
|
|
23
|
+
logger: Logger;
|
|
24
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
25
|
+
initializePoolPricing(pool: AaveGsmEventPool, blockNumber: number): Promise<void>;
|
|
26
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
27
|
+
getAdapters(side: SwapSide): {
|
|
28
|
+
name: string;
|
|
29
|
+
index: number;
|
|
30
|
+
}[] | null;
|
|
31
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
32
|
+
updatePoolState(): Promise<void>;
|
|
33
|
+
getPoolState(gsm: string, blockNumber?: number): Promise<PoolState>;
|
|
34
|
+
getGhoAmountForBuyAsset(assetAmount: bigint, state: PoolState): bigint;
|
|
35
|
+
getAssetAmountForBuyAsset(ghoAmount: bigint, state: PoolState): bigint;
|
|
36
|
+
getGhoAmountForSellAsset(assetAmount: bigint, state: PoolState): bigint;
|
|
37
|
+
getAssetAmountForSellAsset(ghoAmount: bigint, state: PoolState): bigint;
|
|
38
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<AaveGsmData>>;
|
|
39
|
+
getCalldataGasCost(poolPrices: PoolPrices<AaveGsmData>): number | number[];
|
|
40
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AaveGsmData, side: SwapSide): AdapterExchangeParam;
|
|
41
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: AaveGsmData, side: SwapSide): Promise<DexExchangeParam>;
|
|
42
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AaveGsm = void 0;
|
|
30
|
+
const constants_1 = require("../../constants");
|
|
31
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
32
|
+
const utils_1 = require("../../utils");
|
|
33
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
34
|
+
const config_1 = require("./config");
|
|
35
|
+
const Aave_GSM_json_1 = __importDefault(require("../../abi/aave-gsm/Aave_GSM.json"));
|
|
36
|
+
const abi_1 = require("@ethersproject/abi");
|
|
37
|
+
const utils_2 = require("ethers/lib/utils");
|
|
38
|
+
const aave_gsm_pool_1 = require("./aave-gsm-pool");
|
|
39
|
+
const maverick_basic_math_1 = require("../maverick-v1/maverick-math/maverick-basic-math");
|
|
40
|
+
const constants_2 = require("../../executor/constants");
|
|
41
|
+
class AaveGsm extends simple_exchange_1.SimpleExchange {
|
|
42
|
+
constructor(network, dexKey, dexHelper) {
|
|
43
|
+
super(dexHelper, dexKey);
|
|
44
|
+
this.network = network;
|
|
45
|
+
this.dexKey = dexKey;
|
|
46
|
+
this.dexHelper = dexHelper;
|
|
47
|
+
this.hasConstantPriceLargeAmounts = false;
|
|
48
|
+
this.needWrapNative = false;
|
|
49
|
+
this.isFeeOnTransferSupported = false;
|
|
50
|
+
const config = config_1.AaveGsmConfig[dexKey][network];
|
|
51
|
+
this.config = {
|
|
52
|
+
GSM_USDT: config.GSM_USDT.toLowerCase(),
|
|
53
|
+
GSM_USDC: config.GSM_USDC.toLowerCase(),
|
|
54
|
+
USDT: config.USDT.toLowerCase(),
|
|
55
|
+
USDC: config.USDC.toLowerCase(),
|
|
56
|
+
GHO: config.GHO.toLowerCase(),
|
|
57
|
+
};
|
|
58
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
59
|
+
this.eventPools = {
|
|
60
|
+
[this.config.GSM_USDT]: new aave_gsm_pool_1.AaveGsmEventPool(this.config.GSM_USDT, this.dexKey, this.network, this.dexHelper, this.logger),
|
|
61
|
+
[this.config.GSM_USDC]: new aave_gsm_pool_1.AaveGsmEventPool(this.config.GSM_USDC, this.dexKey, this.network, this.dexHelper, this.logger),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async initializePoolPricing(pool, blockNumber) {
|
|
65
|
+
const state = await pool.generateState(blockNumber);
|
|
66
|
+
pool.initialize(blockNumber, {
|
|
67
|
+
state,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async initializePricing(blockNumber) {
|
|
71
|
+
await this.initializePoolPricing(this.eventPools[this.config.GSM_USDT], blockNumber);
|
|
72
|
+
await this.initializePoolPricing(this.eventPools[this.config.GSM_USDC], blockNumber);
|
|
73
|
+
}
|
|
74
|
+
getAdapters(side) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
78
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
79
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
80
|
+
if ((srcTokenAddress === this.config.GHO &&
|
|
81
|
+
destTokenAddress === this.config.USDT) ||
|
|
82
|
+
(srcTokenAddress === this.config.USDT &&
|
|
83
|
+
destTokenAddress === this.config.GHO)) {
|
|
84
|
+
return [`${this.dexKey}_${this.config.GSM_USDT}`];
|
|
85
|
+
}
|
|
86
|
+
else if ((srcTokenAddress === this.config.GHO &&
|
|
87
|
+
destTokenAddress === this.config.USDC) ||
|
|
88
|
+
(srcTokenAddress === this.config.USDC &&
|
|
89
|
+
destTokenAddress === this.config.GHO)) {
|
|
90
|
+
return [`${this.dexKey}_${this.config.GSM_USDC}`];
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async updatePoolState() {
|
|
97
|
+
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
98
|
+
await this.initializePricing(blockNumber);
|
|
99
|
+
}
|
|
100
|
+
async getPoolState(gsm, blockNumber) {
|
|
101
|
+
if (!blockNumber) {
|
|
102
|
+
return this.eventPools[gsm].getStaleState();
|
|
103
|
+
}
|
|
104
|
+
const eventState = this.eventPools[gsm].getState(blockNumber);
|
|
105
|
+
if (eventState)
|
|
106
|
+
return eventState;
|
|
107
|
+
const onChainState = await this.eventPools[gsm].generateState(blockNumber);
|
|
108
|
+
this.eventPools[gsm].setState(onChainState, blockNumber);
|
|
109
|
+
return onChainState;
|
|
110
|
+
}
|
|
111
|
+
getGhoAmountForBuyAsset(assetAmount, state) {
|
|
112
|
+
if (assetAmount === 0n) {
|
|
113
|
+
return 0n;
|
|
114
|
+
}
|
|
115
|
+
const grossAmount = assetAmount * 1000000000000n; // 18 - 6 = 12 (decimals)
|
|
116
|
+
const fee = maverick_basic_math_1.MMath.mulDiv(grossAmount, state.buyFee, 10000n, true);
|
|
117
|
+
return grossAmount + fee;
|
|
118
|
+
}
|
|
119
|
+
getAssetAmountForBuyAsset(ghoAmount, state) {
|
|
120
|
+
const grossAmount = (ghoAmount * 10000n) / (10000n + state.buyFee);
|
|
121
|
+
return grossAmount / 1000000000000n; // 18 - 6 = 12 (decimals)
|
|
122
|
+
}
|
|
123
|
+
getGhoAmountForSellAsset(assetAmount, state) {
|
|
124
|
+
if (assetAmount === 0n) {
|
|
125
|
+
return 0n;
|
|
126
|
+
}
|
|
127
|
+
const grossAmount = assetAmount * 1000000000000n; // 18 - 6 = 12 (decimals)
|
|
128
|
+
const fee = maverick_basic_math_1.MMath.mulDiv(grossAmount, state.sellFee, 10000n, true);
|
|
129
|
+
return grossAmount - fee;
|
|
130
|
+
}
|
|
131
|
+
getAssetAmountForSellAsset(ghoAmount, state) {
|
|
132
|
+
const grossAmount = maverick_basic_math_1.MMath.mulDiv(ghoAmount, 10000n, 10000n - state.sellFee, true);
|
|
133
|
+
return maverick_basic_math_1.MMath.mulDiv(grossAmount, 1n, 1000000000000n, true); // 18 - 6 = 12 (decimals)
|
|
134
|
+
}
|
|
135
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
136
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
137
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
138
|
+
if (!((srcTokenAddress === this.config.GHO &&
|
|
139
|
+
(destTokenAddress === this.config.USDC ||
|
|
140
|
+
destTokenAddress === this.config.USDT)) ||
|
|
141
|
+
(destTokenAddress === this.config.GHO &&
|
|
142
|
+
(srcTokenAddress === this.config.USDC ||
|
|
143
|
+
srcTokenAddress === this.config.USDT)))) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
let endpoint;
|
|
147
|
+
let target;
|
|
148
|
+
let gas;
|
|
149
|
+
if (srcTokenAddress === this.config.USDT ||
|
|
150
|
+
destTokenAddress === this.config.USDT) {
|
|
151
|
+
target = this.config.GSM_USDT;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
target = this.config.GSM_USDC;
|
|
155
|
+
}
|
|
156
|
+
if (srcTokenAddress === this.config.GHO && side === constants_1.SwapSide.BUY) {
|
|
157
|
+
endpoint = this.getGhoAmountForBuyAsset;
|
|
158
|
+
gas = 80000;
|
|
159
|
+
}
|
|
160
|
+
else if (srcTokenAddress === this.config.GHO && side === constants_1.SwapSide.SELL) {
|
|
161
|
+
endpoint = this.getAssetAmountForBuyAsset;
|
|
162
|
+
gas = 80000;
|
|
163
|
+
}
|
|
164
|
+
else if (destTokenAddress === this.config.GHO && side === constants_1.SwapSide.SELL) {
|
|
165
|
+
endpoint = this.getGhoAmountForSellAsset;
|
|
166
|
+
gas = 70000;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
endpoint = this.getAssetAmountForSellAsset;
|
|
170
|
+
gas = 70000;
|
|
171
|
+
}
|
|
172
|
+
const unit = (0, utils_2.parseUnits)('1', side === constants_1.SwapSide.SELL ? srcToken.decimals : destToken.decimals).toBigInt();
|
|
173
|
+
const poolState = await this.getPoolState(target, blockNumber);
|
|
174
|
+
if (poolState.isFrozen || poolState.isSeized) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
unit: endpoint(unit, poolState),
|
|
180
|
+
prices: amounts.map(amount => endpoint(amount, poolState)),
|
|
181
|
+
data: {
|
|
182
|
+
exchange: this.dexKey,
|
|
183
|
+
},
|
|
184
|
+
poolAddresses: [target],
|
|
185
|
+
exchange: this.dexKey,
|
|
186
|
+
gasCost: gas,
|
|
187
|
+
poolIdentifier: `${this.dexKey}_${target}`,
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
getCalldataGasCost(poolPrices) {
|
|
192
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
193
|
+
}
|
|
194
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
195
|
+
const { exchange } = data;
|
|
196
|
+
const payload = '';
|
|
197
|
+
return {
|
|
198
|
+
targetExchange: exchange,
|
|
199
|
+
payload,
|
|
200
|
+
networkFee: '0',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
204
|
+
const isSrcGho = srcToken.toLowerCase() === this.config.GHO;
|
|
205
|
+
const swapFunction = isSrcGho ? 'buyAsset' : 'sellAsset';
|
|
206
|
+
const ghoAmount = isSrcGho ? srcAmount : destAmount;
|
|
207
|
+
let assetAmount = isSrcGho ? destAmount : srcAmount;
|
|
208
|
+
const targetExchange = srcToken.toLowerCase() === this.config.USDT ||
|
|
209
|
+
destToken.toLowerCase() === this.config.USDT
|
|
210
|
+
? this.config.GSM_USDT
|
|
211
|
+
: this.config.GSM_USDC;
|
|
212
|
+
if (BigInt(assetAmount) === 1n) {
|
|
213
|
+
const poolState = await this.getPoolState(targetExchange);
|
|
214
|
+
assetAmount = isSrcGho
|
|
215
|
+
? this.getAssetAmountForBuyAsset(BigInt(ghoAmount), poolState).toString()
|
|
216
|
+
: this.getAssetAmountForSellAsset(BigInt(ghoAmount), poolState).toString();
|
|
217
|
+
}
|
|
218
|
+
const exchangeData = AaveGsm.gsmInterface.encodeFunctionData(swapFunction, [
|
|
219
|
+
assetAmount,
|
|
220
|
+
recipient,
|
|
221
|
+
]);
|
|
222
|
+
return {
|
|
223
|
+
needWrapNative: this.needWrapNative,
|
|
224
|
+
dexFuncHasRecipient: true,
|
|
225
|
+
exchangeData,
|
|
226
|
+
targetExchange,
|
|
227
|
+
returnAmountPos: side === constants_1.SwapSide.SELL
|
|
228
|
+
? isSrcGho
|
|
229
|
+
? constants_2.RETURN_AMOUNT_POS_0
|
|
230
|
+
: constants_2.RETURN_AMOUNT_POS_32
|
|
231
|
+
: undefined,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
235
|
+
tokenAddress = tokenAddress.toLowerCase();
|
|
236
|
+
if (tokenAddress === this.config.GHO) {
|
|
237
|
+
const usdtState = this.eventPools[this.config.GSM_USDT].getStaleState();
|
|
238
|
+
const usdcState = this.eventPools[this.config.GSM_USDC].getStaleState();
|
|
239
|
+
return [
|
|
240
|
+
{
|
|
241
|
+
exchange: this.dexKey,
|
|
242
|
+
address: this.config.GSM_USDT,
|
|
243
|
+
connectorTokens: [
|
|
244
|
+
{
|
|
245
|
+
decimals: 6,
|
|
246
|
+
address: this.config.USDT,
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
liquidityUSD: usdtState
|
|
250
|
+
? +(0, utils_2.formatUnits)(usdtState.underlyingLiquidity, 6)
|
|
251
|
+
: 1000000000,
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
exchange: this.dexKey,
|
|
255
|
+
address: this.config.GSM_USDC,
|
|
256
|
+
connectorTokens: [
|
|
257
|
+
{
|
|
258
|
+
decimals: 6,
|
|
259
|
+
address: this.config.USDC,
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
liquidityUSD: usdcState
|
|
263
|
+
? +(0, utils_2.formatUnits)(usdcState.underlyingLiquidity, 6)
|
|
264
|
+
: 1000000000,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
else if (tokenAddress === this.config.USDC) {
|
|
269
|
+
return [
|
|
270
|
+
{
|
|
271
|
+
exchange: this.dexKey,
|
|
272
|
+
address: this.config.GSM_USDC,
|
|
273
|
+
connectorTokens: [
|
|
274
|
+
{
|
|
275
|
+
decimals: 18,
|
|
276
|
+
address: this.config.GHO,
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
280
|
+
},
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
else if (tokenAddress === this.config.USDT) {
|
|
284
|
+
return [
|
|
285
|
+
{
|
|
286
|
+
exchange: this.dexKey,
|
|
287
|
+
address: this.config.GSM_USDT,
|
|
288
|
+
connectorTokens: [
|
|
289
|
+
{
|
|
290
|
+
decimals: 18,
|
|
291
|
+
address: this.config.GHO,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.AaveGsm = AaveGsm;
|
|
304
|
+
AaveGsm.gsmInterface = new abi_1.Interface(Aave_GSM_json_1.default);
|
|
305
|
+
AaveGsm.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.AaveGsmConfig);
|
|
306
|
+
//# sourceMappingURL=aave-gsm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave-gsm.js","sourceRoot":"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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AaveGsmConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const aave_address_book_1 = require("@bgd-labs/aave-address-book");
|
|
6
|
+
exports.AaveGsmConfig = {
|
|
7
|
+
AaveGsm: {
|
|
8
|
+
[constants_1.Network.MAINNET]: {
|
|
9
|
+
GSM_USDT: aave_address_book_1.MiscEthereum.GSM_USDT,
|
|
10
|
+
GSM_USDC: aave_address_book_1.MiscEthereum.GSM_USDC,
|
|
11
|
+
USDT: aave_address_book_1.AaveV3Ethereum.ASSETS.USDT.UNDERLYING,
|
|
12
|
+
USDC: aave_address_book_1.AaveV3Ethereum.ASSETS.USDC.UNDERLYING,
|
|
13
|
+
GHO: aave_address_book_1.AaveV3Ethereum.ASSETS.GHO.UNDERLYING,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/aave-gsm/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAC1C,mEAA2E;AAE9D,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,QAAQ,EAAE,gCAAY,CAAC,QAAQ;YAC/B,QAAQ,EAAE,gCAAY,CAAC,QAAQ;YAC/B,IAAI,EAAE,kCAAc,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU;YAC3C,IAAI,EAAE,kCAAc,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU;YAC3C,GAAG,EAAE,kCAAc,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU;SAC1C;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export declare type PoolState = {
|
|
3
|
+
buyFee: bigint;
|
|
4
|
+
sellFee: bigint;
|
|
5
|
+
underlyingLiquidity: bigint;
|
|
6
|
+
isFrozen: boolean;
|
|
7
|
+
isSeized: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare type AaveGsmData = {
|
|
10
|
+
exchange: Address;
|
|
11
|
+
};
|
|
12
|
+
export declare type DexParams = {
|
|
13
|
+
GSM_USDT: string;
|
|
14
|
+
GSM_USDC: string;
|
|
15
|
+
USDT: string;
|
|
16
|
+
USDC: string;
|
|
17
|
+
GHO: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/aave-gsm/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
|
|
3
|
+
import { SwapSide, Network } from '../../constants';
|
|
4
|
+
import { IDex } from '../../dex/idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { AaveV1Data, AaveV1Param } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
export declare class AaveV1 extends SimpleExchange implements IDex<AaveV1Data, AaveV1Param> {
|
|
9
|
+
protected network: Network;
|
|
10
|
+
protected dexHelper: IDexHelper;
|
|
11
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
12
|
+
readonly isFeeOnTransferSupported = false;
|
|
13
|
+
static dexKeysWithNetwork: {
|
|
14
|
+
key: string;
|
|
15
|
+
networks: Network[];
|
|
16
|
+
}[];
|
|
17
|
+
logger: Logger;
|
|
18
|
+
aavePool: Interface;
|
|
19
|
+
aContract: Interface;
|
|
20
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
21
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
22
|
+
getAdapters(side: SwapSide): {
|
|
23
|
+
name: string;
|
|
24
|
+
index: number;
|
|
25
|
+
}[] | null;
|
|
26
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
27
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<AaveV1Data>>;
|
|
28
|
+
getCalldataGasCost(poolPrices: PoolPrices<AaveV1Data>): number | number[];
|
|
29
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AaveV1Data, side: SwapSide): AdapterExchangeParam;
|
|
30
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AaveV1Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
31
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: AaveV1Data, side: SwapSide): DexExchangeParam;
|
|
32
|
+
updatePoolState(): Promise<void>;
|
|
33
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
34
|
+
}
|