@paraswap/dex-lib 4.7.13-from-amount-pos.0 → 4.7.13-unified-pair-restriction.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/abi/{apex-defi/ApexDefiRouter.abi.json → BProtocol.json} +573 -538
- package/build/abi/Jarvis.json +1172 -0
- package/build/abi/{apex-defi/ApexDefiFactory.abi.json → MStableAsset.json} +781 -985
- package/build/abi/{apex-defi/ApexDefiWrapperFactory.abi.json → OneInchLp.json} +766 -569
- package/build/abi/Onebit.json +736 -0
- package/build/abi/Shell.json +1294 -0
- package/build/abi/TraderJoeV2Router.json +50 -0
- package/build/abi/wUSDM.json +757 -0
- package/build/abi/zrx.v2.json +1967 -0
- package/build/abi/zrx.v3.json +3454 -0
- package/build/abi/zrx.v4.json +2193 -0
- package/build/dex/OneInchLp.d.ts +24 -0
- package/build/dex/OneInchLp.js +43 -0
- package/build/dex/OneInchLp.js.map +1 -0
- package/build/dex/bProtocol/bProtocol.d.ts +15 -0
- package/build/dex/bProtocol/bProtocol.js +56 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -0
- package/build/dex/bProtocol/types.d.ts +11 -0
- package/build/dex/bProtocol/types.js +8 -0
- package/build/dex/bProtocol/types.js.map +1 -0
- package/build/dex/cables/cables.d.ts +1 -1
- package/build/dex/cables/cables.js +1 -1
- package/build/dex/cables/cables.js.map +1 -1
- package/build/dex/dexalot/dexalot.d.ts +0 -3
- package/build/dex/dexalot/dexalot.js +9 -17
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.d.ts +1 -1
- package/build/dex/generic-rfq/generic-rfq.js +54 -44
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/types.d.ts +3 -0
- package/build/dex/generic-rfq/types.js +6 -0
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/hashflow/hashflow.js +2 -1
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/idex.d.ts +6 -0
- package/build/dex/jarvis.d.ts +56 -0
- package/build/dex/jarvis.js +163 -0
- package/build/dex/jarvis.js.map +1 -0
- package/build/dex/limit-order-exchange.js +1 -0
- package/build/dex/limit-order-exchange.js.map +1 -1
- package/build/dex/mStable.d.ts +44 -0
- package/build/dex/mStable.js +75 -0
- package/build/dex/mStable.js.map +1 -0
- package/build/dex/onebit/onebit.d.ts +16 -0
- package/build/dex/onebit/onebit.js +61 -0
- package/build/dex/onebit/onebit.js.map +1 -0
- package/build/dex/onebit/types.d.ts +14 -0
- package/build/dex/onebit/types.js +8 -0
- package/build/dex/onebit/types.js.map +1 -0
- package/build/dex/{yo → se-vlr}/config.d.ts +1 -1
- package/build/dex/se-vlr/config.js +24 -0
- package/build/dex/se-vlr/config.js.map +1 -0
- package/build/dex/{stabull/stabull-pool.d.ts → se-vlr/se-vlr-pool.d.ts} +6 -13
- package/build/dex/se-vlr/se-vlr-pool.js +70 -0
- package/build/dex/se-vlr/se-vlr-pool.js.map +1 -0
- package/build/dex/se-vlr/se-vlr.d.ts +35 -0
- package/build/dex/se-vlr/se-vlr.js +131 -0
- package/build/dex/se-vlr/se-vlr.js.map +1 -0
- package/build/dex/se-vlr/types.d.ts +6 -0
- package/build/dex/{yo → se-vlr}/types.js.map +1 -1
- package/build/dex/shell.d.ts +25 -0
- package/build/dex/shell.js +41 -0
- package/build/dex/shell.js.map +1 -0
- package/build/dex/simple-exchange-with-restrictions.d.ts +10 -2
- package/build/dex/simple-exchange-with-restrictions.js +30 -1
- package/build/dex/simple-exchange-with-restrictions.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.d.ts +1 -3
- package/build/dex/swaap-v2/swaap-v2.js +11 -24
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swaap-v2/utils.d.ts +1 -0
- package/build/dex/swaap-v2/utils.js +7 -1
- package/build/dex/swaap-v2/utils.js.map +1 -1
- package/build/dex/trader-joe-v2.d.ts +40 -0
- package/build/dex/trader-joe-v2.js +74 -0
- package/build/dex/trader-joe-v2.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +0 -6
- package/build/dex/uniswap-v4/contract-math/Position.js +0 -29
- package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -1
- package/build/dex/{stabull → usual-bond}/config.d.ts +1 -1
- 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/{apex-defi → usual-bond}/types.js.map +1 -1
- package/build/dex/{aave-pt-to-underlying/aave-pt-to-underlying.d.ts → usual-bond/usual-bond.d.ts} +18 -23
- package/build/dex/usual-bond/usual-bond.js +176 -0
- package/build/dex/usual-bond/usual-bond.js.map +1 -0
- package/build/dex/wusdm/config.d.ts +3 -0
- package/build/dex/wusdm/config.js +43 -0
- package/build/dex/wusdm/config.js.map +1 -0
- package/build/dex/wusdm/constants.d.ts +2 -0
- package/build/dex/wusdm/constants.js +6 -0
- package/build/dex/wusdm/constants.js.map +1 -0
- package/build/dex/wusdm/types.d.ts +18 -0
- package/build/dex/wusdm/types.js +11 -0
- package/build/dex/wusdm/types.js.map +1 -0
- package/build/dex/wusdm/wusdm-pool.d.ts +21 -0
- package/build/dex/wusdm/wusdm-pool.js +74 -0
- package/build/dex/wusdm/wusdm-pool.js.map +1 -0
- package/build/dex/wusdm/wusdm.d.ts +46 -0
- package/build/dex/wusdm/wusdm.js +243 -0
- package/build/dex/wusdm/wusdm.js.map +1 -0
- package/build/dex/zerox/config.d.ts +2 -0
- package/build/dex/zerox/config.js +33 -0
- package/build/dex/zerox/config.js.map +1 -0
- package/build/dex/zerox/index.d.ts +22 -0
- package/build/dex/zerox/index.js +225 -0
- package/build/dex/zerox/index.js.map +1 -0
- package/build/dex/zerox/order.d.ts +88 -0
- package/build/dex/zerox/order.js +53 -0
- package/build/dex/zerox/order.js.map +1 -0
- package/build/dex/zerox/types.d.ts +73 -0
- package/build/dex/zerox/types.js +21 -0
- package/build/dex/zerox/types.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.js +4 -10
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/pricing-helper.d.ts +2 -1
- package/build/pricing-helper.js +22 -3
- package/build/pricing-helper.js.map +1 -1
- package/package.json +1 -1
- package/build/abi/PendleRouterStatic.json +0 -19
- package/build/abi/apex-defi/ApexDefiToken.abi.json +0 -229
- package/build/abi/apex-defi/ApexDefiWrapper.abi.json +0 -92
- package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +0 -796
- package/build/abi/pendle/pendle-deployer.abi.json +0 -520
- package/build/abi/pendle/pendle-oracle.abi.json +0 -413
- package/build/abi/ring-v2/few-wrapped-token.json +0 -587
- package/build/abi/ring-v2/ring-v2-factory.json +0 -125
- package/build/abi/ring-v2/ring-v2-pool.json +0 -461
- package/build/abi/ring-v2/ring-v2-router.json +0 -332
- package/build/abi/stabull/stabull-curve.json +0 -738
- package/build/abi/stabull/stabull-router.json +0 -76
- package/build/abi/uniswap-v4/hooks/SpotDynamicFeeManager.json +0 -26
- package/build/abi/uniswap-v4/hooks/SpotHook.json +0 -54
- package/build/abi/uniswap-v4/hooks/SpotPolicyManager.json +0 -45
- package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +0 -682
- package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +0 -1335
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.d.ts +0 -29
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js +0 -153
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js.map +0 -1
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +0 -323
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +0 -1
- package/build/dex/aave-pt-to-underlying/config.d.ts +0 -3
- package/build/dex/aave-pt-to-underlying/config.js +0 -24
- package/build/dex/aave-pt-to-underlying/config.js.map +0 -1
- package/build/dex/aave-pt-to-underlying/constants.d.ts +0 -2
- package/build/dex/aave-pt-to-underlying/constants.js +0 -6
- package/build/dex/aave-pt-to-underlying/constants.js.map +0 -1
- package/build/dex/aave-pt-to-underlying/types.d.ts +0 -24
- package/build/dex/aave-pt-to-underlying/types.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +0 -39
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +0 -244
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/config.d.ts +0 -3
- package/build/dex/aave-pt-to-usdc/config.js +0 -47
- package/build/dex/aave-pt-to-usdc/config.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/constants.d.ts +0 -2
- package/build/dex/aave-pt-to-usdc/constants.js +0 -6
- package/build/dex/aave-pt-to-usdc/constants.js.map +0 -1
- package/build/dex/aave-pt-to-usdc/types.d.ts +0 -22
- package/build/dex/aave-pt-to-usdc/types.js.map +0 -1
- package/build/dex/apex-defi/apex-defi-factory.d.ts +0 -26
- package/build/dex/apex-defi/apex-defi-factory.js +0 -53
- package/build/dex/apex-defi/apex-defi-factory.js.map +0 -1
- package/build/dex/apex-defi/apex-defi-pool.d.ts +0 -55
- package/build/dex/apex-defi/apex-defi-pool.js +0 -247
- package/build/dex/apex-defi/apex-defi-pool.js.map +0 -1
- package/build/dex/apex-defi/apex-defi-wrapper-factory.d.ts +0 -57
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js +0 -250
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js.map +0 -1
- package/build/dex/apex-defi/apex-defi.d.ts +0 -97
- package/build/dex/apex-defi/apex-defi.js +0 -1021
- package/build/dex/apex-defi/apex-defi.js.map +0 -1
- package/build/dex/apex-defi/config.d.ts +0 -4
- package/build/dex/apex-defi/config.js +0 -138
- package/build/dex/apex-defi/config.js.map +0 -1
- package/build/dex/apex-defi/types.d.ts +0 -32
- package/build/dex/apex-defi/types.js +0 -3
- package/build/dex/apex-defi/utils.d.ts +0 -46
- package/build/dex/apex-defi/utils.js +0 -133
- package/build/dex/apex-defi/utils.js.map +0 -1
- package/build/dex/maker-psm/maker-psm-event-pool.d.ts +0 -43
- package/build/dex/maker-psm/maker-psm-event-pool.js +0 -132
- package/build/dex/maker-psm/maker-psm-event-pool.js.map +0 -1
- package/build/dex/miro-migrator/miro-migrator-state.d.ts +0 -27
- package/build/dex/miro-migrator/miro-migrator-state.js +0 -89
- package/build/dex/miro-migrator/miro-migrator-state.js.map +0 -1
- package/build/dex/stabull/config.js +0 -177
- package/build/dex/stabull/config.js.map +0 -1
- package/build/dex/stabull/stabull-pool.js +0 -113
- package/build/dex/stabull/stabull-pool.js.map +0 -1
- package/build/dex/stabull/stabull.d.ts +0 -55
- package/build/dex/stabull/stabull.js +0 -286
- package/build/dex/stabull/stabull.js.map +0 -1
- package/build/dex/stabull/types.d.ts +0 -21
- package/build/dex/stabull/types.js +0 -3
- package/build/dex/stabull/types.js.map +0 -1
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +0 -4
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +0 -56
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +0 -7
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +0 -28
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +0 -2
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +0 -7
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +0 -28
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js +0 -2
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/index.d.ts +0 -1
- package/build/dex/uniswap-v4/hooks/index.js +0 -9
- package/build/dex/uniswap-v4/hooks/index.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/spot.d.ts +0 -15
- package/build/dex/uniswap-v4/hooks/spot.js +0 -109
- package/build/dex/uniswap-v4/hooks/spot.js.map +0 -1
- package/build/dex/uniswap-v4/hooks/template.d.ts +0 -150
- package/build/dex/uniswap-v4/hooks/template.js +0 -104
- package/build/dex/uniswap-v4/hooks/template.js.map +0 -1
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +0 -26
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +0 -75
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +0 -1
- package/build/dex/usual/usual-usdc-usdc.d.ts +0 -17
- package/build/dex/usual/usual-usdc-usdc.js +0 -59
- package/build/dex/usual/usual-usdc-usdc.js.map +0 -1
- package/build/dex/yo/config.js +0 -21
- package/build/dex/yo/config.js.map +0 -1
- package/build/dex/yo/types.d.ts +0 -13
- package/build/dex/yo/types.js +0 -3
- package/build/dex/yo/yo-pool.d.ts +0 -13
- package/build/dex/yo/yo-pool.js +0 -26
- package/build/dex/yo/yo-pool.js.map +0 -1
- package/build/dex/yo/yo.d.ts +0 -39
- package/build/dex/yo/yo.js +0 -248
- package/build/dex/yo/yo.js.map +0 -1
- package/build/implementations/api-paraswap-sdk.d.ts +0 -25
- package/build/implementations/api-paraswap-sdk.js +0 -102
- package/build/implementations/api-paraswap-sdk.js.map +0 -1
- /package/build/dex/{aave-pt-to-underlying → se-vlr}/types.js +0 -0
- /package/build/dex/{aave-pt-to-usdc → usual-bond}/types.js +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../../constants';
|
|
3
|
+
import { AdapterExchangeParam, Address, DexExchangeParam, NumberAsString, SimpleExchangeParam } from '../../types';
|
|
4
|
+
import { IDexTxBuilder } from '../idex';
|
|
5
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper';
|
|
7
|
+
import { OnebitData, OnebitParam } from './types';
|
|
8
|
+
export declare class Onebit extends SimpleExchange implements IDexTxBuilder<OnebitData, OnebitParam> {
|
|
9
|
+
static dexKeys: string[];
|
|
10
|
+
exchangeRouterInterface: Interface;
|
|
11
|
+
needWrapNative: boolean;
|
|
12
|
+
constructor(dexHelper: IDexHelper);
|
|
13
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OnebitData, side: SwapSide): AdapterExchangeParam;
|
|
14
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OnebitData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
15
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: OnebitData, _side: SwapSide): DexExchangeParam;
|
|
16
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.Onebit = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
10
|
+
const Onebit_json_1 = __importDefault(require("../../abi/Onebit.json"));
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const utils_1 = require("../../executor/utils");
|
|
13
|
+
class Onebit extends simple_exchange_1.SimpleExchange {
|
|
14
|
+
constructor(dexHelper) {
|
|
15
|
+
super(dexHelper, 'omm1');
|
|
16
|
+
this.needWrapNative = true;
|
|
17
|
+
this.exchangeRouterInterface = new abi_1.Interface(Onebit_json_1.default);
|
|
18
|
+
}
|
|
19
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
20
|
+
return {
|
|
21
|
+
targetExchange: data.router,
|
|
22
|
+
payload: '0x',
|
|
23
|
+
networkFee: '0',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
27
|
+
const swapFunction = types_1.OnebitFunctions.swapTokensWithTrust;
|
|
28
|
+
const swapFunctionParams = [
|
|
29
|
+
srcToken,
|
|
30
|
+
destToken,
|
|
31
|
+
srcAmount,
|
|
32
|
+
destAmount,
|
|
33
|
+
this.augustusAddress,
|
|
34
|
+
];
|
|
35
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
36
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.router);
|
|
37
|
+
}
|
|
38
|
+
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, _side) {
|
|
39
|
+
const swapFunction = types_1.OnebitFunctions.swapTokensWithTrust;
|
|
40
|
+
const swapFunctionParams = [
|
|
41
|
+
srcToken,
|
|
42
|
+
destToken,
|
|
43
|
+
srcAmount,
|
|
44
|
+
destAmount,
|
|
45
|
+
recipient,
|
|
46
|
+
];
|
|
47
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
48
|
+
return {
|
|
49
|
+
needWrapNative: this.needWrapNative,
|
|
50
|
+
dexFuncHasRecipient: true,
|
|
51
|
+
exchangeData: swapData,
|
|
52
|
+
targetExchange: data.router,
|
|
53
|
+
returnAmountPos: _side === constants_1.SwapSide.SELL
|
|
54
|
+
? (0, utils_1.extractReturnAmountPosition)(this.exchangeRouterInterface, swapFunction)
|
|
55
|
+
: undefined,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Onebit = Onebit;
|
|
60
|
+
Onebit.dexKeys = ['omm1'];
|
|
61
|
+
//# sourceMappingURL=onebit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onebit.js","sourceRoot":"","sources":["../../../src/dex/onebit/onebit.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAE7D,+CAA2C;AAS3C,wDAAoD;AACpD,wEAA8C;AAE9C,mCAAmE;AACnE,gDAAmE;AAEnE,MAAa,MACX,SAAQ,gCAAc;IAOtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAH3B,mBAAc,GAAG,IAAI,CAAC;QAIpB,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,qBAA2B,CAAC,CAAC;IAC5E,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,MAAM;YAC3B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,MAAM,YAAY,GAAG,uBAAe,CAAC,mBAAmB,CAAC;QACzD,MAAM,kBAAkB,GAAgB;YACtC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAI,CAAC,eAAe;SACrB,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,WAAW,CACT,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,SAAkB,EAClB,IAAgB,EAChB,KAAe;QAEf,MAAM,YAAY,GAAG,uBAAe,CAAC,mBAAmB,CAAC;QACzD,MAAM,kBAAkB,GAAgB;YACtC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,SAAS;SACV,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,MAAM;YAC3B,eAAe,EACb,KAAK,KAAK,oBAAQ,CAAC,IAAI;gBACrB,CAAC,CAAC,IAAA,mCAA2B,EACzB,IAAI,CAAC,uBAAuB,EAC5B,YAAY,CACb;gBACH,CAAC,CAAC,SAAS;SAChB,CAAC;IACJ,CAAC;;AA9FH,wBA+FC;AA3FQ,cAAO,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address } from '@paraswap/core';
|
|
2
|
+
export declare type OnebitData = {
|
|
3
|
+
router: Address;
|
|
4
|
+
};
|
|
5
|
+
export declare type OnebitParam = [
|
|
6
|
+
srcToken: string,
|
|
7
|
+
destToken: string,
|
|
8
|
+
srcAmount: string,
|
|
9
|
+
destAmountMin: string,
|
|
10
|
+
to: string
|
|
11
|
+
];
|
|
12
|
+
export declare enum OnebitFunctions {
|
|
13
|
+
swapTokensWithTrust = "swapTokensWithTrust"
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnebitFunctions = void 0;
|
|
4
|
+
var OnebitFunctions;
|
|
5
|
+
(function (OnebitFunctions) {
|
|
6
|
+
OnebitFunctions["swapTokensWithTrust"] = "swapTokensWithTrust";
|
|
7
|
+
})(OnebitFunctions = exports.OnebitFunctions || (exports.OnebitFunctions = {}));
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/onebit/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,8DAA2C,CAAA;AAC7C,CAAC,EAFW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAE1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeVlrConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.SeVlrConfig = {
|
|
6
|
+
seVLR: {
|
|
7
|
+
[constants_1.Network.MAINNET]: {
|
|
8
|
+
contractAddress: '0x40000320d200c110100638040f10500c8f0010b9',
|
|
9
|
+
VLR: '0x4e107a0000db66f0e9fd2039288bf811dd1f9c74',
|
|
10
|
+
WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
11
|
+
},
|
|
12
|
+
[constants_1.Network.BASE]: {
|
|
13
|
+
contractAddress: '0x40000320d200c110100638040f10500c8f0010b9',
|
|
14
|
+
VLR: '0x4e107a0000db66f0e9fd2039288bf811dd1f9c74',
|
|
15
|
+
WETH: '0x4200000000000000000000000000000000000006 ',
|
|
16
|
+
},
|
|
17
|
+
[constants_1.Network.OPTIMISM]: {
|
|
18
|
+
contractAddress: '0x40000320d200c110100638040f10500c8f0010b9',
|
|
19
|
+
VLR: '0x4e107a0000db66f0e9fd2039288bf811dd1f9c74',
|
|
20
|
+
WETH: '0x4200000000000000000000000000000000000006 ',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,WAAW,GAA4B;IAClD,KAAK,EAAE;QACL,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,eAAe,EAAE,4CAA4C;YAC7D,GAAG,EAAE,4CAA4C;YACjD,IAAI,EAAE,4CAA4C;SACnD;QACD,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;YACd,eAAe,EAAE,4CAA4C;YAC7D,GAAG,EAAE,4CAA4C;YACjD,IAAI,EAAE,6CAA6C;SACpD;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,eAAe,EAAE,4CAA4C;YAC7D,GAAG,EAAE,4CAA4C;YACjD,IAAI,EAAE,6CAA6C;SACpD;KACF;CACF,CAAC"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
1
2
|
import { DeepReadonly } from 'ts-essentials';
|
|
2
3
|
import { Log, Logger } from '../../types';
|
|
3
4
|
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
4
5
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
6
|
import { PoolState } from './types';
|
|
6
|
-
export declare class
|
|
7
|
+
export declare class SeVlrEventPool extends StatefulEventSubscriber<PoolState> {
|
|
7
8
|
readonly parentName: string;
|
|
8
9
|
protected network: number;
|
|
9
10
|
protected dexHelper: IDexHelper;
|
|
10
|
-
|
|
11
|
-
protected addressesSubscribed_: string[];
|
|
11
|
+
protected seVlrIface: Interface;
|
|
12
12
|
handlers: {
|
|
13
13
|
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
|
|
14
14
|
};
|
|
15
15
|
logDecoder: (log: Log) => any;
|
|
16
|
-
|
|
16
|
+
addressesSubscribed: string[];
|
|
17
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, seVlrIface?: Interface);
|
|
17
18
|
/**
|
|
18
19
|
* The function is called every time any of the subscribed
|
|
19
20
|
* addresses release log. The function accepts the current
|
|
@@ -34,13 +35,5 @@ export declare class StabullEventPool extends StatefulEventSubscriber<PoolState>
|
|
|
34
35
|
* @returns state of the event subscriber at blocknumber
|
|
35
36
|
*/
|
|
36
37
|
generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
|
|
37
|
-
|
|
38
|
-
* Handles a transfer event and updates the pool state accordingly.
|
|
39
|
-
*
|
|
40
|
-
* @param event - The transfer event object containing details about the transfer.
|
|
41
|
-
* @param state - The current state of the pool.
|
|
42
|
-
* @param log - The log object containing additional information about the event.
|
|
43
|
-
* @returns The updated pool state if the transfer involves the pool, otherwise null.
|
|
44
|
-
*/
|
|
45
|
-
handleTransfer(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
38
|
+
handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
46
39
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeVlrEventPool = 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 SeVlrEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
+
parentName;
|
|
9
|
+
network;
|
|
10
|
+
dexHelper;
|
|
11
|
+
seVlrIface;
|
|
12
|
+
handlers = {};
|
|
13
|
+
logDecoder;
|
|
14
|
+
addressesSubscribed;
|
|
15
|
+
constructor(parentName, network, dexHelper, logger, seVlrIface = new abi_1.Interface('' /* TODO: Import and put here SeVlr ABI */)) {
|
|
16
|
+
// TODO: Add pool name
|
|
17
|
+
super(parentName, 'POOL_NAME', dexHelper, logger);
|
|
18
|
+
this.parentName = parentName;
|
|
19
|
+
this.network = network;
|
|
20
|
+
this.dexHelper = dexHelper;
|
|
21
|
+
this.seVlrIface = seVlrIface;
|
|
22
|
+
// TODO: make logDecoder decode logs that
|
|
23
|
+
this.logDecoder = (log) => this.seVlrIface.parseLog(log);
|
|
24
|
+
this.addressesSubscribed = [
|
|
25
|
+
/* subscribed addresses */
|
|
26
|
+
];
|
|
27
|
+
// Add handlers
|
|
28
|
+
this.handlers['myEvent'] = this.handleMyEvent.bind(this);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The function is called every time any of the subscribed
|
|
32
|
+
* addresses release log. The function accepts the current
|
|
33
|
+
* state, updates the state according to the log, and returns
|
|
34
|
+
* the updated state.
|
|
35
|
+
* @param state - Current state of event subscriber
|
|
36
|
+
* @param log - Log released by one of the subscribed addresses
|
|
37
|
+
* @returns Updates state of the event subscriber after the log
|
|
38
|
+
*/
|
|
39
|
+
processLog(state, log) {
|
|
40
|
+
try {
|
|
41
|
+
const event = this.logDecoder(log);
|
|
42
|
+
if (event.name in this.handlers) {
|
|
43
|
+
return this.handlers[event.name](event, state, log);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The function generates state using on-chain calls. This
|
|
53
|
+
* function is called to regenerate state if the event based
|
|
54
|
+
* system fails to fetch events and the local state is no
|
|
55
|
+
* more correct.
|
|
56
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
57
|
+
* should be generated
|
|
58
|
+
* @returns state of the event subscriber at blocknumber
|
|
59
|
+
*/
|
|
60
|
+
async generateState(blockNumber) {
|
|
61
|
+
// TODO: complete me!
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
// Its just a dummy example
|
|
65
|
+
handleMyEvent(event, state, log) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.SeVlrEventPool = SeVlrEventPool;
|
|
70
|
+
//# sourceMappingURL=se-vlr-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"se-vlr-pool.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/se-vlr-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,cAAe,SAAQ,mDAAkC;IAczD;IACC;IACA;IAEA;IAjBZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,mBAAmB,CAAW;IAE9B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,aAAa,IAAI,eAAS,CAClC,EAAE,CAAC,yCAAyC,CAC7C;QAED,sBAAsB;QACtB,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QATzC,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,eAAU,GAAV,UAAU,CAEnB;QAKD,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9D,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,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;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;AAlFD,wCAkFC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, 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 { SeVlrData } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { SeVlrEventPool } from './se-vlr-pool';
|
|
9
|
+
export declare class SeVlr extends SimpleExchange implements IDex<SeVlrData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected eventPools: SeVlrEventPool;
|
|
14
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
15
|
+
readonly needWrapNative = true;
|
|
16
|
+
readonly isFeeOnTransferSupported = false;
|
|
17
|
+
static dexKeysWithNetwork: {
|
|
18
|
+
key: string;
|
|
19
|
+
networks: Network[];
|
|
20
|
+
}[];
|
|
21
|
+
logger: Logger;
|
|
22
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
23
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
24
|
+
getAdapters(side: SwapSide): {
|
|
25
|
+
name: string;
|
|
26
|
+
index: number;
|
|
27
|
+
}[] | null;
|
|
28
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
29
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<SeVlrData>>;
|
|
30
|
+
getCalldataGasCost(poolPrices: PoolPrices<SeVlrData>): number | number[];
|
|
31
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: SeVlrData, side: SwapSide): AdapterExchangeParam;
|
|
32
|
+
updatePoolState(): Promise<void>;
|
|
33
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
34
|
+
releaseResources(): AsyncOrSync<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SeVlr = void 0;
|
|
37
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
38
|
+
const utils_1 = require("../../utils");
|
|
39
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
40
|
+
const config_1 = require("./config");
|
|
41
|
+
const se_vlr_pool_1 = require("./se-vlr-pool");
|
|
42
|
+
class SeVlr extends simple_exchange_1.SimpleExchange {
|
|
43
|
+
network;
|
|
44
|
+
dexKey;
|
|
45
|
+
dexHelper;
|
|
46
|
+
eventPools;
|
|
47
|
+
hasConstantPriceLargeAmounts = false;
|
|
48
|
+
// TODO: set true here if protocols works only with wrapped asset
|
|
49
|
+
needWrapNative = true;
|
|
50
|
+
isFeeOnTransferSupported = false;
|
|
51
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SeVlrConfig);
|
|
52
|
+
logger;
|
|
53
|
+
constructor(network, dexKey, dexHelper) {
|
|
54
|
+
super(dexHelper, dexKey);
|
|
55
|
+
this.network = network;
|
|
56
|
+
this.dexKey = dexKey;
|
|
57
|
+
this.dexHelper = dexHelper;
|
|
58
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
59
|
+
this.eventPools = new se_vlr_pool_1.SeVlrEventPool(dexKey, network, dexHelper, this.logger);
|
|
60
|
+
}
|
|
61
|
+
// Initialize pricing is called once in the start of
|
|
62
|
+
// pricing service. It is intended to setup the integration
|
|
63
|
+
// for pricing requests. It is optional for a DEX to
|
|
64
|
+
// implement this function
|
|
65
|
+
async initializePricing(blockNumber) {
|
|
66
|
+
// TODO: complete me!
|
|
67
|
+
}
|
|
68
|
+
// Legacy: was only used for V5
|
|
69
|
+
// Returns the list of contract adapters (name and index)
|
|
70
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
71
|
+
getAdapters(side) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Returns list of pool identifiers that can be used
|
|
75
|
+
// for a given swap. poolIdentifiers must be unique
|
|
76
|
+
// across DEXes. It is recommended to use
|
|
77
|
+
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
78
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
79
|
+
// TODO: complete me!
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
// Returns pool prices for amounts.
|
|
83
|
+
// If limitPools is defined only pools in limitPools
|
|
84
|
+
// should be used. If limitPools is undefined then
|
|
85
|
+
// any pools can be used.
|
|
86
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
87
|
+
// TODO: complete me!
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
91
|
+
getCalldataGasCost(poolPrices) {
|
|
92
|
+
// TODO: update if there is any payload in getAdapterParam
|
|
93
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
94
|
+
}
|
|
95
|
+
// Encode params required by the exchange adapter
|
|
96
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
97
|
+
// V6: Not used, can be left blank
|
|
98
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
99
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
100
|
+
// TODO: complete me!
|
|
101
|
+
const { exchange } = data;
|
|
102
|
+
// Encode here the payload for adapter
|
|
103
|
+
const payload = '';
|
|
104
|
+
return {
|
|
105
|
+
targetExchange: exchange,
|
|
106
|
+
payload,
|
|
107
|
+
networkFee: '0',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// This is called once before getTopPoolsForToken is
|
|
111
|
+
// called for multiple tokens. This can be helpful to
|
|
112
|
+
// update common state required for calculating
|
|
113
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
114
|
+
// to implement this
|
|
115
|
+
async updatePoolState() {
|
|
116
|
+
// TODO: complete me!
|
|
117
|
+
}
|
|
118
|
+
// Returns list of top pools based on liquidity. Max
|
|
119
|
+
// limit number pools should be returned.
|
|
120
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
121
|
+
//TODO: complete me!
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
125
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
126
|
+
releaseResources() {
|
|
127
|
+
// TODO: complete me!
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.SeVlr = SeVlr;
|
|
131
|
+
//# sourceMappingURL=se-vlr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"se-vlr.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/se-vlr.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAAuC;AACvC,+CAA+C;AAE/C,MAAa,KAAM,SAAQ,gCAAc;IAe5B;IACA;IACA;IAhBD,UAAU,CAAiB;IAE5B,4BAA4B,GAAG,KAAK,CAAC;IAC9C,iEAAiE;IACxD,cAAc,GAAG,IAAI,CAAC;IAEtB,wBAAwB,GAAG,KAAK,CAAC;IAEnC,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,oBAAW,CAAC,CAAC;IAErC,MAAM,CAAS;IAEf,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB;QAE9B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAJhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QAG9B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,IAAI,4BAAc,CAClC,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,+BAA+B;IAC/B,yDAAyD;IACzD,wDAAwD;IACxD,WAAW,CAAC,IAAc;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oDAAoD;IACpD,mDAAmD;IACnD,yCAAyC;IACzC,+CAA+C;IAC/C,KAAK,CAAC,kBAAkB,CACtB,QAAe,EACf,SAAgB,EAChB,IAAc,EACd,WAAmB;QAEnB,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,mCAAmC;IACnC,oDAAoD;IACpD,kDAAkD;IAClD,yBAAyB;IACzB,KAAK,CAAC,eAAe,CACnB,QAAe,EACf,SAAgB,EAChB,OAAiB,EACjB,IAAc,EACd,WAAmB,EACnB,UAAqB;QAErB,qBAAqB;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,kBAAkB,CAAC,UAAiC;QAClD,0DAA0D;QAC1D,OAAO,iBAAiB,CAAC,cAAc,CAAC;IAC1C,CAAC;IAED,iDAAiD;IACjD,yCAAyC;IACzC,kCAAkC;IAClC,mDAAmD;IACnD,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,qBAAqB;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,sCAAsC;QACtC,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,OAAO;YACL,cAAc,EAAE,QAAQ;YACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;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;;AAhIH,sBAiIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../constants';
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../dex-helper';
|
|
7
|
+
export declare type ShellData = {
|
|
8
|
+
exchange: Address;
|
|
9
|
+
deadline?: number;
|
|
10
|
+
};
|
|
11
|
+
declare type ShellParam = [
|
|
12
|
+
_origin: string,
|
|
13
|
+
_target: string,
|
|
14
|
+
_originAmount: string,
|
|
15
|
+
_minTargetAmount: string,
|
|
16
|
+
_deadline: string
|
|
17
|
+
];
|
|
18
|
+
export declare class Shell extends SimpleExchange implements IDexTxBuilder<ShellData, ShellParam> {
|
|
19
|
+
static dexKeys: string[];
|
|
20
|
+
exchangeRouterInterface: Interface;
|
|
21
|
+
constructor(dexHelper: IDexHelper);
|
|
22
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: ShellData, side: SwapSide): AdapterExchangeParam;
|
|
23
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: ShellData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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.Shell = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const Shell_json_1 = __importDefault(require("../abi/Shell.json"));
|
|
10
|
+
var ShellFunctions;
|
|
11
|
+
(function (ShellFunctions) {
|
|
12
|
+
ShellFunctions["originSwap"] = "originSwap";
|
|
13
|
+
})(ShellFunctions || (ShellFunctions = {}));
|
|
14
|
+
class Shell extends simple_exchange_1.SimpleExchange {
|
|
15
|
+
constructor(dexHelper) {
|
|
16
|
+
super(dexHelper, 'shell');
|
|
17
|
+
this.exchangeRouterInterface = new abi_1.Interface(Shell_json_1.default);
|
|
18
|
+
}
|
|
19
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
20
|
+
return {
|
|
21
|
+
targetExchange: data.exchange,
|
|
22
|
+
payload: '0x',
|
|
23
|
+
networkFee: '0',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
27
|
+
const swapFunction = ShellFunctions.originSwap;
|
|
28
|
+
const swapFunctionParams = [
|
|
29
|
+
srcToken,
|
|
30
|
+
destToken,
|
|
31
|
+
srcAmount,
|
|
32
|
+
destAmount,
|
|
33
|
+
(0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
34
|
+
];
|
|
35
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
36
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Shell = Shell;
|
|
40
|
+
Shell.dexKeys = ['shell'];
|
|
41
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/dex/shell.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAI7D,uDAG2B;AAC3B,mEAAyC;AAczC,IAAK,cAEJ;AAFD,WAAK,cAAc;IACjB,2CAAyB,CAAA;AAC3B,CAAC,EAFI,cAAc,KAAd,cAAc,QAElB;AAED,MAAa,KACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,oBAA0B,CAAC,CAAC;IAC3E,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,MAAM,YAAY,GAAG,cAAc,CAAC,UAAU,CAAC;QAC/C,MAAM,kBAAkB,GAAe;YACrC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAA,uDAAqC,GAAE;SACxC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;;AAxDH,sBAyDC;AArDQ,aAAO,GAAG,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
import { SimpleExchange } from './simple-exchange';
|
|
2
2
|
import { IDexHelper } from '../dex-helper';
|
|
3
3
|
import { Logger } from '../types';
|
|
4
|
-
import { IDexWithBlacklist, IDexWithRestriction } from './idex';
|
|
4
|
+
import { IDexWithBlacklist, IDexWithPairRestriction, IDexWithRestriction } from './idex';
|
|
5
5
|
type CACHE_TTL = number | 'none';
|
|
6
6
|
type DexRestrictionOptions = {
|
|
7
7
|
blacklistedTTL?: CACHE_TTL;
|
|
8
8
|
enableDexRestriction?: boolean;
|
|
9
|
+
enablePairRestriction?: boolean;
|
|
9
10
|
restrictCheckIntervalMs?: number;
|
|
10
11
|
restrictCountThreshold?: number;
|
|
11
12
|
restrictTtlS?: number;
|
|
13
|
+
restrictPairTtlS?: number;
|
|
12
14
|
};
|
|
13
|
-
export declare class SimpleExchangeWithRestrictions extends SimpleExchange implements IDexWithRestriction, IDexWithBlacklist {
|
|
15
|
+
export declare class SimpleExchangeWithRestrictions extends SimpleExchange implements IDexWithRestriction, IDexWithPairRestriction, IDexWithBlacklist {
|
|
14
16
|
protected readonly dexHelper: IDexHelper;
|
|
15
17
|
dexKey: string;
|
|
16
18
|
protected readonly blacklistedTTL: CACHE_TTL;
|
|
17
19
|
protected readonly enableDexRestriction: boolean;
|
|
20
|
+
protected readonly enablePairRestriction: boolean;
|
|
18
21
|
protected restrictCheckIntervalMs: number;
|
|
19
22
|
protected restrictCountThreshold: number;
|
|
20
23
|
protected restrictTtlS: number;
|
|
24
|
+
protected restrictPairTtlS: number;
|
|
21
25
|
protected logger: Logger;
|
|
22
26
|
constructor(dexHelper: IDexHelper, dexKey: string, options?: DexRestrictionOptions);
|
|
23
27
|
hasDexRestriction(): this is IDexWithRestriction;
|
|
28
|
+
hasPairRestriction(): this is IDexWithPairRestriction;
|
|
24
29
|
hasBlacklist(): this is IDexWithBlacklist;
|
|
25
30
|
isBlacklisted(address: string): Promise<boolean>;
|
|
26
31
|
protected setBlacklist(addresses: string[], ttl?: CACHE_TTL): Promise<void>;
|
|
27
32
|
addBlacklistedAddress(address: string, ttl?: CACHE_TTL): Promise<boolean>;
|
|
28
33
|
getBlacklistedCacheKey(address: string): string;
|
|
34
|
+
getRestrictedPairCacheKey(token0: string, token1: string): string;
|
|
29
35
|
getRestrictedCacheKey(): string;
|
|
30
36
|
isRestricted(): Promise<boolean>;
|
|
37
|
+
isRestrictedPair(token0: string, token1: string): Promise<boolean>;
|
|
38
|
+
protected restrictPair(token0: string, token1: string, ttl?: number): Promise<boolean>;
|
|
31
39
|
protected restrict(): Promise<void>;
|
|
32
40
|
}
|
|
33
41
|
export {};
|
|
@@ -6,19 +6,23 @@ const utils_1 = require("../utils");
|
|
|
6
6
|
const ERRORS_CACHE_KEY = 'errors';
|
|
7
7
|
const RESTRICT_CHECK_INTERVAL_MS = 1000 * 60 * 3; // 3 min
|
|
8
8
|
const RESTRICT_COUNT_THRESHOLD = 3;
|
|
9
|
-
const RESTRICT_TTL_S = 10 * 60; // 10 min
|
|
9
|
+
const RESTRICT_TTL_S = 10 * 60; // 10 min
|
|
10
|
+
const RESTRICT_PAIR_TTL_S = 15 * 60; // 15 min
|
|
10
11
|
const RESTRICTED_CACHE_VALUE = 'restricted';
|
|
11
12
|
const BLACKLISTED_CACHE_VALUE = 'blacklisted';
|
|
12
13
|
const DEFAULT_BLACKLISTED_TTL_S = 180 * 60; // 3 hours
|
|
13
14
|
const DEFAULT_ENABLE_DEX_RESTRICTION = false;
|
|
15
|
+
const DEFAULT_ENABLE_PAIR_RESTRICTION = false;
|
|
14
16
|
class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
15
17
|
dexHelper;
|
|
16
18
|
dexKey;
|
|
17
19
|
blacklistedTTL;
|
|
18
20
|
enableDexRestriction;
|
|
21
|
+
enablePairRestriction;
|
|
19
22
|
restrictCheckIntervalMs;
|
|
20
23
|
restrictCountThreshold;
|
|
21
24
|
restrictTtlS;
|
|
25
|
+
restrictPairTtlS;
|
|
22
26
|
logger;
|
|
23
27
|
constructor(dexHelper, dexKey, options = {}) {
|
|
24
28
|
super(dexHelper, dexKey);
|
|
@@ -28,15 +32,21 @@ class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
|
28
32
|
this.blacklistedTTL = options.blacklistedTTL ?? DEFAULT_BLACKLISTED_TTL_S;
|
|
29
33
|
this.enableDexRestriction =
|
|
30
34
|
options.enableDexRestriction ?? DEFAULT_ENABLE_DEX_RESTRICTION;
|
|
35
|
+
this.enablePairRestriction =
|
|
36
|
+
options.enablePairRestriction ?? DEFAULT_ENABLE_PAIR_RESTRICTION;
|
|
31
37
|
this.restrictCheckIntervalMs =
|
|
32
38
|
options.restrictCheckIntervalMs ?? RESTRICT_CHECK_INTERVAL_MS;
|
|
33
39
|
this.restrictCountThreshold =
|
|
34
40
|
options.restrictCountThreshold ?? RESTRICT_COUNT_THRESHOLD;
|
|
35
41
|
this.restrictTtlS = options.restrictTtlS ?? RESTRICT_TTL_S;
|
|
42
|
+
this.restrictPairTtlS = options.restrictPairTtlS ?? RESTRICT_PAIR_TTL_S;
|
|
36
43
|
}
|
|
37
44
|
hasDexRestriction() {
|
|
38
45
|
return this.enableDexRestriction;
|
|
39
46
|
}
|
|
47
|
+
hasPairRestriction() {
|
|
48
|
+
return this.enablePairRestriction;
|
|
49
|
+
}
|
|
40
50
|
hasBlacklist() {
|
|
41
51
|
return true; // make configurable if makes sense
|
|
42
52
|
}
|
|
@@ -76,6 +86,15 @@ class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
|
76
86
|
getBlacklistedCacheKey(address) {
|
|
77
87
|
return `${this.network}_${this.dexKey}_blacklisted_${address.toLowerCase()}`;
|
|
78
88
|
}
|
|
89
|
+
getRestrictedPairCacheKey(token0, token1) {
|
|
90
|
+
const pair = [
|
|
91
|
+
this.dexHelper.config.wrapETH(token0).toLowerCase(),
|
|
92
|
+
this.dexHelper.config.wrapETH(token1).toLowerCase(),
|
|
93
|
+
]
|
|
94
|
+
.sort()
|
|
95
|
+
.join('_');
|
|
96
|
+
return `${this.network}_${this.dexKey}_restricted_pair_${pair}`;
|
|
97
|
+
}
|
|
79
98
|
getRestrictedCacheKey() {
|
|
80
99
|
return `${this.network}_${this.dexKey}_restricted`;
|
|
81
100
|
}
|
|
@@ -83,6 +102,16 @@ class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
|
83
102
|
const cached = await this.dexHelper.cache.rawget(this.getRestrictedCacheKey());
|
|
84
103
|
return cached !== null;
|
|
85
104
|
}
|
|
105
|
+
async isRestrictedPair(token0, token1) {
|
|
106
|
+
const cached = await this.dexHelper.cache.rawget(this.getRestrictedPairCacheKey(token0, token1));
|
|
107
|
+
return cached !== null;
|
|
108
|
+
}
|
|
109
|
+
async restrictPair(token0, token1, ttl = this.restrictPairTtlS) {
|
|
110
|
+
const key = this.getRestrictedPairCacheKey(token0, token1);
|
|
111
|
+
return this.dexHelper.cache
|
|
112
|
+
.rawset(key, RESTRICTED_CACHE_VALUE, ttl)
|
|
113
|
+
.then(() => true);
|
|
114
|
+
}
|
|
86
115
|
async restrict() {
|
|
87
116
|
const errorsDataRaw = await this.dexHelper.cache.get(this.dexKey, this.network, ERRORS_CACHE_KEY);
|
|
88
117
|
const errorsData = utils_1.Utils.Parse(errorsDataRaw);
|