@gearbox-protocol/sdk 2.1.34 → 3.0.0-next.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/apy/convexAPY.d.ts +4 -6
- package/lib/apy/convexAPY.js +15 -16
- package/lib/apy/curveAPY.d.ts +2 -2
- package/lib/apy/curveAPY.js +3 -4
- package/lib/apy/index.d.ts +1 -1
- package/lib/apy/index.js +2 -2
- package/lib/apy/lidoAPY.js +2 -2
- package/lib/apy/yearnAPY.d.ts +1 -1
- package/lib/apy/yearnAPY.js +3 -5
- package/lib/contracts/contractsRegister.d.ts +1 -1
- package/lib/contracts/contractsRegister.js +6 -7
- package/lib/core/creditAccount.js +20 -22
- package/lib/core/creditAccount.spec.js +32 -34
- package/lib/core/creditManager.js +16 -17
- package/lib/core/creditSession.js +12 -13
- package/lib/core/events.js +34 -35
- package/lib/core/pool/data.js +22 -23
- package/lib/core/priceOracle.js +3 -3
- package/lib/core/rewardClaimer.d.ts +1 -3
- package/lib/core/rewardConvex.d.ts +1 -4
- package/lib/core/rewardConvex.js +7 -10
- package/lib/core/rewardConvex.spec.js +15 -16
- package/lib/core/strategy.js +14 -16
- package/lib/core/strategy.spec.js +20 -22
- package/lib/core/trade.d.ts +1 -1
- package/lib/core/trade.js +12 -15
- package/lib/core/transactions.d.ts +1 -1
- package/lib/core/transactions.js +18 -20
- package/lib/index.d.ts +2 -20
- package/lib/index.js +27 -24
- package/lib/parsers/ERC20Parser.d.ts +1 -1
- package/lib/parsers/abstractParser.d.ts +1 -1
- package/lib/parsers/abstractParser.js +3 -4
- package/lib/parsers/convexBaseRewardPoolAdapterParser.d.ts +1 -1
- package/lib/parsers/convexBaseRewardPoolAdapterParser.js +2 -2
- package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +4 -4
- package/lib/parsers/convexBoosterAdapterParser.d.ts +1 -1
- package/lib/parsers/convexBoosterAdapterParser.js +3 -3
- package/lib/parsers/convexBoosterAdapterParser.spec.js +3 -3
- package/lib/parsers/convextRewardPoolParser.d.ts +1 -1
- package/lib/parsers/creditFacadeParser.d.ts +1 -1
- package/lib/parsers/creditFacadeParser.spec.js +8 -9
- package/lib/parsers/curveAdapterParser.d.ts +1 -2
- package/lib/parsers/curveAdapterParser.js +5 -5
- package/lib/parsers/curveAdapterParser.spec.js +13 -13
- package/lib/parsers/lidoAdapterParser.d.ts +1 -1
- package/lib/parsers/lidoAdapterParser.spec.js +2 -2
- package/lib/parsers/lidoSTETHParser.d.ts +1 -1
- package/lib/parsers/txParser.d.ts +1 -3
- package/lib/parsers/txParser.js +12 -15
- package/lib/parsers/uniV2AdapterParser.d.ts +1 -1
- package/lib/parsers/uniV2AdapterParser.spec.js +15 -16
- package/lib/parsers/uniV3AdapterParser.d.ts +1 -1
- package/lib/parsers/uniV3AdapterParser.spec.js +15 -16
- package/lib/parsers/wstETHAdapterParser.d.ts +1 -1
- package/lib/parsers/wstETHAdapterParser.spec.js +3 -3
- package/lib/parsers/yearnAdapterParser.spec.js +12 -12
- package/lib/parsers/yearnV2AdapterParser.d.ts +1 -1
- package/lib/parsers/yearnV2AdapterParser.js +2 -2
- package/lib/pathfinder/pathOptions.d.ts +1 -2
- package/lib/pathfinder/pathOptions.js +12 -16
- package/lib/pathfinder/pathOptions.spec.js +36 -36
- package/lib/pathfinder/pathfinder.d.ts +1 -2
- package/lib/pathfinder/pathfinder.js +9 -10
- package/lib/pathfinder/pathfinder.spec.js +11 -12
- package/lib/payload/creditAccount.d.ts +1 -1
- package/lib/payload/creditManager.d.ts +1 -1
- package/lib/payload/pool.d.ts +1 -1
- package/lib/tokens/tokenData.d.ts +0 -4
- package/lib/tokens/tokenData.js +1 -16
- package/lib/utils/formatter.js +3 -3
- package/lib/utils/math.js +5 -5
- package/lib/utils/price.js +4 -4
- package/lib/watchers/creditAccountWatcher.js +2 -2
- package/lib/watchers/creditAccountWatcher.spec.js +18 -18
- package/lib/watchers/creditManagerWatcher.spec.js +19 -19
- package/package.json +2 -1
- package/lib/contracts/adapters.d.ts +0 -24
- package/lib/contracts/adapters.js +0 -28
- package/lib/contracts/contracts.d.ts +0 -112
- package/lib/contracts/contracts.js +0 -654
- package/lib/contracts/protocols.d.ts +0 -12
- package/lib/contracts/protocols.js +0 -16
- package/lib/contracts/utilsContracts.d.ts +0 -7
- package/lib/contracts/utilsContracts.js +0 -28
- package/lib/core/chains.d.ts +0 -23
- package/lib/core/chains.js +0 -63
- package/lib/core/constants.d.ts +0 -21
- package/lib/core/constants.js +0 -31
- package/lib/tokens/aave.d.ts +0 -20
- package/lib/tokens/aave.js +0 -62
- package/lib/tokens/balancer.d.ts +0 -12
- package/lib/tokens/balancer.js +0 -36
- package/lib/tokens/compound.d.ts +0 -11
- package/lib/tokens/compound.js +0 -38
- package/lib/tokens/convex.d.ts +0 -30
- package/lib/tokens/convex.js +0 -262
- package/lib/tokens/curveLP.d.ts +0 -27
- package/lib/tokens/curveLP.js +0 -141
- package/lib/tokens/decimals.d.ts +0 -2
- package/lib/tokens/decimals.js +0 -115
- package/lib/tokens/gear.d.ts +0 -14
- package/lib/tokens/gear.js +0 -47
- package/lib/tokens/normal.d.ts +0 -9
- package/lib/tokens/normal.js +0 -194
- package/lib/tokens/quoted.d.ts +0 -3
- package/lib/tokens/quoted.js +0 -7
- package/lib/tokens/token.d.ts +0 -25
- package/lib/tokens/token.js +0 -305
- package/lib/tokens/tokenType.d.ts +0 -15
- package/lib/tokens/tokenType.js +0 -19
- package/lib/tokens/tokens.spec.d.ts +0 -1
- package/lib/tokens/tokens.spec.js +0 -151
- package/lib/tokens/yearn.d.ts +0 -26
- package/lib/tokens/yearn.js +0 -52
- package/lib/utils/mappers.d.ts +0 -8
- package/lib/utils/mappers.js +0 -13
- package/lib/utils/multicall.d.ts +0 -36
- package/lib/utils/multicall.js +0 -90
- package/lib/utils/safeEnum.d.ts +0 -1
- package/lib/utils/safeEnum.js +0 -10
- package/lib/utils/types.d.ts +0 -10
- package/lib/utils/types.js +0 -2
package/lib/core/strategy.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Strategy = void 0;
|
|
4
|
-
const
|
|
5
|
-
const token_1 = require("../tokens/token");
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
6
5
|
const price_1 = require("../utils/price");
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
6
|
class Strategy {
|
|
9
7
|
apy;
|
|
10
8
|
name;
|
|
@@ -24,30 +22,30 @@ class Strategy {
|
|
|
24
22
|
}
|
|
25
23
|
static maxLeverage(lpToken, cms) {
|
|
26
24
|
const [maxThreshold] = Strategy.maxLeverageThreshold(lpToken, cms);
|
|
27
|
-
const maxLeverage = (
|
|
28
|
-
(
|
|
29
|
-
return Number(maxLeverage -
|
|
25
|
+
const maxLeverage = (sdk_gov_1.PERCENTAGE_FACTOR * sdk_gov_1.LEVERAGE_DECIMALS) /
|
|
26
|
+
(sdk_gov_1.PERCENTAGE_FACTOR - maxThreshold);
|
|
27
|
+
return Number(maxLeverage - sdk_gov_1.LEVERAGE_DECIMALS);
|
|
30
28
|
}
|
|
31
29
|
maxAPY(baseAPY, maxLeverage, borrowAPY) {
|
|
32
30
|
return (baseAPY +
|
|
33
|
-
((baseAPY - borrowAPY) * (maxLeverage - Number(
|
|
34
|
-
Number(
|
|
31
|
+
((baseAPY - borrowAPY) * (maxLeverage - Number(sdk_gov_1.LEVERAGE_DECIMALS))) /
|
|
32
|
+
Number(sdk_gov_1.LEVERAGE_DECIMALS));
|
|
35
33
|
}
|
|
36
34
|
static liquidationPrice({ prices, liquidationThresholds, borrowed, underlyingToken, lpAmount, lpToken, }) {
|
|
37
35
|
const underlyingTokenAddressLC = underlyingToken.toLowerCase();
|
|
38
|
-
const underlyingTokenSymbol =
|
|
39
|
-
const underlyingTokenDecimals =
|
|
40
|
-
const underlyingPrice = prices[underlyingTokenAddressLC] ||
|
|
36
|
+
const underlyingTokenSymbol = sdk_gov_1.tokenSymbolByAddress[underlyingTokenAddressLC];
|
|
37
|
+
const underlyingTokenDecimals = sdk_gov_1.decimals[underlyingTokenSymbol];
|
|
38
|
+
const underlyingPrice = prices[underlyingTokenAddressLC] || sdk_gov_1.PRICE_DECIMALS;
|
|
41
39
|
const borrowedMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice, borrowed, underlyingTokenDecimals);
|
|
42
40
|
const lpTokenAddressLC = lpToken.toLowerCase();
|
|
43
|
-
const lpTokenSymbol =
|
|
44
|
-
const lpTokenDecimals =
|
|
41
|
+
const lpTokenSymbol = sdk_gov_1.tokenSymbolByAddress[lpTokenAddressLC];
|
|
42
|
+
const lpTokenDecimals = sdk_gov_1.decimals[lpTokenSymbol];
|
|
45
43
|
const lpLT = liquidationThresholds[lpTokenAddressLC] || 0n;
|
|
46
|
-
const lpPrice = prices[lpTokenAddressLC] ||
|
|
44
|
+
const lpPrice = prices[lpTokenAddressLC] || sdk_gov_1.PRICE_DECIMALS;
|
|
47
45
|
const lpMoney = price_1.PriceUtils.calcTotalPrice(lpPrice, lpAmount, lpTokenDecimals);
|
|
48
|
-
const lpLTMoney = (lpMoney * lpLT) /
|
|
46
|
+
const lpLTMoney = (lpMoney * lpLT) / sdk_gov_1.PERCENTAGE_FACTOR;
|
|
49
47
|
if (lpLTMoney > 0) {
|
|
50
|
-
const lqPrice = (borrowedMoney *
|
|
48
|
+
const lqPrice = (borrowedMoney * sdk_gov_1.WAD) / lpLTMoney;
|
|
51
49
|
return lqPrice >= 0 ? lqPrice : 0n;
|
|
52
50
|
}
|
|
53
51
|
return 0n;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
3
4
|
const chai_1 = require("chai");
|
|
4
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
5
|
-
const decimals_1 = require("../tokens/decimals");
|
|
6
|
-
const token_1 = require("../tokens/token");
|
|
7
6
|
const formatter_1 = require("../utils/formatter");
|
|
8
|
-
const constants_1 = require("./constants");
|
|
9
7
|
const strategy_1 = require("./strategy");
|
|
10
8
|
const lidoPayload = {
|
|
11
9
|
name: "Lido",
|
|
12
|
-
lpToken:
|
|
10
|
+
lpToken: sdk_gov_1.tokenDataByNetwork.Mainnet.STETH,
|
|
13
11
|
apy: 38434,
|
|
14
12
|
creditManagers: [contractsRegister_1.creditManagerByNetwork.Mainnet.WETH_V2],
|
|
15
13
|
unleveragableCollateral: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
sdk_gov_1.tokenDataByNetwork.Mainnet.USDC,
|
|
15
|
+
sdk_gov_1.tokenDataByNetwork.Mainnet.DAI,
|
|
16
|
+
sdk_gov_1.tokenDataByNetwork.Mainnet.WBTC,
|
|
19
17
|
],
|
|
20
18
|
leveragableCollateral: [],
|
|
21
|
-
baseAssets: [
|
|
19
|
+
baseAssets: [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH],
|
|
22
20
|
};
|
|
23
21
|
const lidoStrategy = new strategy_1.Strategy(lidoPayload);
|
|
24
22
|
const pools = {
|
|
@@ -30,35 +28,35 @@ const pools = {
|
|
|
30
28
|
},
|
|
31
29
|
};
|
|
32
30
|
const prices = {
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
31
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: (0, formatter_1.toBN)("1738.11830000", sdk_gov_1.PRICE_DECIMALS_POW),
|
|
32
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: (0, formatter_1.toBN)("0.99941103", sdk_gov_1.PRICE_DECIMALS_POW),
|
|
33
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: (0, formatter_1.toBN)("1703.87588096", sdk_gov_1.PRICE_DECIMALS_POW),
|
|
36
34
|
};
|
|
37
35
|
const liquidationThresholds = {
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
36
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: 9300n,
|
|
37
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 8500n,
|
|
38
|
+
[sdk_gov_1.tokenDataByNetwork.Mainnet.STETH.toLowerCase()]: 9000n,
|
|
41
39
|
};
|
|
42
40
|
describe("Strategy test", () => {
|
|
43
41
|
it("maxAPY calculation is correct", () => {
|
|
44
|
-
const result = lidoStrategy.maxAPY(53203, 10 * Number(
|
|
42
|
+
const result = lidoStrategy.maxAPY(53203, 10 * Number(sdk_gov_1.LEVERAGE_DECIMALS), pools["0x1"].borrowRate);
|
|
45
43
|
(0, chai_1.expect)(result).to.be.eq(284143);
|
|
46
44
|
});
|
|
47
45
|
it("liquidationPrice calculation is correct", () => {
|
|
48
46
|
const result = strategy_1.Strategy.liquidationPrice({
|
|
49
47
|
liquidationThresholds,
|
|
50
48
|
prices,
|
|
51
|
-
borrowed: (0, formatter_1.toBN)("350",
|
|
52
|
-
underlyingToken:
|
|
53
|
-
lpAmount: (0, formatter_1.toBN)("400",
|
|
54
|
-
lpToken:
|
|
49
|
+
borrowed: (0, formatter_1.toBN)("350", sdk_gov_1.decimals.WETH),
|
|
50
|
+
underlyingToken: sdk_gov_1.tokenDataByNetwork.Mainnet.WETH,
|
|
51
|
+
lpAmount: (0, formatter_1.toBN)("400", sdk_gov_1.decimals.STETH),
|
|
52
|
+
lpToken: sdk_gov_1.tokenDataByNetwork.Mainnet.STETH,
|
|
55
53
|
});
|
|
56
|
-
(0, chai_1.expect)(Number((0, formatter_1.toSignificant)(result,
|
|
54
|
+
(0, chai_1.expect)(Number((0, formatter_1.toSignificant)(result, sdk_gov_1.WAD_DECIMALS_POW)).toFixed(3)).to.be.eq("0.992");
|
|
57
55
|
});
|
|
58
56
|
it("maxLeverage is correct", () => {
|
|
59
|
-
const result = strategy_1.Strategy.maxLeverage(
|
|
57
|
+
const result = strategy_1.Strategy.maxLeverage(sdk_gov_1.tokenDataByNetwork.Mainnet.STETH, [
|
|
60
58
|
{ address: "0x1", liquidationThresholds },
|
|
61
59
|
]);
|
|
62
|
-
(0, chai_1.expect)(result).to.be.eq(9 * Number(
|
|
60
|
+
(0, chai_1.expect)(result).to.be.eq(9 * Number(sdk_gov_1.LEVERAGE_DECIMALS));
|
|
63
61
|
});
|
|
64
62
|
});
|
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
1
2
|
import { Signer } from "ethers";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
4
|
import { ICreditFacade } from "../types";
|
|
5
5
|
import { CreditManagerData } from "./creditManager";
|
package/lib/core/trade.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Trade = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const txParser_1 = require("../parsers/txParser");
|
|
6
6
|
const core_1 = require("../pathfinder/core");
|
|
7
|
-
const decimals_1 = require("../tokens/decimals");
|
|
8
|
-
const token_1 = require("../tokens/token");
|
|
9
7
|
const types_1 = require("../types");
|
|
10
8
|
const formatter_1 = require("../utils/formatter");
|
|
11
|
-
const constants_1 = require("./constants");
|
|
12
9
|
const transactions_1 = require("./transactions");
|
|
13
10
|
const OPERATION_NAMES = {
|
|
14
11
|
farmWithdraw: "Farm withdraw",
|
|
@@ -34,7 +31,7 @@ class Trade {
|
|
|
34
31
|
this.swapType = props.swapType;
|
|
35
32
|
this.sourceAmount = props.sourceAmount;
|
|
36
33
|
this.expectedAmount = props.expectedAmount;
|
|
37
|
-
this.rate = (
|
|
34
|
+
this.rate = (sdk_gov_1.WAD * props.expectedAmount) / props.sourceAmount;
|
|
38
35
|
this.tokenFrom = props.tokenFrom;
|
|
39
36
|
this.tokenTo = props.tokenTo;
|
|
40
37
|
this.operationName = props.swapName;
|
|
@@ -57,14 +54,14 @@ class Trade {
|
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
56
|
toString() {
|
|
60
|
-
const symbolFrom =
|
|
61
|
-
const symbolTo =
|
|
57
|
+
const symbolFrom = sdk_gov_1.tokenSymbolByAddress[this.tokenFrom.toLowerCase()];
|
|
58
|
+
const symbolTo = sdk_gov_1.tokenSymbolByAddress[this.tokenTo.toLowerCase()];
|
|
62
59
|
if (!symbolFrom)
|
|
63
60
|
throw new Error(`Unknown token: ${this.tokenFrom}`);
|
|
64
61
|
if (!symbolTo)
|
|
65
62
|
throw new Error(`Unknown token: ${this.tokenTo}`);
|
|
66
|
-
const decimalsFrom =
|
|
67
|
-
const decimalsTo =
|
|
63
|
+
const decimalsFrom = sdk_gov_1.decimals[symbolFrom];
|
|
64
|
+
const decimalsTo = sdk_gov_1.decimals[symbolTo];
|
|
68
65
|
return `${this.operationName} ${(0, formatter_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, formatter_1.formatBN)(this.expectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
|
|
69
66
|
}
|
|
70
67
|
static getTrades({ from, to, amount, results, creditManager, currentContracts, }) {
|
|
@@ -88,10 +85,10 @@ class Trade {
|
|
|
88
85
|
return trades;
|
|
89
86
|
}
|
|
90
87
|
static getOperationName(tokenInAddress, tokenOutAddress) {
|
|
91
|
-
const tokenInSymbol =
|
|
92
|
-
const tokenOutSymbol =
|
|
93
|
-
const tokenInIsLp = (0,
|
|
94
|
-
const tokenOutIsLp = (0,
|
|
88
|
+
const tokenInSymbol = sdk_gov_1.tokenSymbolByAddress[tokenInAddress];
|
|
89
|
+
const tokenOutSymbol = sdk_gov_1.tokenSymbolByAddress[tokenOutAddress];
|
|
90
|
+
const tokenInIsLp = (0, sdk_gov_1.isLPToken)(tokenInSymbol);
|
|
91
|
+
const tokenOutIsLp = (0, sdk_gov_1.isLPToken)(tokenOutSymbol);
|
|
95
92
|
if (!tokenInSymbol)
|
|
96
93
|
throw new Error(`Unknown token: ${tokenInAddress}`);
|
|
97
94
|
if (!tokenOutSymbol)
|
|
@@ -107,9 +104,9 @@ class Trade {
|
|
|
107
104
|
static getCallInfo(calls, creditManager, currentContracts) {
|
|
108
105
|
const callAdapters = calls.reduce((acc, call) => {
|
|
109
106
|
const contractSymbol = this.getContractSymbol(call.target.toLowerCase());
|
|
110
|
-
if (!(0,
|
|
107
|
+
if (!(0, sdk_gov_1.isSupportedContract)(contractSymbol))
|
|
111
108
|
return acc;
|
|
112
|
-
const { name } =
|
|
109
|
+
const { name } = sdk_gov_1.contractParams[contractSymbol];
|
|
113
110
|
const contractAddress = currentContracts[contractSymbol];
|
|
114
111
|
acc.push({
|
|
115
112
|
name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportedContract } from "
|
|
1
|
+
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
2
2
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
3
3
|
export interface TxSerialized {
|
|
4
4
|
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens";
|
package/lib/core/transactions.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxDecreaseBorrowAmount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
6
|
-
const token_1 = require("../tokens/token");
|
|
7
6
|
const formatter_1 = require("../utils/formatter");
|
|
8
|
-
const constants_1 = require("./constants");
|
|
9
7
|
const eventOrTx_1 = require("./eventOrTx");
|
|
10
8
|
class TxSerializer {
|
|
11
9
|
static serialize(items) {
|
|
@@ -68,7 +66,7 @@ class TxAddLiquidity extends eventOrTx_1.EVMTx {
|
|
|
68
66
|
this.pool = opts.pool;
|
|
69
67
|
}
|
|
70
68
|
toString() {
|
|
71
|
-
const [underlyingSymbol, underlyingDecimals] = (0,
|
|
69
|
+
const [underlyingSymbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
72
70
|
return `${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, formatter_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
|
|
73
71
|
}
|
|
74
72
|
serialize() {
|
|
@@ -95,7 +93,7 @@ class TxRemoveLiquidity extends eventOrTx_1.EVMTx {
|
|
|
95
93
|
this.pool = opts.pool;
|
|
96
94
|
}
|
|
97
95
|
toString() {
|
|
98
|
-
const [dSymbol, dDecimals] = (0,
|
|
96
|
+
const [dSymbol, dDecimals] = (0, sdk_gov_1.extractTokenData)(this.dieselToken);
|
|
99
97
|
return `${(0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, formatter_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
|
|
100
98
|
}
|
|
101
99
|
serialize() {
|
|
@@ -132,10 +130,10 @@ class TXSwap extends eventOrTx_1.EVMTx {
|
|
|
132
130
|
toString() {
|
|
133
131
|
let toPart = "";
|
|
134
132
|
if (this.tokenTo && this.amountTo) {
|
|
135
|
-
const [toSymbol, toDecimals] = (0,
|
|
133
|
+
const [toSymbol, toDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenTo);
|
|
136
134
|
toPart = ` ⇒ ${(0, formatter_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
|
|
137
135
|
}
|
|
138
|
-
const [fromSymbol, fromDecimals] = (0,
|
|
136
|
+
const [fromSymbol, fromDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenFrom);
|
|
139
137
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, formatter_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${(0, contractsRegister_1.getContractName)(this.protocol)}`;
|
|
140
138
|
}
|
|
141
139
|
serialize() {
|
|
@@ -162,7 +160,7 @@ class TxAddCollateral extends eventOrTx_1.EVMTx {
|
|
|
162
160
|
this.creditManager = opts.creditManager;
|
|
163
161
|
}
|
|
164
162
|
toString() {
|
|
165
|
-
const [addedSymbol, addedDecimals] = (0,
|
|
163
|
+
const [addedSymbol, addedDecimals] = (0, sdk_gov_1.extractTokenData)(this.addedToken);
|
|
166
164
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, formatter_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
|
|
167
165
|
}
|
|
168
166
|
serialize() {
|
|
@@ -189,7 +187,7 @@ class TxIncreaseBorrowAmount extends eventOrTx_1.EVMTx {
|
|
|
189
187
|
this.creditManager = opts.creditManager;
|
|
190
188
|
}
|
|
191
189
|
toString() {
|
|
192
|
-
const [tokenSymbol, tokenDecimals] = (0,
|
|
190
|
+
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
193
191
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
194
192
|
}
|
|
195
193
|
serialize() {
|
|
@@ -216,7 +214,7 @@ class TxDecreaseBorrowAmount extends eventOrTx_1.EVMTx {
|
|
|
216
214
|
this.creditManager = opts.creditManager;
|
|
217
215
|
}
|
|
218
216
|
toString() {
|
|
219
|
-
const [tokenSymbol, tokenDecimals] = (0,
|
|
217
|
+
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
220
218
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
221
219
|
}
|
|
222
220
|
serialize() {
|
|
@@ -245,11 +243,11 @@ class TxOpenAccount extends eventOrTx_1.EVMTx {
|
|
|
245
243
|
this.creditManager = opts.creditManager;
|
|
246
244
|
}
|
|
247
245
|
toString() {
|
|
248
|
-
const [tokenSymbol, tokenDecimals] = (0,
|
|
246
|
+
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
249
247
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, formatter_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
|
|
250
248
|
${(0, formatter_1.formatBN)((this.amount *
|
|
251
|
-
BigInt(Math.floor(this.leverage * Number(
|
|
252
|
-
|
|
249
|
+
BigInt(Math.floor(this.leverage * Number(sdk_gov_1.LEVERAGE_DECIMALS)))) /
|
|
250
|
+
sdk_gov_1.LEVERAGE_DECIMALS, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
253
251
|
}
|
|
254
252
|
serialize() {
|
|
255
253
|
return {
|
|
@@ -278,12 +276,12 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
|
|
|
278
276
|
}
|
|
279
277
|
toString() {
|
|
280
278
|
const assetSymbols = this.assets.reduce((acc, assetAddress) => {
|
|
281
|
-
const [tokenSymbol] = (0,
|
|
279
|
+
const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(assetAddress);
|
|
282
280
|
if (tokenSymbol)
|
|
283
281
|
acc.push(tokenSymbol);
|
|
284
282
|
return acc;
|
|
285
283
|
}, []);
|
|
286
|
-
const [symbol, underlyingDecimals] = (0,
|
|
284
|
+
const [symbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
287
285
|
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, formatter_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
|
|
288
286
|
}
|
|
289
287
|
serialize() {
|
|
@@ -307,7 +305,7 @@ class TxClaimReward extends eventOrTx_1.EVMTx {
|
|
|
307
305
|
}
|
|
308
306
|
toString() {
|
|
309
307
|
const contractNames = this.contracts.map(contract => {
|
|
310
|
-
const contractInfo =
|
|
308
|
+
const contractInfo = sdk_gov_1.contractParams[contract];
|
|
311
309
|
return contractInfo.name;
|
|
312
310
|
});
|
|
313
311
|
return `Pools reward claimed: ${contractNames.join(", ")}`;
|
|
@@ -354,7 +352,7 @@ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
|
|
|
354
352
|
this.token = opts.token;
|
|
355
353
|
}
|
|
356
354
|
toString() {
|
|
357
|
-
const [symbol, decimals] = (0,
|
|
355
|
+
const [symbol, decimals] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
358
356
|
return `GEAR Rewards claimed: ${(0, formatter_1.formatBN)(this.amount, decimals || 18)} ${symbol} `;
|
|
359
357
|
}
|
|
360
358
|
serialize() {
|
|
@@ -421,7 +419,7 @@ class TxApprove extends eventOrTx_1.EVMTx {
|
|
|
421
419
|
this.token = opts.token;
|
|
422
420
|
}
|
|
423
421
|
toString() {
|
|
424
|
-
const [symbol] = (0,
|
|
422
|
+
const [symbol] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
425
423
|
return `Approve ${symbol}`;
|
|
426
424
|
}
|
|
427
425
|
serialize() {
|
|
@@ -449,11 +447,11 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
|
|
|
449
447
|
}
|
|
450
448
|
toString() {
|
|
451
449
|
const enabledSymbols = this.enabledTokens.map(address => {
|
|
452
|
-
const [tokenSymbol] = (0,
|
|
450
|
+
const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(address);
|
|
453
451
|
return tokenSymbol;
|
|
454
452
|
});
|
|
455
453
|
const disabledSymbols = this.disabledTokens.map(address => {
|
|
456
|
-
const [tokenSymbol] = (0,
|
|
454
|
+
const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(address);
|
|
457
455
|
return tokenSymbol;
|
|
458
456
|
});
|
|
459
457
|
const currentSentences = [
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export * from "./contracts/contracts";
|
|
2
|
-
export * from "./contracts/protocols";
|
|
3
1
|
export * from "./core/assets";
|
|
4
|
-
export * from "./core/chains";
|
|
5
|
-
export * from "./core/constants";
|
|
6
2
|
export * from "./core/creditAccount";
|
|
7
3
|
export * from "./core/creditManager";
|
|
8
4
|
export * from "./core/creditSession";
|
|
@@ -27,27 +23,13 @@ export * from "./utils/loading";
|
|
|
27
23
|
export * from "./utils/math";
|
|
28
24
|
export * from "./utils/validate";
|
|
29
25
|
export * from "./apy";
|
|
30
|
-
export { AdapterInterface } from "./contracts/adapters";
|
|
31
|
-
export * from "./contracts/contractsRegister";
|
|
32
|
-
export * from "./contracts/utilsContracts";
|
|
33
26
|
export * from "./parsers/txParser";
|
|
34
27
|
export * from "./pathfinder/core";
|
|
35
28
|
export * from "./pathfinder/pathfinder";
|
|
36
|
-
export * from "./tokens/convex";
|
|
37
|
-
export * from "./tokens/curveLP";
|
|
38
|
-
export * from "./tokens/decimals";
|
|
39
|
-
export * from "./tokens/gear";
|
|
40
|
-
export * from "./tokens/normal";
|
|
41
|
-
export * from "./tokens/token";
|
|
42
|
-
export * from "./tokens/tokenData";
|
|
43
|
-
export { TokenType } from "./tokens/tokenType";
|
|
44
|
-
export * from "./tokens/yearn";
|
|
45
29
|
export * from "./utils/errors";
|
|
46
|
-
export * from "./utils/mappers";
|
|
47
|
-
export * from "./utils/multicall";
|
|
48
30
|
export * from "./utils/price";
|
|
49
31
|
export { callRepeater } from "./utils/repeater";
|
|
50
|
-
export { safeEnum } from "./utils/safeEnum";
|
|
51
|
-
export * from "./utils/types";
|
|
52
32
|
export * from "./watchers/creditAccountWatcher";
|
|
53
33
|
export * from "./watchers/creditManagerWatcher";
|
|
34
|
+
export type { CallData, MCall, NetworkType, NormalToken, NormalTokenData, SupportedToken, } from "@gearbox-protocol/sdk-gov";
|
|
35
|
+
export { ARBITRUM_NETWORK, CHAINS, extractTokenData, getDecimals, getNetworkType, GOERLI_NETWORK, HARDHAT_NETWORK, isLPToken, isNormalToken, isSupportedNetwork, isSupportedToken, LOCAL_NETWORK, lpTokens, MAINNET_NETWORK, MultiCallContract, normalTokens, OPTIMISM_NETWORK, POLYGON_NETWORK, safeMulticall, supportedChains, supportedTokens, TENDERLY_NETWORK, tokenDataByNetwork, tokenSymbolByAddress, WAD, } from "@gearbox-protocol/sdk-gov";
|
package/lib/index.js
CHANGED
|
@@ -14,12 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
__exportStar(require("./contracts/contracts"), exports);
|
|
19
|
-
__exportStar(require("./contracts/protocols"), exports);
|
|
17
|
+
exports.WAD = exports.tokenSymbolByAddress = exports.tokenDataByNetwork = exports.TENDERLY_NETWORK = exports.supportedTokens = exports.supportedChains = exports.safeMulticall = exports.POLYGON_NETWORK = exports.OPTIMISM_NETWORK = exports.normalTokens = exports.MultiCallContract = exports.MAINNET_NETWORK = exports.lpTokens = exports.LOCAL_NETWORK = exports.isSupportedToken = exports.isSupportedNetwork = exports.isNormalToken = exports.isLPToken = exports.HARDHAT_NETWORK = exports.GOERLI_NETWORK = exports.getNetworkType = exports.getDecimals = exports.extractTokenData = exports.CHAINS = exports.ARBITRUM_NETWORK = exports.callRepeater = void 0;
|
|
20
18
|
__exportStar(require("./core/assets"), exports);
|
|
21
|
-
__exportStar(require("./core/chains"), exports);
|
|
22
|
-
__exportStar(require("./core/constants"), exports);
|
|
23
19
|
__exportStar(require("./core/creditAccount"), exports);
|
|
24
20
|
__exportStar(require("./core/creditManager"), exports);
|
|
25
21
|
__exportStar(require("./core/creditSession"), exports);
|
|
@@ -45,31 +41,38 @@ __exportStar(require("./utils/math"), exports);
|
|
|
45
41
|
__exportStar(require("./utils/validate"), exports);
|
|
46
42
|
// Tokens
|
|
47
43
|
__exportStar(require("./apy"), exports);
|
|
48
|
-
var adapters_1 = require("./contracts/adapters");
|
|
49
|
-
Object.defineProperty(exports, "AdapterInterface", { enumerable: true, get: function () { return adapters_1.AdapterInterface; } });
|
|
50
|
-
__exportStar(require("./contracts/contractsRegister"), exports);
|
|
51
|
-
__exportStar(require("./contracts/utilsContracts"), exports);
|
|
52
44
|
__exportStar(require("./parsers/txParser"), exports);
|
|
53
45
|
__exportStar(require("./pathfinder/core"), exports);
|
|
54
46
|
__exportStar(require("./pathfinder/pathfinder"), exports);
|
|
55
|
-
__exportStar(require("./tokens/convex"), exports);
|
|
56
|
-
__exportStar(require("./tokens/curveLP"), exports);
|
|
57
|
-
__exportStar(require("./tokens/decimals"), exports);
|
|
58
|
-
__exportStar(require("./tokens/gear"), exports);
|
|
59
|
-
__exportStar(require("./tokens/normal"), exports);
|
|
60
|
-
__exportStar(require("./tokens/token"), exports);
|
|
61
|
-
__exportStar(require("./tokens/tokenData"), exports);
|
|
62
|
-
var tokenType_1 = require("./tokens/tokenType");
|
|
63
|
-
Object.defineProperty(exports, "TokenType", { enumerable: true, get: function () { return tokenType_1.TokenType; } });
|
|
64
|
-
__exportStar(require("./tokens/yearn"), exports);
|
|
65
47
|
__exportStar(require("./utils/errors"), exports);
|
|
66
|
-
__exportStar(require("./utils/mappers"), exports);
|
|
67
|
-
__exportStar(require("./utils/multicall"), exports);
|
|
68
48
|
__exportStar(require("./utils/price"), exports);
|
|
69
49
|
var repeater_1 = require("./utils/repeater");
|
|
70
50
|
Object.defineProperty(exports, "callRepeater", { enumerable: true, get: function () { return repeater_1.callRepeater; } });
|
|
71
|
-
var safeEnum_1 = require("./utils/safeEnum");
|
|
72
|
-
Object.defineProperty(exports, "safeEnum", { enumerable: true, get: function () { return safeEnum_1.safeEnum; } });
|
|
73
|
-
__exportStar(require("./utils/types"), exports);
|
|
74
51
|
__exportStar(require("./watchers/creditAccountWatcher"), exports);
|
|
75
52
|
__exportStar(require("./watchers/creditManagerWatcher"), exports);
|
|
53
|
+
var sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
54
|
+
Object.defineProperty(exports, "ARBITRUM_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.ARBITRUM_NETWORK; } });
|
|
55
|
+
Object.defineProperty(exports, "CHAINS", { enumerable: true, get: function () { return sdk_gov_1.CHAINS; } });
|
|
56
|
+
Object.defineProperty(exports, "extractTokenData", { enumerable: true, get: function () { return sdk_gov_1.extractTokenData; } });
|
|
57
|
+
Object.defineProperty(exports, "getDecimals", { enumerable: true, get: function () { return sdk_gov_1.getDecimals; } });
|
|
58
|
+
Object.defineProperty(exports, "getNetworkType", { enumerable: true, get: function () { return sdk_gov_1.getNetworkType; } });
|
|
59
|
+
Object.defineProperty(exports, "GOERLI_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.GOERLI_NETWORK; } });
|
|
60
|
+
Object.defineProperty(exports, "HARDHAT_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.HARDHAT_NETWORK; } });
|
|
61
|
+
Object.defineProperty(exports, "isLPToken", { enumerable: true, get: function () { return sdk_gov_1.isLPToken; } });
|
|
62
|
+
Object.defineProperty(exports, "isNormalToken", { enumerable: true, get: function () { return sdk_gov_1.isNormalToken; } });
|
|
63
|
+
Object.defineProperty(exports, "isSupportedNetwork", { enumerable: true, get: function () { return sdk_gov_1.isSupportedNetwork; } });
|
|
64
|
+
Object.defineProperty(exports, "isSupportedToken", { enumerable: true, get: function () { return sdk_gov_1.isSupportedToken; } });
|
|
65
|
+
Object.defineProperty(exports, "LOCAL_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.LOCAL_NETWORK; } });
|
|
66
|
+
Object.defineProperty(exports, "lpTokens", { enumerable: true, get: function () { return sdk_gov_1.lpTokens; } });
|
|
67
|
+
Object.defineProperty(exports, "MAINNET_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.MAINNET_NETWORK; } });
|
|
68
|
+
Object.defineProperty(exports, "MultiCallContract", { enumerable: true, get: function () { return sdk_gov_1.MultiCallContract; } });
|
|
69
|
+
Object.defineProperty(exports, "normalTokens", { enumerable: true, get: function () { return sdk_gov_1.normalTokens; } });
|
|
70
|
+
Object.defineProperty(exports, "OPTIMISM_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.OPTIMISM_NETWORK; } });
|
|
71
|
+
Object.defineProperty(exports, "POLYGON_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.POLYGON_NETWORK; } });
|
|
72
|
+
Object.defineProperty(exports, "safeMulticall", { enumerable: true, get: function () { return sdk_gov_1.safeMulticall; } });
|
|
73
|
+
Object.defineProperty(exports, "supportedChains", { enumerable: true, get: function () { return sdk_gov_1.supportedChains; } });
|
|
74
|
+
Object.defineProperty(exports, "supportedTokens", { enumerable: true, get: function () { return sdk_gov_1.supportedTokens; } });
|
|
75
|
+
Object.defineProperty(exports, "TENDERLY_NETWORK", { enumerable: true, get: function () { return sdk_gov_1.TENDERLY_NETWORK; } });
|
|
76
|
+
Object.defineProperty(exports, "tokenDataByNetwork", { enumerable: true, get: function () { return sdk_gov_1.tokenDataByNetwork; } });
|
|
77
|
+
Object.defineProperty(exports, "tokenSymbolByAddress", { enumerable: true, get: function () { return sdk_gov_1.tokenSymbolByAddress; } });
|
|
78
|
+
Object.defineProperty(exports, "WAD", { enumerable: true, get: function () { return sdk_gov_1.WAD; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportedToken } from "
|
|
1
|
+
import { SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
2
|
import { AbstractParser } from "./abstractParser";
|
|
3
3
|
import { IParser } from "./iParser";
|
|
4
4
|
export declare class ERC20Parser extends AbstractParser implements IParser {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionFragment, Result } from "@ethersproject/abi";
|
|
2
|
+
import { SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
3
|
import { BigNumberish, BytesLike, utils } from "ethers";
|
|
3
|
-
import { SupportedToken } from "../tokens/token";
|
|
4
4
|
interface ParseSelectorResult {
|
|
5
5
|
functionFragment: FunctionFragment;
|
|
6
6
|
functionName: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractParser = void 0;
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
4
5
|
const ethers_1 = require("ethers");
|
|
5
|
-
const decimals_1 = require("../tokens/decimals");
|
|
6
|
-
const token_1 = require("../tokens/token");
|
|
7
6
|
const formatter_1 = require("../utils/formatter");
|
|
8
7
|
class AbstractParser {
|
|
9
8
|
contract;
|
|
@@ -25,13 +24,13 @@ class AbstractParser {
|
|
|
25
24
|
return this.ifc.encodeFunctionResult(functionFragment, data);
|
|
26
25
|
}
|
|
27
26
|
tokenSymbol(address) {
|
|
28
|
-
const symbol =
|
|
27
|
+
const symbol = sdk_gov_1.tokenSymbolByAddress[address.toLowerCase()];
|
|
29
28
|
if (!symbol)
|
|
30
29
|
throw new Error(`Unknown token: ${address}`);
|
|
31
30
|
return symbol;
|
|
32
31
|
}
|
|
33
32
|
formatBN(amount, token) {
|
|
34
|
-
return `${(0, formatter_1.formatBN)(amount,
|
|
33
|
+
return `${(0, formatter_1.formatBN)(amount, sdk_gov_1.decimals[token])} [${(0, formatter_1.toBigInt)(amount).toString()}]`;
|
|
35
34
|
}
|
|
36
35
|
parseToObject(address, calldata) {
|
|
37
36
|
const { functionFragment } = this.parseSelector(calldata);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
1
2
|
import { BigNumberish } from "ethers";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { AbstractParser } from "./abstractParser";
|
|
4
4
|
import { IParser } from "./iParser";
|
|
5
5
|
export declare class ConvexBaseRewardPoolAdapterParser extends AbstractParser implements IParser {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConvexBaseRewardPoolAdapterParser = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const abstractParser_1 = require("./abstractParser");
|
|
7
7
|
class ConvexBaseRewardPoolAdapterParser extends abstractParser_1.AbstractParser {
|
|
@@ -39,7 +39,7 @@ class ConvexBaseRewardPoolAdapterParser extends abstractParser_1.AbstractParser
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
formatAmount(amount) {
|
|
42
|
-
return this.formatBN(amount,
|
|
42
|
+
return this.formatBN(amount, sdk_gov_1.contractParams[this.contract]
|
|
43
43
|
.stakedToken);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
3
4
|
const chai_1 = require("chai");
|
|
4
|
-
const constants_1 = require("../core/constants");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const convexBaseRewardPoolAdapterParser_1 = require("./convexBaseRewardPoolAdapterParser");
|
|
7
7
|
describe("ConvexV1BaseRewardPoolAdapterParser test", () => {
|
|
8
8
|
it("stake / withdraw functions works well", () => {
|
|
9
9
|
let parser = new convexBaseRewardPoolAdapterParser_1.ConvexBaseRewardPoolAdapterParser("CONVEX_FRAX3CRV_POOL", false);
|
|
10
10
|
const ifc = types_1.IConvexV1BaseRewardPoolAdapter__factory.createInterface();
|
|
11
|
-
let parsed = parser.parse(ifc.encodeFunctionData("stake", [(
|
|
11
|
+
let parsed = parser.parse(ifc.encodeFunctionData("stake", [(sdk_gov_1.WAD * 199n) / 10n]));
|
|
12
12
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BaseRewardPoolAdapter[CONVEX_FRAX3CRV_POOL].stake(amount: 19.90 [19900000000000000000])", "Incorrect parse stake");
|
|
13
13
|
parsed = parser.parse(ifc.encodeFunctionData("stakeAll"));
|
|
14
14
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BaseRewardPoolAdapter[CONVEX_FRAX3CRV_POOL].stakeAll()", "Incorrect parse stakeAll");
|
|
15
|
-
parsed = parser.parse(ifc.encodeFunctionData("withdraw", [(
|
|
15
|
+
parsed = parser.parse(ifc.encodeFunctionData("withdraw", [(sdk_gov_1.WAD * 199n) / 1000n, false]));
|
|
16
16
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BaseRewardPoolAdapter[CONVEX_FRAX3CRV_POOL].withdraw(amount: 0.19 [199000000000000000], claim: false)", "Incorrect parse withdraw");
|
|
17
|
-
parsed = parser.parse(ifc.encodeFunctionData("withdrawAndUnwrap", [(
|
|
17
|
+
parsed = parser.parse(ifc.encodeFunctionData("withdrawAndUnwrap", [(sdk_gov_1.WAD * 2n) / 1000n, true]));
|
|
18
18
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BaseRewardPoolAdapter[CONVEX_FRAX3CRV_POOL].withdrawAndUnwrap(amount: 0.002 [2000000000000000], claim: true)", "Incorrect parse withdrawAndUnwrap");
|
|
19
19
|
parsed = parser.parse(ifc.encodeFunctionData("withdrawAll", [false]));
|
|
20
20
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BaseRewardPoolAdapter[CONVEX_FRAX3CRV_POOL].withdrawAll(claim: false)", "Incorrect parse withdrawAll");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
1
2
|
import { BigNumberish } from "ethers";
|
|
2
|
-
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { AbstractParser } from "./abstractParser";
|
|
4
4
|
import { IParser } from "./iParser";
|
|
5
5
|
export declare class ConvexBoosterAdapterParser extends AbstractParser implements IParser {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConvexBoosterAdapterParser = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const abstractParser_1 = require("./abstractParser");
|
|
7
7
|
class ConvexBoosterAdapterParser extends abstractParser_1.AbstractParser {
|
|
@@ -35,10 +35,10 @@ class ConvexBoosterAdapterParser extends abstractParser_1.AbstractParser {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
formatAmount(amount, pid) {
|
|
38
|
-
return this.formatBN(amount,
|
|
38
|
+
return this.formatBN(amount, sdk_gov_1.convexLpTokenByPid[pid]);
|
|
39
39
|
}
|
|
40
40
|
formatPid(pid) {
|
|
41
|
-
return `${pid} [${
|
|
41
|
+
return `${pid} [${sdk_gov_1.convexPoolByPid[pid]}]`;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.ConvexBoosterAdapterParser = ConvexBoosterAdapterParser;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
3
4
|
const chai_1 = require("chai");
|
|
4
|
-
const constants_1 = require("../core/constants");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const convexBoosterAdapterParser_1 = require("./convexBoosterAdapterParser");
|
|
7
7
|
describe("ConvexV1BaseRewardPoolAdapterParser test", () => {
|
|
8
8
|
it("stake / withdraw functions works well", () => {
|
|
9
9
|
let parser = new convexBoosterAdapterParser_1.ConvexBoosterAdapterParser("CONVEX_BOOSTER", false);
|
|
10
10
|
const ifc = types_1.IConvexV1BoosterAdapter__factory.createInterface();
|
|
11
|
-
let parsed = parser.parse(ifc.encodeFunctionData("deposit", [9,
|
|
11
|
+
let parsed = parser.parse(ifc.encodeFunctionData("deposit", [9, sdk_gov_1.WAD * 19999n, false]));
|
|
12
12
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BoosterAdapter[CONVEX_BOOSTER].deposit(pid: 9 [CONVEX_3CRV_POOL], amount: 19.99K [19999000000000000000000], stake: false)", "Incorrect parse deposit");
|
|
13
13
|
parsed = parser.parse(ifc.encodeFunctionData("depositAll", [32, true]));
|
|
14
14
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BoosterAdapter[CONVEX_BOOSTER].depositAll(pid: 32 [CONVEX_FRAX3CRV_POOL], stake: true)", "Incorrect parse depositAll");
|
|
15
|
-
parsed = parser.parse(ifc.encodeFunctionData("withdraw", [9, (
|
|
15
|
+
parsed = parser.parse(ifc.encodeFunctionData("withdraw", [9, (sdk_gov_1.WAD * 555n) / 10n]));
|
|
16
16
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BoosterAdapter[CONVEX_BOOSTER].withdraw(pid: 9 [CONVEX_3CRV_POOL], amount: 55.50 [55500000000000000000])", "Incorrect parse withdraw");
|
|
17
17
|
parsed = parser.parse(ifc.encodeFunctionData("withdrawAll", [32]));
|
|
18
18
|
(0, chai_1.expect)(parsed).to.be.eq("ConvexV1BoosterAdapter[CONVEX_BOOSTER].withdrawAll(pid: 32 [CONVEX_FRAX3CRV_POOL])", "Incorrect parse withdrawAll");
|