@paraswap/dex-lib 4.2.14 → 4.2.15
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/BProtocol.json +1155 -0
- package/build/abi/Jarvis.json +1172 -0
- package/build/abi/MStableAsset.json +1545 -0
- package/build/abi/OneInchLp.json +1304 -0
- package/build/abi/Onebit.json +736 -0
- package/build/abi/Shell.json +1294 -0
- package/build/abi/TraderJoeV2Router.json +50 -0
- package/build/abi/algebra-integral/Quoter.abi.json +231 -0
- package/build/abi/algebra-integral/SwapRouter.abi.json +810 -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/algebra-integral/algebra-integral.d.ts +43 -0
- package/build/dex/algebra-integral/algebra-integral.js +446 -0
- package/build/dex/algebra-integral/algebra-integral.js.map +1 -0
- package/build/dex/algebra-integral/config.d.ts +3 -0
- package/build/dex/algebra-integral/config.js +17 -0
- package/build/dex/algebra-integral/config.js.map +1 -0
- package/build/dex/algebra-integral/types.d.ts +33 -0
- package/build/dex/algebra-integral/types.js +10 -0
- package/build/dex/algebra-integral/types.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/jarvis.d.ts +56 -0
- package/build/dex/jarvis.js +163 -0
- package/build/dex/jarvis.js.map +1 -0
- package/build/dex/lido/lido.d.ts +3 -2
- package/build/dex/lido/lido.js +8 -8
- package/build/dex/lido/lido.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/shell.d.ts +25 -0
- package/build/dex/shell.js +41 -0
- package/build/dex/shell.js.map +1 -0
- 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/{miro-migrator → 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/usual-bond/types.js +3 -0
- package/build/dex/usual-bond/types.js.map +1 -0
- package/build/dex/usual-bond/usual-bond.d.ts +35 -0
- package/build/dex/usual-bond/usual-bond.js +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/{miro-migrator/miro-migrator.d.ts → wusdm/wusdm.d.ts} +24 -17
- 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/types.d.ts +2 -1
- package/package.json +1 -1
- package/build/abi/miro-migrator/MiroMigrator.abi.json +0 -540
- package/build/dex/miro-migrator/config.js +0 -14
- package/build/dex/miro-migrator/config.js.map +0 -1
- package/build/dex/miro-migrator/constants.d.ts +0 -1
- package/build/dex/miro-migrator/constants.js +0 -5
- package/build/dex/miro-migrator/constants.js.map +0 -1
- package/build/dex/miro-migrator/miro-migrator.js +0 -152
- package/build/dex/miro-migrator/miro-migrator.js.map +0 -1
- package/build/dex/miro-migrator/types.d.ts +0 -10
- package/build/dex/miro-migrator/types.js +0 -8
- package/build/dex/miro-migrator/types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/algebra-integral/types.ts"],"names":[],"mappings":";;;AAiCA,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,qDAAyB,CAAA;IACzB,uDAA2B,CAAA;IAC3B,oGAAwE,CAAA;AAC1E,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { BProtocolData, BProtocolParam } from './types';
|
|
8
|
+
export declare class BProtocol extends SimpleExchange implements IDexTxBuilder<BProtocolData, BProtocolParam> {
|
|
9
|
+
static dexKeys: string[];
|
|
10
|
+
exchangeRouterInterface: Interface;
|
|
11
|
+
constructor(dexHelper: IDexHelper);
|
|
12
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BProtocolData, side: SwapSide): AdapterExchangeParam;
|
|
13
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: BProtocolData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
14
|
+
getDexParam(_srcToken: Address, _destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: BProtocolData, _side: SwapSide): DexExchangeParam;
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.BProtocol = 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 BProtocol_json_1 = __importDefault(require("../../abi/BProtocol.json"));
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const utils_1 = require("../../executor/utils");
|
|
13
|
+
class BProtocol extends simple_exchange_1.SimpleExchange {
|
|
14
|
+
constructor(dexHelper) {
|
|
15
|
+
super(dexHelper, 'bprotocol');
|
|
16
|
+
this.exchangeRouterInterface = new abi_1.Interface(BProtocol_json_1.default);
|
|
17
|
+
}
|
|
18
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
19
|
+
return {
|
|
20
|
+
targetExchange: data.exchange,
|
|
21
|
+
payload: '0x',
|
|
22
|
+
networkFee: '0',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
26
|
+
const swapFunction = types_1.BProtocolFunctions.swap;
|
|
27
|
+
const swapFunctionParams = [
|
|
28
|
+
srcAmount,
|
|
29
|
+
destAmount,
|
|
30
|
+
this.augustusAddress,
|
|
31
|
+
];
|
|
32
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
33
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
|
|
34
|
+
}
|
|
35
|
+
getDexParam(_srcToken, _destToken, srcAmount, destAmount, recipient, data, _side) {
|
|
36
|
+
const swapFunction = types_1.BProtocolFunctions.swap;
|
|
37
|
+
const swapFunctionParams = [
|
|
38
|
+
srcAmount,
|
|
39
|
+
destAmount,
|
|
40
|
+
recipient,
|
|
41
|
+
];
|
|
42
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
43
|
+
return {
|
|
44
|
+
needWrapNative: this.needWrapNative,
|
|
45
|
+
dexFuncHasRecipient: true,
|
|
46
|
+
exchangeData: swapData,
|
|
47
|
+
targetExchange: data.exchange,
|
|
48
|
+
returnAmountPos: _side === constants_1.SwapSide.SELL
|
|
49
|
+
? (0, utils_1.extractReturnAmountPosition)(this.exchangeRouterInterface, swapFunction)
|
|
50
|
+
: undefined,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.BProtocol = BProtocol;
|
|
55
|
+
BProtocol.dexKeys = ['bprotocol'];
|
|
56
|
+
//# sourceMappingURL=bProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bProtocol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AU;YACV,SAAS;SACV,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QACF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,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;;AA1FH,8BA2FC;AAvFQ,iBAAO,GAAG,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BProtocolFunctions = void 0;
|
|
4
|
+
var BProtocolFunctions;
|
|
5
|
+
(function (BProtocolFunctions) {
|
|
6
|
+
BProtocolFunctions["swap"] = "swap";
|
|
7
|
+
})(BProtocolFunctions = exports.BProtocolFunctions || (exports.BProtocolFunctions = {}));
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/bProtocol/types.ts"],"names":[],"mappings":";;;AAUA,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;AACf,CAAC,EAFW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAE7B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
export declare type JarvisData = {
|
|
8
|
+
derivatives: string;
|
|
9
|
+
destDerivatives?: string;
|
|
10
|
+
pools: string[];
|
|
11
|
+
fee: string;
|
|
12
|
+
method: JarvisFunctions;
|
|
13
|
+
router: Address;
|
|
14
|
+
};
|
|
15
|
+
declare type JarvisMintParam = [
|
|
16
|
+
derivative: string,
|
|
17
|
+
minNumTokens: string,
|
|
18
|
+
collateralAmount: string,
|
|
19
|
+
feePercentage: string,
|
|
20
|
+
expiration: string,
|
|
21
|
+
recipient: string
|
|
22
|
+
];
|
|
23
|
+
declare type JarvisRedeemParam = [
|
|
24
|
+
derivative: string,
|
|
25
|
+
numTokens: string,
|
|
26
|
+
minCollateral: string,
|
|
27
|
+
feePercentage: string,
|
|
28
|
+
expiration: string,
|
|
29
|
+
recipient: string
|
|
30
|
+
];
|
|
31
|
+
declare type JarvisExchangeParam = [
|
|
32
|
+
derivative: string,
|
|
33
|
+
destPool: string,
|
|
34
|
+
destDerivative: string,
|
|
35
|
+
numTokens: string,
|
|
36
|
+
minDestNumTokens: string,
|
|
37
|
+
feePercentage: string,
|
|
38
|
+
expiration: string,
|
|
39
|
+
recipient: string
|
|
40
|
+
];
|
|
41
|
+
declare type JarvisParam = JarvisExchangeParam | JarvisMintParam | JarvisRedeemParam;
|
|
42
|
+
declare enum JarvisFunctions {
|
|
43
|
+
mint = "mint",
|
|
44
|
+
redeem = "redeem",
|
|
45
|
+
exchange = "exchange"
|
|
46
|
+
}
|
|
47
|
+
export declare class Jarvis extends SimpleExchange implements IDexTxBuilder<JarvisData, JarvisParam> {
|
|
48
|
+
static dexKeys: string[];
|
|
49
|
+
poolInterface: Interface;
|
|
50
|
+
needWrapNative: boolean;
|
|
51
|
+
constructor(dexHelper: IDexHelper);
|
|
52
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: JarvisData, side: SwapSide): AdapterExchangeParam;
|
|
53
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: JarvisData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
54
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: JarvisData, side: SwapSide): DexExchangeParam;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
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.Jarvis = 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 Jarvis_json_1 = __importDefault(require("../abi/Jarvis.json"));
|
|
11
|
+
const utils_1 = require("../executor/utils");
|
|
12
|
+
const THIRTY_MINUTES = 60 * 30;
|
|
13
|
+
var JarvisFunctions;
|
|
14
|
+
(function (JarvisFunctions) {
|
|
15
|
+
JarvisFunctions["mint"] = "mint";
|
|
16
|
+
JarvisFunctions["redeem"] = "redeem";
|
|
17
|
+
JarvisFunctions["exchange"] = "exchange";
|
|
18
|
+
})(JarvisFunctions || (JarvisFunctions = {}));
|
|
19
|
+
class Jarvis extends simple_exchange_1.SimpleExchange {
|
|
20
|
+
constructor(dexHelper) {
|
|
21
|
+
super(dexHelper, 'jarvis');
|
|
22
|
+
this.needWrapNative = false;
|
|
23
|
+
this.poolInterface = new abi_1.Interface(Jarvis_json_1.default);
|
|
24
|
+
}
|
|
25
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
26
|
+
const { method } = data;
|
|
27
|
+
const type = [
|
|
28
|
+
JarvisFunctions.mint,
|
|
29
|
+
JarvisFunctions.redeem,
|
|
30
|
+
JarvisFunctions.exchange,
|
|
31
|
+
].indexOf(method);
|
|
32
|
+
if (type === undefined) {
|
|
33
|
+
throw new Error(`Jarvis: Invalid OpType ${method}, Should be one of ['mint', 'exchange', 'redeem']`);
|
|
34
|
+
}
|
|
35
|
+
const payload = this.abiCoder.encodeParameter({
|
|
36
|
+
ParentStruct: {
|
|
37
|
+
opType: 'uint',
|
|
38
|
+
derivatives: 'address',
|
|
39
|
+
destDerivatives: 'address',
|
|
40
|
+
fee: 'uint128',
|
|
41
|
+
destPool: 'address',
|
|
42
|
+
expiration: 'uint128',
|
|
43
|
+
},
|
|
44
|
+
}, {
|
|
45
|
+
opType: type,
|
|
46
|
+
derivatives: data.derivatives,
|
|
47
|
+
destDerivatives: data.destDerivatives || constants_1.NULL_ADDRESS,
|
|
48
|
+
fee: data.fee,
|
|
49
|
+
destPool: data.pools[1] || constants_1.NULL_ADDRESS,
|
|
50
|
+
expiration: (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0),
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
targetExchange: data.pools[0],
|
|
54
|
+
payload,
|
|
55
|
+
networkFee: '0',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
59
|
+
const swapFunction = data.method;
|
|
60
|
+
const timestamp = (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0);
|
|
61
|
+
let swapFunctionParams;
|
|
62
|
+
switch (swapFunction) {
|
|
63
|
+
case JarvisFunctions.mint:
|
|
64
|
+
swapFunctionParams = [
|
|
65
|
+
data.derivatives,
|
|
66
|
+
destAmount,
|
|
67
|
+
srcAmount,
|
|
68
|
+
data.fee,
|
|
69
|
+
timestamp,
|
|
70
|
+
this.augustusAddress,
|
|
71
|
+
];
|
|
72
|
+
break;
|
|
73
|
+
case JarvisFunctions.redeem:
|
|
74
|
+
swapFunctionParams = [
|
|
75
|
+
data.derivatives,
|
|
76
|
+
srcAmount,
|
|
77
|
+
destAmount,
|
|
78
|
+
data.fee,
|
|
79
|
+
timestamp,
|
|
80
|
+
this.augustusAddress,
|
|
81
|
+
];
|
|
82
|
+
break;
|
|
83
|
+
case JarvisFunctions.exchange:
|
|
84
|
+
swapFunctionParams = [
|
|
85
|
+
data.derivatives,
|
|
86
|
+
data.pools[1],
|
|
87
|
+
data.destDerivatives,
|
|
88
|
+
srcAmount,
|
|
89
|
+
destAmount,
|
|
90
|
+
data.fee,
|
|
91
|
+
timestamp,
|
|
92
|
+
this.augustusAddress,
|
|
93
|
+
];
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Unknown function ${swapFunction}`);
|
|
97
|
+
}
|
|
98
|
+
const swapData = this.poolInterface.encodeFunctionData(swapFunction, [
|
|
99
|
+
swapFunctionParams,
|
|
100
|
+
]);
|
|
101
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.pools[0]);
|
|
102
|
+
}
|
|
103
|
+
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
104
|
+
const swapFunction = data.method;
|
|
105
|
+
const timestamp = (Date.now() / 1000 + THIRTY_MINUTES).toFixed(0);
|
|
106
|
+
let swapFunctionParams;
|
|
107
|
+
let outputName;
|
|
108
|
+
switch (swapFunction) {
|
|
109
|
+
case JarvisFunctions.mint:
|
|
110
|
+
swapFunctionParams = [
|
|
111
|
+
data.derivatives,
|
|
112
|
+
destAmount,
|
|
113
|
+
srcAmount,
|
|
114
|
+
data.fee,
|
|
115
|
+
timestamp,
|
|
116
|
+
recipient,
|
|
117
|
+
];
|
|
118
|
+
outputName = 'syntheticTokensMinted';
|
|
119
|
+
break;
|
|
120
|
+
case JarvisFunctions.redeem:
|
|
121
|
+
swapFunctionParams = [
|
|
122
|
+
data.derivatives,
|
|
123
|
+
srcAmount,
|
|
124
|
+
destAmount,
|
|
125
|
+
data.fee,
|
|
126
|
+
timestamp,
|
|
127
|
+
recipient,
|
|
128
|
+
];
|
|
129
|
+
outputName = 'collateralRedeemed';
|
|
130
|
+
break;
|
|
131
|
+
case JarvisFunctions.exchange:
|
|
132
|
+
swapFunctionParams = [
|
|
133
|
+
data.derivatives,
|
|
134
|
+
data.pools[1],
|
|
135
|
+
data.destDerivatives,
|
|
136
|
+
srcAmount,
|
|
137
|
+
destAmount,
|
|
138
|
+
data.fee,
|
|
139
|
+
timestamp,
|
|
140
|
+
recipient,
|
|
141
|
+
];
|
|
142
|
+
outputName = 'destNumTokensMinted';
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
throw new Error(`Unknown function ${swapFunction}`);
|
|
146
|
+
}
|
|
147
|
+
const swapData = this.poolInterface.encodeFunctionData(swapFunction, [
|
|
148
|
+
swapFunctionParams,
|
|
149
|
+
]);
|
|
150
|
+
return {
|
|
151
|
+
needWrapNative: this.needWrapNative,
|
|
152
|
+
dexFuncHasRecipient: true,
|
|
153
|
+
exchangeData: swapData,
|
|
154
|
+
targetExchange: data.pools[0],
|
|
155
|
+
returnAmountPos: side === constants_1.SwapSide.SELL
|
|
156
|
+
? (0, utils_1.extractReturnAmountPosition)(this.poolInterface, swapFunction, outputName)
|
|
157
|
+
: undefined,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.Jarvis = Jarvis;
|
|
162
|
+
Jarvis.dexKeys = ['jarvis'];
|
|
163
|
+
//# sourceMappingURL=jarvis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jarvis.js","sourceRoot":"","sources":["../../src/dex/jarvis.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAStD,uDAAmD;AACnD,qEAA2C;AAG3C,6CAAgE;AAEhE,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC;AA0C/B,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,gCAAa,CAAA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B,CAAC;gBACnC,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;SACvD;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,YAAY,EAAE;YACnE,kBAAkB;SACnB,CAAC,CAAC;QAEH,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7B,eAAe,EACb,IAAI,KAAK,oBAAQ,CAAC,IAAI;gBACpB,CAAC,CAAC,IAAA,mCAA2B,EACzB,IAAI,CAAC,aAAa,EAClB,YAAY,EACZ,UAAU,CACX;gBACH,CAAC,CAAC,SAAS;SAChB,CAAC;IACJ,CAAC;;AApMH,wBAqMC;AAjMQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC"}
|
package/build/dex/lido/lido.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export declare class Lido implements IDexTxBuilder<LidoData, any> {
|
|
|
9
9
|
stETHInterface: Interface;
|
|
10
10
|
erc20Interface: Interface;
|
|
11
11
|
needWrapNative: boolean;
|
|
12
|
-
private network;
|
|
13
|
-
private
|
|
12
|
+
private readonly network;
|
|
13
|
+
private readonly referralAddress;
|
|
14
|
+
private readonly wethAddress;
|
|
14
15
|
constructor(dexHelper: IDexHelper);
|
|
15
16
|
getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): AdapterExchangeParam;
|
|
16
17
|
getSimpleParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): Promise<SimpleExchangeParam>;
|
package/build/dex/lido/lido.js
CHANGED
|
@@ -5,25 +5,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Lido = void 0;
|
|
7
7
|
const abi_1 = require("@ethersproject/abi");
|
|
8
|
-
const core_1 = require("@paraswap/core");
|
|
9
8
|
const stETH_json_1 = __importDefault(require("../../abi/stETH.json"));
|
|
10
9
|
const constants_1 = require("../../constants");
|
|
11
10
|
const types_1 = require("./types");
|
|
12
11
|
const config_1 = require("./config");
|
|
13
12
|
const types_2 = require("../weth/types");
|
|
14
13
|
const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
|
|
15
|
-
const utils_1 = require("../../executor/utils");
|
|
16
14
|
class Lido {
|
|
17
15
|
static dexKeys = ['lido'];
|
|
18
16
|
stETHInterface;
|
|
19
17
|
erc20Interface;
|
|
20
18
|
needWrapNative = false;
|
|
21
19
|
network;
|
|
22
|
-
|
|
20
|
+
referralAddress;
|
|
21
|
+
wethAddress;
|
|
23
22
|
constructor(dexHelper) {
|
|
24
23
|
this.network = dexHelper.config.data.network;
|
|
25
24
|
this.stETHInterface = new abi_1.Interface(stETH_json_1.default);
|
|
26
25
|
this.erc20Interface = new abi_1.Interface(erc20_json_1.default);
|
|
26
|
+
this.referralAddress =
|
|
27
|
+
dexHelper.config.data.lidoReferralAddress ?? constants_1.NULL_ADDRESS;
|
|
28
|
+
this.wethAddress =
|
|
29
|
+
dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
27
30
|
}
|
|
28
31
|
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
29
32
|
return {
|
|
@@ -33,7 +36,7 @@ class Lido {
|
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
36
|
-
const swapData = this.stETHInterface.encodeFunctionData(types_1.stETHFunctions.submit, [
|
|
39
|
+
const swapData = this.stETHInterface.encodeFunctionData(types_1.stETHFunctions.submit, [this.referralAddress]);
|
|
37
40
|
return {
|
|
38
41
|
callees: [config_1.stETH[this.network]],
|
|
39
42
|
calldata: [swapData],
|
|
@@ -45,7 +48,7 @@ class Lido {
|
|
|
45
48
|
return tokenAddress.toLowerCase() === this.wethAddress;
|
|
46
49
|
}
|
|
47
50
|
getDexParam(srcToken, _destToken, srcAmount, _destAmount, _recipient, _data, _side) {
|
|
48
|
-
const swapData = this.stETHInterface.encodeFunctionData(types_1.stETHFunctions.submit, [
|
|
51
|
+
const swapData = this.stETHInterface.encodeFunctionData(types_1.stETHFunctions.submit, [this.referralAddress]);
|
|
49
52
|
return {
|
|
50
53
|
needWrapNative: this.needWrapNative,
|
|
51
54
|
dexFuncHasRecipient: false,
|
|
@@ -56,9 +59,6 @@ class Lido {
|
|
|
56
59
|
srcAmount,
|
|
57
60
|
])
|
|
58
61
|
: undefined,
|
|
59
|
-
returnAmountPos: _side === core_1.SwapSide.SELL
|
|
60
|
-
? (0, utils_1.extractReturnAmountPosition)(this.stETHInterface, types_1.stETHFunctions.submit)
|
|
61
|
-
: undefined,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lido.js","sourceRoot":"","sources":["../../../src/dex/lido/lido.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;
|
|
1
|
+
{"version":3,"file":"lido.js","sourceRoot":"","sources":["../../../src/dex/lido/lido.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAS7D,sEAA4C;AAC5C,+CAA+C;AAE/C,mCAAmD;AACnD,qCAAiC;AACjC,yCAA8C;AAC9C,sEAA4C;AAE5C,MAAa,IAAI;IACf,MAAM,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,cAAc,CAAY;IAC1B,cAAc,CAAY;IAE1B,cAAc,GAAG,KAAK,CAAC;IAEN,OAAO,CAAS;IAChB,eAAe,CAAU;IACzB,WAAW,CAAU;IAEtC,YAAY,SAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,IAA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,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACrD,sBAAc,CAAC,MAAM,EACrB,CAAC,IAAI,CAAC,eAAe,CAAC,CACvB,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,mBAAmB,EAAE,KAAK;YAC1B,YAAY,EAAE,QAAQ;YACtB,cAAc,EAAE,cAAK,CAAC,IAAI,CAAC,OAAO,CAAC;YACnC,qBAAqB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAC1C,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,qBAAa,CAAC,QAAQ,EAAE;oBAC7D,SAAS;iBACV,CAAC;gBACJ,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;;AAvFH,oBAwFC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../constants';
|
|
3
|
+
import { AdapterExchangeParam, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../dex-helper';
|
|
7
|
+
declare enum MStableFunctions {
|
|
8
|
+
mint = "mint",
|
|
9
|
+
swap = "swap",
|
|
10
|
+
redeem = "redeem"
|
|
11
|
+
}
|
|
12
|
+
declare type MStableData = {
|
|
13
|
+
exchange: string;
|
|
14
|
+
opType: MStableFunctions;
|
|
15
|
+
isAssetContract: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare type MStableMint = [
|
|
18
|
+
_input: string,
|
|
19
|
+
_inputQuantity: string,
|
|
20
|
+
_minOutputQuantity: string,
|
|
21
|
+
_recipient: string
|
|
22
|
+
];
|
|
23
|
+
declare type MStableSwap = [
|
|
24
|
+
_input: string,
|
|
25
|
+
_output: string,
|
|
26
|
+
_inputQuantity: string,
|
|
27
|
+
_minOutputQuantity: string,
|
|
28
|
+
_recipient: string
|
|
29
|
+
];
|
|
30
|
+
declare type MStableRedeem = [
|
|
31
|
+
_output: string,
|
|
32
|
+
_mAssetQuantity: string,
|
|
33
|
+
_minOutputQuantity: string,
|
|
34
|
+
_recipient: string
|
|
35
|
+
];
|
|
36
|
+
declare type MStableParam = MStableMint | MStableSwap | MStableRedeem;
|
|
37
|
+
export declare class MStable extends SimpleExchange implements IDexTxBuilder<MStableData, MStableParam> {
|
|
38
|
+
static dexKeys: string[];
|
|
39
|
+
mStableAsset: Interface;
|
|
40
|
+
constructor(dexHelper: IDexHelper);
|
|
41
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MStableData, side: SwapSide): AdapterExchangeParam;
|
|
42
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MStableData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
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.MStable = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const MStableAsset_json_1 = __importDefault(require("../abi/MStableAsset.json"));
|
|
10
|
+
var MStableFunctions;
|
|
11
|
+
(function (MStableFunctions) {
|
|
12
|
+
MStableFunctions["mint"] = "mint";
|
|
13
|
+
MStableFunctions["swap"] = "swap";
|
|
14
|
+
MStableFunctions["redeem"] = "redeem";
|
|
15
|
+
})(MStableFunctions || (MStableFunctions = {}));
|
|
16
|
+
class MStable extends simple_exchange_1.SimpleExchange {
|
|
17
|
+
constructor(dexHelper) {
|
|
18
|
+
super(dexHelper, 'mStable');
|
|
19
|
+
this.mStableAsset = new abi_1.Interface(MStableAsset_json_1.default);
|
|
20
|
+
}
|
|
21
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
22
|
+
const { opType } = data;
|
|
23
|
+
const type = [
|
|
24
|
+
MStableFunctions.swap,
|
|
25
|
+
MStableFunctions.mint,
|
|
26
|
+
MStableFunctions.redeem,
|
|
27
|
+
].indexOf(opType);
|
|
28
|
+
if (type === undefined) {
|
|
29
|
+
throw new Error(`mStable: Invalid OpType ${opType}, Should be one of ['mint', 'swap', 'redeem']`);
|
|
30
|
+
}
|
|
31
|
+
const payload = this.abiCoder.encodeParameter({
|
|
32
|
+
ParentStruct: {
|
|
33
|
+
opType: 'uint',
|
|
34
|
+
},
|
|
35
|
+
}, {
|
|
36
|
+
opType: type,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
targetExchange: data.exchange,
|
|
40
|
+
payload,
|
|
41
|
+
networkFee: '0',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
45
|
+
const { opType, isAssetContract } = data;
|
|
46
|
+
const [swapFunction, swapFunctionsParams] = (() => {
|
|
47
|
+
switch (opType) {
|
|
48
|
+
case MStableFunctions.mint:
|
|
49
|
+
return [
|
|
50
|
+
opType,
|
|
51
|
+
[srcToken, srcAmount, destAmount, this.augustusAddress],
|
|
52
|
+
];
|
|
53
|
+
case MStableFunctions.swap:
|
|
54
|
+
return [
|
|
55
|
+
opType,
|
|
56
|
+
[srcToken, destToken, srcAmount, destAmount, this.augustusAddress],
|
|
57
|
+
];
|
|
58
|
+
case MStableFunctions.redeem:
|
|
59
|
+
return [
|
|
60
|
+
opType,
|
|
61
|
+
[destToken, srcAmount, destAmount, this.augustusAddress],
|
|
62
|
+
];
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`mStable's OpType ${opType} not supported, failed to build`);
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
// mStableAsset & mStablePool both have the same interface hence we can
|
|
68
|
+
// simply use mStableAsset contract
|
|
69
|
+
const swapData = this.mStableAsset.encodeFunctionData(swapFunction, swapFunctionsParams);
|
|
70
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.MStable = MStable;
|
|
74
|
+
MStable.dexKeys = ['mStable'];
|
|
75
|
+
//# sourceMappingURL=mStable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mStable.js","sourceRoot":"","sources":["../../src/dex/mStable.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAK7D,uDAAmD;AACnD,iFAAuD;AAIvD,IAAK,gBAIJ;AAJD,WAAK,gBAAgB;IACnB,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,qCAAiB,CAAA;AACnB,CAAC,EAJI,gBAAgB,KAAhB,gBAAgB,QAIpB;AA4BD,MAAa,OACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,eAAS,CAAC,2BAAiC,CAAC,CAAC;IACvE,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAiB,EACjB,IAAc;QAEd,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,IAAI,GAAG;YACX,gBAAgB,CAAC,IAAI;YACrB,gBAAgB,CAAC,IAAI;YACrB,gBAAgB,CAAC,MAAM;SACxB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElB,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,+CAA+C,CACjF,CAAC;SACH;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,e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V,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;;AAvGH,0BAwGC;AApGQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -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
|
+
}
|