@gearbox-protocol/sdk 3.0.0-next.236 → 3.0.0-next.237

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.
Files changed (85) hide show
  1. package/lib/core/creditAccount.d.ts +5 -5
  2. package/lib/core/creditAccount.js +11 -13
  3. package/lib/core/creditManager.d.ts +12 -0
  4. package/lib/core/creditManager.js +114 -0
  5. package/lib/core/pool.d.ts +6 -0
  6. package/lib/core/pool.js +11 -0
  7. package/lib/core/protocols.js +4 -0
  8. package/lib/core/rewardConvex.js +1 -1
  9. package/lib/core/trade.d.ts +38 -0
  10. package/lib/core/trade.js +110 -0
  11. package/lib/gearboxRewards/api.d.ts +2 -8
  12. package/lib/gearboxRewards/api.js +15 -31
  13. package/lib/index.d.ts +2 -0
  14. package/lib/index.js +2 -0
  15. package/lib/parsers/ERC20Parser.d.ts +8 -0
  16. package/lib/parsers/ERC20Parser.js +36 -0
  17. package/lib/parsers/aaveV2LendingPoolAdapterParser.d.ts +8 -0
  18. package/lib/parsers/aaveV2LendingPoolAdapterParser.js +21 -0
  19. package/lib/parsers/aaveV2WrappedATokenAdapterParser.d.ts +8 -0
  20. package/lib/parsers/aaveV2WrappedATokenAdapterParser.js +21 -0
  21. package/lib/parsers/abstractParser.d.ts +30 -0
  22. package/lib/parsers/abstractParser.js +61 -0
  23. package/lib/parsers/balancerV2VaultParser.d.ts +8 -0
  24. package/lib/parsers/balancerV2VaultParser.js +32 -0
  25. package/lib/parsers/compoundV2CTokenAdapterParser.d.ts +8 -0
  26. package/lib/parsers/compoundV2CTokenAdapterParser.js +21 -0
  27. package/lib/parsers/convexBaseRewardPoolAdapterParser.d.ts +10 -0
  28. package/lib/parsers/convexBaseRewardPoolAdapterParser.js +50 -0
  29. package/lib/parsers/convexBoosterAdapterParser.d.ts +10 -0
  30. package/lib/parsers/convexBoosterAdapterParser.js +44 -0
  31. package/lib/parsers/convextRewardPoolParser.d.ts +8 -0
  32. package/lib/parsers/convextRewardPoolParser.js +21 -0
  33. package/lib/parsers/creditFacadeParser.d.ts +11 -0
  34. package/lib/parsers/creditFacadeParser.js +84 -0
  35. package/lib/parsers/creditManagerParser.d.ts +7 -0
  36. package/lib/parsers/creditManagerParser.js +22 -0
  37. package/lib/parsers/curveAdapterParser.d.ts +13 -0
  38. package/lib/parsers/curveAdapterParser.js +124 -0
  39. package/lib/parsers/erc626AdapterParser.d.ts +8 -0
  40. package/lib/parsers/erc626AdapterParser.js +21 -0
  41. package/lib/parsers/iParser.d.ts +6 -0
  42. package/lib/parsers/iParser.js +2 -0
  43. package/lib/parsers/lidoAdapterParser.d.ts +8 -0
  44. package/lib/parsers/lidoAdapterParser.js +29 -0
  45. package/lib/parsers/lidoSTETHParser.d.ts +8 -0
  46. package/lib/parsers/lidoSTETHParser.js +36 -0
  47. package/lib/parsers/priceOracleParser.d.ts +7 -0
  48. package/lib/parsers/priceOracleParser.js +23 -0
  49. package/lib/parsers/txParser.d.ts +37 -0
  50. package/lib/parsers/txParser.js +170 -0
  51. package/lib/parsers/uniV2AdapterParser.d.ts +8 -0
  52. package/lib/parsers/uniV2AdapterParser.js +51 -0
  53. package/lib/parsers/uniV2AdapterParser.spec.d.ts +1 -0
  54. package/lib/parsers/uniV2AdapterParser.spec.js +59 -0
  55. package/lib/parsers/uniV3AdapterParser.d.ts +10 -0
  56. package/lib/parsers/uniV3AdapterParser.js +101 -0
  57. package/lib/parsers/uniV3AdapterParser.spec.d.ts +1 -0
  58. package/lib/parsers/uniV3AdapterParser.spec.js +96 -0
  59. package/lib/parsers/wstETHAdapterParser.d.ts +8 -0
  60. package/lib/parsers/wstETHAdapterParser.js +50 -0
  61. package/lib/parsers/wstETHAdapterParser.spec.d.ts +1 -0
  62. package/lib/parsers/wstETHAdapterParser.spec.js +37 -0
  63. package/lib/parsers/yearnAdapterParser.spec.d.ts +1 -0
  64. package/lib/parsers/yearnAdapterParser.spec.js +54 -0
  65. package/lib/parsers/yearnV2AdapterParser.d.ts +8 -0
  66. package/lib/parsers/yearnV2AdapterParser.js +57 -0
  67. package/lib/pathfinder/balancerVault.d.ts +33 -0
  68. package/lib/pathfinder/balancerVault.js +59 -0
  69. package/lib/pathfinder/core.d.ts +14 -0
  70. package/lib/pathfinder/core.js +7 -0
  71. package/lib/pathfinder/index.d.ts +3 -0
  72. package/lib/pathfinder/index.js +3 -0
  73. package/lib/pathfinder/pathOptions.d.ts +16 -0
  74. package/lib/pathfinder/pathOptions.js +93 -0
  75. package/lib/pathfinder/pathOptions.spec.d.ts +1 -0
  76. package/lib/pathfinder/pathOptions.spec.js +138 -0
  77. package/lib/pathfinder/pathfinder.d.ts +72 -0
  78. package/lib/pathfinder/pathfinder.js +176 -0
  79. package/lib/pathfinder/pathfinder.spec.d.ts +1 -0
  80. package/lib/pathfinder/pathfinder.spec.js +52 -0
  81. package/lib/pathfinder/utils.d.ts +34 -0
  82. package/lib/pathfinder/utils.js +186 -0
  83. package/lib/payload/creditAccount.d.ts +1 -4
  84. package/lib/payload/pool.d.ts +6 -0
  85. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -31,8 +31,10 @@ __exportStar(require("./core/protocols"), exports);
31
31
  __exportStar(require("./core/rewardClaimer"), exports);
32
32
  __exportStar(require("./core/strategy"), exports);
33
33
  __exportStar(require("./core/tokenDistributor"), exports);
34
+ __exportStar(require("./core/trade"), exports);
34
35
  __exportStar(require("./core/transactions"), exports);
35
36
  __exportStar(require("./gearboxRewards"), exports);
37
+ __exportStar(require("./parsers/txParser"), exports);
36
38
  __exportStar(require("./pathfinder"), exports);
37
39
  __exportStar(require("./payload/bot"), exports);
38
40
  __exportStar(require("./payload/creditAccount"), exports);
@@ -0,0 +1,8 @@
1
+ import { SupportedToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class ERC20Parser extends AbstractParser implements IParser {
6
+ constructor(symbol: SupportedToken);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERC20Parser = void 0;
4
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
+ const types_1 = require("../types");
6
+ const abstractParser_1 = require("./abstractParser");
7
+ class ERC20Parser extends abstractParser_1.AbstractParser {
8
+ constructor(symbol) {
9
+ super(symbol);
10
+ this.adapterName = "Token";
11
+ this.abi = types_1.ierc20Abi;
12
+ }
13
+ parse(calldata) {
14
+ const { functionName, functionData } = this.parseSelector(calldata);
15
+ switch (functionData.functionName) {
16
+ case "totalSupply": {
17
+ return `${functionName}()`;
18
+ }
19
+ case "balanceOf": {
20
+ const [address] = functionData.args || [];
21
+ return `${functionName}(${address})`;
22
+ }
23
+ case "allowance": {
24
+ const [account, to] = functionData.args || [];
25
+ return `${functionName}(account: ${account}, to: ${to})`;
26
+ }
27
+ case "approve": {
28
+ const [spender, amount] = functionData.args || [];
29
+ return `${functionName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
30
+ }
31
+ default:
32
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
33
+ }
34
+ }
35
+ }
36
+ exports.ERC20Parser = ERC20Parser;
@@ -0,0 +1,8 @@
1
+ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class AaveV2LendingPoolAdapterParser extends AbstractParser implements IParser {
6
+ constructor(contract: SupportedContract, isContract: boolean);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AaveV2LendingPoolAdapterParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class AaveV2LendingPoolAdapterParser extends abstractParser_1.AbstractParser {
7
+ constructor(contract, isContract) {
8
+ super(contract);
9
+ this.abi = types_1.iAaveV2LendingPoolAdapterAbi;
10
+ if (!isContract)
11
+ this.adapterName = "AaveV2_LendingPoolAdapter";
12
+ }
13
+ parse(calldata) {
14
+ const { functionName, functionData } = this.parseSelector(calldata);
15
+ switch (functionData.functionName) {
16
+ default:
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
18
+ }
19
+ }
20
+ }
21
+ exports.AaveV2LendingPoolAdapterParser = AaveV2LendingPoolAdapterParser;
@@ -0,0 +1,8 @@
1
+ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class AaveV2WrappedATokenAdapterParser extends AbstractParser implements IParser {
6
+ constructor(contract: SupportedContract, isContract: boolean);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AaveV2WrappedATokenAdapterParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class AaveV2WrappedATokenAdapterParser extends abstractParser_1.AbstractParser {
7
+ constructor(contract, isContract) {
8
+ super(contract);
9
+ this.abi = types_1.iAaveV2WrappedATokenAdapterAbi;
10
+ if (!isContract)
11
+ this.adapterName = "AaveV2_WrappedATokenAdapter";
12
+ }
13
+ parse(calldata) {
14
+ const { functionName, functionData } = this.parseSelector(calldata);
15
+ switch (functionData.functionName) {
16
+ default:
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
18
+ }
19
+ }
20
+ }
21
+ exports.AaveV2WrappedATokenAdapterParser = AaveV2WrappedATokenAdapterParser;
@@ -0,0 +1,30 @@
1
+ import { SupportedToken, TickerToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Abi, Address } from "viem";
3
+ import { BigNumberish } from "../utils/formatter";
4
+ export interface ParsedObject {
5
+ address: Address;
6
+ functionName: string;
7
+ args: readonly any[];
8
+ }
9
+ export declare class AbstractParser {
10
+ readonly contract: string;
11
+ protected abi: Abi;
12
+ adapterName: string;
13
+ constructor(contract: string);
14
+ parseSelector(calldata: Address): {
15
+ functionData: {
16
+ args: Array<any> | undefined;
17
+ functionName: string;
18
+ };
19
+ functionName: string;
20
+ };
21
+ decodeFunctionData(data: Address): {
22
+ args: readonly unknown[] | undefined;
23
+ functionName: string;
24
+ };
25
+ tokenSymbol(address: Address): SupportedToken;
26
+ tokenOrTickerSymbol(address: Address): SupportedToken | TickerToken;
27
+ formatBN(amount: BigNumberish, token: SupportedToken): string;
28
+ parseToObject(address: Address, calldata: Address): ParsedObject;
29
+ reportUnknownFragment(parserName: string, functionName: string, calldata: string): string;
30
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractParser = void 0;
4
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
+ const viem_1 = require("viem");
6
+ class AbstractParser {
7
+ contract;
8
+ abi;
9
+ adapterName;
10
+ constructor(contract) {
11
+ this.contract = contract;
12
+ this.adapterName = "Contract";
13
+ }
14
+ parseSelector(calldata) {
15
+ const functionData = (0, viem_1.decodeFunctionData)({
16
+ abi: this.abi,
17
+ data: calldata,
18
+ });
19
+ if (!functionData.functionName)
20
+ throw new Error("Function fragment not found");
21
+ const functionName = `${this.adapterName}[${this.contract}].${functionData.functionName}`;
22
+ return {
23
+ functionData: functionData,
24
+ functionName,
25
+ };
26
+ }
27
+ decodeFunctionData(data) {
28
+ return (0, viem_1.decodeFunctionData)({
29
+ abi: this.abi,
30
+ data,
31
+ });
32
+ }
33
+ tokenSymbol(address) {
34
+ const symbol = sdk_gov_1.tokenSymbolByAddress[address.toLowerCase()];
35
+ if (!symbol)
36
+ throw new Error(`Unknown token: ${address}`);
37
+ return symbol;
38
+ }
39
+ tokenOrTickerSymbol(address) {
40
+ const symbol = (0, sdk_gov_1.getTokenSymbolOrTicker)(address);
41
+ if (!symbol) {
42
+ throw new Error(`Unknown token or ticker: ${address}`);
43
+ }
44
+ return symbol;
45
+ }
46
+ formatBN(amount, token) {
47
+ return `${(0, sdk_gov_1.formatBN)(amount, sdk_gov_1.decimals[token])} [${(0, sdk_gov_1.toBigInt)(amount).toString()}]`;
48
+ }
49
+ parseToObject(address, calldata) {
50
+ const { functionName, functionData } = this.parseSelector(calldata);
51
+ return {
52
+ address,
53
+ functionName,
54
+ args: functionData.args || [],
55
+ };
56
+ }
57
+ reportUnknownFragment(parserName, functionName, calldata) {
58
+ return `${parserName}: Unknown operation ${functionName} with calldata ${calldata}`;
59
+ }
60
+ }
61
+ exports.AbstractParser = AbstractParser;
@@ -0,0 +1,8 @@
1
+ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class BalancerV2VaultParser extends AbstractParser implements IParser {
6
+ constructor(contract: SupportedContract, isContract: boolean);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalancerV2VaultParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class BalancerV2VaultParser extends abstractParser_1.AbstractParser {
7
+ constructor(contract, isContract) {
8
+ super(contract);
9
+ this.abi = types_1.iBalancerV2VaultAdapterAbi;
10
+ if (!isContract)
11
+ this.adapterName = "BalancerV2Vault";
12
+ }
13
+ parse(calldata) {
14
+ const { functionName, functionData } = this.parseSelector(calldata);
15
+ switch (functionData.functionName) {
16
+ case "batchSwap": {
17
+ return `${functionName}(undefined)`;
18
+ }
19
+ case "swapDiff": {
20
+ const [{ leftoverAmount = 0, assetIn = "", assetOut = "" }] = functionData.args || [{}];
21
+ return `${functionName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(leftoverAmount, this.tokenSymbol(assetIn))}}`;
22
+ }
23
+ case "swap": {
24
+ const [{ assetIn = "", assetOut = "", amount = 0 }] = functionData.args || [{}];
25
+ return `${functionName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(amount, this.tokenSymbol(assetIn))}}`;
26
+ }
27
+ default:
28
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
29
+ }
30
+ }
31
+ }
32
+ exports.BalancerV2VaultParser = BalancerV2VaultParser;
@@ -0,0 +1,8 @@
1
+ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class CompoundV2CTokenAdapterParser extends AbstractParser implements IParser {
6
+ constructor(contract: SupportedContract, isContract: boolean);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompoundV2CTokenAdapterParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class CompoundV2CTokenAdapterParser extends abstractParser_1.AbstractParser {
7
+ constructor(contract, isContract) {
8
+ super(contract);
9
+ this.abi = types_1.iCompoundV2CTokenAdapterAbi;
10
+ if (!isContract)
11
+ this.adapterName = "CompoundV2_CTokenAdapter";
12
+ }
13
+ parse(calldata) {
14
+ const { functionName, functionData } = this.parseSelector(calldata);
15
+ switch (functionData.functionName) {
16
+ default:
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
18
+ }
19
+ }
20
+ }
21
+ exports.CompoundV2CTokenAdapterParser = CompoundV2CTokenAdapterParser;
@@ -0,0 +1,10 @@
1
+ import { SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { BigNumberish } from "../utils/formatter";
4
+ import { AbstractParser } from "./abstractParser";
5
+ import { IParser } from "./iParser";
6
+ export declare class ConvexBaseRewardPoolAdapterParser extends AbstractParser implements IParser {
7
+ constructor(contract: SupportedContract, isContract: boolean);
8
+ parse(calldata: Address): string;
9
+ formatAmount(amount: BigNumberish): string;
10
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConvexBaseRewardPoolAdapterParser = void 0;
4
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
+ const types_1 = require("../types");
6
+ const abstractParser_1 = require("./abstractParser");
7
+ class ConvexBaseRewardPoolAdapterParser extends abstractParser_1.AbstractParser {
8
+ constructor(contract, isContract) {
9
+ super(contract);
10
+ this.abi = types_1.iConvexV1BaseRewardPoolAdapterAbi;
11
+ if (!isContract)
12
+ this.adapterName = "ConvexV1BaseRewardPoolAdapter";
13
+ }
14
+ parse(calldata) {
15
+ const { functionName, functionData } = this.parseSelector(calldata);
16
+ switch (functionData.functionName) {
17
+ case "stake": {
18
+ const [amount] = functionData.args || [];
19
+ return `${functionName}(amount: ${this.formatAmount(amount)})`;
20
+ }
21
+ case "stakeDiff": {
22
+ const [leftoverAmount] = functionData.args || [];
23
+ return `${functionName}(leftoverAmount: ${this.formatAmount(leftoverAmount)})`;
24
+ }
25
+ case "withdraw":
26
+ case "withdrawAndUnwrap": {
27
+ const [amount, claim] = functionData.args || [];
28
+ return `${functionName}(amount: ${this.formatAmount(amount)}, claim: ${claim})`;
29
+ }
30
+ case "withdrawDiff":
31
+ case "withdrawDiffAndUnwrap": {
32
+ const [leftoverAmount, claim] = functionData.args || [];
33
+ return `${functionName}(leftoverAmount: ${this.formatAmount(leftoverAmount)}, claim: ${claim})`;
34
+ }
35
+ case "rewardRate":
36
+ return `${functionName}()`;
37
+ case "totalSupply":
38
+ return `${functionName}()`;
39
+ case "getReward":
40
+ return `${functionName}()`;
41
+ default:
42
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
43
+ }
44
+ }
45
+ formatAmount(amount) {
46
+ return this.formatBN(amount, sdk_gov_1.contractParams[this.contract]
47
+ .stakedToken);
48
+ }
49
+ }
50
+ exports.ConvexBaseRewardPoolAdapterParser = ConvexBaseRewardPoolAdapterParser;
@@ -0,0 +1,10 @@
1
+ import { Address, SupportedContract } from "@gearbox-protocol/sdk-gov";
2
+ import { BigNumberish } from "../utils/formatter";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class ConvexBoosterAdapterParser extends AbstractParser implements IParser {
6
+ constructor(contract: SupportedContract, isContract: boolean);
7
+ parse(calldata: Address): string;
8
+ formatAmount(amount: BigNumberish, pid: number): string;
9
+ formatPid(pid: number): string;
10
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConvexBoosterAdapterParser = void 0;
4
+ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
5
+ const types_1 = require("../types");
6
+ const abstractParser_1 = require("./abstractParser");
7
+ class ConvexBoosterAdapterParser extends abstractParser_1.AbstractParser {
8
+ constructor(contract, isContract) {
9
+ super(contract);
10
+ this.abi = types_1.iConvexV1BoosterAdapterAbi;
11
+ if (!isContract)
12
+ this.adapterName = "ConvexV1BoosterAdapter";
13
+ }
14
+ parse(calldata) {
15
+ const { functionName, functionData } = this.parseSelector(calldata);
16
+ switch (functionData.functionName) {
17
+ case "deposit": {
18
+ const [pid, amount, stake] = functionData.args || [];
19
+ return `${functionName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)}, stake: ${stake})`;
20
+ }
21
+ case "depositDiff": {
22
+ const [pid, leftoverAmount, stake] = functionData.args || [];
23
+ return `${functionName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)}, stake: ${stake})`;
24
+ }
25
+ case "withdraw": {
26
+ const [pid, amount] = functionData.args || [];
27
+ return `${functionName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)})`;
28
+ }
29
+ case "withdrawDiff": {
30
+ const [pid, leftoverAmount] = functionData.args || [];
31
+ return `${functionName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)})`;
32
+ }
33
+ default:
34
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
35
+ }
36
+ }
37
+ formatAmount(amount, pid) {
38
+ return this.formatBN(amount, sdk_gov_1.convexLpTokenByPid[pid]);
39
+ }
40
+ formatPid(pid) {
41
+ return `${pid} [${sdk_gov_1.convexPoolByPid[pid]}]`;
42
+ }
43
+ }
44
+ exports.ConvexBoosterAdapterParser = ConvexBoosterAdapterParser;
@@ -0,0 +1,8 @@
1
+ import { NormalToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { AbstractParser } from "./abstractParser";
4
+ import { IParser } from "./iParser";
5
+ export declare class ConvexRewardPoolParser extends AbstractParser implements IParser {
6
+ constructor(token: NormalToken);
7
+ parse(calldata: Address): string;
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConvexRewardPoolParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class ConvexRewardPoolParser extends abstractParser_1.AbstractParser {
7
+ constructor(token) {
8
+ super(`ConvexRewardPool_${token}`);
9
+ this.abi = types_1.iBaseRewardPoolAbi;
10
+ }
11
+ parse(calldata) {
12
+ const { functionName, functionData } = this.parseSelector(calldata);
13
+ switch (functionData.functionName) {
14
+ case "rewardRate":
15
+ return `${functionName}()`;
16
+ default:
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
18
+ }
19
+ }
20
+ }
21
+ exports.ConvexRewardPoolParser = ConvexRewardPoolParser;
@@ -0,0 +1,11 @@
1
+ import { SupportedToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { BigNumberish } from "../utils/formatter";
4
+ import { AbstractParser } from "./abstractParser";
5
+ import { IParser } from "./iParser";
6
+ export declare class CreditFacadeParser extends AbstractParser implements IParser {
7
+ version: number;
8
+ constructor(token: SupportedToken, version: number);
9
+ parse(calldata: Address): string;
10
+ formatAmount(amount: BigNumberish): string;
11
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreditFacadeParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class CreditFacadeParser extends abstractParser_1.AbstractParser {
7
+ version;
8
+ constructor(token, version) {
9
+ super(token);
10
+ this.version = version;
11
+ this.abi =
12
+ version >= 300 ? types_1.iCreditFacadeV3MulticallAbi : types_1.iCreditFacadeV2ExtendedAbi;
13
+ this.adapterName = "CreditFacade";
14
+ }
15
+ parse(calldata) {
16
+ const { functionName, functionData } = this.parseSelector(calldata);
17
+ switch (functionData.functionName) {
18
+ case "addCollateral": {
19
+ const r = functionData.args || [];
20
+ const token = r[0];
21
+ const amount = r[1];
22
+ return `${functionName}(token: ${this.tokenSymbol(token)}, amount: ${this.formatBN(amount, this.tokenSymbol(token))})`;
23
+ }
24
+ case "increaseDebt":
25
+ case "decreaseDebt": {
26
+ const [amount] = functionData.args || [];
27
+ return `${functionName}(amount: ${this.formatAmount(amount)})`;
28
+ }
29
+ case "enableToken":
30
+ case "disableToken": {
31
+ const [address] = functionData.args || [];
32
+ return `${functionName}(token: ${this.tokenSymbol(address)})`;
33
+ }
34
+ case "updateQuota": {
35
+ const [address, quotaUpdate, minQuota] = functionData.args || [];
36
+ return `${functionName}(token: ${this.tokenSymbol(address)}, quotaUpdate: ${this.formatAmount(quotaUpdate)}, minQuota: ${this.formatAmount(minQuota)})`;
37
+ }
38
+ case "revertIfReceivedLessThan": {
39
+ const [balances] = functionData.args || [];
40
+ const balancesStr = balances
41
+ .map(b => {
42
+ const balance = "balance" in b ? b.balance : b.amount;
43
+ const symbol = this.tokenSymbol(b.token);
44
+ return `${symbol}: ${this.formatBN(balance, symbol)}`;
45
+ })
46
+ .join(", ");
47
+ return `${functionName}(${balancesStr})`;
48
+ }
49
+ case "withdrawCollateral": {
50
+ const [token, amount, to] = functionData.args || [];
51
+ return `${functionName}(token: ${this.tokenSymbol(token)}, withdraw: ${this.formatBN(amount, this.tokenSymbol(token))}, to: ${to})`;
52
+ }
53
+ case "addCollateralWithPermit": {
54
+ const [tokenAddress, amount, deadline, v, r, s] = functionData.args || [];
55
+ return `${functionName}(token: ${this.tokenSymbol(tokenAddress)}, amount: ${this.formatBN(amount, this.tokenSymbol(tokenAddress))}, ${[deadline, v, r, s].join(", ")})`;
56
+ }
57
+ case "compareBalances": {
58
+ return `${functionName}()`;
59
+ }
60
+ case "setFullCheckParams": {
61
+ const [collateralHints, minHealthFactor] = functionData.args || [];
62
+ return `${functionName}(token: ${collateralHints
63
+ .map((a) => this.formatAmount(a))
64
+ .join(", ")}, minHealthFactor: ${minHealthFactor})`;
65
+ }
66
+ case "storeExpectedBalances": {
67
+ const [balanceDeltas] = functionData.args || [];
68
+ return `${functionName}(balanceDeltas: ${balanceDeltas
69
+ .map((b) => `${this.tokenSymbol(b.token)}: ${this.formatBN(b.amount, this.tokenSymbol(b.token))}`)
70
+ .join(", ")})`;
71
+ }
72
+ case "onDemandPriceUpdate": {
73
+ const [token, reserve, data] = functionData.args || [];
74
+ return `${functionName}(token: ${this.tokenOrTickerSymbol(token)}, reserve: ${reserve}, data: ${data})`;
75
+ }
76
+ default:
77
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
78
+ }
79
+ }
80
+ formatAmount(amount) {
81
+ return this.formatBN(amount, this.contract);
82
+ }
83
+ }
84
+ exports.CreditFacadeParser = CreditFacadeParser;
@@ -0,0 +1,7 @@
1
+ import { Address } from "viem";
2
+ import { AbstractParser } from "./abstractParser";
3
+ import { IParser } from "./iParser";
4
+ export declare class CreditManagerParser extends AbstractParser implements IParser {
5
+ constructor(version: number);
6
+ parse(calldata: Address): string;
7
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreditManagerParser = void 0;
4
+ const types_1 = require("../types");
5
+ const abstractParser_1 = require("./abstractParser");
6
+ class CreditManagerParser extends abstractParser_1.AbstractParser {
7
+ constructor(version) {
8
+ super(`CreditManager_V${version}`);
9
+ this.abi = version === 2 ? types_1.iCreditManagerV2Abi : types_1.iCreditManagerV3Abi;
10
+ }
11
+ parse(calldata) {
12
+ const { functionName, functionData } = this.parseSelector(calldata);
13
+ switch (functionData.functionName) {
14
+ case "creditConfigurator": {
15
+ return `${functionName}()`;
16
+ }
17
+ default:
18
+ return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
19
+ }
20
+ }
21
+ }
22
+ exports.CreditManagerParser = CreditManagerParser;
@@ -0,0 +1,13 @@
1
+ import { SupportedContract, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
+ import { Address } from "viem";
3
+ import { BigNumberish } from "../utils/formatter";
4
+ import { AbstractParser } from "./abstractParser";
5
+ import { IParser } from "./iParser";
6
+ export declare class CurveAdapterParser extends AbstractParser implements IParser {
7
+ protected lpToken: SupportedToken;
8
+ constructor(contract: SupportedContract, isContract: boolean);
9
+ parse(calldata: Address): string;
10
+ getTokenByIndex(index: number): SupportedToken;
11
+ getUnderlyingTokenByIndex(index: number): SupportedToken;
12
+ convertAmounts(amounts: Array<BigNumberish>): string;
13
+ }