@gearbox-protocol/sdk 1.20.0 → 1.20.2
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/parsers/ERC20Parser.js +4 -3
- package/lib/parsers/abstractParser.d.ts +1 -0
- package/lib/parsers/abstractParser.js +3 -0
- package/lib/parsers/addressProviderParser.js +1 -1
- package/lib/parsers/airdropDistributorParser.js +1 -1
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +2 -2
- package/lib/parsers/convextRewardPoolParser.js +1 -1
- package/lib/parsers/creditManagerParser.js +1 -1
- package/lib/parsers/curveAdapterParser.js +2 -2
- package/lib/parsers/dataCompressorParser.js +1 -1
- package/lib/parsers/lidoOracleParser.js +1 -1
- package/lib/parsers/lidoSTETHParser.js +7 -3
- package/lib/parsers/multicallParser.js +1 -1
- package/lib/parsers/txParser.js +1 -2
- package/lib/parsers/wstETHAdapterParser.js +8 -1
- package/lib/parsers/wstETHAdapterParser.spec.js +5 -5
- package/lib/parsers/yearnV2AdapterParser.js +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ERC20Parser = void 0;
|
|
19
|
+
var ethers_1 = require("ethers/lib/ethers");
|
|
19
20
|
var types_1 = require("../types");
|
|
20
21
|
var abstractParser_1 = require("./abstractParser");
|
|
21
22
|
var ERC20Parser = /** @class */ (function (_super) {
|
|
@@ -30,7 +31,7 @@ var ERC20Parser = /** @class */ (function (_super) {
|
|
|
30
31
|
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
31
32
|
switch (functionFragment.name) {
|
|
32
33
|
case "totalSupply": {
|
|
33
|
-
return "".concat(functionName);
|
|
34
|
+
return "".concat(functionName, "()");
|
|
34
35
|
}
|
|
35
36
|
case "balanceOf": {
|
|
36
37
|
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
@@ -41,8 +42,8 @@ var ERC20Parser = /** @class */ (function (_super) {
|
|
|
41
42
|
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
42
43
|
}
|
|
43
44
|
case "approve": {
|
|
44
|
-
var
|
|
45
|
-
return "".concat(functionName, "(").concat(spender, ")");
|
|
45
|
+
var _c = this.decodeFunctionData(functionFragment, calldata), spender = _c[0], amount = _c[1];
|
|
46
|
+
return "".concat(functionName, "(").concat(spender, ", [").concat(ethers_1.BigNumber.from(amount).toString(), "])");
|
|
46
47
|
}
|
|
47
48
|
default:
|
|
48
49
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
@@ -12,6 +12,7 @@ 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;
|
|
17
18
|
parseToObject(address: string, calldata: string): {
|
|
@@ -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)
|
|
@@ -34,7 +34,7 @@ var AddressProviderParser = /** @class */ (function (_super) {
|
|
|
34
34
|
case "getDataCompressor":
|
|
35
35
|
case "getWETHGateway":
|
|
36
36
|
case "getPriceOracle": {
|
|
37
|
-
return "".concat(functionName);
|
|
37
|
+
return "".concat(functionName, "()");
|
|
38
38
|
}
|
|
39
39
|
default:
|
|
40
40
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
@@ -29,7 +29,7 @@ var AirdropDistributorParser = /** @class */ (function (_super) {
|
|
|
29
29
|
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
30
|
switch (functionFragment.name) {
|
|
31
31
|
case "merkleRoot": {
|
|
32
|
-
return "".concat(functionName);
|
|
32
|
+
return "".concat(functionName, "()");
|
|
33
33
|
}
|
|
34
34
|
default:
|
|
35
35
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
@@ -48,9 +48,9 @@ var ConvexBaseRewardPoolAdapterParser = /** @class */ (function (_super) {
|
|
|
48
48
|
return "".concat(functionName, "(claim: ").concat(claim, ")");
|
|
49
49
|
}
|
|
50
50
|
case "rewardRate":
|
|
51
|
-
return "".concat(functionName);
|
|
51
|
+
return "".concat(functionName, "()");
|
|
52
52
|
case "totalSupply":
|
|
53
|
-
return "".concat(functionName);
|
|
53
|
+
return "".concat(functionName, "()");
|
|
54
54
|
default:
|
|
55
55
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
56
56
|
}
|
|
@@ -29,7 +29,7 @@ var ConvexRewardPoolParser = /** @class */ (function (_super) {
|
|
|
29
29
|
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
30
|
switch (functionFragment.name) {
|
|
31
31
|
case "rewardRate":
|
|
32
|
-
return "".concat(functionName);
|
|
32
|
+
return "".concat(functionName, "()");
|
|
33
33
|
default:
|
|
34
34
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
35
35
|
}
|
|
@@ -32,7 +32,7 @@ var CreditManagerParser = /** @class */ (function (_super) {
|
|
|
32
32
|
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
33
33
|
switch (functionFragment.name) {
|
|
34
34
|
case "creditConfigurator": {
|
|
35
|
-
return "".concat(functionName);
|
|
35
|
+
return "".concat(functionName, "()");
|
|
36
36
|
}
|
|
37
37
|
default:
|
|
38
38
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
@@ -95,7 +95,7 @@ var CurveAdapterParser = /** @class */ (function (_super) {
|
|
|
95
95
|
return "".concat(functionName, "(amounts: [").concat(this.convertAmounts(amounts), "], max_burn_amount: ").concat(this.formatBN(maxBurnAmount, this.lpToken), ")");
|
|
96
96
|
}
|
|
97
97
|
case "totalSupply": {
|
|
98
|
-
return "".concat(functionName);
|
|
98
|
+
return "".concat(functionName, "()");
|
|
99
99
|
}
|
|
100
100
|
case "balances": {
|
|
101
101
|
var i = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
@@ -106,7 +106,7 @@ var CurveAdapterParser = /** @class */ (function (_super) {
|
|
|
106
106
|
return "".concat(functionName, "(").concat(address, ")");
|
|
107
107
|
}
|
|
108
108
|
case "get_virtual_price": {
|
|
109
|
-
return "".concat(functionName);
|
|
109
|
+
return "".concat(functionName, "()");
|
|
110
110
|
}
|
|
111
111
|
case "allowance": {
|
|
112
112
|
var _j = this.decodeFunctionData(functionFragment, calldata), account = _j[0], to = _j[1];
|
|
@@ -30,7 +30,7 @@ var DataCompressorParser = /** @class */ (function (_super) {
|
|
|
30
30
|
switch (functionFragment.name) {
|
|
31
31
|
case "getPoolsList":
|
|
32
32
|
case "getCreditManagersList": {
|
|
33
|
-
return "".concat(functionName);
|
|
33
|
+
return "".concat(functionName, "()");
|
|
34
34
|
}
|
|
35
35
|
default:
|
|
36
36
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
@@ -29,7 +29,7 @@ var LidoOracleParser = /** @class */ (function (_super) {
|
|
|
29
29
|
var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
|
|
30
30
|
switch (functionFragment.name) {
|
|
31
31
|
case "getLastCompletedReportDelta":
|
|
32
|
-
return "".concat(functionName);
|
|
32
|
+
return "".concat(functionName, "()");
|
|
33
33
|
default:
|
|
34
34
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
35
35
|
}
|
|
@@ -16,14 +16,14 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.LidoSTETHParser = void 0;
|
|
19
|
+
var ethers_1 = require("ethers");
|
|
19
20
|
var types_1 = require("../types");
|
|
20
21
|
var abstractParser_1 = require("./abstractParser");
|
|
21
22
|
var LidoSTETHParser = /** @class */ (function (_super) {
|
|
22
23
|
__extends(LidoSTETHParser, _super);
|
|
23
24
|
function LidoSTETHParser(symbol) {
|
|
24
|
-
var _this = _super.call(this, symbol) || this;
|
|
25
|
+
var _this = _super.call(this, "LIDO_".concat(symbol)) || this;
|
|
25
26
|
_this.ifc = types_1.IstETH__factory.createInterface();
|
|
26
|
-
_this.adapterName = "TokenLido";
|
|
27
27
|
return _this;
|
|
28
28
|
}
|
|
29
29
|
LidoSTETHParser.prototype.parse = function (calldata) {
|
|
@@ -31,7 +31,7 @@ var LidoSTETHParser = /** @class */ (function (_super) {
|
|
|
31
31
|
switch (functionFragment.name) {
|
|
32
32
|
case "getFee":
|
|
33
33
|
case "totalSupply": {
|
|
34
|
-
return "".concat(functionName);
|
|
34
|
+
return "".concat(functionName, "()");
|
|
35
35
|
}
|
|
36
36
|
case "balanceOf": {
|
|
37
37
|
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|
|
@@ -41,6 +41,10 @@ var LidoSTETHParser = /** @class */ (function (_super) {
|
|
|
41
41
|
var _b = this.decodeFunctionData(functionFragment, calldata), account = _b[0], to = _b[1];
|
|
42
42
|
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
43
43
|
}
|
|
44
|
+
case "approve": {
|
|
45
|
+
var _c = this.decodeFunctionData(functionFragment, calldata), spender = _c[0], amount = _c[1];
|
|
46
|
+
return "".concat(functionName, "(").concat(spender, ", [").concat(ethers_1.BigNumber.from(amount).toString(), "])");
|
|
47
|
+
}
|
|
44
48
|
default:
|
|
45
49
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
46
50
|
}
|
|
@@ -33,7 +33,7 @@ var MulticallParser = /** @class */ (function (_super) {
|
|
|
33
33
|
return "".concat(functionName, ": ").concat(calls);
|
|
34
34
|
}
|
|
35
35
|
case "getBlockNumber": {
|
|
36
|
-
return "".concat(functionName);
|
|
36
|
+
return "".concat(functionName, "()");
|
|
37
37
|
}
|
|
38
38
|
case "getEthBalance": {
|
|
39
39
|
var account = this.decodeFunctionData(functionFragment, calldata)[0];
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -33,9 +33,8 @@ var TxParser = /** @class */ (function () {
|
|
|
33
33
|
return parser.parse(calldata);
|
|
34
34
|
};
|
|
35
35
|
TxParser.parseToObject = function (address, calldata) {
|
|
36
|
-
var _a;
|
|
37
36
|
var parser = TxParser.getParser(address);
|
|
38
|
-
return
|
|
37
|
+
return parser.parseToObject(address, calldata);
|
|
39
38
|
};
|
|
40
39
|
TxParser.getParseData = function (address) {
|
|
41
40
|
var parser = TxParser.getParser(address);
|
|
@@ -16,13 +16,16 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.WstETHAdapterParser = void 0;
|
|
19
|
+
var ethers_1 = require("ethers");
|
|
19
20
|
var types_1 = require("../types");
|
|
20
21
|
var abstractParser_1 = require("./abstractParser");
|
|
21
22
|
var WstETHAdapterParser = /** @class */ (function (_super) {
|
|
22
23
|
__extends(WstETHAdapterParser, _super);
|
|
23
24
|
function WstETHAdapterParser(contract, isContract) {
|
|
24
25
|
var _this = _super.call(this, contract) || this;
|
|
25
|
-
_this.ifc =
|
|
26
|
+
_this.ifc = !isContract
|
|
27
|
+
? types_1.IwstETHV1Adapter__factory.createInterface()
|
|
28
|
+
: types_1.IwstETH__factory.createInterface();
|
|
26
29
|
if (!isContract)
|
|
27
30
|
_this.adapterName = "wstETHAdapter";
|
|
28
31
|
return _this;
|
|
@@ -52,6 +55,10 @@ var WstETHAdapterParser = /** @class */ (function (_super) {
|
|
|
52
55
|
var _b = this.decodeFunctionData(functionFragment, calldata), account = _b[0], to = _b[1];
|
|
53
56
|
return "".concat(functionName, "(account: ").concat(account, ", to: ").concat(to, ")");
|
|
54
57
|
}
|
|
58
|
+
case "approve": {
|
|
59
|
+
var _c = this.decodeFunctionData(functionFragment, calldata), spender = _c[0], amount = _c[1];
|
|
60
|
+
return "".concat(functionName, "(").concat(spender, ", [").concat(ethers_1.BigNumber.from(amount).toString(), "])");
|
|
61
|
+
}
|
|
55
62
|
default:
|
|
56
63
|
return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
|
|
57
64
|
}
|
|
@@ -8,14 +8,14 @@ describe("WstETHAdapterParser test", function () {
|
|
|
8
8
|
it("wrap / unwrap function works well", function () {
|
|
9
9
|
var parser = new wstETHAdapterParser_1.WstETHAdapterParser("LIDO_WSTETH", false);
|
|
10
10
|
var ifc = types_1.IwstETHV1Adapter__factory.createInterface();
|
|
11
|
-
var parsed = parser.parse(ifc.encodeFunctionData("
|
|
12
|
-
(0, chai_1.expect)(parsed).to.be.eq("wstETHAdapter[LIDO_WSTETH].wrap(amount: 1.02K [1020000000000000000000])", "Incorrect parse wrap(amount)");
|
|
13
|
-
parsed = parser.parse(ifc.encodeFunctionData("wrapAll"));
|
|
11
|
+
var parsed = parser.parse(ifc.encodeFunctionData("wrapAll"));
|
|
14
12
|
(0, chai_1.expect)(parsed).to.be.eq("wstETHAdapter[LIDO_WSTETH].wrapAll()", "Incorrect parse wrapAll()");
|
|
13
|
+
parsed = parser.parse(ifc.encodeFunctionData("unwrapAll"));
|
|
14
|
+
(0, chai_1.expect)(parsed).to.be.eq("wstETHAdapter[LIDO_WSTETH].unwrapAll()", "Incorrect parse unwrapAll()");
|
|
15
15
|
parser = new wstETHAdapterParser_1.WstETHAdapterParser("LIDO_WSTETH", true);
|
|
16
|
+
parsed = parser.parse(ifc.encodeFunctionData("wrap", [constants_1.WAD.mul(1020)]));
|
|
17
|
+
(0, chai_1.expect)(parsed).to.be.eq("Contract[LIDO_WSTETH].wrap(amount: 1.02K [1020000000000000000000])", "Incorrect parse wrap(amount)");
|
|
16
18
|
parsed = parser.parse(ifc.encodeFunctionData("unwrap", [constants_1.WAD.mul(1020)]));
|
|
17
19
|
(0, chai_1.expect)(parsed).to.be.eq("Contract[LIDO_WSTETH].unwrap(amount: 1.02K [1020000000000000000000])", "Incorrect parse unwrap(amount)");
|
|
18
|
-
parsed = parser.parse(ifc.encodeFunctionData("unwrapAll"));
|
|
19
|
-
(0, chai_1.expect)(parsed).to.be.eq("Contract[LIDO_WSTETH].unwrapAll()", "Incorrect parse unwrapAll()");
|
|
20
20
|
});
|
|
21
21
|
});
|
|
@@ -46,7 +46,7 @@ var YearnV2AdapterParser = /** @class */ (function (_super) {
|
|
|
46
46
|
return "".concat(functionName, "(").concat(amountStr).concat(addressStr).concat(maxLossStr, ")");
|
|
47
47
|
}
|
|
48
48
|
case "pricePerShare": {
|
|
49
|
-
return "".concat(functionName);
|
|
49
|
+
return "".concat(functionName, "()");
|
|
50
50
|
}
|
|
51
51
|
case "balanceOf": {
|
|
52
52
|
var address = this.decodeFunctionData(functionFragment, calldata)[0];
|