@gearbox-protocol/sdk 3.0.0-next.240 → 3.0.0-next.241

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.
@@ -11,25 +11,25 @@ class ERC20Parser extends abstractParser_1.AbstractParser {
11
11
  this.abi = types_1.ierc20Abi;
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  case "totalSupply": {
17
- return `${functionName}()`;
17
+ return `${operationName}()`;
18
18
  }
19
19
  case "balanceOf": {
20
20
  const [address] = functionData.args || [];
21
- return `${functionName}(${address})`;
21
+ return `${operationName}(${address})`;
22
22
  }
23
23
  case "allowance": {
24
24
  const [account, to] = functionData.args || [];
25
- return `${functionName}(account: ${account}, to: ${to})`;
25
+ return `${operationName}(account: ${account}, to: ${to})`;
26
26
  }
27
27
  case "approve": {
28
28
  const [spender, amount] = functionData.args || [];
29
- return `${functionName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
29
+ return `${operationName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
30
30
  }
31
31
  default:
32
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
32
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
33
33
  }
34
34
  }
35
35
  }
@@ -11,10 +11,10 @@ class AaveV2LendingPoolAdapterParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "AaveV2_LendingPoolAdapter";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  default:
17
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
18
18
  }
19
19
  }
20
20
  }
@@ -11,10 +11,10 @@ class AaveV2WrappedATokenAdapterParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "AaveV2_WrappedATokenAdapter";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  default:
17
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
18
18
  }
19
19
  }
20
20
  }
@@ -16,7 +16,7 @@ export declare class AbstractParser {
16
16
  args: Array<any> | undefined;
17
17
  functionName: string;
18
18
  };
19
- functionName: string;
19
+ operationName: string;
20
20
  };
21
21
  decodeFunctionData(data: Address): {
22
22
  args: readonly unknown[] | undefined;
@@ -18,10 +18,10 @@ class AbstractParser {
18
18
  });
19
19
  if (!functionData.functionName)
20
20
  throw new Error("Function fragment not found");
21
- const functionName = `${this.adapterName}[${this.contract}].${functionData.functionName}`;
21
+ const operationName = `${this.adapterName}[${this.contract}].${functionData.functionName}`;
22
22
  return {
23
23
  functionData: functionData,
24
- functionName,
24
+ operationName,
25
25
  };
26
26
  }
27
27
  decodeFunctionData(data) {
@@ -47,10 +47,10 @@ class AbstractParser {
47
47
  return `${(0, sdk_gov_1.formatBN)(amount, sdk_gov_1.decimals[token])} [${(0, sdk_gov_1.toBigInt)(amount).toString()}]`;
48
48
  }
49
49
  parseToObject(address, calldata) {
50
- const { functionName, functionData } = this.parseSelector(calldata);
50
+ const { functionData } = this.parseSelector(calldata);
51
51
  return {
52
52
  address,
53
- functionName,
53
+ functionName: functionData.functionName,
54
54
  args: functionData.args || [],
55
55
  };
56
56
  }
@@ -11,21 +11,21 @@ class BalancerV2VaultParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "BalancerV2Vault";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  case "batchSwap": {
17
- return `${functionName}(undefined)`;
17
+ return `${operationName}(undefined)`;
18
18
  }
19
19
  case "swapDiff": {
20
20
  const [{ leftoverAmount = 0, assetIn = "", assetOut = "" }] = functionData.args || [{}];
21
- return `${functionName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(leftoverAmount, this.tokenSymbol(assetIn))}}`;
21
+ return `${operationName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(leftoverAmount, this.tokenSymbol(assetIn))}}`;
22
22
  }
23
23
  case "swap": {
24
24
  const [{ assetIn = "", assetOut = "", amount = 0 }] = functionData.args || [{}];
25
- return `${functionName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(amount, this.tokenSymbol(assetIn))}}`;
25
+ return `${operationName}(${this.tokenSymbol(assetIn)} => ${this.tokenSymbol(assetOut)} ${this.formatBN(amount, this.tokenSymbol(assetIn))}}`;
26
26
  }
27
27
  default:
28
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
28
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
29
29
  }
30
30
  }
31
31
  }
@@ -11,10 +11,10 @@ class CompoundV2CTokenAdapterParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "CompoundV2_CTokenAdapter";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  default:
17
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
18
18
  }
19
19
  }
20
20
  }
@@ -12,34 +12,34 @@ class ConvexBaseRewardPoolAdapterParser extends abstractParser_1.AbstractParser
12
12
  this.adapterName = "ConvexV1BaseRewardPoolAdapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionName, functionData } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "stake": {
18
18
  const [amount] = functionData.args || [];
19
- return `${functionName}(amount: ${this.formatAmount(amount)})`;
19
+ return `${operationName}(amount: ${this.formatAmount(amount)})`;
20
20
  }
21
21
  case "stakeDiff": {
22
22
  const [leftoverAmount] = functionData.args || [];
23
- return `${functionName}(leftoverAmount: ${this.formatAmount(leftoverAmount)})`;
23
+ return `${operationName}(leftoverAmount: ${this.formatAmount(leftoverAmount)})`;
24
24
  }
25
25
  case "withdraw":
26
26
  case "withdrawAndUnwrap": {
27
27
  const [amount, claim] = functionData.args || [];
28
- return `${functionName}(amount: ${this.formatAmount(amount)}, claim: ${claim})`;
28
+ return `${operationName}(amount: ${this.formatAmount(amount)}, claim: ${claim})`;
29
29
  }
30
30
  case "withdrawDiff":
31
31
  case "withdrawDiffAndUnwrap": {
32
32
  const [leftoverAmount, claim] = functionData.args || [];
33
- return `${functionName}(leftoverAmount: ${this.formatAmount(leftoverAmount)}, claim: ${claim})`;
33
+ return `${operationName}(leftoverAmount: ${this.formatAmount(leftoverAmount)}, claim: ${claim})`;
34
34
  }
35
35
  case "rewardRate":
36
- return `${functionName}()`;
36
+ return `${operationName}()`;
37
37
  case "totalSupply":
38
- return `${functionName}()`;
38
+ return `${operationName}()`;
39
39
  case "getReward":
40
- return `${functionName}()`;
40
+ return `${operationName}()`;
41
41
  default:
42
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
42
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
43
43
  }
44
44
  }
45
45
  formatAmount(amount) {
@@ -12,26 +12,26 @@ class ConvexBoosterAdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "ConvexV1BoosterAdapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionName, functionData } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "deposit": {
18
18
  const [pid, amount, stake] = functionData.args || [];
19
- return `${functionName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)}, stake: ${stake})`;
19
+ return `${operationName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)}, stake: ${stake})`;
20
20
  }
21
21
  case "depositDiff": {
22
22
  const [pid, leftoverAmount, stake] = functionData.args || [];
23
- return `${functionName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)}, stake: ${stake})`;
23
+ return `${operationName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)}, stake: ${stake})`;
24
24
  }
25
25
  case "withdraw": {
26
26
  const [pid, amount] = functionData.args || [];
27
- return `${functionName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)})`;
27
+ return `${operationName}(pid: ${this.formatPid(pid)}, amount: ${this.formatAmount(amount, pid)})`;
28
28
  }
29
29
  case "withdrawDiff": {
30
30
  const [pid, leftoverAmount] = functionData.args || [];
31
- return `${functionName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)})`;
31
+ return `${operationName}(pid: ${this.formatPid(pid)}, leftoverAmount: ${this.formatAmount(leftoverAmount, pid)})`;
32
32
  }
33
33
  default:
34
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
34
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
35
35
  }
36
36
  }
37
37
  formatAmount(amount, pid) {
@@ -9,12 +9,12 @@ class ConvexRewardPoolParser extends abstractParser_1.AbstractParser {
9
9
  this.abi = types_1.iBaseRewardPoolAbi;
10
10
  }
11
11
  parse(calldata) {
12
- const { functionName, functionData } = this.parseSelector(calldata);
12
+ const { operationName, functionData } = this.parseSelector(calldata);
13
13
  switch (functionData.functionName) {
14
14
  case "rewardRate":
15
- return `${functionName}()`;
15
+ return `${operationName}()`;
16
16
  default:
17
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
18
18
  }
19
19
  }
20
20
  }
@@ -13,27 +13,27 @@ class CreditFacadeParser extends abstractParser_1.AbstractParser {
13
13
  this.adapterName = "CreditFacade";
14
14
  }
15
15
  parse(calldata) {
16
- const { functionName, functionData } = this.parseSelector(calldata);
16
+ const { operationName, functionData } = this.parseSelector(calldata);
17
17
  switch (functionData.functionName) {
18
18
  case "addCollateral": {
19
19
  const r = functionData.args || [];
20
20
  const token = r[0];
21
21
  const amount = r[1];
22
- return `${functionName}(token: ${this.tokenSymbol(token)}, amount: ${this.formatBN(amount, this.tokenSymbol(token))})`;
22
+ return `${operationName}(token: ${this.tokenSymbol(token)}, amount: ${this.formatBN(amount, this.tokenSymbol(token))})`;
23
23
  }
24
24
  case "increaseDebt":
25
25
  case "decreaseDebt": {
26
26
  const [amount] = functionData.args || [];
27
- return `${functionName}(amount: ${this.formatAmount(amount)})`;
27
+ return `${operationName}(amount: ${this.formatAmount(amount)})`;
28
28
  }
29
29
  case "enableToken":
30
30
  case "disableToken": {
31
31
  const [address] = functionData.args || [];
32
- return `${functionName}(token: ${this.tokenSymbol(address)})`;
32
+ return `${operationName}(token: ${this.tokenSymbol(address)})`;
33
33
  }
34
34
  case "updateQuota": {
35
35
  const [address, quotaUpdate, minQuota] = functionData.args || [];
36
- return `${functionName}(token: ${this.tokenSymbol(address)}, quotaUpdate: ${this.formatAmount(quotaUpdate)}, minQuota: ${this.formatAmount(minQuota)})`;
36
+ return `${operationName}(token: ${this.tokenSymbol(address)}, quotaUpdate: ${this.formatAmount(quotaUpdate)}, minQuota: ${this.formatAmount(minQuota)})`;
37
37
  }
38
38
  case "revertIfReceivedLessThan": {
39
39
  const [balances] = functionData.args || [];
@@ -44,37 +44,37 @@ class CreditFacadeParser extends abstractParser_1.AbstractParser {
44
44
  return `${symbol}: ${this.formatBN(balance, symbol)}`;
45
45
  })
46
46
  .join(", ");
47
- return `${functionName}(${balancesStr})`;
47
+ return `${operationName}(${balancesStr})`;
48
48
  }
49
49
  case "withdrawCollateral": {
50
50
  const [token, amount, to] = functionData.args || [];
51
- return `${functionName}(token: ${this.tokenSymbol(token)}, withdraw: ${this.formatBN(amount, this.tokenSymbol(token))}, to: ${to})`;
51
+ return `${operationName}(token: ${this.tokenSymbol(token)}, withdraw: ${this.formatBN(amount, this.tokenSymbol(token))}, to: ${to})`;
52
52
  }
53
53
  case "addCollateralWithPermit": {
54
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(", ")})`;
55
+ return `${operationName}(token: ${this.tokenSymbol(tokenAddress)}, amount: ${this.formatBN(amount, this.tokenSymbol(tokenAddress))}, ${[deadline, v, r, s].join(", ")})`;
56
56
  }
57
57
  case "compareBalances": {
58
- return `${functionName}()`;
58
+ return `${operationName}()`;
59
59
  }
60
60
  case "setFullCheckParams": {
61
61
  const [collateralHints, minHealthFactor] = functionData.args || [];
62
- return `${functionName}(token: ${collateralHints
62
+ return `${operationName}(token: ${collateralHints
63
63
  .map((a) => this.formatAmount(a))
64
64
  .join(", ")}, minHealthFactor: ${minHealthFactor})`;
65
65
  }
66
66
  case "storeExpectedBalances": {
67
67
  const [balanceDeltas] = functionData.args || [];
68
- return `${functionName}(balanceDeltas: ${balanceDeltas
68
+ return `${operationName}(balanceDeltas: ${balanceDeltas
69
69
  .map((b) => `${this.tokenSymbol(b.token)}: ${this.formatBN(b.amount, this.tokenSymbol(b.token))}`)
70
70
  .join(", ")})`;
71
71
  }
72
72
  case "onDemandPriceUpdate": {
73
73
  const [token, reserve, data] = functionData.args || [];
74
- return `${functionName}(token: ${this.tokenOrTickerSymbol(token)}, reserve: ${reserve}, data: ${data})`;
74
+ return `${operationName}(token: ${this.tokenOrTickerSymbol(token)}, reserve: ${reserve}, data: ${data})`;
75
75
  }
76
76
  default:
77
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
77
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
78
78
  }
79
79
  }
80
80
  formatAmount(amount) {
@@ -9,13 +9,13 @@ class CreditManagerParser extends abstractParser_1.AbstractParser {
9
9
  this.abi = version === 2 ? types_1.iCreditManagerV2Abi : types_1.iCreditManagerV3Abi;
10
10
  }
11
11
  parse(calldata) {
12
- const { functionName, functionData } = this.parseSelector(calldata);
12
+ const { operationName, functionData } = this.parseSelector(calldata);
13
13
  switch (functionData.functionName) {
14
14
  case "creditConfigurator": {
15
- return `${functionName}()`;
15
+ return `${operationName}()`;
16
16
  }
17
17
  default:
18
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
18
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
19
19
  }
20
20
  }
21
21
  }
@@ -31,7 +31,7 @@ class CurveAdapterParser extends abstractParser_1.AbstractParser {
31
31
  this.adapterName = contractName;
32
32
  }
33
33
  parse(calldata) {
34
- const { functionName, functionData } = this.parseSelector(calldata);
34
+ const { operationName, functionData } = this.parseSelector(calldata);
35
35
  switch (functionData.functionName) {
36
36
  case "exchange":
37
37
  case "exchange_underlying": {
@@ -42,7 +42,7 @@ class CurveAdapterParser extends abstractParser_1.AbstractParser {
42
42
  const jSym = functionData.functionName === "exchange_underlying"
43
43
  ? this.getUnderlyingTokenByIndex(j)
44
44
  : this.getTokenByIndex(j);
45
- return `${functionName}(i ,j: ${iSym} => ${jSym}, dx: ${this.formatBN(dx, iSym)}, min_dy: ${this.formatBN(min_dy, jSym)})`;
45
+ return `${operationName}(i ,j: ${iSym} => ${jSym}, dx: ${this.formatBN(dx, iSym)}, min_dy: ${this.formatBN(min_dy, jSym)})`;
46
46
  }
47
47
  case "exchange_diff":
48
48
  case "exchange_diff_underlying": {
@@ -53,55 +53,55 @@ class CurveAdapterParser extends abstractParser_1.AbstractParser {
53
53
  const jSym = functionData.functionName === "exchange_diff_underlying"
54
54
  ? this.getUnderlyingTokenByIndex(j)
55
55
  : this.getTokenByIndex(j);
56
- return `${functionName}(i: ${iSym}, j: ${jSym}, leftoverAmount: ${this.formatBN(leftoverAmount, iSym)}, rateMinRAY: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}`;
56
+ return `${operationName}(i: ${iSym}, j: ${jSym}, leftoverAmount: ${this.formatBN(leftoverAmount, iSym)}, rateMinRAY: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}`;
57
57
  }
58
58
  case "add_liquidity_one_coin": {
59
59
  const [amount, i, minAmount] = functionData.args || [];
60
60
  const iSym = this.getTokenByIndex(i);
61
- return `${functionName}(amount: ${this.formatBN(amount, iSym)}, i: ${iSym}, minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
61
+ return `${operationName}(amount: ${this.formatBN(amount, iSym)}, i: ${iSym}, minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
62
62
  }
63
63
  case "add_diff_liquidity_one_coin":
64
64
  case "remove_diff_liquidity_one_coin": {
65
65
  const [leftoverAmount, i, rateMinRAY] = functionData.args || [];
66
- return `${functionName}(leftoverAmount: ${this.formatBN(leftoverAmount, i)}, i: ${this.getTokenByIndex(i)}, rateMinRAY: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)})`;
66
+ return `${operationName}(leftoverAmount: ${this.formatBN(leftoverAmount, i)}, i: ${this.getTokenByIndex(i)}, rateMinRAY: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)})`;
67
67
  }
68
68
  case "add_liquidity": {
69
69
  const [amounts, minAmount] = functionData.args || [];
70
- return `${functionName}(amounts: [${this.convertAmounts(amounts)}], minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
70
+ return `${operationName}(amounts: [${this.convertAmounts(amounts)}], minAmount: ${this.formatBN(minAmount, this.lpToken)})`;
71
71
  }
72
72
  case "remove_liquidity": {
73
73
  const [amount, min_amounts] = functionData.args || [];
74
- return `${functionName}(amount: ${this.formatBN(amount, this.lpToken)}, min_amounts: [${this.convertAmounts(min_amounts)}])`;
74
+ return `${operationName}(amount: ${this.formatBN(amount, this.lpToken)}, min_amounts: [${this.convertAmounts(min_amounts)}])`;
75
75
  }
76
76
  case "remove_liquidity_imbalance": {
77
77
  const [amounts, maxBurnAmount] = functionData.args || [];
78
- return `${functionName}(amounts: [${this.convertAmounts(amounts)}], max_burn_amount: ${this.formatBN(maxBurnAmount, this.lpToken)})`;
78
+ return `${operationName}(amounts: [${this.convertAmounts(amounts)}], max_burn_amount: ${this.formatBN(maxBurnAmount, this.lpToken)})`;
79
79
  }
80
80
  case "remove_liquidity_one_coin": {
81
81
  const [amount, i, min_amount] = functionData.args || [];
82
82
  const iSym = this.getTokenByIndex(i);
83
- return `${functionName}(amount: ${this.formatBN(amount, this.lpToken)},i: ${iSym}, min_amount: ${this.formatBN(min_amount, iSym)})`;
83
+ return `${operationName}(amount: ${this.formatBN(amount, this.lpToken)},i: ${iSym}, min_amount: ${this.formatBN(min_amount, iSym)})`;
84
84
  }
85
85
  case "totalSupply": {
86
- return `${functionName}()`;
86
+ return `${operationName}()`;
87
87
  }
88
88
  case "balances": {
89
89
  const [i] = functionData.args || [];
90
- return `${functionName}(${this.getTokenByIndex(i)})`;
90
+ return `${operationName}(${this.getTokenByIndex(i)})`;
91
91
  }
92
92
  case "balanceOf": {
93
93
  const [address] = functionData.args || [];
94
- return `${functionName}(${address})`;
94
+ return `${operationName}(${address})`;
95
95
  }
96
96
  case "get_virtual_price": {
97
- return `${functionName}()`;
97
+ return `${operationName}()`;
98
98
  }
99
99
  case "allowance": {
100
100
  const [account, to] = functionData.args || [];
101
- return `${functionName}(account: ${account}, to: ${to})`;
101
+ return `${operationName}(account: ${account}, to: ${to})`;
102
102
  }
103
103
  default:
104
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
104
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
105
105
  }
106
106
  }
107
107
  getTokenByIndex(index) {
@@ -11,10 +11,10 @@ class ERC4626AdapterParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "ERC4626Adapter";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  default:
17
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
17
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
18
18
  }
19
19
  }
20
20
  }
@@ -11,18 +11,18 @@ class LidoAdapterParser extends abstractParser_1.AbstractParser {
11
11
  this.adapterName = "LidoV1Adapter";
12
12
  }
13
13
  parse(calldata) {
14
- const { functionName, functionData } = this.parseSelector(calldata);
14
+ const { operationName, functionData } = this.parseSelector(calldata);
15
15
  switch (functionData.functionName) {
16
16
  case "submit": {
17
17
  const [amount] = functionData.args || [];
18
- return `${functionName}(amount: ${this.formatBN(amount, "STETH")})`;
18
+ return `${operationName}(amount: ${this.formatBN(amount, "STETH")})`;
19
19
  }
20
20
  case "submitDiff": {
21
21
  const [leftoverAmount] = functionData.args || [];
22
- return `${functionName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
22
+ return `${operationName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
23
23
  }
24
24
  default:
25
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
25
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
26
26
  }
27
27
  }
28
28
  }
@@ -10,26 +10,26 @@ class LidoSTETHParser extends abstractParser_1.AbstractParser {
10
10
  this.abi = types_1.istEthAbi;
11
11
  }
12
12
  parse(calldata) {
13
- const { functionName, functionData } = this.parseSelector(calldata);
13
+ const { operationName, functionData } = this.parseSelector(calldata);
14
14
  switch (functionData.functionName) {
15
15
  case "getFee":
16
16
  case "totalSupply": {
17
- return `${functionName}()`;
17
+ return `${operationName}()`;
18
18
  }
19
19
  case "balanceOf": {
20
20
  const [address] = functionData.args || [];
21
- return `${functionName}(${address})`;
21
+ return `${operationName}(${address})`;
22
22
  }
23
23
  case "allowance": {
24
24
  const [account, to] = functionData.args || [];
25
- return `${functionName}(account: ${account}, to: ${to})`;
25
+ return `${operationName}(account: ${account}, to: ${to})`;
26
26
  }
27
27
  case "approve": {
28
28
  const [spender, amount] = functionData.args || [];
29
- return `${functionName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
29
+ return `${operationName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
30
30
  }
31
31
  default:
32
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
32
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
33
33
  }
34
34
  }
35
35
  }
@@ -9,14 +9,14 @@ class PriceOracleParser extends abstractParser_1.AbstractParser {
9
9
  this.abi = types_1.iPriceOracleBaseAbi;
10
10
  }
11
11
  parse(calldata) {
12
- const { functionName, functionData } = this.parseSelector(calldata);
12
+ const { operationName, functionData } = this.parseSelector(calldata);
13
13
  switch (functionData.functionName) {
14
14
  case "getPrice": {
15
15
  const [token] = functionData.args || [];
16
- return `${functionName}(${this.tokenSymbol(token)})`;
16
+ return `${operationName}(${this.tokenSymbol(token)})`;
17
17
  }
18
18
  default:
19
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
19
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
20
20
  }
21
21
  }
22
22
  }
@@ -12,20 +12,20 @@ class StakingRewardsAdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "StakingRewardsAdapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionName, functionData } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "withdraw": {
18
18
  const [amount] = functionData.args || [];
19
- return `${functionName}(amount: ${this.formatAmount(amount)}`;
19
+ return `${operationName}(amount: ${this.formatAmount(amount)}`;
20
20
  }
21
21
  case "withdrawDiff": {
22
22
  const [leftoverAmount] = functionData.args || [];
23
- return `${functionName}(leftoverAmount: ${this.formatAmount(leftoverAmount)}`;
23
+ return `${operationName}(leftoverAmount: ${this.formatAmount(leftoverAmount)}`;
24
24
  }
25
25
  case "getReward":
26
- return `${functionName}()`;
26
+ return `${operationName}()`;
27
27
  default:
28
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
28
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
29
29
  }
30
30
  }
31
31
  formatAmount(amount) {
@@ -12,7 +12,7 @@ class UniswapV2AdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "UniswapV2Adapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionData, functionName } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "swapExactTokensForTokens": {
18
18
  const [amountIn, amountOutMin, path] = functionData.args || [];
@@ -23,7 +23,7 @@ class UniswapV2AdapterParser extends abstractParser_1.AbstractParser {
23
23
  const tokenOut = this.tokenSymbol(path[path.length - 1]);
24
24
  const amountInStr = this.formatBN(amountIn, tokenIn);
25
25
  const amountOutStr = this.formatBN(amountOutMin, tokenOut);
26
- return `${functionName}(amountIn: ${amountInStr}, amountOutMin: ${amountOutStr}, path: [${pathStr}])`;
26
+ return `${operationName}(amountIn: ${amountInStr}, amountOutMin: ${amountOutStr}, path: [${pathStr}])`;
27
27
  }
28
28
  case "swapTokensForExactTokens": {
29
29
  const [amountOut, amountInMax, path] = functionData.args || [];
@@ -34,17 +34,17 @@ class UniswapV2AdapterParser extends abstractParser_1.AbstractParser {
34
34
  const tokenOut = this.tokenSymbol(path[path.length - 1]);
35
35
  const amountOutStr = this.formatBN(amountOut, tokenIn);
36
36
  const amountInMaxStr = this.formatBN(amountInMax, tokenOut);
37
- return `${functionName}(amountOut: ${amountOutStr}, amountInMax: ${amountInMaxStr}, path: [${pathStr}])`;
37
+ return `${operationName}(amountOut: ${amountOutStr}, amountInMax: ${amountInMaxStr}, path: [${pathStr}])`;
38
38
  }
39
39
  case "swapDiffTokensForTokens": {
40
40
  const [leftoverAmount, rateMinRAY, path] = functionData.args || [];
41
41
  const tokenIn = this.tokenSymbol(path[0]);
42
- return `${functionName}(leftoverAmount: ${this.formatBN(leftoverAmount, tokenIn)}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: [${path
42
+ return `${operationName}(leftoverAmount: ${this.formatBN(leftoverAmount, tokenIn)}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: [${path
43
43
  .map(r => this.tokenSymbol(r))
44
44
  .join(" => ")}])`;
45
45
  }
46
46
  default:
47
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
47
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
48
48
  }
49
49
  }
50
50
  }
@@ -12,7 +12,7 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "UniswapV3Adapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionData, functionName } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "exactInputSingle": {
18
18
  const [{ tokenIn, tokenOut, fee, amountIn, amountOutMinimum }] = functionData.args || [{}];
@@ -20,14 +20,14 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
20
20
  const tokenOutSym = this.tokenSymbol(tokenOut);
21
21
  const amountInStr = this.formatBN(amountIn, tokenIn);
22
22
  const amountOutMinimumStr = this.formatBN(amountOutMinimum, tokenOut);
23
- return `${functionName}(amountIn: ${amountInStr}, amountOutMinimum: ${amountOutMinimumStr}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
23
+ return `${operationName}(amountIn: ${amountInStr}, amountOutMinimum: ${amountOutMinimumStr}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
24
24
  }
25
25
  case "exactDiffInputSingle": {
26
26
  const [{ tokenIn, tokenOut, fee, leftoverAmount, rateMinRAY }] = functionData.args || [{}];
27
27
  const tokenInSym = this.tokenSymbol(tokenIn);
28
28
  const tokenOutSym = this.tokenSymbol(tokenOut);
29
29
  const leftoverAmountStr = this.formatBN(leftoverAmount, tokenIn);
30
- return `${functionName}(leftoverAmount: ${leftoverAmountStr}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
30
+ return `${operationName}(leftoverAmount: ${leftoverAmountStr}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
31
31
  }
32
32
  case "exactInput": {
33
33
  const [{ path, amountIn, amountOutMinimum }] = functionData.args || [
@@ -36,7 +36,7 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
36
36
  const pathStr = this.trackInputPath(path);
37
37
  const amountInStr = this.formatBN(amountIn, this.tokenSymbol(`0x${path.replace("0x", "").slice(0, 40)}`));
38
38
  const amountOutMinimumStr = this.formatBN(amountOutMinimum, this.tokenSymbol(`0x${path.slice(-40, path.length)}`));
39
- return `${functionName}(amountIn: ${amountInStr}, amountOutMinimum: ${amountOutMinimumStr}, path: ${pathStr}`;
39
+ return `${operationName}(amountIn: ${amountInStr}, amountOutMinimum: ${amountOutMinimumStr}, path: ${pathStr}`;
40
40
  }
41
41
  case "exactDiffInput": {
42
42
  const [{ path, leftoverAmount, rateMinRAY }] = functionData.args || [
@@ -44,7 +44,7 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
44
44
  ];
45
45
  const leftoverAmountStr = this.formatBN(leftoverAmount, this.tokenSymbol(`0x${path.replace("0x", "").slice(0, 40)}`));
46
46
  const pathStr = this.trackInputPath(path);
47
- return `${functionName}(leftoverAmount: ${leftoverAmountStr}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: ${pathStr}`;
47
+ return `${operationName}(leftoverAmount: ${leftoverAmountStr}, rate: ${(0, sdk_gov_1.formatBN)(rateMinRAY, 27)}, path: ${pathStr}`;
48
48
  }
49
49
  case "exactOutput": {
50
50
  const [{ path, amountOut, amountInMaximum }] = functionData.args || [
@@ -53,7 +53,7 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
53
53
  const pathStr = this.trackOutputPath(path);
54
54
  const amountInMaximumStr = this.formatBN(amountInMaximum, this.tokenSymbol(`0x${path.slice(-40, path.length)}`));
55
55
  const amountOutStr = this.formatBN(amountOut, this.tokenSymbol(`0x${path.replace("0x", "").slice(0, 40)}`));
56
- return `${functionName}(amountInMaximum: ${amountInMaximumStr}, amountOut: ${amountOutStr}, path: ${pathStr}`;
56
+ return `${operationName}(amountInMaximum: ${amountInMaximumStr}, amountOut: ${amountOutStr}, path: ${pathStr}`;
57
57
  }
58
58
  case "exactOutputSingle": {
59
59
  const [{ tokenIn, tokenOut, fee, amountOut, amountInMaximum }] = functionData.args || [{}];
@@ -61,10 +61,10 @@ class UniswapV3AdapterParser extends abstractParser_1.AbstractParser {
61
61
  const tokenOutSym = this.tokenSymbol(tokenOut);
62
62
  const amountInMaximumStr = this.formatBN(amountInMaximum, tokenInSym);
63
63
  const amountOutStr = this.formatBN(amountOut, tokenOutSym);
64
- return `${functionName}(amountInMaximum: ${amountInMaximumStr}, amountOut: ${amountOutStr}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
64
+ return `${operationName}(amountInMaximum: ${amountInMaximumStr}, amountOut: ${amountOutStr}, path: ${tokenInSym} ==(fee: ${fee})==> ${tokenOutSym})`;
65
65
  }
66
66
  default:
67
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
67
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
68
68
  }
69
69
  }
70
70
  trackInputPath(path) {
@@ -12,38 +12,38 @@ class WstETHAdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "wstETHAdapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionData, functionName } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "wrap": {
18
18
  const [amount] = functionData.args || [];
19
- return `${functionName}(amount: ${this.formatBN(amount, "STETH")})`;
19
+ return `${operationName}(amount: ${this.formatBN(amount, "STETH")})`;
20
20
  }
21
21
  case "wrapDiff": {
22
22
  const [leftoverAmount] = functionData.args || [];
23
- return `${functionName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
23
+ return `${operationName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
24
24
  }
25
25
  case "unwrap": {
26
26
  const [amount] = functionData.args || [];
27
- return `${functionName}(amount: ${this.formatBN(amount, "wstETH")})`;
27
+ return `${operationName}(amount: ${this.formatBN(amount, "wstETH")})`;
28
28
  }
29
29
  case "unwrapDiff": {
30
30
  const [leftoverAmount] = functionData.args || [];
31
- return `${functionName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
31
+ return `${operationName}(leftoverAmount: ${this.formatBN(leftoverAmount, "STETH")})`;
32
32
  }
33
33
  case "balanceOf": {
34
34
  const [address] = functionData.args || [];
35
- return `${functionName}(${address})`;
35
+ return `${operationName}(${address})`;
36
36
  }
37
37
  case "allowance": {
38
38
  const [account, to] = functionData.args || [];
39
- return `${functionName}(account: ${account}, to: ${to})`;
39
+ return `${operationName}(account: ${account}, to: ${to})`;
40
40
  }
41
41
  case "approve": {
42
42
  const [spender, amount] = functionData.args || [];
43
- return `${functionName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
43
+ return `${operationName}(${spender}, [${(0, sdk_gov_1.toBigInt)(amount).toString()}])`;
44
44
  }
45
45
  default:
46
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
46
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
47
47
  }
48
48
  }
49
49
  }
@@ -12,7 +12,7 @@ class YearnV2AdapterParser extends abstractParser_1.AbstractParser {
12
12
  this.adapterName = "YearnV2Adapter";
13
13
  }
14
14
  parse(calldata) {
15
- const { functionName, functionData } = this.parseSelector(calldata);
15
+ const { operationName, functionData } = this.parseSelector(calldata);
16
16
  switch (functionData.functionName) {
17
17
  case "deposit":
18
18
  case "withdraw":
@@ -24,33 +24,33 @@ class YearnV2AdapterParser extends abstractParser_1.AbstractParser {
24
24
  : "";
25
25
  const addressStr = address ? `, address: ${address}` : "";
26
26
  const maxLossStr = maxLoss ? `, maxLoss: ${maxLoss}` : "";
27
- return `${functionName}(${amountStr}${addressStr}${maxLossStr})`;
27
+ return `${operationName}(${amountStr}${addressStr}${maxLossStr})`;
28
28
  }
29
29
  case "depositDiff": {
30
30
  const [leftoverAmount] = functionData.args || [];
31
31
  const yvSym = this.tokenSymbol(sdk_gov_1.contractsByNetwork.Mainnet[this.contract]);
32
32
  const leftoverAmountStr = this.formatBN(leftoverAmount, yvSym);
33
- return `${functionName}(leftoverAmount: ${leftoverAmountStr})`;
33
+ return `${operationName}(leftoverAmount: ${leftoverAmountStr})`;
34
34
  }
35
35
  case "withdrawDiff": {
36
36
  const [leftoverAmount] = functionData.args || [];
37
37
  const yvSym = this.tokenSymbol(sdk_gov_1.contractsByNetwork.Mainnet[this.contract]);
38
38
  const leftoverAmountStr = this.formatBN(leftoverAmount, yvSym);
39
- return `${functionName}(leftoverAmount: ${leftoverAmountStr})`;
39
+ return `${operationName}(leftoverAmount: ${leftoverAmountStr})`;
40
40
  }
41
41
  case "pricePerShare": {
42
- return `${functionName}()`;
42
+ return `${operationName}()`;
43
43
  }
44
44
  case "balanceOf": {
45
45
  const [address] = functionData.args || [];
46
- return `${functionName}(${address})`;
46
+ return `${operationName}(${address})`;
47
47
  }
48
48
  case "allowance": {
49
49
  const [account, to] = functionData.args || [];
50
- return `${functionName}(account: ${account}, to: ${to})`;
50
+ return `${operationName}(account: ${account}, to: ${to})`;
51
51
  }
52
52
  default:
53
- return this.reportUnknownFragment(this.adapterName || this.contract, functionName, calldata);
53
+ return this.reportUnknownFragment(this.adapterName || this.contract, operationName, calldata);
54
54
  }
55
55
  }
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.240",
3
+ "version": "3.0.0-next.241",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",