@paraswap/dex-lib 2.20.3 → 2.21.1
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/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/curve-v1-factory/config.js +91 -9
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +9 -3
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +2 -0
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +27 -3
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +66 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +20 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +26 -3
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +6 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.d.ts +1 -4
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +2 -5
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +3 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +22 -3
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/polling-manager.d.ts +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/polling-manager.js +28 -3
- package/build/dex/curve-v1-factory/state-polling-pools/polling-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.d.ts +2 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js +2 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +16 -0
- package/build/dex/curve-v1-factory/types.js +6 -0
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/quickswap/config.js +8 -0
- package/build/dex/quickswap/config.js.map +1 -1
- package/build/dex/swaap-v2/rate-fetcher.js.map +1 -1
- package/build/dex/test-dex/config.d.ts +4 -0
- package/build/dex/test-dex/config.js +15 -0
- package/build/dex/test-dex/config.js.map +1 -0
- package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
- package/build/dex/test-dex/test-dex-pool.js +63 -0
- package/build/dex/test-dex/test-dex-pool.js.map +1 -0
- package/build/dex/test-dex/test-dex.d.ts +37 -0
- package/build/dex/test-dex/test-dex.js +126 -0
- package/build/dex/test-dex/test-dex.js.map +1 -0
- package/build/dex/test-dex/types.d.ts +6 -0
- package/build/dex/test-dex/types.js +3 -0
- package/build/dex/test-dex/types.js.map +1 -0
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/curve-v1-factory/config.ts +91 -9
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +36 -0
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +12 -1
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +6 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +53 -6
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +78 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +13 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +40 -3
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +53 -4
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +7 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +7 -0
- package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +5 -3
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +42 -1
- package/src/dex/curve-v1-factory/state-polling-pools/polling-manager.ts +43 -9
- package/src/dex/curve-v1-factory/state-polling-pools/pool-polling-base.ts +1 -0
- package/src/dex/curve-v1-factory/types.ts +14 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/quickswap/camelot-v3.ts +15 -0
- package/src/dex/quickswap/config.ts +9 -0
- package/src/dex/quickswap/quickswap-e2e.test.ts +109 -0
- package/src/dex/swaap-v2/rate-fetcher.ts +10 -10
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +1 -4
- package/tests/constants-e2e.ts +6 -10
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestDexEventPool = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
7
|
+
class TestDexEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
+
constructor(parentName, network, dexHelper, logger, testDexIface = new abi_1.Interface('' /* TODO: Import and put here TestDex ABI */)) {
|
|
9
|
+
super(parentName, logger);
|
|
10
|
+
this.parentName = parentName;
|
|
11
|
+
this.network = network;
|
|
12
|
+
this.dexHelper = dexHelper;
|
|
13
|
+
this.testDexIface = testDexIface;
|
|
14
|
+
this.handlers = {};
|
|
15
|
+
// TODO: make logDecoder decode logs that
|
|
16
|
+
this.logDecoder = (log) => this.testDexIface.parseLog(log);
|
|
17
|
+
this.addressesSubscribed = [
|
|
18
|
+
/* subscribed addresses */
|
|
19
|
+
];
|
|
20
|
+
// Add handlers
|
|
21
|
+
this.handlers['myEvent'] = this.handleMyEvent.bind(this);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The function is called every time any of the subscribed
|
|
25
|
+
* addresses release log. The function accepts the current
|
|
26
|
+
* state, updates the state according to the log, and returns
|
|
27
|
+
* the updated state.
|
|
28
|
+
* @param state - Current state of event subscriber
|
|
29
|
+
* @param log - Log released by one of the subscribed addresses
|
|
30
|
+
* @returns Updates state of the event subscriber after the log
|
|
31
|
+
*/
|
|
32
|
+
processLog(state, log) {
|
|
33
|
+
try {
|
|
34
|
+
const event = this.logDecoder(log);
|
|
35
|
+
if (event.name in this.handlers) {
|
|
36
|
+
return this.handlers[event.name](event, state, log);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The function generates state using on-chain calls. This
|
|
46
|
+
* function is called to regenerate state if the event based
|
|
47
|
+
* system fails to fetch events and the local state is no
|
|
48
|
+
* more correct.
|
|
49
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
50
|
+
* should be generated
|
|
51
|
+
* @returns state of the event subscriber at blocknumber
|
|
52
|
+
*/
|
|
53
|
+
async generateState(blockNumber) {
|
|
54
|
+
// TODO: complete me!
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
// Its just a dummy example
|
|
58
|
+
handleMyEvent(event, state, log) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.TestDexEventPool = TestDexEventPool;
|
|
63
|
+
//# sourceMappingURL=test-dex-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-dex-pool.js","sourceRoot":"","sources":["../../../src/dex/test-dex/test-dex-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,gBAAiB,SAAQ,mDAAkC;IAWtE,YACY,UAAkB,EAClB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,eAAe,IAAI,eAAS,CACpC,EAAE,CAAC,2CAA2C,CAC/C;QAED,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QARhB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,iBAAY,GAAZ,YAAY,CAErB;QAjBH,aAAQ,GAIJ,EAAE,CAAC;QAiBL,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,mBAAmB,GAAG;QACzB,0BAA0B;SAC3B,CAAC;QAEF,eAAe;QACf,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;aACrD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,aAAa,CACX,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,4CA+EC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
+
import { SwapSide, Network } from '../../constants';
|
|
4
|
+
import { IDex } from '../../dex/idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { TestDexData } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { TestDexEventPool } from './test-dex-pool';
|
|
9
|
+
export declare class TestDex extends SimpleExchange implements IDex<TestDexData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
14
|
+
protected eventPools: TestDexEventPool;
|
|
15
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
16
|
+
readonly needWrapNative = true;
|
|
17
|
+
readonly isFeeOnTransferSupported = false;
|
|
18
|
+
static dexKeysWithNetwork: {
|
|
19
|
+
key: string;
|
|
20
|
+
networks: Network[];
|
|
21
|
+
}[];
|
|
22
|
+
logger: Logger;
|
|
23
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
24
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
25
|
+
getAdapters(side: SwapSide): {
|
|
26
|
+
name: string;
|
|
27
|
+
index: number;
|
|
28
|
+
}[] | null;
|
|
29
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
30
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<TestDexData>>;
|
|
31
|
+
getCalldataGasCost(poolPrices: PoolPrices<TestDexData>): number | number[];
|
|
32
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): AdapterExchangeParam;
|
|
33
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
34
|
+
updatePoolState(): Promise<void>;
|
|
35
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
36
|
+
releaseResources(): AsyncOrSync<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TestDex = void 0;
|
|
27
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
28
|
+
const utils_1 = require("../../utils");
|
|
29
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
30
|
+
const config_1 = require("./config");
|
|
31
|
+
const test_dex_pool_1 = require("./test-dex-pool");
|
|
32
|
+
class TestDex extends simple_exchange_1.SimpleExchange {
|
|
33
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
|
|
34
|
+
super(dexHelper, dexKey);
|
|
35
|
+
this.network = network;
|
|
36
|
+
this.dexKey = dexKey;
|
|
37
|
+
this.dexHelper = dexHelper;
|
|
38
|
+
this.adapters = adapters;
|
|
39
|
+
this.hasConstantPriceLargeAmounts = false;
|
|
40
|
+
// TODO: set true here if protocols works only with wrapped asset
|
|
41
|
+
this.needWrapNative = true;
|
|
42
|
+
this.isFeeOnTransferSupported = false;
|
|
43
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
44
|
+
this.eventPools = new test_dex_pool_1.TestDexEventPool(dexKey, network, dexHelper, this.logger);
|
|
45
|
+
}
|
|
46
|
+
// Initialize pricing is called once in the start of
|
|
47
|
+
// pricing service. It is intended to setup the integration
|
|
48
|
+
// for pricing requests. It is optional for a DEX to
|
|
49
|
+
// implement this function
|
|
50
|
+
async initializePricing(blockNumber) {
|
|
51
|
+
// TODO: complete me!
|
|
52
|
+
}
|
|
53
|
+
// Returns the list of contract adapters (name and index)
|
|
54
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
55
|
+
getAdapters(side) {
|
|
56
|
+
return this.adapters[side] ? this.adapters[side] : null;
|
|
57
|
+
}
|
|
58
|
+
// Returns list of pool identifiers that can be used
|
|
59
|
+
// for a given swap. poolIdentifiers must be unique
|
|
60
|
+
// across DEXes. It is recommended to use
|
|
61
|
+
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
62
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
63
|
+
// TODO: complete me!
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
// Returns pool prices for amounts.
|
|
67
|
+
// If limitPools is defined only pools in limitPools
|
|
68
|
+
// should be used. If limitPools is undefined then
|
|
69
|
+
// any pools can be used.
|
|
70
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
71
|
+
// TODO: complete me!
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
75
|
+
getCalldataGasCost(poolPrices) {
|
|
76
|
+
// TODO: update if there is any payload in getAdapterParam
|
|
77
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
78
|
+
}
|
|
79
|
+
// Encode params required by the exchange adapter
|
|
80
|
+
// Used for multiSwap, buy & megaSwap
|
|
81
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
82
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
83
|
+
// TODO: complete me!
|
|
84
|
+
const { exchange } = data;
|
|
85
|
+
// Encode here the payload for adapter
|
|
86
|
+
const payload = '';
|
|
87
|
+
return {
|
|
88
|
+
targetExchange: exchange,
|
|
89
|
+
payload,
|
|
90
|
+
networkFee: '0',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Encode call data used by simpleSwap like routers
|
|
94
|
+
// Used for simpleSwap & simpleBuy
|
|
95
|
+
// Hint: this.buildSimpleParamWithoutWETHConversion
|
|
96
|
+
// could be useful
|
|
97
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
98
|
+
// TODO: complete me!
|
|
99
|
+
const { exchange } = data;
|
|
100
|
+
// Encode here the transaction arguments
|
|
101
|
+
const swapData = '';
|
|
102
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
|
|
103
|
+
}
|
|
104
|
+
// This is called once before getTopPoolsForToken is
|
|
105
|
+
// called for multiple tokens. This can be helpful to
|
|
106
|
+
// update common state required for calculating
|
|
107
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
108
|
+
// to implement this
|
|
109
|
+
async updatePoolState() {
|
|
110
|
+
// TODO: complete me!
|
|
111
|
+
}
|
|
112
|
+
// Returns list of top pools based on liquidity. Max
|
|
113
|
+
// limit number pools should be returned.
|
|
114
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
115
|
+
//TODO: complete me!
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
119
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
120
|
+
releaseResources() {
|
|
121
|
+
// TODO: complete me!
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.TestDex = TestDex;
|
|
125
|
+
TestDex.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.TestDexConfig);
|
|
126
|
+
//# sourceMappingURL=test-dex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-dex.js","sourceRoot":"","sources":["../../../src/dex/test-dex/test-dex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAAmD;AACnD,mDAAmD;AAEnD,MAAa,OACX,SAAQ,gCAAc;IAgBtB,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAA0B;QAfrC,iCAA4B,GAAG,KAAK,CAAC;QAC9C,iEAAiE;QACxD,mBAAc,GAAG,IAAI,CAAC;QAEtB,6BAAwB,GAAG,KAAK,CAAC;QAcxC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,IAAI,gCAAgB,CACpC,MAAM,EACN,OAAO,EACP,SAAS,EACT,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,2DAA2D;IAC3D,oDAAoD;IACpD,0BAA0B;IAC1B,KAAK,CAAC,iBAAiB,CAAC,WAAmB;QACzC,qBAAqB;IACvB,CAAC;IAED,yDAAyD;IACzD,wDAAwD;IACxD,WAAW,CAAC,IAAc;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,CA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AC;IACJ,CAAC;IAED,oDAAoD;IACpD,qDAAqD;IACrD,+CAA+C;IAC/C,gDAAgD;IAChD,oBAAoB;IACpB,KAAK,CAAC,eAAe;QACnB,qBAAqB;IACvB,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,oBAAoB;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sFAAsF;IACtF,uFAAuF;IACvF,gBAAgB;QACd,qBAAqB;IACvB,CAAC;;AAhKH,0BAiKC;AArJe,0BAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/test-dex/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PoolState, TokenState } from './types';
|
|
2
|
+
import { Address, Logger } from '../../types';
|
|
3
|
+
export declare class WooFiV2Math {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly _quoteToken;
|
|
6
|
+
state: PoolState;
|
|
7
|
+
constructor(logger: Logger, _quoteToken: Address);
|
|
8
|
+
query(fromToken: Address, toToken: Address, fromAmounts: bigint[]): bigint[] | null;
|
|
9
|
+
_querySellBase(baseToken: Address, baseAmounts: bigint[]): bigint[] | null;
|
|
10
|
+
_querySellQuote(baseToken: Address, quoteAmounts: bigint[]): bigint[] | null;
|
|
11
|
+
_queryBaseToBase(baseToken1: Address, baseToken2: Address, base1Amounts: bigint[]): bigint[] | null;
|
|
12
|
+
protected _takeFeeAndCheckReserve(amounts: bigint[], feeRate: bigint): bigint[];
|
|
13
|
+
protected _takeFee(amounts: bigint[], feeRate: bigint): bigint[];
|
|
14
|
+
protected _calcQuoteAmountSellBase(baseToken: Address, baseAmounts: bigint[], state: TokenState): bigint[];
|
|
15
|
+
protected _calcBaseAmountSellQuote(baseToken: string, quoteAmounts: bigint[], state: TokenState): bigint[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WooFiV2Math = void 0;
|
|
4
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function handleMathError(e, logger) {
|
|
7
|
+
if (e instanceof Error && e.message.startsWith('WooGuardian:')) {
|
|
8
|
+
logger.warn('WooFi Guardian check Error:', e);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
logger.error('Unexpected error in WooFi math:', e);
|
|
12
|
+
}
|
|
13
|
+
function max(a, b) {
|
|
14
|
+
return a > b ? a : b;
|
|
15
|
+
}
|
|
16
|
+
class WooFiV2Math {
|
|
17
|
+
constructor(logger, _quoteToken) {
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
this._quoteToken = _quoteToken;
|
|
20
|
+
this.state = constants_1.NULL_STATE;
|
|
21
|
+
}
|
|
22
|
+
query(fromToken, toToken, fromAmounts) {
|
|
23
|
+
try {
|
|
24
|
+
if (fromToken === this._quoteToken) {
|
|
25
|
+
return this._querySellQuote(toToken, fromAmounts);
|
|
26
|
+
}
|
|
27
|
+
else if (toToken === this._quoteToken) {
|
|
28
|
+
return this._querySellBase(fromToken, fromAmounts);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return this._queryBaseToBase(fromToken, toToken, fromAmounts);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
handleMathError(e, this.logger);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
_querySellBase(baseToken, baseAmounts) {
|
|
40
|
+
try {
|
|
41
|
+
const _state = this.state.tokenStates[baseToken];
|
|
42
|
+
let quoteAmounts = this._calcQuoteAmountSellBase(baseToken, baseAmounts, _state);
|
|
43
|
+
quoteAmounts = quoteAmounts.map(amount => {
|
|
44
|
+
return amount <= this.state.tokenInfos[this._quoteToken].reserve
|
|
45
|
+
? amount
|
|
46
|
+
: 0n;
|
|
47
|
+
});
|
|
48
|
+
const feeRate = this.state.tokenInfos[baseToken].feeRate;
|
|
49
|
+
return this._takeFee(quoteAmounts, feeRate);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
handleMathError(e, this.logger);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_querySellQuote(baseToken, quoteAmounts) {
|
|
57
|
+
try {
|
|
58
|
+
const feeRate = this.state.tokenInfos[baseToken].feeRate;
|
|
59
|
+
quoteAmounts = this._takeFee(quoteAmounts, feeRate);
|
|
60
|
+
const _state = this.state.tokenStates[baseToken];
|
|
61
|
+
let toAmounts = this._calcBaseAmountSellQuote(baseToken, quoteAmounts, _state);
|
|
62
|
+
const baseReserve = this.state.tokenInfos[baseToken].reserve;
|
|
63
|
+
return toAmounts.map(amount => {
|
|
64
|
+
return amount >= baseReserve ? amount : 0n;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
handleMathError(e, this.logger);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
_queryBaseToBase(baseToken1, baseToken2, base1Amounts) {
|
|
73
|
+
try {
|
|
74
|
+
let state1 = this.state.tokenStates[baseToken1];
|
|
75
|
+
let state2 = this.state.tokenStates[baseToken1];
|
|
76
|
+
const feeRate1 = this.state.tokenInfos[baseToken1].feeRate;
|
|
77
|
+
const feeRate2 = this.state.tokenInfos[baseToken2].feeRate;
|
|
78
|
+
const spread = max(state1.spread, state2.spread) / 2n;
|
|
79
|
+
const feeRate = max(feeRate1, feeRate2);
|
|
80
|
+
state1.spread = spread;
|
|
81
|
+
state2.spread = spread;
|
|
82
|
+
let quoteAmounts = this._calcQuoteAmountSellBase(baseToken1, base1Amounts, state1);
|
|
83
|
+
quoteAmounts = this._takeFeeAndCheckReserve(quoteAmounts, feeRate);
|
|
84
|
+
let toAmounts = this._calcBaseAmountSellQuote(baseToken2, quoteAmounts, state2);
|
|
85
|
+
return toAmounts.map(toAmount => {
|
|
86
|
+
return toAmount <= this.state.tokenInfos[baseToken2].reserve
|
|
87
|
+
? toAmount
|
|
88
|
+
: 0n;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
handleMathError(e, this.logger);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
_takeFeeAndCheckReserve(amounts, feeRate) {
|
|
97
|
+
return amounts.map(amount => {
|
|
98
|
+
if (amount === 0n)
|
|
99
|
+
return 0n;
|
|
100
|
+
const lpFee = (amount * feeRate) / bigint_constants_1.BI_POWS[5];
|
|
101
|
+
const reserve = this.state.tokenInfos[this._quoteToken].reserve;
|
|
102
|
+
return lpFee > reserve ? 0n : amount - lpFee;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
_takeFee(amounts, feeRate) {
|
|
106
|
+
return amounts.map(amount => {
|
|
107
|
+
const lpFee = (amount * feeRate) / bigint_constants_1.BI_POWS[5];
|
|
108
|
+
return amount === 0n ? 0n : amount - lpFee;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
_calcQuoteAmountSellBase(baseToken, baseAmounts, state) {
|
|
112
|
+
let { priceDec, quoteDec, baseDec } = this.state.decimals[baseToken];
|
|
113
|
+
return baseAmounts.map(baseAmount => {
|
|
114
|
+
if (baseAmount === 0n)
|
|
115
|
+
return 0n;
|
|
116
|
+
const coef = bigint_constants_1.BI_POWS[18] -
|
|
117
|
+
(state.coeff * baseAmount * state.price) / baseDec / priceDec -
|
|
118
|
+
state.spread;
|
|
119
|
+
return ((((baseAmount * quoteDec * state.price) / priceDec) * coef) /
|
|
120
|
+
bigint_constants_1.BI_POWS[18] /
|
|
121
|
+
baseDec);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
_calcBaseAmountSellQuote(baseToken, quoteAmounts, state) {
|
|
125
|
+
let { priceDec, quoteDec, baseDec } = this.state.decimals[baseToken];
|
|
126
|
+
return quoteAmounts.map(quoteAmount => {
|
|
127
|
+
if (quoteAmount === 0n)
|
|
128
|
+
return 0n;
|
|
129
|
+
const coef = bigint_constants_1.BI_POWS[18] - (quoteAmount * state.coeff) / quoteDec - state.spread;
|
|
130
|
+
return ((((quoteAmount * baseDec * priceDec) / state.price) * coef) /
|
|
131
|
+
bigint_constants_1.BI_POWS[18] /
|
|
132
|
+
quoteDec);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.WooFiV2Math = WooFiV2Math;
|
|
137
|
+
//# sourceMappingURL=woo-fi-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"woo-fi-math.js","sourceRoot":"","sources":["../../../src/dex/woo-fi-v2/woo-fi-math.ts"],"names":[],"mappings":";;;AAEA,6DAAiD;AAEjD,2CAAyC;AAEzC,SAAS,eAAe,CAAC,CAAU,EAAE,MAAc;IACjD,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;QAC9D,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO;KACR;IACD,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS;IAC/B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,MAAa,WAAW;IAGtB,YACmB,MAAc,EACd,WAAoB;QADpB,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAS;QAJvC,UAAK,GAAc,sBAAU,CAAC;IAK3B,CAAC;IAEJ,KAAK,C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,CAAC,CAAC;QAErE,OAAO,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACpC,IAAI,WAAW,KAAK,EAAE;gBAAE,OAAO,EAAE,CAAC;YAElC,MAAM,IAAI,GACR,0BAAO,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;YAEtE,OAAO,CACL,CAAC,CAAC,CAAC,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;gBAC3D,0BAAO,CAAC,EAAE,CAAC;gBACX,QAAQ,CACT,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhLD,kCAgLC"}
|
package/package.json
CHANGED
|
@@ -15,7 +15,9 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
15
15
|
[Network.MAINNET]: {
|
|
16
16
|
factoryAddress: '0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
|
|
17
17
|
stateUpdatePeriodMs: 5 * 1000,
|
|
18
|
-
disabledPools: new Set([
|
|
18
|
+
disabledPools: new Set([
|
|
19
|
+
'0x28B0Cf1baFB707F2c6826d10caf6DD901a6540C5', // It is rug pool token
|
|
20
|
+
]),
|
|
19
21
|
disabledImplementations: new Set([]),
|
|
20
22
|
factoryPoolImplementations: {
|
|
21
23
|
'0x2f956eee002b0debd468cf2e0490d1aec65e027f': {
|
|
@@ -68,6 +70,38 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
68
70
|
address: '0x2eb24483ef551da247ab87cf18e1cc980073032d',
|
|
69
71
|
basePoolAddress: '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2',
|
|
70
72
|
},
|
|
73
|
+
'0x008cfa89df5b0c780ca3462fc2602d7f8c7ac315': {
|
|
74
|
+
name: ImplementationNames.FACTORY_META_BTC_SBTC2,
|
|
75
|
+
address: '0x008cfa89df5b0c780ca3462fc2602d7f8c7ac315',
|
|
76
|
+
basePoolAddress: '0xf253f83AcA21aAbD2A20553AE0BF7F65C755A07F',
|
|
77
|
+
},
|
|
78
|
+
'0xabc533ebcdded41215c46ee078c5818b5b0a252f': {
|
|
79
|
+
name: ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2,
|
|
80
|
+
address: '0xabc533ebcdded41215c46ee078c5818b5b0a252f',
|
|
81
|
+
basePoolAddress: '0xf253f83AcA21aAbD2A20553AE0BF7F65C755A07F',
|
|
82
|
+
},
|
|
83
|
+
'0xc629a01ec23ab04e1050500a3717a2a5c0701497': {
|
|
84
|
+
name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
|
|
85
|
+
address: '0xc629a01ec23ab04e1050500a3717a2a5c0701497',
|
|
86
|
+
customGasCost: 130_000,
|
|
87
|
+
},
|
|
88
|
+
'0x94b4dfd9ba5865cc931195c99a2db42f3fc5d45b': {
|
|
89
|
+
name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA,
|
|
90
|
+
address: '0x94b4dfd9ba5865cc931195c99a2db42f3fc5d45b',
|
|
91
|
+
customGasCost: 130_000,
|
|
92
|
+
},
|
|
93
|
+
'0x847ee1227a9900b73aeeb3a47fac92c52fd54ed9': {
|
|
94
|
+
name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
|
|
95
|
+
address: '0x847ee1227a9900b73aeeb3a47fac92c52fd54ed9',
|
|
96
|
+
customGasCost: 130_000,
|
|
97
|
+
isStoreRateSupported: true,
|
|
98
|
+
},
|
|
99
|
+
'0x1713141278648a4edd5b027fdbd448bb4a13ac0f': {
|
|
100
|
+
name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
|
|
101
|
+
address: '0x1713141278648a4edd5b027fdbd448bb4a13ac0f',
|
|
102
|
+
customGasCost: 130_000,
|
|
103
|
+
isStoreRateSupported: true,
|
|
104
|
+
},
|
|
71
105
|
'0x24d937143d3f5cf04c72ba112735151a8cae2262': {
|
|
72
106
|
name: ImplementationNames.FACTORY_PLAIN_2_BALANCES,
|
|
73
107
|
address: '0x24d937143d3f5cf04c72ba112735151a8cae2262',
|
|
@@ -125,6 +159,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
125
159
|
liquidityApiSlug: '/main',
|
|
126
160
|
coinsInputType: 'uint256',
|
|
127
161
|
balancesInputType: 'uint256',
|
|
162
|
+
useForPricing: false,
|
|
128
163
|
},
|
|
129
164
|
'0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714': {
|
|
130
165
|
name: CustomImplementationNames.CUSTOM_PLAIN_3COIN_SBTC,
|
|
@@ -133,6 +168,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
133
168
|
liquidityApiSlug: '/main',
|
|
134
169
|
coinsInputType: 'int128',
|
|
135
170
|
balancesInputType: 'int128',
|
|
171
|
+
useForPricing: false,
|
|
136
172
|
},
|
|
137
173
|
'0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7': {
|
|
138
174
|
name: CustomImplementationNames.CUSTOM_PLAIN_3COIN_THREE,
|
|
@@ -141,6 +177,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
141
177
|
liquidityApiSlug: '/main',
|
|
142
178
|
coinsInputType: 'uint256',
|
|
143
179
|
balancesInputType: 'uint256',
|
|
180
|
+
useForPricing: false,
|
|
144
181
|
},
|
|
145
182
|
'0x93054188d876f558f4a66B2EF1d97d16eDf0895B': {
|
|
146
183
|
name: CustomImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC,
|
|
@@ -149,6 +186,16 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
149
186
|
liquidityApiSlug: '/main',
|
|
150
187
|
coinsInputType: 'int128',
|
|
151
188
|
balancesInputType: 'int128',
|
|
189
|
+
useForPricing: false,
|
|
190
|
+
},
|
|
191
|
+
'0xf253f83aca21aabd2a20553ae0bf7f65c755a07f': {
|
|
192
|
+
name: CustomImplementationNames.CUSTOM_PLAIN_2COIN_WBTC,
|
|
193
|
+
address: '0xf253f83aca21aabd2a20553ae0bf7f65c755a07f',
|
|
194
|
+
lpTokenAddress: '0x051d7e5609917Bd9b73f04BAc0DED8Dd46a74301',
|
|
195
|
+
liquidityApiSlug: '/main',
|
|
196
|
+
coinsInputType: 'uint256',
|
|
197
|
+
balancesInputType: 'uint256',
|
|
198
|
+
useForPricing: true,
|
|
152
199
|
},
|
|
153
200
|
},
|
|
154
201
|
},
|
|
@@ -245,6 +292,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
245
292
|
liquidityApiSlug: '/main',
|
|
246
293
|
coinsInputType: 'uint256',
|
|
247
294
|
balancesInputType: 'uint256',
|
|
295
|
+
useForPricing: false,
|
|
248
296
|
},
|
|
249
297
|
'0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67': {
|
|
250
298
|
name: CustomImplementationNames.CUSTOM_POLYGON_2COIN_LENDING,
|
|
@@ -253,6 +301,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
253
301
|
liquidityApiSlug: '/main',
|
|
254
302
|
coinsInputType: 'uint256',
|
|
255
303
|
balancesInputType: 'uint256',
|
|
304
|
+
useForPricing: false,
|
|
256
305
|
},
|
|
257
306
|
},
|
|
258
307
|
},
|
|
@@ -349,6 +398,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
349
398
|
liquidityApiSlug: '/main',
|
|
350
399
|
coinsInputType: 'uint256',
|
|
351
400
|
balancesInputType: 'uint256',
|
|
401
|
+
useForPricing: false,
|
|
352
402
|
},
|
|
353
403
|
'0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604': {
|
|
354
404
|
name: CustomImplementationNames.CUSTOM_FANTOM_2COIN_BTC,
|
|
@@ -357,15 +407,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
357
407
|
liquidityApiSlug: '/main',
|
|
358
408
|
coinsInputType: 'uint256',
|
|
359
409
|
balancesInputType: 'uint256',
|
|
410
|
+
useForPricing: false,
|
|
411
|
+
},
|
|
412
|
+
'0x0fa949783947Bf6c1b171DB13AEACBB488845B3f': {
|
|
413
|
+
name: CustomImplementationNames.CUSTOM_FANTOM_3COIN_LENDING,
|
|
414
|
+
address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
|
|
415
|
+
lpTokenAddress: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F',
|
|
416
|
+
liquidityApiSlug: '/main',
|
|
417
|
+
coinsInputType: 'uint256',
|
|
418
|
+
balancesInputType: 'uint256',
|
|
419
|
+
useForPricing: false,
|
|
360
420
|
},
|
|
361
|
-
// '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f': {
|
|
362
|
-
// name: CustomImplementationNames.CUSTOM_FANTOM_3COIN_LENDING,
|
|
363
|
-
// address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
|
|
364
|
-
// lpTokenAddress: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F',
|
|
365
|
-
// liquidityApiSlug: '/main',
|
|
366
|
-
// coinsInputType: 'uint256',
|
|
367
|
-
// balancesInputType: 'uint256',
|
|
368
|
-
// },
|
|
369
421
|
},
|
|
370
422
|
},
|
|
371
423
|
[Network.AVALANCHE]: {
|
|
@@ -454,6 +506,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
454
506
|
liquidityApiSlug: '/main',
|
|
455
507
|
coinsInputType: 'uint256',
|
|
456
508
|
balancesInputType: 'uint256',
|
|
509
|
+
useForPricing: false,
|
|
457
510
|
},
|
|
458
511
|
// This contract is not verified. I think it is just abandoned. I am commenting both related
|
|
459
512
|
// btc meta pools
|
|
@@ -549,6 +602,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
549
602
|
address: '0xF1f85a74AD6c64315F85af52d3d46bF715236ADc',
|
|
550
603
|
basePoolAddress: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb',
|
|
551
604
|
},
|
|
605
|
+
'0x73ec37618683c274d0bbf5f5726aa856b2bdab81': {
|
|
606
|
+
name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
|
|
607
|
+
address: '0x73ec37618683c274d0bbf5f5726aa856b2bdab81',
|
|
608
|
+
customGasCost: 130_000,
|
|
609
|
+
},
|
|
610
|
+
'0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5': {
|
|
611
|
+
name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
|
|
612
|
+
address: '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5',
|
|
613
|
+
customGasCost: 130_000,
|
|
614
|
+
isStoreRateSupported: true,
|
|
615
|
+
},
|
|
552
616
|
},
|
|
553
617
|
customPools: {
|
|
554
618
|
'0x7f90122BF0700F9E7e1F688fe926940E8839F353': {
|
|
@@ -558,6 +622,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
558
622
|
liquidityApiSlug: '/main',
|
|
559
623
|
coinsInputType: 'uint256',
|
|
560
624
|
balancesInputType: 'uint256',
|
|
625
|
+
useForPricing: false,
|
|
561
626
|
},
|
|
562
627
|
'0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5': {
|
|
563
628
|
name: FactoryImplementationNames.FACTORY_PLAIN_2_BASIC,
|
|
@@ -566,6 +631,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
566
631
|
liquidityApiSlug: '/factory',
|
|
567
632
|
coinsInputType: 'uint256',
|
|
568
633
|
balancesInputType: 'uint256',
|
|
634
|
+
useForPricing: false,
|
|
569
635
|
},
|
|
570
636
|
'0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb': {
|
|
571
637
|
name: CustomImplementationNames.CUSTOM_ARBITRUM_2COIN_BTC,
|
|
@@ -574,6 +640,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
574
640
|
liquidityApiSlug: '/main',
|
|
575
641
|
coinsInputType: 'uint256',
|
|
576
642
|
balancesInputType: 'uint256',
|
|
643
|
+
useForPricing: false,
|
|
577
644
|
},
|
|
578
645
|
},
|
|
579
646
|
},
|
|
@@ -651,6 +718,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
651
718
|
address: '0x114C4042B11a2b16F58Fe1BFe847589a122F678a',
|
|
652
719
|
basePoolAddress: '0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7',
|
|
653
720
|
},
|
|
721
|
+
'0x73ec37618683c274d0bbf5f5726aa856b2bdab81': {
|
|
722
|
+
name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
|
|
723
|
+
address: '0x73ec37618683c274d0bbf5f5726aa856b2bdab81',
|
|
724
|
+
customGasCost: 130_000,
|
|
725
|
+
},
|
|
726
|
+
'0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5': {
|
|
727
|
+
name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
|
|
728
|
+
address: '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5',
|
|
729
|
+
customGasCost: 130_000,
|
|
730
|
+
isStoreRateSupported: true,
|
|
731
|
+
},
|
|
654
732
|
},
|
|
655
733
|
customPools: {
|
|
656
734
|
'0x1337BedC9D22ecbe766dF105c9623922A27963EC': {
|
|
@@ -660,6 +738,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
660
738
|
liquidityApiSlug: '/main',
|
|
661
739
|
coinsInputType: 'uint256',
|
|
662
740
|
balancesInputType: 'uint256',
|
|
741
|
+
useForPricing: false,
|
|
663
742
|
},
|
|
664
743
|
'0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7': {
|
|
665
744
|
name: FactoryImplementationNames.FACTORY_PLAIN_2_BASIC,
|
|
@@ -668,6 +747,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
668
747
|
liquidityApiSlug: '/factory',
|
|
669
748
|
coinsInputType: 'uint256',
|
|
670
749
|
balancesInputType: 'uint256',
|
|
750
|
+
useForPricing: false,
|
|
671
751
|
},
|
|
672
752
|
},
|
|
673
753
|
},
|
|
@@ -761,6 +841,7 @@ const configAddressesNormalizer = (
|
|
|
761
841
|
balancesInputType: customPoolConfig.balancesInputType,
|
|
762
842
|
address: normalizeAddress(customPoolConfig.address),
|
|
763
843
|
lpTokenAddress: normalizeAddress(customPoolConfig.lpTokenAddress),
|
|
844
|
+
useForPricing: customPoolConfig.useForPricing,
|
|
764
845
|
};
|
|
765
846
|
acc[normalizeAddress(customPoolAddress)] = normalizedImplementation;
|
|
766
847
|
return acc;
|
|
@@ -777,6 +858,7 @@ const configAddressesNormalizer = (
|
|
|
777
858
|
basePoolAddress: implementationConfig.basePoolAddress
|
|
778
859
|
? normalizeAddress(implementationConfig.basePoolAddress)
|
|
779
860
|
: undefined,
|
|
861
|
+
isStoreRateSupported: implementationConfig.isStoreRateSupported,
|
|
780
862
|
};
|
|
781
863
|
acc[normalizeAddress(implementationAddress)] =
|
|
782
864
|
normalizedImplementation;
|