@gearbox-protocol/sdk 1.19.4 → 1.20.0
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/apy/convexAPY.js +1 -1
- package/lib/apy/curveAPY.d.ts +6 -5
- package/lib/apy/curveAPY.js +57 -55
- package/lib/core/creditManager.js +2 -1
- package/lib/parsers/ERC20Parser.d.ts +7 -0
- package/lib/parsers/ERC20Parser.js +53 -0
- package/lib/parsers/abstractParser.d.ts +5 -0
- package/lib/parsers/abstractParser.js +9 -0
- package/lib/parsers/addressProviderParser.d.ts +6 -0
- package/lib/parsers/addressProviderParser.js +45 -0
- package/lib/parsers/airdropDistributorParser.d.ts +6 -0
- package/lib/parsers/airdropDistributorParser.js +40 -0
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +4 -0
- package/lib/parsers/convextRewardPoolParser.d.ts +7 -0
- package/lib/parsers/convextRewardPoolParser.js +39 -0
- package/lib/parsers/creditManagerParser.d.ts +6 -0
- package/lib/parsers/creditManagerParser.js +43 -0
- package/lib/parsers/curveAdapterParser.js +18 -0
- package/lib/parsers/dataCompressorParser.d.ts +6 -0
- package/lib/parsers/dataCompressorParser.js +41 -0
- package/lib/parsers/iParser.d.ts +6 -0
- package/lib/parsers/lidoOracleParser.d.ts +6 -0
- package/lib/parsers/lidoOracleParser.js +39 -0
- package/lib/parsers/lidoSTETHParser.d.ts +7 -0
- package/lib/parsers/lidoSTETHParser.js +50 -0
- package/lib/parsers/multicallParser.d.ts +6 -0
- package/lib/parsers/multicallParser.js +48 -0
- package/lib/parsers/offchainOracleParser.d.ts +6 -0
- package/lib/parsers/offchainOracleParser.js +41 -0
- package/lib/parsers/priceOracleParser.d.ts +6 -0
- package/lib/parsers/priceOracleParser.js +41 -0
- package/lib/parsers/txParser.d.ts +20 -1
- package/lib/parsers/txParser.js +93 -19
- package/lib/parsers/wstETHAdapterParser.js +8 -0
- package/lib/parsers/yearnV2AdapterParser.js +11 -0
- package/package.json +1 -1
package/lib/apy/convexAPY.js
CHANGED
|
@@ -151,6 +151,6 @@ function calculateConvexAPY(_a) {
|
|
|
151
151
|
return extraAPY;
|
|
152
152
|
});
|
|
153
153
|
var extraAPYTotal = extraAPRs.reduce(function (acc, apy) { return acc.add(apy); }, ethers_1.BigNumber.from(0));
|
|
154
|
-
var baseApyWAD = curveAPY[underlying];
|
|
154
|
+
var baseApyWAD = curveAPY[underlying].base;
|
|
155
155
|
return baseApyWAD.add(crvAPY).add(cvxAPY).add(extraAPYTotal);
|
|
156
156
|
}
|
package/lib/apy/curveAPY.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BigNumber } from "ethers";
|
|
2
2
|
import { CurveLPToken } from "../tokens/curveLP";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface GEARCurveAPY {
|
|
3
|
+
import { GearboxToken } from "../tokens/gear";
|
|
4
|
+
declare type CurveAPYTokens = CurveLPToken | GearboxToken;
|
|
5
|
+
interface CurveAPY {
|
|
7
6
|
base: BigNumber;
|
|
8
7
|
crv: BigNumber;
|
|
9
|
-
|
|
8
|
+
gauge: Array<[string, BigNumber]>;
|
|
10
9
|
}
|
|
10
|
+
export declare type CurveAPYResult = Record<CurveAPYTokens, CurveAPY>;
|
|
11
|
+
export declare function getCurveAPY(): Promise<CurveAPYResult>;
|
|
11
12
|
export {};
|
package/lib/apy/curveAPY.js
CHANGED
|
@@ -35,6 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
38
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
49
|
};
|
|
@@ -52,57 +61,77 @@ var APY_DICTIONARY = {
|
|
|
52
61
|
LUSD3CRV: "33",
|
|
53
62
|
crvPlain3andSUSD: "15",
|
|
54
63
|
steCRV: "14",
|
|
55
|
-
crvFRAX: "44",
|
|
64
|
+
crvFRAX: "44",
|
|
65
|
+
GEAR: "factory-crypto-192", // 0x0e9b5b092cad6f1c5e6bc7f89ffe1abb5c95f1c2
|
|
56
66
|
};
|
|
57
67
|
var CRV_APY_RESPONSE_DECIMALS = 100;
|
|
58
|
-
var ZERO =
|
|
59
|
-
|
|
68
|
+
var ZERO = {
|
|
69
|
+
base: ethers_1.BigNumber.from(0),
|
|
70
|
+
crv: ethers_1.BigNumber.from(0),
|
|
71
|
+
gauge: [],
|
|
72
|
+
};
|
|
60
73
|
// const CRYPTO = "https://api.curve.fi/api/getPools/ethereum/crypto";
|
|
61
74
|
// const FACTORY = "https://api.curve.fi/api/getPools/ethereum/factory";
|
|
62
75
|
var CURVE_FACTORY_CRYPTO_URL = "https://api.curve.fi/api/getPools/ethereum/factory-crypto";
|
|
76
|
+
var CURVE_MAIN_URL = "https://api.curve.fi/api/getPools/ethereum/main";
|
|
63
77
|
var CURVE_APY_URL = "https://www.convexfinance.com/api/curve-apys";
|
|
64
78
|
function getCurveAPY() {
|
|
65
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var _a, apyData,
|
|
67
|
-
return __generator(this, function (
|
|
68
|
-
switch (
|
|
80
|
+
var _a, apyData, factoryCrypto, main, apys_1, _b, factoryCryptoPoolData, _c, mainPoolData, poolDataByID_1, curveAPY, e_1;
|
|
81
|
+
return __generator(this, function (_d) {
|
|
82
|
+
switch (_d.label) {
|
|
69
83
|
case 0:
|
|
70
|
-
|
|
84
|
+
_d.trys.push([0, 2, , 3]);
|
|
71
85
|
return [4 /*yield*/, Promise.all([
|
|
72
86
|
axios_1.default.get(CURVE_APY_URL),
|
|
73
87
|
axios_1.default.get(CURVE_FACTORY_CRYPTO_URL),
|
|
88
|
+
axios_1.default.get(CURVE_MAIN_URL),
|
|
74
89
|
])];
|
|
75
90
|
case 1:
|
|
76
|
-
_a =
|
|
91
|
+
_a = _d.sent(), apyData = _a[0].data, factoryCrypto = _a[1].data, main = _a[2].data;
|
|
77
92
|
apys_1 = (apyData || {}).apys;
|
|
93
|
+
_b = ((factoryCrypto === null || factoryCrypto === void 0 ? void 0 : factoryCrypto.data) || {}).poolData, factoryCryptoPoolData = _b === void 0 ? [] : _b;
|
|
94
|
+
_c = ((main === null || main === void 0 ? void 0 : main.data) || {}).poolData, mainPoolData = _c === void 0 ? [] : _c;
|
|
95
|
+
poolDataByID_1 = Object.fromEntries(__spreadArray(__spreadArray([], factoryCryptoPoolData.map(function (p) { return [p.id, p]; }), true), mainPoolData.map(function (p) { return [p.id, p]; }), true));
|
|
78
96
|
curveAPY = (0, mappers_1.objectEntries)(APY_DICTIONARY).reduce(function (acc, _a) {
|
|
79
97
|
var curveSymbol = _a[0], poolId = _a[1];
|
|
80
|
-
var
|
|
98
|
+
var _b = apys_1[poolId] || {}, baseApy = _b.baseApy, crvApy = _b.crvApy;
|
|
81
99
|
if (baseApy === undefined)
|
|
82
100
|
console.warn("No base apy for: ".concat(curveSymbol, ", ").concat(poolId));
|
|
83
|
-
|
|
101
|
+
var pool = poolDataByID_1[poolId];
|
|
102
|
+
var _c = (pool || {}).gaugeRewards, gaugeRewards = _c === void 0 ? [] : _c;
|
|
103
|
+
if (pool === undefined)
|
|
104
|
+
console.warn("No pool data for: ".concat(curveSymbol, ", ").concat(poolId));
|
|
105
|
+
var extraRewards = gaugeRewards.map(function (_a) {
|
|
106
|
+
var _b = _a.apy, apy = _b === void 0 ? 0 : _b, symbol = _a.symbol;
|
|
107
|
+
return [
|
|
108
|
+
symbol.toLowerCase(),
|
|
109
|
+
curveAPYToBn(apy),
|
|
110
|
+
];
|
|
111
|
+
});
|
|
112
|
+
var maxCrv = (pool === null || pool === void 0 ? void 0 : pool.gaugeCrvApy.length) > 0 ? Math.max.apply(Math, pool.gaugeCrvApy) : crvApy;
|
|
113
|
+
acc[curveSymbol] = {
|
|
114
|
+
base: curveAPYToBn(baseApy || 0),
|
|
115
|
+
crv: curveAPYToBn(maxCrv || 0),
|
|
116
|
+
gauge: extraRewards,
|
|
117
|
+
};
|
|
84
118
|
return acc;
|
|
85
119
|
}, {});
|
|
86
|
-
return [
|
|
120
|
+
return [2 /*return*/, curveAPY];
|
|
87
121
|
case 2:
|
|
88
|
-
|
|
89
|
-
return [2 /*return*/, [curveAPY, gearAPY]];
|
|
90
|
-
case 3:
|
|
91
|
-
e_1 = _b.sent();
|
|
122
|
+
e_1 = _d.sent();
|
|
92
123
|
console.error(e_1);
|
|
93
|
-
return [2 /*return*/,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
]];
|
|
105
|
-
case 4: return [2 /*return*/];
|
|
124
|
+
return [2 /*return*/, {
|
|
125
|
+
"3Crv": ZERO,
|
|
126
|
+
crvFRAX: ZERO,
|
|
127
|
+
FRAX3CRV: ZERO,
|
|
128
|
+
gusd3CRV: ZERO,
|
|
129
|
+
LUSD3CRV: ZERO,
|
|
130
|
+
crvPlain3andSUSD: ZERO,
|
|
131
|
+
steCRV: ZERO,
|
|
132
|
+
GEAR: ZERO,
|
|
133
|
+
}];
|
|
134
|
+
case 3: return [2 /*return*/];
|
|
106
135
|
}
|
|
107
136
|
});
|
|
108
137
|
});
|
|
@@ -111,30 +140,3 @@ exports.getCurveAPY = getCurveAPY;
|
|
|
111
140
|
function curveAPYToBn(baseApy) {
|
|
112
141
|
return (0, formatter_1.toBN)((baseApy / CRV_APY_RESPONSE_DECIMALS).toString(), constants_1.WAD_DECIMALS_POW);
|
|
113
142
|
}
|
|
114
|
-
var POOL_DICTIONARY = {
|
|
115
|
-
GEAR: "factory-crypto-192", // 0x0e9b5b092cad6f1c5e6bc7f89ffe1abb5c95f1c2
|
|
116
|
-
};
|
|
117
|
-
function getGEARCurveAPY(apys, poolDataResp) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
var _a, poolData, gearPool, _b, gaugeRewards, gearGauge, _c, gearApy, _d, baseApy, crvApy, base, crv, gear;
|
|
120
|
-
return __generator(this, function (_e) {
|
|
121
|
-
_a = ((poolDataResp === null || poolDataResp === void 0 ? void 0 : poolDataResp.data) || {}).poolData, poolData = _a === void 0 ? [] : _a;
|
|
122
|
-
gearPool = poolData.find(function (p) { return p.id === POOL_DICTIONARY.GEAR; });
|
|
123
|
-
if (gearPool === undefined)
|
|
124
|
-
console.warn("No GEAR pool found");
|
|
125
|
-
_b = (gearPool || {}).gaugeRewards, gaugeRewards = _b === void 0 ? [] : _b;
|
|
126
|
-
console.log("GEAR POOL", gaugeRewards);
|
|
127
|
-
gearGauge = gaugeRewards.find(function (g) { return g.symbol.toLowerCase() === "gear"; });
|
|
128
|
-
if (gearGauge === undefined)
|
|
129
|
-
console.warn("No GEAR gauge found");
|
|
130
|
-
_c = (gearGauge || {}).apy, gearApy = _c === void 0 ? 0 : _c;
|
|
131
|
-
_d = apys[POOL_DICTIONARY.GEAR] || {}, baseApy = _d.baseApy, crvApy = _d.crvApy;
|
|
132
|
-
if (baseApy === undefined)
|
|
133
|
-
console.warn("No base apy for: GEAR, ".concat(POOL_DICTIONARY.GEAR));
|
|
134
|
-
base = curveAPYToBn(baseApy || 0);
|
|
135
|
-
crv = curveAPYToBn(crvApy || 0);
|
|
136
|
-
gear = curveAPYToBn(gearApy || 0);
|
|
137
|
-
return [2 /*return*/, { base: base, crv: crv, gear: gear }];
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
@@ -77,7 +77,8 @@ var CreditManagerData = /** @class */ (function () {
|
|
|
77
77
|
this.liquidationDiscount = payload.liquidationDiscount;
|
|
78
78
|
this.feeLiquidationExpired = payload.feeLiquidationExpired;
|
|
79
79
|
this.liquidationDiscountExpired = payload.liquidationDiscountExpired;
|
|
80
|
-
|
|
80
|
+
txParser_1.TxParser.addCreditManager(this.address, this.version);
|
|
81
|
+
if (this.creditFacade !== "" && this.creditFacade !== constants_1.ADDRESS_0X0) {
|
|
81
82
|
txParser_1.TxParser.addCreditFacade(this.creditFacade, token_1.tokenSymbolByAddress[this.underlyingToken]);
|
|
82
83
|
txParser_1.TxParser.addAdapters(payload.adapters.map(function (a) { return ({
|
|
83
84
|
adapter: a.adapter,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SupportedToken } from "../tokens/token";
|
|
2
|
+
import { AbstractParser } from "./abstractParser";
|
|
3
|
+
import { IParser } from "./iParser";
|
|
4
|
+
export declare class ERC20Parser extends AbstractParser implements IParser {
|
|
5
|
+
constructor(symbol: SupportedToken);
|
|
6
|
+
parse(calldata: string): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ERC20Parser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var ERC20Parser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(ERC20Parser, _super);
|
|
23
|
+
function ERC20Parser(symbol) {
|
|
24
|
+
var _this = _super.call(this, symbol) || this;
|
|
25
|
+
_this.adapterName = "Token";
|
|
26
|
+
_this.ifc = types_1.IERC20__factory.createInterface();
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
ERC20Parser.prototype.parse = function (calldata) {
|
|
30
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
31
|
+
switch (functionFragment.name) {
|
|
32
|
+
case "totalSupply": {
|
|
33
|
+
return "".concat(functionName);
|
|
34
|
+
}
|
|
35
|
+
case "balanceOf": {
|
|
36
|
+
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
37
|
+
return "".concat(functionName, "(").concat(address, ")");
|
|
38
|
+
}
|
|
39
|
+
case "allowance": {
|
|
40
|
+
var _b = this.decodeFunctionData(functionFragment, calldata), account = _b[0], to = _b[1];
|
|
41
|
+
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
42
|
+
}
|
|
43
|
+
case "approve": {
|
|
44
|
+
var spender = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
45
|
+
return "".concat(functionName, "(").concat(spender, ")");
|
|
46
|
+
}
|
|
47
|
+
default:
|
|
48
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return ERC20Parser;
|
|
52
|
+
}(abstractParser_1.AbstractParser));
|
|
53
|
+
exports.ERC20Parser = ERC20Parser;
|
|
@@ -14,5 +14,10 @@ export declare class AbstractParser {
|
|
|
14
14
|
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
|
15
15
|
tokenSymbol(address: string): SupportedToken;
|
|
16
16
|
formatBN(amount: BigNumberish, token: SupportedToken): string;
|
|
17
|
+
parseToObject(address: string, calldata: string): {
|
|
18
|
+
address: string;
|
|
19
|
+
functionFragment: FunctionFragment;
|
|
20
|
+
args: Result;
|
|
21
|
+
};
|
|
17
22
|
}
|
|
18
23
|
export {};
|
|
@@ -27,6 +27,15 @@ var AbstractParser = /** @class */ (function () {
|
|
|
27
27
|
AbstractParser.prototype.formatBN = function (amount, token) {
|
|
28
28
|
return "".concat((0, formatter_1.formatBN)(amount, decimals_1.decimals[token]), " [").concat(ethers_1.BigNumber.from(amount).toString(), "]");
|
|
29
29
|
};
|
|
30
|
+
AbstractParser.prototype.parseToObject = function (address, calldata) {
|
|
31
|
+
var functionFragment = this.parseSelector(calldata).functionFragment;
|
|
32
|
+
var args = this.decodeFunctionData(functionFragment, calldata);
|
|
33
|
+
return {
|
|
34
|
+
address: address,
|
|
35
|
+
functionFragment: functionFragment,
|
|
36
|
+
args: args,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
30
39
|
return AbstractParser;
|
|
31
40
|
}());
|
|
32
41
|
exports.AbstractParser = AbstractParser;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AddressProviderParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var AddressProviderParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddressProviderParser, _super);
|
|
23
|
+
function AddressProviderParser() {
|
|
24
|
+
var _this = _super.call(this, "AddressProvider") || this;
|
|
25
|
+
_this.ifc = types_1.IAddressProvider__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
AddressProviderParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getWethToken":
|
|
32
|
+
case "getGearToken":
|
|
33
|
+
case "getLeveragedActions":
|
|
34
|
+
case "getDataCompressor":
|
|
35
|
+
case "getWETHGateway":
|
|
36
|
+
case "getPriceOracle": {
|
|
37
|
+
return "".concat(functionName);
|
|
38
|
+
}
|
|
39
|
+
default:
|
|
40
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return AddressProviderParser;
|
|
44
|
+
}(abstractParser_1.AbstractParser));
|
|
45
|
+
exports.AddressProviderParser = AddressProviderParser;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AirdropDistributorParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var AirdropDistributorParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AirdropDistributorParser, _super);
|
|
23
|
+
function AirdropDistributorParser() {
|
|
24
|
+
var _this = _super.call(this, "AirdropDistributor") || this;
|
|
25
|
+
_this.ifc = types_1.IAirdropDistributor__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
AirdropDistributorParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "merkleRoot": {
|
|
32
|
+
return "".concat(functionName);
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return AirdropDistributorParser;
|
|
39
|
+
}(abstractParser_1.AbstractParser));
|
|
40
|
+
exports.AirdropDistributorParser = AirdropDistributorParser;
|
|
@@ -47,6 +47,10 @@ var ConvexBaseRewardPoolAdapterParser = /** @class */ (function (_super) {
|
|
|
47
47
|
var claim = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
48
48
|
return "".concat(functionName, "(claim: ").concat(claim, ")");
|
|
49
49
|
}
|
|
50
|
+
case "rewardRate":
|
|
51
|
+
return "".concat(functionName);
|
|
52
|
+
case "totalSupply":
|
|
53
|
+
return "".concat(functionName);
|
|
50
54
|
default:
|
|
51
55
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
52
56
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NormalToken } from "../tokens/normal";
|
|
2
|
+
import { AbstractParser } from "./abstractParser";
|
|
3
|
+
import { IParser } from "./iParser";
|
|
4
|
+
export declare class ConvexRewardPoolParser extends AbstractParser implements IParser {
|
|
5
|
+
constructor(token: NormalToken);
|
|
6
|
+
parse(calldata: string): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ConvexRewardPoolParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var ConvexRewardPoolParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(ConvexRewardPoolParser, _super);
|
|
23
|
+
function ConvexRewardPoolParser(token) {
|
|
24
|
+
var _this = _super.call(this, "ConvexRewardPool_".concat(token)) || this;
|
|
25
|
+
_this.ifc = types_1.IBaseRewardPool__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
ConvexRewardPoolParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "rewardRate":
|
|
32
|
+
return "".concat(functionName);
|
|
33
|
+
default:
|
|
34
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return ConvexRewardPoolParser;
|
|
38
|
+
}(abstractParser_1.AbstractParser));
|
|
39
|
+
exports.ConvexRewardPoolParser = ConvexRewardPoolParser;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CreditManagerParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var CreditManagerParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(CreditManagerParser, _super);
|
|
23
|
+
function CreditManagerParser(version) {
|
|
24
|
+
var _this = _super.call(this, "CreditManager_V".concat(version)) || this;
|
|
25
|
+
_this.ifc =
|
|
26
|
+
version === 1
|
|
27
|
+
? types_1.ICreditManager__factory.createInterface()
|
|
28
|
+
: types_1.ICreditManagerV2__factory.createInterface();
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
CreditManagerParser.prototype.parse = function (calldata) {
|
|
32
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
33
|
+
switch (functionFragment.name) {
|
|
34
|
+
case "creditConfigurator": {
|
|
35
|
+
return "".concat(functionName);
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return CreditManagerParser;
|
|
42
|
+
}(abstractParser_1.AbstractParser));
|
|
43
|
+
exports.CreditManagerParser = CreditManagerParser;
|
|
@@ -94,6 +94,24 @@ var CurveAdapterParser = /** @class */ (function (_super) {
|
|
|
94
94
|
var _h = this.decodeFunctionData(functionFragment, calldata), amounts = _h[0], maxBurnAmount = _h[1];
|
|
95
95
|
return "".concat(functionName, "(amounts: [").concat(this.convertAmounts(amounts), "], max_burn_amount: ").concat(this.formatBN(maxBurnAmount, this.lpToken), ")");
|
|
96
96
|
}
|
|
97
|
+
case "totalSupply": {
|
|
98
|
+
return "".concat(functionName);
|
|
99
|
+
}
|
|
100
|
+
case "balances": {
|
|
101
|
+
var i = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
102
|
+
return "".concat(functionName, "(").concat(this.getTokenByIndex(i), ")");
|
|
103
|
+
}
|
|
104
|
+
case "balanceOf": {
|
|
105
|
+
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
106
|
+
return "".concat(functionName, "(").concat(address, ")");
|
|
107
|
+
}
|
|
108
|
+
case "get_virtual_price": {
|
|
109
|
+
return "".concat(functionName);
|
|
110
|
+
}
|
|
111
|
+
case "allowance": {
|
|
112
|
+
var _j = this.decodeFunctionData(functionFragment, calldata), account = _j[0], to = _j[1];
|
|
113
|
+
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
114
|
+
}
|
|
97
115
|
default:
|
|
98
116
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
99
117
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DataCompressorParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var DataCompressorParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(DataCompressorParser, _super);
|
|
23
|
+
function DataCompressorParser() {
|
|
24
|
+
var _this = _super.call(this, "DataCompressor") || this;
|
|
25
|
+
_this.ifc = types_1.IDataCompressor__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
DataCompressorParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getPoolsList":
|
|
32
|
+
case "getCreditManagersList": {
|
|
33
|
+
return "".concat(functionName);
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return DataCompressorParser;
|
|
40
|
+
}(abstractParser_1.AbstractParser));
|
|
41
|
+
exports.DataCompressorParser = DataCompressorParser;
|
package/lib/parsers/iParser.d.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.LidoOracleParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var LidoOracleParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(LidoOracleParser, _super);
|
|
23
|
+
function LidoOracleParser() {
|
|
24
|
+
var _this = _super.call(this, "LidoOracle") || this;
|
|
25
|
+
_this.ifc = types_1.ILidoOracle__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
LidoOracleParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getLastCompletedReportDelta":
|
|
32
|
+
return "".concat(functionName);
|
|
33
|
+
default:
|
|
34
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return LidoOracleParser;
|
|
38
|
+
}(abstractParser_1.AbstractParser));
|
|
39
|
+
exports.LidoOracleParser = LidoOracleParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SupportedToken } from "../tokens/token";
|
|
2
|
+
import { AbstractParser } from "./abstractParser";
|
|
3
|
+
import { IParser } from "./iParser";
|
|
4
|
+
export declare class LidoSTETHParser extends AbstractParser implements IParser {
|
|
5
|
+
constructor(symbol: SupportedToken);
|
|
6
|
+
parse(calldata: string): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.LidoSTETHParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var LidoSTETHParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(LidoSTETHParser, _super);
|
|
23
|
+
function LidoSTETHParser(symbol) {
|
|
24
|
+
var _this = _super.call(this, symbol) || this;
|
|
25
|
+
_this.ifc = types_1.IstETH__factory.createInterface();
|
|
26
|
+
_this.adapterName = "TokenLido";
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
LidoSTETHParser.prototype.parse = function (calldata) {
|
|
30
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
31
|
+
switch (functionFragment.name) {
|
|
32
|
+
case "getFee":
|
|
33
|
+
case "totalSupply": {
|
|
34
|
+
return "".concat(functionName);
|
|
35
|
+
}
|
|
36
|
+
case "balanceOf": {
|
|
37
|
+
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
38
|
+
return "".concat(functionName, "(").concat(address, ")");
|
|
39
|
+
}
|
|
40
|
+
case "allowance": {
|
|
41
|
+
var _b = this.decodeFunctionData(functionFragment, calldata), account = _b[0], to = _b[1];
|
|
42
|
+
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return LidoSTETHParser;
|
|
49
|
+
}(abstractParser_1.AbstractParser));
|
|
50
|
+
exports.LidoSTETHParser = LidoSTETHParser;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.MulticallParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var MulticallParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(MulticallParser, _super);
|
|
23
|
+
function MulticallParser() {
|
|
24
|
+
var _this = _super.call(this, "Multicall") || this;
|
|
25
|
+
_this.ifc = types_1.Multicall2__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
MulticallParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "aggregate": {
|
|
32
|
+
var calls = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
33
|
+
return "".concat(functionName, ": ").concat(calls);
|
|
34
|
+
}
|
|
35
|
+
case "getBlockNumber": {
|
|
36
|
+
return "".concat(functionName);
|
|
37
|
+
}
|
|
38
|
+
case "getEthBalance": {
|
|
39
|
+
var account = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
40
|
+
return "".concat(functionName, "(").concat(account, ")");
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return MulticallParser;
|
|
47
|
+
}(abstractParser_1.AbstractParser));
|
|
48
|
+
exports.MulticallParser = MulticallParser;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.OffchainOracleParserParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var OffchainOracleParserParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(OffchainOracleParserParser, _super);
|
|
23
|
+
function OffchainOracleParserParser() {
|
|
24
|
+
var _this = _super.call(this, "OffchainOracleParser") || this;
|
|
25
|
+
_this.ifc = types_1.IOffchainOracle__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
OffchainOracleParserParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getRate": {
|
|
32
|
+
var _b = this.decodeFunctionData(functionFragment, calldata), srcToken = _b[0], dstToken = _b[1], useWrappers = _b[2];
|
|
33
|
+
return "".concat(functionName, "(token: ").concat(this.tokenSymbol(srcToken), ", measured in: ").concat(this.tokenSymbol(dstToken), ", use wrappers: ").concat(useWrappers, ")");
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return OffchainOracleParserParser;
|
|
40
|
+
}(abstractParser_1.AbstractParser));
|
|
41
|
+
exports.OffchainOracleParserParser = OffchainOracleParserParser;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PriceOracleParser = void 0;
|
|
19
|
+
var types_1 = require("../types");
|
|
20
|
+
var abstractParser_1 = require("./abstractParser");
|
|
21
|
+
var PriceOracleParser = /** @class */ (function (_super) {
|
|
22
|
+
__extends(PriceOracleParser, _super);
|
|
23
|
+
function PriceOracleParser() {
|
|
24
|
+
var _this = _super.call(this, "PriceOracle") || this;
|
|
25
|
+
_this.ifc = types_1.IPriceOracleV2__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
PriceOracleParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getPrice": {
|
|
32
|
+
var token = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
33
|
+
return "".concat(functionName, "(").concat(this.tokenSymbol(token), ")");
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return PriceOracleParser;
|
|
40
|
+
}(abstractParser_1.AbstractParser));
|
|
41
|
+
exports.PriceOracleParser = PriceOracleParser;
|
|
@@ -15,12 +15,31 @@ interface ParseData {
|
|
|
15
15
|
export declare class TxParser {
|
|
16
16
|
protected static parsers: Record<string, IParser & AbstractParser>;
|
|
17
17
|
static parse(address: string, calldata: string): string;
|
|
18
|
+
static parseToObject(address: string, calldata: string): {
|
|
19
|
+
address: string;
|
|
20
|
+
functionFragment: import("@ethersproject/abi").FunctionFragment;
|
|
21
|
+
args: any;
|
|
22
|
+
};
|
|
18
23
|
static getParseData(address: string): ParseData;
|
|
19
24
|
static parseMultiCall(calls: Array<MultiCallStruct>): Array<string>;
|
|
25
|
+
static parseToObjectMultiCall(calls: Array<MultiCallStruct>): {
|
|
26
|
+
address: string;
|
|
27
|
+
functionFragment: import("@ethersproject/abi").FunctionFragment;
|
|
28
|
+
args: any;
|
|
29
|
+
}[];
|
|
20
30
|
static addAdapters(adapters: Array<AdapterForParser>): void;
|
|
21
31
|
static addContracts(network: NetworkType): void;
|
|
22
32
|
static addCreditFacade(creditFacade: string, underlying: SupportedToken): void;
|
|
33
|
+
static addTokens(network: NetworkType): void;
|
|
34
|
+
static addOffchainOracleParser(address: string): void;
|
|
35
|
+
static addPriceOracle(address: string): void;
|
|
36
|
+
static addDataCompressor(address: string): void;
|
|
37
|
+
static addAddressProvider(address: string): void;
|
|
38
|
+
static addMulticall(address: string): void;
|
|
39
|
+
static addAirdropDistributor(address: string): void;
|
|
40
|
+
static addCreditManager(address: string, version: number): void;
|
|
23
41
|
static getParser(address: string): IParser & AbstractParser;
|
|
24
|
-
protected static
|
|
42
|
+
protected static chooseContractParser(address: string, contract: SupportedContract, adapterType: number, isContract: boolean): void;
|
|
43
|
+
protected static _addParser(address: string, parser: IParser & AbstractParser): void;
|
|
25
44
|
}
|
|
26
45
|
export {};
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -3,11 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TxParser = void 0;
|
|
4
4
|
var adapters_1 = require("../contracts/adapters");
|
|
5
5
|
var contracts_1 = require("../contracts/contracts");
|
|
6
|
+
var token_1 = require("../tokens/token");
|
|
7
|
+
var mappers_1 = require("../utils/mappers");
|
|
8
|
+
var addressProviderParser_1 = require("./addressProviderParser");
|
|
9
|
+
var airdropDistributorParser_1 = require("./airdropDistributorParser");
|
|
6
10
|
var convexBaseRewardPoolAdapterParser_1 = require("./convexBaseRewardPoolAdapterParser");
|
|
7
11
|
var convexBoosterAdapterParser_1 = require("./convexBoosterAdapterParser");
|
|
12
|
+
var convextRewardPoolParser_1 = require("./convextRewardPoolParser");
|
|
8
13
|
var creditFacadeParser_1 = require("./creditFacadeParser");
|
|
14
|
+
var creditManagerParser_1 = require("./creditManagerParser");
|
|
9
15
|
var curveAdapterParser_1 = require("./curveAdapterParser");
|
|
16
|
+
var dataCompressorParser_1 = require("./dataCompressorParser");
|
|
17
|
+
var ERC20Parser_1 = require("./ERC20Parser");
|
|
10
18
|
var lidoAdapterParser_1 = require("./lidoAdapterParser");
|
|
19
|
+
var lidoOracleParser_1 = require("./lidoOracleParser");
|
|
20
|
+
var lidoSTETHParser_1 = require("./lidoSTETHParser");
|
|
21
|
+
var multicallParser_1 = require("./multicallParser");
|
|
22
|
+
var offchainOracleParser_1 = require("./offchainOracleParser");
|
|
23
|
+
var priceOracleParser_1 = require("./priceOracleParser");
|
|
11
24
|
var uniV2AdapterParser_1 = require("./uniV2AdapterParser");
|
|
12
25
|
var uniV3AdapterParser_1 = require("./uniV3AdapterParser");
|
|
13
26
|
var wstETHAdapterParser_1 = require("./wstETHAdapterParser");
|
|
@@ -16,11 +29,16 @@ var TxParser = /** @class */ (function () {
|
|
|
16
29
|
function TxParser() {
|
|
17
30
|
}
|
|
18
31
|
TxParser.parse = function (address, calldata) {
|
|
19
|
-
var parser =
|
|
32
|
+
var parser = TxParser.getParser(address);
|
|
20
33
|
return parser.parse(calldata);
|
|
21
34
|
};
|
|
35
|
+
TxParser.parseToObject = function (address, calldata) {
|
|
36
|
+
var _a;
|
|
37
|
+
var parser = TxParser.getParser(address);
|
|
38
|
+
return (_a = parser.parseToObject) === null || _a === void 0 ? void 0 : _a.call(parser, address, calldata);
|
|
39
|
+
};
|
|
22
40
|
TxParser.getParseData = function (address) {
|
|
23
|
-
var parser =
|
|
41
|
+
var parser = TxParser.getParser(address);
|
|
24
42
|
return { contract: parser.contract, adapterName: parser.adapterName };
|
|
25
43
|
};
|
|
26
44
|
TxParser.parseMultiCall = function (calls) {
|
|
@@ -28,12 +46,17 @@ var TxParser = /** @class */ (function () {
|
|
|
28
46
|
return TxParser.parse(call.target, call.callData.toString());
|
|
29
47
|
});
|
|
30
48
|
};
|
|
49
|
+
TxParser.parseToObjectMultiCall = function (calls) {
|
|
50
|
+
return calls.map(function (call) {
|
|
51
|
+
return TxParser.parseToObject(call.target, call.callData.toString());
|
|
52
|
+
});
|
|
53
|
+
};
|
|
31
54
|
TxParser.addAdapters = function (adapters) {
|
|
32
55
|
for (var _i = 0, adapters_2 = adapters; _i < adapters_2.length; _i++) {
|
|
33
56
|
var a = adapters_2[_i];
|
|
34
57
|
var contract = contracts_1.contractsByAddress[a.contract.toLowerCase()];
|
|
35
58
|
if (contract && contracts_1.contractParams[contract]) {
|
|
36
|
-
TxParser.
|
|
59
|
+
TxParser.chooseContractParser(a.adapter, contract, contracts_1.contractParams[contract].type, false);
|
|
37
60
|
}
|
|
38
61
|
else {
|
|
39
62
|
console.error("Unknown address: ".concat(contract, " at ").concat(a.contract));
|
|
@@ -41,29 +64,77 @@ var TxParser = /** @class */ (function () {
|
|
|
41
64
|
}
|
|
42
65
|
};
|
|
43
66
|
TxParser.addContracts = function (network) {
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
var address = contracts_1.contractsByNetwork[network][
|
|
47
|
-
TxParser.
|
|
48
|
-
|
|
67
|
+
(0, mappers_1.objectEntries)(contracts_1.contractParams).forEach(function (_a) {
|
|
68
|
+
var contract = _a[0], contractData = _a[1];
|
|
69
|
+
var address = contracts_1.contractsByNetwork[network][contract];
|
|
70
|
+
TxParser.chooseContractParser(address, contract, contractData.type, true);
|
|
71
|
+
if (contractData.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL) {
|
|
72
|
+
contractData.extraRewards.forEach(function (r) {
|
|
73
|
+
var extraAddress = r.poolAddress[network];
|
|
74
|
+
TxParser._addParser(extraAddress, new convextRewardPoolParser_1.ConvexRewardPoolParser(r.rewardToken));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (contractData.type === adapters_1.AdapterInterface.LIDO_V1) {
|
|
78
|
+
var extraAddress = contractData.oracle[network];
|
|
79
|
+
TxParser._addParser(extraAddress, new lidoOracleParser_1.LidoOracleParser());
|
|
80
|
+
}
|
|
81
|
+
});
|
|
49
82
|
};
|
|
50
83
|
TxParser.addCreditFacade = function (creditFacade, underlying) {
|
|
51
|
-
|
|
84
|
+
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying));
|
|
85
|
+
};
|
|
86
|
+
TxParser.addTokens = function (network) {
|
|
87
|
+
(0, mappers_1.objectEntries)(token_1.tokenDataByNetwork[network]).forEach(function (_a) {
|
|
88
|
+
var s = _a[0], t = _a[1];
|
|
89
|
+
if (s === "STETH") {
|
|
90
|
+
TxParser._addParser(t, new lidoSTETHParser_1.LidoSTETHParser(s));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
var contract = contracts_1.contractsByAddress[t.toLowerCase()];
|
|
94
|
+
if (contract) {
|
|
95
|
+
TxParser.chooseContractParser(t, contract, contracts_1.contractParams[contract].type, true);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
TxParser._addParser(t, new ERC20Parser_1.ERC20Parser(s));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
TxParser.addOffchainOracleParser = function (address) {
|
|
104
|
+
TxParser._addParser(address, new offchainOracleParser_1.OffchainOracleParserParser());
|
|
105
|
+
};
|
|
106
|
+
TxParser.addPriceOracle = function (address) {
|
|
107
|
+
TxParser._addParser(address, new priceOracleParser_1.PriceOracleParser());
|
|
108
|
+
};
|
|
109
|
+
TxParser.addDataCompressor = function (address) {
|
|
110
|
+
TxParser._addParser(address, new dataCompressorParser_1.DataCompressorParser());
|
|
111
|
+
};
|
|
112
|
+
TxParser.addAddressProvider = function (address) {
|
|
113
|
+
TxParser._addParser(address, new addressProviderParser_1.AddressProviderParser());
|
|
114
|
+
};
|
|
115
|
+
TxParser.addMulticall = function (address) {
|
|
116
|
+
TxParser._addParser(address, new multicallParser_1.MulticallParser());
|
|
117
|
+
};
|
|
118
|
+
TxParser.addAirdropDistributor = function (address) {
|
|
119
|
+
TxParser._addParser(address, new airdropDistributorParser_1.AirdropDistributorParser());
|
|
120
|
+
};
|
|
121
|
+
TxParser.addCreditManager = function (address, version) {
|
|
122
|
+
TxParser._addParser(address, new creditManagerParser_1.CreditManagerParser(version));
|
|
52
123
|
};
|
|
53
124
|
TxParser.getParser = function (address) {
|
|
54
|
-
var parser =
|
|
125
|
+
var parser = TxParser.parsers[address.toLowerCase()];
|
|
55
126
|
if (!parser)
|
|
56
127
|
throw new Error("Can find parser for ".concat(address));
|
|
57
128
|
return parser;
|
|
58
129
|
};
|
|
59
|
-
TxParser.
|
|
130
|
+
TxParser.chooseContractParser = function (address, contract, adapterType, isContract) {
|
|
60
131
|
var addressLC = address.toLowerCase();
|
|
61
132
|
switch (adapters_1.AdapterInterface[adapterType]) {
|
|
62
133
|
case "UNISWAP_V2_ROUTER":
|
|
63
|
-
TxParser.
|
|
134
|
+
TxParser._addParser(addressLC, new uniV2AdapterParser_1.UniswapV2AdapterParser(contract, isContract));
|
|
64
135
|
break;
|
|
65
136
|
case "UNISWAP_V3_ROUTER":
|
|
66
|
-
TxParser.
|
|
137
|
+
TxParser._addParser(addressLC, new uniV3AdapterParser_1.UniswapV3AdapterParser(contract, isContract));
|
|
67
138
|
break;
|
|
68
139
|
case "CURVE_V1_EXCHANGE_ONLY":
|
|
69
140
|
case "CURVE_V1_2ASSETS":
|
|
@@ -71,27 +142,30 @@ var TxParser = /** @class */ (function () {
|
|
|
71
142
|
case "CURVE_V1_4ASSETS":
|
|
72
143
|
case "CURVE_V1_STECRV_POOL":
|
|
73
144
|
case "CURVE_V1_WRAPPER":
|
|
74
|
-
TxParser.
|
|
145
|
+
TxParser._addParser(addressLC, new curveAdapterParser_1.CurveAdapterParser(contract, isContract));
|
|
75
146
|
break;
|
|
76
147
|
case "YEARN_V2":
|
|
77
|
-
TxParser.
|
|
148
|
+
TxParser._addParser(addressLC, new yearnV2AdapterParser_1.YearnV2AdapterParser(contract, isContract));
|
|
78
149
|
break;
|
|
79
150
|
case "CONVEX_V1_BASE_REWARD_POOL":
|
|
80
|
-
TxParser.
|
|
151
|
+
TxParser._addParser(addressLC, new convexBaseRewardPoolAdapterParser_1.ConvexBaseRewardPoolAdapterParser(contract, isContract));
|
|
81
152
|
break;
|
|
82
153
|
case "CONVEX_V1_BOOSTER":
|
|
83
|
-
TxParser.
|
|
154
|
+
TxParser._addParser(addressLC, new convexBoosterAdapterParser_1.ConvexBoosterAdapterParser(contract, isContract));
|
|
84
155
|
break;
|
|
85
156
|
case "CONVEX_V1_CLAIM_ZAP":
|
|
86
157
|
break;
|
|
87
158
|
case "LIDO_V1":
|
|
88
|
-
TxParser.
|
|
159
|
+
TxParser._addParser(addressLC, new lidoAdapterParser_1.LidoAdapterParser(contract, isContract));
|
|
89
160
|
break;
|
|
90
161
|
case "LIDO_WSTETH_V1":
|
|
91
|
-
TxParser.
|
|
162
|
+
TxParser._addParser(addressLC, new wstETHAdapterParser_1.WstETHAdapterParser(contract, isContract));
|
|
92
163
|
break;
|
|
93
164
|
}
|
|
94
165
|
};
|
|
166
|
+
TxParser._addParser = function (address, parser) {
|
|
167
|
+
TxParser.parsers[address.toLowerCase()] = parser;
|
|
168
|
+
};
|
|
95
169
|
TxParser.parsers = {};
|
|
96
170
|
return TxParser;
|
|
97
171
|
}());
|
|
@@ -44,6 +44,14 @@ var WstETHAdapterParser = /** @class */ (function (_super) {
|
|
|
44
44
|
case "unwrapAll": {
|
|
45
45
|
return "".concat(functionName, "()");
|
|
46
46
|
}
|
|
47
|
+
case "balanceOf": {
|
|
48
|
+
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
49
|
+
return "".concat(functionName, "(").concat(address, ")");
|
|
50
|
+
}
|
|
51
|
+
case "allowance": {
|
|
52
|
+
var _b = this.decodeFunctionData(functionFragment, calldata), account = _b[0], to = _b[1];
|
|
53
|
+
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
54
|
+
}
|
|
47
55
|
default:
|
|
48
56
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
49
57
|
}
|
|
@@ -45,6 +45,17 @@ var YearnV2AdapterParser = /** @class */ (function (_super) {
|
|
|
45
45
|
var maxLossStr = maxLoss ? ", maxLoss: ".concat(maxLoss) : "";
|
|
46
46
|
return "".concat(functionName, "(").concat(amountStr).concat(addressStr).concat(maxLossStr, ")");
|
|
47
47
|
}
|
|
48
|
+
case "pricePerShare": {
|
|
49
|
+
return "".concat(functionName);
|
|
50
|
+
}
|
|
51
|
+
case "balanceOf": {
|
|
52
|
+
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
53
|
+
return "".concat(functionName, "(").concat(address, ")");
|
|
54
|
+
}
|
|
55
|
+
case "allowance": {
|
|
56
|
+
var _c = this.decodeFunctionData(functionFragment, calldata), account = _c[0], to = _c[1];
|
|
57
|
+
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
58
|
+
}
|
|
48
59
|
default:
|
|
49
60
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
50
61
|
}
|