@gearbox-protocol/sdk 1.19.5 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +6 -0
- package/lib/parsers/abstractParser.js +12 -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 +49 -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 +92 -19
- package/lib/parsers/wstETHAdapterParser.js +8 -0
- package/lib/parsers/yearnV2AdapterParser.js +11 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -12,7 +12,13 @@ export declare class AbstractParser {
|
|
|
12
12
|
constructor(contract: string);
|
|
13
13
|
parseSelector(calldata: string): ParseSelectorResult;
|
|
14
14
|
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
|
15
|
+
encodeFunctionResult(functionFragment: FunctionFragment | string, data: Array<any>): string;
|
|
15
16
|
tokenSymbol(address: string): SupportedToken;
|
|
16
17
|
formatBN(amount: BigNumberish, token: SupportedToken): string;
|
|
18
|
+
parseToObject(address: string, calldata: string): {
|
|
19
|
+
address: string;
|
|
20
|
+
functionFragment: FunctionFragment;
|
|
21
|
+
args: Result;
|
|
22
|
+
};
|
|
17
23
|
}
|
|
18
24
|
export {};
|
|
@@ -18,6 +18,9 @@ var AbstractParser = /** @class */ (function () {
|
|
|
18
18
|
AbstractParser.prototype.decodeFunctionData = function (functionFragment, data) {
|
|
19
19
|
return this.ifc.decodeFunctionData(functionFragment, data);
|
|
20
20
|
};
|
|
21
|
+
AbstractParser.prototype.encodeFunctionResult = function (functionFragment, data) {
|
|
22
|
+
return this.ifc.encodeFunctionResult(functionFragment, data);
|
|
23
|
+
};
|
|
21
24
|
AbstractParser.prototype.tokenSymbol = function (address) {
|
|
22
25
|
var symbol = token_1.tokenSymbolByAddress[address.toLowerCase()];
|
|
23
26
|
if (!symbol)
|
|
@@ -27,6 +30,15 @@ var AbstractParser = /** @class */ (function () {
|
|
|
27
30
|
AbstractParser.prototype.formatBN = function (amount, token) {
|
|
28
31
|
return "".concat((0, formatter_1.formatBN)(amount, decimals_1.decimals[token]), " [").concat(ethers_1.BigNumber.from(amount).toString(), "]");
|
|
29
32
|
};
|
|
33
|
+
AbstractParser.prototype.parseToObject = function (address, calldata) {
|
|
34
|
+
var functionFragment = this.parseSelector(calldata).functionFragment;
|
|
35
|
+
var args = this.decodeFunctionData(functionFragment, calldata);
|
|
36
|
+
return {
|
|
37
|
+
address: address,
|
|
38
|
+
functionFragment: functionFragment,
|
|
39
|
+
args: args,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
30
42
|
return AbstractParser;
|
|
31
43
|
}());
|
|
32
44
|
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,49 @@
|
|
|
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, "LIDO_".concat(symbol)) || this;
|
|
25
|
+
_this.ifc = types_1.IstETH__factory.createInterface();
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
LidoSTETHParser.prototype.parse = function (calldata) {
|
|
29
|
+
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
|
+
switch (functionFragment.name) {
|
|
31
|
+
case "getFee":
|
|
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
|
+
default:
|
|
44
|
+
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return LidoSTETHParser;
|
|
48
|
+
}(abstractParser_1.AbstractParser));
|
|
49
|
+
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,15 @@ 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 parser = TxParser.getParser(address);
|
|
37
|
+
return parser.parseToObject(address, calldata);
|
|
38
|
+
};
|
|
22
39
|
TxParser.getParseData = function (address) {
|
|
23
|
-
var parser =
|
|
40
|
+
var parser = TxParser.getParser(address);
|
|
24
41
|
return { contract: parser.contract, adapterName: parser.adapterName };
|
|
25
42
|
};
|
|
26
43
|
TxParser.parseMultiCall = function (calls) {
|
|
@@ -28,12 +45,17 @@ var TxParser = /** @class */ (function () {
|
|
|
28
45
|
return TxParser.parse(call.target, call.callData.toString());
|
|
29
46
|
});
|
|
30
47
|
};
|
|
48
|
+
TxParser.parseToObjectMultiCall = function (calls) {
|
|
49
|
+
return calls.map(function (call) {
|
|
50
|
+
return TxParser.parseToObject(call.target, call.callData.toString());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
31
53
|
TxParser.addAdapters = function (adapters) {
|
|
32
54
|
for (var _i = 0, adapters_2 = adapters; _i < adapters_2.length; _i++) {
|
|
33
55
|
var a = adapters_2[_i];
|
|
34
56
|
var contract = contracts_1.contractsByAddress[a.contract.toLowerCase()];
|
|
35
57
|
if (contract && contracts_1.contractParams[contract]) {
|
|
36
|
-
TxParser.
|
|
58
|
+
TxParser.chooseContractParser(a.adapter, contract, contracts_1.contractParams[contract].type, false);
|
|
37
59
|
}
|
|
38
60
|
else {
|
|
39
61
|
console.error("Unknown address: ".concat(contract, " at ").concat(a.contract));
|
|
@@ -41,29 +63,77 @@ var TxParser = /** @class */ (function () {
|
|
|
41
63
|
}
|
|
42
64
|
};
|
|
43
65
|
TxParser.addContracts = function (network) {
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
var address = contracts_1.contractsByNetwork[network][
|
|
47
|
-
TxParser.
|
|
48
|
-
|
|
66
|
+
(0, mappers_1.objectEntries)(contracts_1.contractParams).forEach(function (_a) {
|
|
67
|
+
var contract = _a[0], contractData = _a[1];
|
|
68
|
+
var address = contracts_1.contractsByNetwork[network][contract];
|
|
69
|
+
TxParser.chooseContractParser(address, contract, contractData.type, true);
|
|
70
|
+
if (contractData.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL) {
|
|
71
|
+
contractData.extraRewards.forEach(function (r) {
|
|
72
|
+
var extraAddress = r.poolAddress[network];
|
|
73
|
+
TxParser._addParser(extraAddress, new convextRewardPoolParser_1.ConvexRewardPoolParser(r.rewardToken));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (contractData.type === adapters_1.AdapterInterface.LIDO_V1) {
|
|
77
|
+
var extraAddress = contractData.oracle[network];
|
|
78
|
+
TxParser._addParser(extraAddress, new lidoOracleParser_1.LidoOracleParser());
|
|
79
|
+
}
|
|
80
|
+
});
|
|
49
81
|
};
|
|
50
82
|
TxParser.addCreditFacade = function (creditFacade, underlying) {
|
|
51
|
-
|
|
83
|
+
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying));
|
|
84
|
+
};
|
|
85
|
+
TxParser.addTokens = function (network) {
|
|
86
|
+
(0, mappers_1.objectEntries)(token_1.tokenDataByNetwork[network]).forEach(function (_a) {
|
|
87
|
+
var s = _a[0], t = _a[1];
|
|
88
|
+
if (s === "STETH") {
|
|
89
|
+
TxParser._addParser(t, new lidoSTETHParser_1.LidoSTETHParser(s));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
var contract = contracts_1.contractsByAddress[t.toLowerCase()];
|
|
93
|
+
if (contract) {
|
|
94
|
+
TxParser.chooseContractParser(t, contract, contracts_1.contractParams[contract].type, true);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
TxParser._addParser(t, new ERC20Parser_1.ERC20Parser(s));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
TxParser.addOffchainOracleParser = function (address) {
|
|
103
|
+
TxParser._addParser(address, new offchainOracleParser_1.OffchainOracleParserParser());
|
|
104
|
+
};
|
|
105
|
+
TxParser.addPriceOracle = function (address) {
|
|
106
|
+
TxParser._addParser(address, new priceOracleParser_1.PriceOracleParser());
|
|
107
|
+
};
|
|
108
|
+
TxParser.addDataCompressor = function (address) {
|
|
109
|
+
TxParser._addParser(address, new dataCompressorParser_1.DataCompressorParser());
|
|
110
|
+
};
|
|
111
|
+
TxParser.addAddressProvider = function (address) {
|
|
112
|
+
TxParser._addParser(address, new addressProviderParser_1.AddressProviderParser());
|
|
113
|
+
};
|
|
114
|
+
TxParser.addMulticall = function (address) {
|
|
115
|
+
TxParser._addParser(address, new multicallParser_1.MulticallParser());
|
|
116
|
+
};
|
|
117
|
+
TxParser.addAirdropDistributor = function (address) {
|
|
118
|
+
TxParser._addParser(address, new airdropDistributorParser_1.AirdropDistributorParser());
|
|
119
|
+
};
|
|
120
|
+
TxParser.addCreditManager = function (address, version) {
|
|
121
|
+
TxParser._addParser(address, new creditManagerParser_1.CreditManagerParser(version));
|
|
52
122
|
};
|
|
53
123
|
TxParser.getParser = function (address) {
|
|
54
|
-
var parser =
|
|
124
|
+
var parser = TxParser.parsers[address.toLowerCase()];
|
|
55
125
|
if (!parser)
|
|
56
126
|
throw new Error("Can find parser for ".concat(address));
|
|
57
127
|
return parser;
|
|
58
128
|
};
|
|
59
|
-
TxParser.
|
|
129
|
+
TxParser.chooseContractParser = function (address, contract, adapterType, isContract) {
|
|
60
130
|
var addressLC = address.toLowerCase();
|
|
61
131
|
switch (adapters_1.AdapterInterface[adapterType]) {
|
|
62
132
|
case "UNISWAP_V2_ROUTER":
|
|
63
|
-
TxParser.
|
|
133
|
+
TxParser._addParser(addressLC, new uniV2AdapterParser_1.UniswapV2AdapterParser(contract, isContract));
|
|
64
134
|
break;
|
|
65
135
|
case "UNISWAP_V3_ROUTER":
|
|
66
|
-
TxParser.
|
|
136
|
+
TxParser._addParser(addressLC, new uniV3AdapterParser_1.UniswapV3AdapterParser(contract, isContract));
|
|
67
137
|
break;
|
|
68
138
|
case "CURVE_V1_EXCHANGE_ONLY":
|
|
69
139
|
case "CURVE_V1_2ASSETS":
|
|
@@ -71,27 +141,30 @@ var TxParser = /** @class */ (function () {
|
|
|
71
141
|
case "CURVE_V1_4ASSETS":
|
|
72
142
|
case "CURVE_V1_STECRV_POOL":
|
|
73
143
|
case "CURVE_V1_WRAPPER":
|
|
74
|
-
TxParser.
|
|
144
|
+
TxParser._addParser(addressLC, new curveAdapterParser_1.CurveAdapterParser(contract, isContract));
|
|
75
145
|
break;
|
|
76
146
|
case "YEARN_V2":
|
|
77
|
-
TxParser.
|
|
147
|
+
TxParser._addParser(addressLC, new yearnV2AdapterParser_1.YearnV2AdapterParser(contract, isContract));
|
|
78
148
|
break;
|
|
79
149
|
case "CONVEX_V1_BASE_REWARD_POOL":
|
|
80
|
-
TxParser.
|
|
150
|
+
TxParser._addParser(addressLC, new convexBaseRewardPoolAdapterParser_1.ConvexBaseRewardPoolAdapterParser(contract, isContract));
|
|
81
151
|
break;
|
|
82
152
|
case "CONVEX_V1_BOOSTER":
|
|
83
|
-
TxParser.
|
|
153
|
+
TxParser._addParser(addressLC, new convexBoosterAdapterParser_1.ConvexBoosterAdapterParser(contract, isContract));
|
|
84
154
|
break;
|
|
85
155
|
case "CONVEX_V1_CLAIM_ZAP":
|
|
86
156
|
break;
|
|
87
157
|
case "LIDO_V1":
|
|
88
|
-
TxParser.
|
|
158
|
+
TxParser._addParser(addressLC, new lidoAdapterParser_1.LidoAdapterParser(contract, isContract));
|
|
89
159
|
break;
|
|
90
160
|
case "LIDO_WSTETH_V1":
|
|
91
|
-
TxParser.
|
|
161
|
+
TxParser._addParser(addressLC, new wstETHAdapterParser_1.WstETHAdapterParser(contract, isContract));
|
|
92
162
|
break;
|
|
93
163
|
}
|
|
94
164
|
};
|
|
165
|
+
TxParser._addParser = function (address, parser) {
|
|
166
|
+
TxParser.parsers[address.toLowerCase()] = parser;
|
|
167
|
+
};
|
|
95
168
|
TxParser.parsers = {};
|
|
96
169
|
return TxParser;
|
|
97
170
|
}());
|
|
@@ -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
|
}
|