@gearbox-protocol/sdk 2.1.32 → 2.1.34
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/lib/contracts/protocols.d.ts +0 -5
- package/lib/contracts/protocols.js +1 -43
- package/lib/core/creditManager.d.ts +3 -0
- package/lib/core/creditManager.js +22 -0
- package/lib/core/pool/index.d.ts +0 -1
- package/lib/core/pool/index.js +0 -1
- package/lib/core/trade.d.ts +29 -16
- package/lib/core/trade.js +67 -10
- package/lib/index.d.ts +0 -11
- package/lib/index.js +1 -14
- package/lib/parsers/txParser.js +1 -1
- package/lib/tokens/aave.d.ts +0 -3
- package/lib/tokens/aave.js +0 -57
- package/lib/tokens/balancer.d.ts +1 -11
- package/lib/tokens/balancer.js +3 -32
- package/lib/tokens/compound.d.ts +0 -2
- package/lib/tokens/compound.js +0 -36
- package/lib/tokens/convex.d.ts +2 -2
- package/lib/tokens/convex.js +9 -322
- package/lib/tokens/curveLP.d.ts +3 -4
- package/lib/tokens/curveLP.js +17 -240
- package/lib/tokens/decimals.js +1 -1
- package/lib/tokens/gear.d.ts +0 -2
- package/lib/tokens/normal.d.ts +0 -3
- package/lib/tokens/normal.js +0 -718
- package/lib/tokens/token.js +2 -2
- package/lib/tokens/tokens.spec.js +25 -4
- package/lib/tokens/yearn.d.ts +0 -4
- package/lib/tokens/yearn.js +0 -43
- package/lib/utils/multicall.d.ts +1 -1
- package/lib/utils/multicall.js +21 -6
- package/package.json +1 -1
- package/lib/core/adapter.d.ts +0 -20
- package/lib/core/adapter.js +0 -20
- package/lib/core/creditOperation.d.ts +0 -9
- package/lib/core/creditOperation.js +0 -2
- package/lib/core/operations.d.ts +0 -22
- package/lib/core/operations.js +0 -26
- package/lib/core/pool/operation.d.ts +0 -28
- package/lib/core/pool/operation.js +0 -36
- package/lib/pathfinder/tradeTypes.d.ts +0 -113
- package/lib/pathfinder/tradeTypes.js +0 -28
- package/lib/strategies/convex.d.ts +0 -57
- package/lib/strategies/convex.js +0 -220
- package/lib/strategies/creditFacade.d.ts +0 -21
- package/lib/strategies/creditFacade.js +0 -71
- package/lib/strategies/curve.d.ts +0 -45
- package/lib/strategies/curve.js +0 -207
- package/lib/strategies/lido.d.ts +0 -18
- package/lib/strategies/lido.js +0 -51
- package/lib/strategies/uniswapV2.d.ts +0 -15
- package/lib/strategies/uniswapV2.js +0 -44
- package/lib/strategies/uniswapV3.d.ts +0 -21
- package/lib/strategies/uniswapV3.js +0 -71
- package/lib/strategies/yearn.d.ts +0 -20
- package/lib/strategies/yearn.js +0 -128
- package/lib/utils/extracter.d.ts +0 -11
- package/lib/utils/extracter.js +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Protocols = void 0;
|
|
4
4
|
var Protocols;
|
|
5
5
|
(function (Protocols) {
|
|
6
6
|
Protocols[Protocols["Uniswap"] = 0] = "Uniswap";
|
|
@@ -14,45 +14,3 @@ var Protocols;
|
|
|
14
14
|
Protocols[Protocols["AaveV2"] = 8] = "AaveV2";
|
|
15
15
|
Protocols[Protocols["CompoundV2"] = 9] = "CompoundV2";
|
|
16
16
|
})(Protocols = exports.Protocols || (exports.Protocols = {}));
|
|
17
|
-
exports.protocolData = {
|
|
18
|
-
[Protocols.Uniswap]: {
|
|
19
|
-
name: "Uniswap",
|
|
20
|
-
icon: "/protocols/uniswap.png",
|
|
21
|
-
},
|
|
22
|
-
[Protocols.Sushiswap]: {
|
|
23
|
-
name: "Sushiswap",
|
|
24
|
-
icon: "/protocols/sushi.svg",
|
|
25
|
-
},
|
|
26
|
-
[Protocols.Curve]: {
|
|
27
|
-
name: "Curve",
|
|
28
|
-
icon: "/protocols/curve.svg",
|
|
29
|
-
},
|
|
30
|
-
[Protocols.Yearn]: {
|
|
31
|
-
name: "Yearn",
|
|
32
|
-
icon: "/protocols/yearn.svg",
|
|
33
|
-
},
|
|
34
|
-
[Protocols.Convex]: {
|
|
35
|
-
name: "Convex",
|
|
36
|
-
icon: "/protocols/convex.svg",
|
|
37
|
-
},
|
|
38
|
-
[Protocols.Lido]: {
|
|
39
|
-
name: "Lido",
|
|
40
|
-
icon: "/protocols/lido.svg",
|
|
41
|
-
},
|
|
42
|
-
[Protocols.Gearbox]: {
|
|
43
|
-
name: "Gearbox",
|
|
44
|
-
icon: "",
|
|
45
|
-
},
|
|
46
|
-
[Protocols.Balancer]: {
|
|
47
|
-
name: "Balancer",
|
|
48
|
-
icon: "",
|
|
49
|
-
},
|
|
50
|
-
[Protocols.AaveV2]: {
|
|
51
|
-
name: "AaveV2",
|
|
52
|
-
icon: "",
|
|
53
|
-
},
|
|
54
|
-
[Protocols.CompoundV2]: {
|
|
55
|
-
name: "CompoundV2",
|
|
56
|
-
icon: "",
|
|
57
|
-
},
|
|
58
|
-
};
|
|
@@ -41,6 +41,9 @@ export declare class CreditManagerData {
|
|
|
41
41
|
encodeAddCollateral(accountAddress: string, tokenAddress: string, amount: bigint): MultiCall;
|
|
42
42
|
encodeIncreaseDebt(amount: bigint): MultiCall;
|
|
43
43
|
encodeDecreaseDebt(amount: bigint): MultiCall;
|
|
44
|
+
encodeEnableToken(token: string): MultiCall;
|
|
45
|
+
encodeDisableToken(token: string): MultiCall;
|
|
46
|
+
static withdrawAllAndUnwrap_Convex(address: string, claim: boolean): MultiCall;
|
|
44
47
|
validateOpenAccount(collateral: bigint, debt: bigint): true;
|
|
45
48
|
protected validateOpenAccountV1(collateral: bigint, debt: bigint): true;
|
|
46
49
|
protected validateOpenAccountV2(debt: bigint): true;
|
|
@@ -124,6 +124,28 @@ class CreditManagerData {
|
|
|
124
124
|
callData: types_1.ICreditFacade__factory.createInterface().encodeFunctionData("decreaseDebt", [amount]),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
+
encodeEnableToken(token) {
|
|
128
|
+
if (this.version === 1)
|
|
129
|
+
throw new Error("Multicall is eligible only for version 2");
|
|
130
|
+
return {
|
|
131
|
+
target: this.creditFacade,
|
|
132
|
+
callData: types_1.ICreditFacade__factory.createInterface().encodeFunctionData("enableToken", [token]),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
encodeDisableToken(token) {
|
|
136
|
+
if (this.version === 1)
|
|
137
|
+
throw new Error("Multicall is eligible only for version 2");
|
|
138
|
+
return {
|
|
139
|
+
target: this.creditFacade,
|
|
140
|
+
callData: types_1.ICreditFacadeExtended__factory.createInterface().encodeFunctionData("disableToken", [token]),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
static withdrawAllAndUnwrap_Convex(address, claim) {
|
|
144
|
+
return {
|
|
145
|
+
target: address,
|
|
146
|
+
callData: types_1.IConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData("withdrawAllAndUnwrap", [claim]),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
127
149
|
validateOpenAccount(collateral, debt) {
|
|
128
150
|
return this.version === 1
|
|
129
151
|
? this.validateOpenAccountV1(collateral, debt)
|
package/lib/core/pool/index.d.ts
CHANGED
package/lib/core/pool/index.js
CHANGED
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { Signer } from "ethers";
|
|
2
|
-
import {
|
|
2
|
+
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
4
|
import { ICreditFacade } from "../types";
|
|
5
|
-
import {
|
|
5
|
+
import { CreditManagerData } from "./creditManager";
|
|
6
6
|
import { EVMTx } from "./eventOrTx";
|
|
7
|
-
interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
tokenFrom: string;
|
|
12
|
-
tokenTo: string;
|
|
13
|
-
operationName: TradeOperations;
|
|
7
|
+
interface Info {
|
|
8
|
+
name: string;
|
|
9
|
+
contractAddress: string;
|
|
10
|
+
creditManager: string;
|
|
14
11
|
}
|
|
15
|
-
export interface TradeProps
|
|
16
|
-
adapter:
|
|
12
|
+
export interface TradeProps {
|
|
13
|
+
adapter: Info;
|
|
17
14
|
tradePath: PathFinderResult;
|
|
18
15
|
creditFacade: string;
|
|
16
|
+
tokenFrom: string;
|
|
17
|
+
tokenTo: string;
|
|
18
|
+
sourceAmount: bigint;
|
|
19
|
+
expectedAmount: bigint;
|
|
20
|
+
swapType: SwapOperation;
|
|
21
|
+
swapName: TradeOperations;
|
|
19
22
|
}
|
|
20
23
|
export type TradeOperations = "farmWithdraw" | "farmDeposit" | "swap" | "unknownOperation";
|
|
21
|
-
export
|
|
22
|
-
|
|
24
|
+
export interface GetTradesProps {
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
results: Array<PathFinderResult>;
|
|
29
|
+
creditManager: CreditManagerData;
|
|
30
|
+
currentContracts: Record<SupportedContract, string>;
|
|
31
|
+
}
|
|
32
|
+
export declare class Trade {
|
|
33
|
+
readonly helper: Info;
|
|
23
34
|
readonly tradePath: PathFinderResult;
|
|
24
35
|
readonly creditFacade: string;
|
|
25
36
|
readonly swapType: SwapOperation;
|
|
@@ -31,12 +42,14 @@ export declare class Trade implements BaseTradeInterface {
|
|
|
31
42
|
readonly operationName: TradeOperations;
|
|
32
43
|
constructor(props: TradeProps);
|
|
33
44
|
getName(): string;
|
|
34
|
-
getAdapterInterface(): AdapterInterface;
|
|
35
|
-
getContractAddress(): string;
|
|
36
|
-
getAdapterAddress(): string;
|
|
37
45
|
execute(signer: Signer): Promise<EVMTx>;
|
|
38
46
|
toString(): string;
|
|
47
|
+
static getTrades({ from, to, amount, results, creditManager, currentContracts, }: GetTradesProps): Trade[];
|
|
39
48
|
static getOperationName(tokenInAddress: string, tokenOutAddress: string): TradeOperations;
|
|
49
|
+
static getCallInfo(calls: Array<MultiCall>, creditManager: string, currentContracts: Record<SupportedContract, string>): Info[];
|
|
50
|
+
private static getContractSymbol;
|
|
51
|
+
static getTradeId(trade: Trade): string;
|
|
52
|
+
static sortTrades(trades: Array<Trade>, swapStrategy: string): Trade[];
|
|
40
53
|
static executeMulticallPath(creditFacade: string | ICreditFacade, signer: Signer, calls: Array<MultiCall>): Promise<import("ethers").ContractTransaction>;
|
|
41
54
|
private static executeOnCreditFacade;
|
|
42
55
|
}
|
package/lib/core/trade.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Trade = void 0;
|
|
4
|
+
const contracts_1 = require("../contracts/contracts");
|
|
5
|
+
const txParser_1 = require("../parsers/txParser");
|
|
6
|
+
const core_1 = require("../pathfinder/core");
|
|
4
7
|
const decimals_1 = require("../tokens/decimals");
|
|
5
8
|
const token_1 = require("../tokens/token");
|
|
6
9
|
const types_1 = require("../types");
|
|
@@ -34,20 +37,11 @@ class Trade {
|
|
|
34
37
|
this.rate = (constants_1.WAD * props.expectedAmount) / props.sourceAmount;
|
|
35
38
|
this.tokenFrom = props.tokenFrom;
|
|
36
39
|
this.tokenTo = props.tokenTo;
|
|
37
|
-
this.operationName = props.
|
|
40
|
+
this.operationName = props.swapName;
|
|
38
41
|
}
|
|
39
42
|
getName() {
|
|
40
43
|
return this.helper.name;
|
|
41
44
|
}
|
|
42
|
-
getAdapterInterface() {
|
|
43
|
-
return this.helper.adapterInterface;
|
|
44
|
-
}
|
|
45
|
-
getContractAddress() {
|
|
46
|
-
return this.helper.contractAddress;
|
|
47
|
-
}
|
|
48
|
-
getAdapterAddress() {
|
|
49
|
-
return this.helper.adapterAddress;
|
|
50
|
-
}
|
|
51
45
|
async execute(signer) {
|
|
52
46
|
const receipt = await Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls);
|
|
53
47
|
return new transactions_1.TXSwap({
|
|
@@ -73,6 +67,26 @@ class Trade {
|
|
|
73
67
|
const decimalsTo = decimals_1.decimals[symbolTo];
|
|
74
68
|
return `${this.operationName} ${(0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, formatter_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
|
|
75
69
|
}
|
|
70
|
+
static getTrades({ from, to, amount, results, creditManager, currentContracts, }) {
|
|
71
|
+
const trades = results.reduce((acc, tradePath) => {
|
|
72
|
+
const { calls } = tradePath;
|
|
73
|
+
const callInfo = Trade.getCallInfo(calls, creditManager.address, currentContracts);
|
|
74
|
+
const trade = new Trade({
|
|
75
|
+
tradePath,
|
|
76
|
+
creditFacade: creditManager.creditFacade,
|
|
77
|
+
adapter: callInfo[0],
|
|
78
|
+
swapType: core_1.SwapOperation.EXACT_INPUT,
|
|
79
|
+
sourceAmount: amount,
|
|
80
|
+
expectedAmount: tradePath.amount,
|
|
81
|
+
tokenFrom: from,
|
|
82
|
+
tokenTo: to,
|
|
83
|
+
swapName: Trade.getOperationName(from, to),
|
|
84
|
+
});
|
|
85
|
+
acc.push(trade);
|
|
86
|
+
return acc;
|
|
87
|
+
}, []);
|
|
88
|
+
return trades;
|
|
89
|
+
}
|
|
76
90
|
static getOperationName(tokenInAddress, tokenOutAddress) {
|
|
77
91
|
const tokenInSymbol = token_1.tokenSymbolByAddress[tokenInAddress];
|
|
78
92
|
const tokenOutSymbol = token_1.tokenSymbolByAddress[tokenOutAddress];
|
|
@@ -90,6 +104,49 @@ class Trade {
|
|
|
90
104
|
return "swap";
|
|
91
105
|
return "unknownOperation";
|
|
92
106
|
}
|
|
107
|
+
static getCallInfo(calls, creditManager, currentContracts) {
|
|
108
|
+
const callAdapters = calls.reduce((acc, call) => {
|
|
109
|
+
const contractSymbol = this.getContractSymbol(call.target.toLowerCase());
|
|
110
|
+
if (!(0, contracts_1.isSupportedContract)(contractSymbol))
|
|
111
|
+
return acc;
|
|
112
|
+
const { name } = contracts_1.contractParams[contractSymbol];
|
|
113
|
+
const contractAddress = currentContracts[contractSymbol];
|
|
114
|
+
acc.push({
|
|
115
|
+
name,
|
|
116
|
+
contractAddress,
|
|
117
|
+
creditManager,
|
|
118
|
+
});
|
|
119
|
+
return acc;
|
|
120
|
+
}, []);
|
|
121
|
+
return callAdapters;
|
|
122
|
+
}
|
|
123
|
+
static getContractSymbol(address) {
|
|
124
|
+
try {
|
|
125
|
+
const { contract } = txParser_1.TxParser.getParseData(address);
|
|
126
|
+
return contract;
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
static getTradeId(trade) {
|
|
133
|
+
return `${trade.getName()}:${trade.expectedAmount.toString()}`;
|
|
134
|
+
}
|
|
135
|
+
static sortTrades(trades, swapStrategy) {
|
|
136
|
+
if (trades.length === 0)
|
|
137
|
+
return [];
|
|
138
|
+
const { swapType } = trades[0];
|
|
139
|
+
const sorted = [...trades].sort((a, b) => {
|
|
140
|
+
const aSelected = a.getName().toLowerCase().search(swapStrategy.toLowerCase()) >= 0;
|
|
141
|
+
const bSelected = b.getName().toLowerCase().search(swapStrategy.toLowerCase()) >= 0;
|
|
142
|
+
if ((aSelected && bSelected) || (!aSelected && !bSelected)) {
|
|
143
|
+
const sign = a.expectedAmount > b.expectedAmount ? -1 : 1;
|
|
144
|
+
return swapType === core_1.SwapOperation.EXACT_INPUT ? sign : -sign;
|
|
145
|
+
}
|
|
146
|
+
return aSelected ? -1 : 1;
|
|
147
|
+
});
|
|
148
|
+
return sorted;
|
|
149
|
+
}
|
|
93
150
|
static async executeMulticallPath(creditFacade, signer, calls) {
|
|
94
151
|
if (calls.length < 1)
|
|
95
152
|
throw new Error("No path to execute");
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./contracts/contracts";
|
|
2
2
|
export * from "./contracts/protocols";
|
|
3
|
-
export * from "./core/adapter";
|
|
4
3
|
export * from "./core/assets";
|
|
5
4
|
export * from "./core/chains";
|
|
6
5
|
export * from "./core/constants";
|
|
@@ -10,7 +9,6 @@ export * from "./core/creditSession";
|
|
|
10
9
|
export * from "./core/errors";
|
|
11
10
|
export * from "./core/eventOrTx";
|
|
12
11
|
export * from "./core/events";
|
|
13
|
-
export * from "./core/operations";
|
|
14
12
|
export * from "./core/pool";
|
|
15
13
|
export * from "./core/rewardClaimer";
|
|
16
14
|
export * from "./core/strategy";
|
|
@@ -35,14 +33,6 @@ export * from "./contracts/utilsContracts";
|
|
|
35
33
|
export * from "./parsers/txParser";
|
|
36
34
|
export * from "./pathfinder/core";
|
|
37
35
|
export * from "./pathfinder/pathfinder";
|
|
38
|
-
export * from "./pathfinder/tradeTypes";
|
|
39
|
-
export * from "./strategies/convex";
|
|
40
|
-
export * from "./strategies/creditFacade";
|
|
41
|
-
export * from "./strategies/curve";
|
|
42
|
-
export * from "./strategies/lido";
|
|
43
|
-
export * from "./strategies/uniswapV2";
|
|
44
|
-
export * from "./strategies/uniswapV3";
|
|
45
|
-
export * from "./strategies/yearn";
|
|
46
36
|
export * from "./tokens/convex";
|
|
47
37
|
export * from "./tokens/curveLP";
|
|
48
38
|
export * from "./tokens/decimals";
|
|
@@ -53,7 +43,6 @@ export * from "./tokens/tokenData";
|
|
|
53
43
|
export { TokenType } from "./tokens/tokenType";
|
|
54
44
|
export * from "./tokens/yearn";
|
|
55
45
|
export * from "./utils/errors";
|
|
56
|
-
export { getPoolTokens, getUnderlyingToken } from "./utils/extracter";
|
|
57
46
|
export * from "./utils/mappers";
|
|
58
47
|
export * from "./utils/multicall";
|
|
59
48
|
export * from "./utils/price";
|
package/lib/index.js
CHANGED
|
@@ -14,10 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.safeEnum = exports.callRepeater = exports.
|
|
17
|
+
exports.safeEnum = exports.callRepeater = exports.TokenType = exports.AdapterInterface = void 0;
|
|
18
18
|
__exportStar(require("./contracts/contracts"), exports);
|
|
19
19
|
__exportStar(require("./contracts/protocols"), exports);
|
|
20
|
-
__exportStar(require("./core/adapter"), exports);
|
|
21
20
|
__exportStar(require("./core/assets"), exports);
|
|
22
21
|
__exportStar(require("./core/chains"), exports);
|
|
23
22
|
__exportStar(require("./core/constants"), exports);
|
|
@@ -27,7 +26,6 @@ __exportStar(require("./core/creditSession"), exports);
|
|
|
27
26
|
__exportStar(require("./core/errors"), exports);
|
|
28
27
|
__exportStar(require("./core/eventOrTx"), exports);
|
|
29
28
|
__exportStar(require("./core/events"), exports);
|
|
30
|
-
__exportStar(require("./core/operations"), exports);
|
|
31
29
|
__exportStar(require("./core/pool"), exports);
|
|
32
30
|
__exportStar(require("./core/rewardClaimer"), exports);
|
|
33
31
|
__exportStar(require("./core/strategy"), exports);
|
|
@@ -54,14 +52,6 @@ __exportStar(require("./contracts/utilsContracts"), exports);
|
|
|
54
52
|
__exportStar(require("./parsers/txParser"), exports);
|
|
55
53
|
__exportStar(require("./pathfinder/core"), exports);
|
|
56
54
|
__exportStar(require("./pathfinder/pathfinder"), exports);
|
|
57
|
-
__exportStar(require("./pathfinder/tradeTypes"), exports);
|
|
58
|
-
__exportStar(require("./strategies/convex"), exports);
|
|
59
|
-
__exportStar(require("./strategies/creditFacade"), exports);
|
|
60
|
-
__exportStar(require("./strategies/curve"), exports);
|
|
61
|
-
__exportStar(require("./strategies/lido"), exports);
|
|
62
|
-
__exportStar(require("./strategies/uniswapV2"), exports);
|
|
63
|
-
__exportStar(require("./strategies/uniswapV3"), exports);
|
|
64
|
-
__exportStar(require("./strategies/yearn"), exports);
|
|
65
55
|
__exportStar(require("./tokens/convex"), exports);
|
|
66
56
|
__exportStar(require("./tokens/curveLP"), exports);
|
|
67
57
|
__exportStar(require("./tokens/decimals"), exports);
|
|
@@ -73,9 +63,6 @@ var tokenType_1 = require("./tokens/tokenType");
|
|
|
73
63
|
Object.defineProperty(exports, "TokenType", { enumerable: true, get: function () { return tokenType_1.TokenType; } });
|
|
74
64
|
__exportStar(require("./tokens/yearn"), exports);
|
|
75
65
|
__exportStar(require("./utils/errors"), exports);
|
|
76
|
-
var extracter_1 = require("./utils/extracter");
|
|
77
|
-
Object.defineProperty(exports, "getPoolTokens", { enumerable: true, get: function () { return extracter_1.getPoolTokens; } });
|
|
78
|
-
Object.defineProperty(exports, "getUnderlyingToken", { enumerable: true, get: function () { return extracter_1.getUnderlyingToken; } });
|
|
79
66
|
__exportStar(require("./utils/mappers"), exports);
|
|
80
67
|
__exportStar(require("./utils/multicall"), exports);
|
|
81
68
|
__exportStar(require("./utils/price"), exports);
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -119,7 +119,7 @@ class TxParser {
|
|
|
119
119
|
static getParser(address) {
|
|
120
120
|
const parser = TxParser.parsers[address.toLowerCase()];
|
|
121
121
|
if (!parser)
|
|
122
|
-
throw new Error(`Can find parser for ${address}`);
|
|
122
|
+
throw new Error(`Can't find parser for ${address}`);
|
|
123
123
|
return parser;
|
|
124
124
|
}
|
|
125
125
|
static chooseContractParser(address, contract, adapterType, isContract) {
|
package/lib/tokens/aave.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AaveV2PoolContract } from "../contracts/contracts";
|
|
2
|
-
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
3
2
|
import { NormalToken } from "./normal";
|
|
4
3
|
import type { TokenBase } from "./token";
|
|
5
4
|
import { TokenType } from "./tokenType";
|
|
@@ -9,14 +8,12 @@ export type AaveV2PoolTokenData = {
|
|
|
9
8
|
symbol: AaveV2LPToken;
|
|
10
9
|
type: TokenType.AAVE_V2_A_TOKEN;
|
|
11
10
|
underlying: NormalToken;
|
|
12
|
-
lpActions: Array<TradeAction>;
|
|
13
11
|
pool: AaveV2PoolContract;
|
|
14
12
|
} & TokenBase;
|
|
15
13
|
export type WrappedAaveV2PoolTokenData = {
|
|
16
14
|
symbol: WrappedAaveV2LPToken;
|
|
17
15
|
type: TokenType.WRAPPED_AAVE_V2_TOKEN;
|
|
18
16
|
underlying: AaveV2LPToken;
|
|
19
|
-
lpActions: Array<TradeAction>;
|
|
20
17
|
} & TokenBase;
|
|
21
18
|
export declare const aaveV2Tokens: Record<AaveV2LPToken, AaveV2PoolTokenData>;
|
|
22
19
|
export declare const wrappedAaveV2Tokens: Record<WrappedAaveV2LPToken, WrappedAaveV2PoolTokenData>;
|
package/lib/tokens/aave.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAaveV2LPToken = exports.wrappedAaveV2Tokens = exports.aaveV2Tokens = void 0;
|
|
4
|
-
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
4
|
const tokenType_1 = require("./tokenType");
|
|
6
5
|
exports.aaveV2Tokens = {
|
|
7
6
|
aDAI: {
|
|
@@ -10,13 +9,6 @@ exports.aaveV2Tokens = {
|
|
|
10
9
|
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
11
10
|
underlying: "DAI",
|
|
12
11
|
pool: "AAVE_V2_DAI_POOL",
|
|
13
|
-
lpActions: [
|
|
14
|
-
{
|
|
15
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
16
|
-
contract: "AAVE_V2_DAI_POOL",
|
|
17
|
-
tokenOut: "DAI",
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
12
|
},
|
|
21
13
|
aUSDC: {
|
|
22
14
|
name: "AaveV2 aUSDC",
|
|
@@ -24,13 +16,6 @@ exports.aaveV2Tokens = {
|
|
|
24
16
|
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
25
17
|
underlying: "USDC",
|
|
26
18
|
pool: "AAVE_V2_USDC_POOL",
|
|
27
|
-
lpActions: [
|
|
28
|
-
{
|
|
29
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
30
|
-
contract: "AAVE_V2_USDC_POOL",
|
|
31
|
-
tokenOut: "USDC",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
19
|
},
|
|
35
20
|
aUSDT: {
|
|
36
21
|
name: "AaveV2 aUSDT",
|
|
@@ -38,13 +23,6 @@ exports.aaveV2Tokens = {
|
|
|
38
23
|
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
39
24
|
underlying: "USDT",
|
|
40
25
|
pool: "AAVE_V2_USDT_POOL",
|
|
41
|
-
lpActions: [
|
|
42
|
-
{
|
|
43
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
44
|
-
contract: "AAVE_V2_USDT_POOL",
|
|
45
|
-
tokenOut: "USDT",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
26
|
},
|
|
49
27
|
aWETH: {
|
|
50
28
|
name: "AaveV2 aWETH",
|
|
@@ -52,13 +30,6 @@ exports.aaveV2Tokens = {
|
|
|
52
30
|
type: tokenType_1.TokenType.AAVE_V2_A_TOKEN,
|
|
53
31
|
underlying: "WETH",
|
|
54
32
|
pool: "AAVE_V2_WETH_POOL",
|
|
55
|
-
lpActions: [
|
|
56
|
-
{
|
|
57
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
58
|
-
contract: "AAVE_V2_WETH_POOL",
|
|
59
|
-
tokenOut: "WETH",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
33
|
},
|
|
63
34
|
};
|
|
64
35
|
exports.wrappedAaveV2Tokens = {
|
|
@@ -67,52 +38,24 @@ exports.wrappedAaveV2Tokens = {
|
|
|
67
38
|
symbol: "waDAI",
|
|
68
39
|
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
69
40
|
underlying: "aDAI",
|
|
70
|
-
lpActions: [
|
|
71
|
-
{
|
|
72
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
73
|
-
contract: "AAVE_V2_DAI_POOL",
|
|
74
|
-
tokenOut: "DAI",
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
41
|
},
|
|
78
42
|
waUSDC: {
|
|
79
43
|
name: "Wrapped AaveV2 aUSDC",
|
|
80
44
|
symbol: "waUSDC",
|
|
81
45
|
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
82
46
|
underlying: "aUSDC",
|
|
83
|
-
lpActions: [
|
|
84
|
-
{
|
|
85
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
86
|
-
contract: "AAVE_V2_USDC_POOL",
|
|
87
|
-
tokenOut: "USDC",
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
47
|
},
|
|
91
48
|
waUSDT: {
|
|
92
49
|
name: "Wrapped AaveV2 aUSDT",
|
|
93
50
|
symbol: "waUSDT",
|
|
94
51
|
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
95
52
|
underlying: "aUSDT",
|
|
96
|
-
lpActions: [
|
|
97
|
-
{
|
|
98
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
99
|
-
contract: "AAVE_V2_USDT_POOL",
|
|
100
|
-
tokenOut: "USDT",
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
53
|
},
|
|
104
54
|
waWETH: {
|
|
105
55
|
name: "Wrapped AaveV2 aWETH",
|
|
106
56
|
symbol: "waWETH",
|
|
107
57
|
type: tokenType_1.TokenType.WRAPPED_AAVE_V2_TOKEN,
|
|
108
58
|
underlying: "aWETH",
|
|
109
|
-
lpActions: [
|
|
110
|
-
{
|
|
111
|
-
type: tradeTypes_1.TradeType.AaveV2Withdraw,
|
|
112
|
-
contract: "AAVE_V2_WETH_POOL",
|
|
113
|
-
tokenOut: "WETH",
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
59
|
},
|
|
117
60
|
};
|
|
118
61
|
const isAaveV2LPToken = (t) => typeof t === "string" && !!exports.aaveV2Tokens[t];
|
package/lib/tokens/balancer.d.ts
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import { TradeType } from "../pathfinder/tradeTypes";
|
|
2
1
|
import { NormalToken } from "./normal";
|
|
3
2
|
import type { TokenBase } from "./token";
|
|
4
3
|
import { TokenType } from "./tokenType";
|
|
5
|
-
export type BalancerLPToken = "50OHM_50DAI" | "50OHM_50WETH" | "OHM_wstETH" | "
|
|
4
|
+
export type BalancerLPToken = "50OHM_50DAI" | "50OHM_50WETH" | "OHM_wstETH" | "USDC_DAI_USDT";
|
|
6
5
|
export type BalancerLpTokenData = {
|
|
7
6
|
symbol: BalancerLPToken;
|
|
8
7
|
type: TokenType.BALANCER_LP_TOKEN;
|
|
9
8
|
underlying: Array<NormalToken | BalancerLPToken>;
|
|
10
|
-
lpActions: Array<{
|
|
11
|
-
type: TradeType.BalancerJoin;
|
|
12
|
-
contract: "BALANCER_VAULT";
|
|
13
|
-
tokenOut: BalancerLPToken;
|
|
14
|
-
} | {
|
|
15
|
-
type: TradeType.BalancerExit;
|
|
16
|
-
contract: "BALANCER_VAULT";
|
|
17
|
-
tokenOut: Array<NormalToken | BalancerLPToken>;
|
|
18
|
-
}>;
|
|
19
9
|
poolId: string;
|
|
20
10
|
} & TokenBase;
|
|
21
11
|
export declare const balancerLpTokens: Record<BalancerLPToken, BalancerLpTokenData>;
|
package/lib/tokens/balancer.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBalancerLPToken = exports.balancerLpTokens = void 0;
|
|
4
|
-
const tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
4
|
const tokenType_1 = require("./tokenType");
|
|
6
5
|
exports.balancerLpTokens = {
|
|
7
6
|
"50OHM_50DAI": {
|
|
@@ -10,13 +9,6 @@ exports.balancerLpTokens = {
|
|
|
10
9
|
type: tokenType_1.TokenType.BALANCER_LP_TOKEN,
|
|
11
10
|
underlying: ["OHM", "DAI"],
|
|
12
11
|
poolId: "0x76fcf0e8c7ff37a47a799fa2cd4c13cde0d981c90002000000000000000003d2",
|
|
13
|
-
lpActions: [
|
|
14
|
-
{
|
|
15
|
-
type: tradeTypes_1.TradeType.BalancerExit,
|
|
16
|
-
contract: "BALANCER_VAULT",
|
|
17
|
-
tokenOut: ["OHM", "DAI"],
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
12
|
},
|
|
21
13
|
"50OHM_50WETH": {
|
|
22
14
|
name: "Balancer 50OHM_50WETH",
|
|
@@ -24,13 +16,6 @@ exports.balancerLpTokens = {
|
|
|
24
16
|
type: tokenType_1.TokenType.BALANCER_LP_TOKEN,
|
|
25
17
|
underlying: ["OHM", "WETH"],
|
|
26
18
|
poolId: "0xd1ec5e215e8148d76f4460e4097fd3d5ae0a35580002000000000000000003d3",
|
|
27
|
-
lpActions: [
|
|
28
|
-
{
|
|
29
|
-
type: tradeTypes_1.TradeType.BalancerExit,
|
|
30
|
-
contract: "BALANCER_VAULT",
|
|
31
|
-
tokenOut: ["OHM", "WETH"],
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
19
|
},
|
|
35
20
|
OHM_wstETH: {
|
|
36
21
|
name: "Balancer OHM_wstETH",
|
|
@@ -38,27 +23,13 @@ exports.balancerLpTokens = {
|
|
|
38
23
|
type: tokenType_1.TokenType.BALANCER_LP_TOKEN,
|
|
39
24
|
underlying: ["OHM", "wstETH"],
|
|
40
25
|
poolId: "0xd4f79ca0ac83192693bce4699d0c10c66aa6cf0f00020000000000000000047e",
|
|
41
|
-
lpActions: [
|
|
42
|
-
{
|
|
43
|
-
type: tradeTypes_1.TradeType.BalancerExit,
|
|
44
|
-
contract: "BALANCER_VAULT",
|
|
45
|
-
tokenOut: ["OHM", "wstETH"],
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
26
|
},
|
|
49
|
-
|
|
50
|
-
name: "Balancer
|
|
51
|
-
symbol: "
|
|
27
|
+
USDC_DAI_USDT: {
|
|
28
|
+
name: "Balancer USDC_DAI_USDT",
|
|
29
|
+
symbol: "USDC_DAI_USDT",
|
|
52
30
|
type: tokenType_1.TokenType.BALANCER_LP_TOKEN,
|
|
53
31
|
underlying: ["USDC", "DAI", "USDT"],
|
|
54
32
|
poolId: "0x79c58f70905f734641735bc61e45c19dd9ad60bc0000000000000000000004e7",
|
|
55
|
-
lpActions: [
|
|
56
|
-
{
|
|
57
|
-
type: tradeTypes_1.TradeType.BalancerExit,
|
|
58
|
-
contract: "BALANCER_VAULT",
|
|
59
|
-
tokenOut: ["USDC", "DAI", "USDT"],
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
33
|
},
|
|
63
34
|
};
|
|
64
35
|
const isBalancerLPToken = (t) => typeof t === "string" && !!exports.balancerLpTokens[t];
|
package/lib/tokens/compound.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
1
|
import { NormalToken } from "./normal";
|
|
3
2
|
import type { TokenBase } from "./token";
|
|
4
3
|
import { TokenType } from "./tokenType";
|
|
@@ -7,7 +6,6 @@ export type CompoundV2PoolTokenData = {
|
|
|
7
6
|
symbol: CompoundV2LPToken;
|
|
8
7
|
type: TokenType.COMPOUND_V2_C_TOKEN;
|
|
9
8
|
underlying: NormalToken;
|
|
10
|
-
lpActions: Array<TradeAction>;
|
|
11
9
|
} & TokenBase;
|
|
12
10
|
export declare const compoundV2Tokens: Record<CompoundV2LPToken, CompoundV2PoolTokenData>;
|
|
13
11
|
export declare const isCompoundV2LPToken: (t: unknown) => t is CompoundV2LPToken;
|