@gearbox-protocol/sdk 1.17.3 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apy/convexAPY.d.ts +27 -4
- package/lib/apy/convexAPY.js +153 -74
- package/lib/core/transactions.d.ts +16 -3
- package/lib/core/transactions.js +43 -1
- package/package.json +1 -1
package/lib/apy/convexAPY.d.ts
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { BigNumber, providers } from "ethers";
|
|
2
|
-
import { ConvexPoolContract } from "../contracts/contracts";
|
|
2
|
+
import { ConvexPoolContract, ConvexPoolParams } from "../contracts/contracts";
|
|
3
3
|
import { NetworkType } from "../core/constants";
|
|
4
|
+
import { CurveLPToken } from "../tokens/curveLP";
|
|
5
|
+
import { SupportedToken } from "../tokens/token";
|
|
4
6
|
import { CurveAPYResult } from "./curveAPY";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
declare type GetTokenPriceCallback = (tokenAddress: string, currency?: string) => BigNumber;
|
|
8
|
+
export interface GetConvexAPYBaseProps {
|
|
7
9
|
provider: providers.Provider;
|
|
8
10
|
networkType: NetworkType;
|
|
9
|
-
getTokenPrice:
|
|
11
|
+
getTokenPrice: GetTokenPriceCallback;
|
|
10
12
|
curveAPY: CurveAPYResult;
|
|
11
13
|
}
|
|
14
|
+
export interface GetConvexAPYBulkProps extends GetConvexAPYBaseProps {
|
|
15
|
+
pools: Array<ConvexPoolContract>;
|
|
16
|
+
}
|
|
17
|
+
export declare function getConvexAPYBulk({ pools, provider, networkType, getTokenPrice, curveAPY, }: GetConvexAPYBulkProps): Promise<BigNumber[]>;
|
|
18
|
+
export interface GetConvexAPYProps extends GetConvexAPYBaseProps {
|
|
19
|
+
pool: ConvexPoolContract;
|
|
20
|
+
}
|
|
12
21
|
export declare function getConvexAPY({ pool, provider, networkType, getTokenPrice, curveAPY, }: GetConvexAPYProps): Promise<BigNumber>;
|
|
13
22
|
export declare function getCVXMintAmount(crvAmount: BigNumber, cvxSupply: BigNumber): BigNumber;
|
|
23
|
+
export interface CalculateConvexAPYProps {
|
|
24
|
+
basePoolRate: BigNumber;
|
|
25
|
+
basePoolSupply: BigNumber;
|
|
26
|
+
vPrice: BigNumber;
|
|
27
|
+
cvxSupply: BigNumber;
|
|
28
|
+
extra: Array<BigNumber>;
|
|
29
|
+
extraPoolAddresses: string[];
|
|
30
|
+
poolParams: ConvexPoolParams;
|
|
31
|
+
underlying: CurveLPToken;
|
|
32
|
+
getTokenPrice: GetTokenPriceCallback;
|
|
33
|
+
curveAPY: CurveAPYResult;
|
|
34
|
+
tokenList: Record<SupportedToken, string>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
package/lib/apy/convexAPY.js
CHANGED
|
@@ -45,65 +45,150 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.getCVXMintAmount = exports.getConvexAPY = void 0;
|
|
48
|
+
exports.getCVXMintAmount = exports.getConvexAPY = exports.getConvexAPYBulk = void 0;
|
|
49
49
|
var ethers_1 = require("ethers");
|
|
50
50
|
var contracts_1 = require("../contracts/contracts");
|
|
51
51
|
var constants_1 = require("../core/constants");
|
|
52
52
|
var token_1 = require("../tokens/token");
|
|
53
53
|
var types_1 = require("../types");
|
|
54
54
|
var multicall_1 = require("../utils/multicall");
|
|
55
|
-
function
|
|
56
|
-
var
|
|
55
|
+
function getConvexAPYBulk(_a) {
|
|
56
|
+
var pools = _a.pools, provider = _a.provider, networkType = _a.networkType, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY;
|
|
57
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
var
|
|
59
|
-
return __generator(this, function (
|
|
60
|
-
switch (
|
|
58
|
+
var poolsInfo, calls, response, parsedResponse, apyList;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
switch (_b.label) {
|
|
61
61
|
case 0:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
underlying = stakedTokenParams.underlying;
|
|
67
|
-
basePoolAddress = contractsList[pool];
|
|
68
|
-
crvParams = token_1.supportedTokens[underlying];
|
|
69
|
-
swapPoolAddress = contractsList[crvParams.pool];
|
|
70
|
-
cvxAddress = tokenList.CVX;
|
|
71
|
-
extraPoolAddresses = poolParams.extraRewards.map(function (d) { return d.poolAddress[networkType]; });
|
|
72
|
-
return [4 /*yield*/, getPoolData({
|
|
62
|
+
poolsInfo = pools.map(function (pool) { return getPoolInfo({ networkType: networkType, pool: pool }); });
|
|
63
|
+
calls = poolsInfo.map(function (_a) {
|
|
64
|
+
var basePoolAddress = _a[1], swapPoolAddress = _a[2], extraPoolAddresses = _a[4], tokenList = _a[5];
|
|
65
|
+
return getPoolDataCalls({
|
|
73
66
|
basePoolAddress: basePoolAddress,
|
|
74
67
|
swapPoolAddress: swapPoolAddress,
|
|
75
|
-
cvxAddress:
|
|
68
|
+
cvxAddress: tokenList.CVX,
|
|
76
69
|
extraPoolAddresses: extraPoolAddresses,
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return [4 /*yield*/, (0, multicall_1.multicall)(calls.flat(1), provider)];
|
|
79
73
|
case 1:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
response = _b.sent();
|
|
75
|
+
parsedResponse = calls.reduce(function (_a, call) {
|
|
76
|
+
var acc = _a[0], start = _a[1];
|
|
77
|
+
var end = start + call.length;
|
|
78
|
+
var currentResponse = response.slice(start, end);
|
|
79
|
+
acc.push(currentResponse);
|
|
80
|
+
return [acc, end];
|
|
81
|
+
}, [[], 0])[0];
|
|
82
|
+
apyList = parsedResponse.map(function (_a, i) {
|
|
83
|
+
var basePoolRate = _a[0], basePoolSupply = _a[1], vPrice = _a[2], cvxSupply = _a[3], extra = _a.slice(4);
|
|
84
|
+
var _b = poolsInfo[i], poolParams = _b[0], underlying = _b[3], extraPoolAddresses = _b[4], tokenList = _b[5];
|
|
85
|
+
var apy = calculateConvexAPY({
|
|
86
|
+
basePoolRate: basePoolRate,
|
|
87
|
+
basePoolSupply: basePoolSupply,
|
|
88
|
+
vPrice: vPrice,
|
|
89
|
+
cvxSupply: cvxSupply,
|
|
90
|
+
extra: extra,
|
|
91
|
+
extraPoolAddresses: extraPoolAddresses,
|
|
92
|
+
poolParams: poolParams,
|
|
93
|
+
underlying: underlying,
|
|
94
|
+
getTokenPrice: getTokenPrice,
|
|
95
|
+
curveAPY: curveAPY,
|
|
96
|
+
tokenList: tokenList,
|
|
97
|
+
});
|
|
98
|
+
return apy;
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
return [2 /*return*/, apyList];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
exports.getConvexAPYBulk = getConvexAPYBulk;
|
|
106
|
+
function getConvexAPY(_a) {
|
|
107
|
+
var pool = _a.pool, provider = _a.provider, networkType = _a.networkType, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY;
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var _b, poolParams, basePoolAddress, swapPoolAddress, underlying, extraPoolAddresses, tokenList, calls, _c, basePoolRate, basePoolSupply, vPrice, cvxSupply, extra, apy;
|
|
110
|
+
return __generator(this, function (_d) {
|
|
111
|
+
switch (_d.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
_b = getPoolInfo({ networkType: networkType, pool: pool }), poolParams = _b[0], basePoolAddress = _b[1], swapPoolAddress = _b[2], underlying = _b[3], extraPoolAddresses = _b[4], tokenList = _b[5];
|
|
114
|
+
calls = getPoolDataCalls({
|
|
115
|
+
basePoolAddress: basePoolAddress,
|
|
116
|
+
swapPoolAddress: swapPoolAddress,
|
|
117
|
+
cvxAddress: tokenList.CVX,
|
|
118
|
+
extraPoolAddresses: extraPoolAddresses,
|
|
119
|
+
});
|
|
120
|
+
return [4 /*yield*/, (0, multicall_1.multicall)(calls, provider)];
|
|
121
|
+
case 1:
|
|
122
|
+
_c = _d.sent(), basePoolRate = _c[0], basePoolSupply = _c[1], vPrice = _c[2], cvxSupply = _c[3], extra = _c.slice(4);
|
|
123
|
+
apy = calculateConvexAPY({
|
|
124
|
+
basePoolRate: basePoolRate,
|
|
125
|
+
basePoolSupply: basePoolSupply,
|
|
126
|
+
vPrice: vPrice,
|
|
127
|
+
cvxSupply: cvxSupply,
|
|
128
|
+
extra: extra,
|
|
129
|
+
extraPoolAddresses: extraPoolAddresses,
|
|
130
|
+
poolParams: poolParams,
|
|
131
|
+
underlying: underlying,
|
|
132
|
+
getTokenPrice: getTokenPrice,
|
|
133
|
+
curveAPY: curveAPY,
|
|
134
|
+
tokenList: tokenList,
|
|
135
|
+
});
|
|
136
|
+
return [2 /*return*/, apy];
|
|
102
137
|
}
|
|
103
138
|
});
|
|
104
139
|
});
|
|
105
140
|
}
|
|
106
141
|
exports.getConvexAPY = getConvexAPY;
|
|
142
|
+
function getPoolInfo(_a) {
|
|
143
|
+
var pool = _a.pool, networkType = _a.networkType;
|
|
144
|
+
var tokenList = token_1.tokenDataByNetwork[networkType];
|
|
145
|
+
var contractsList = contracts_1.contractsByNetwork[networkType];
|
|
146
|
+
var poolParams = contracts_1.contractParams[pool];
|
|
147
|
+
var stakedTokenParams = token_1.supportedTokens[poolParams.stakedToken];
|
|
148
|
+
var underlying = stakedTokenParams.underlying;
|
|
149
|
+
var basePoolAddress = contractsList[pool];
|
|
150
|
+
var crvParams = token_1.supportedTokens[underlying];
|
|
151
|
+
var swapPoolAddress = contractsList[crvParams.pool];
|
|
152
|
+
var extraPoolAddresses = poolParams.extraRewards.map(function (d) { return d.poolAddress[networkType]; });
|
|
153
|
+
return [
|
|
154
|
+
poolParams,
|
|
155
|
+
basePoolAddress,
|
|
156
|
+
swapPoolAddress,
|
|
157
|
+
underlying,
|
|
158
|
+
extraPoolAddresses,
|
|
159
|
+
tokenList,
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
function getPoolDataCalls(_a) {
|
|
163
|
+
var basePoolAddress = _a.basePoolAddress, swapPoolAddress = _a.swapPoolAddress, cvxAddress = _a.cvxAddress, extraPoolAddresses = _a.extraPoolAddresses;
|
|
164
|
+
var calls = __spreadArray([
|
|
165
|
+
{
|
|
166
|
+
address: basePoolAddress,
|
|
167
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
168
|
+
method: "rewardRate()",
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
address: basePoolAddress,
|
|
172
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
173
|
+
method: "totalSupply()",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
address: swapPoolAddress,
|
|
177
|
+
interface: types_1.ICurvePool__factory.createInterface(),
|
|
178
|
+
method: "get_virtual_price()",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
address: cvxAddress,
|
|
182
|
+
interface: types_1.IConvexToken__factory.createInterface(),
|
|
183
|
+
method: "totalSupply()",
|
|
184
|
+
}
|
|
185
|
+
], extraPoolAddresses.map(function (extraPoolAddress) { return ({
|
|
186
|
+
address: extraPoolAddress,
|
|
187
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
188
|
+
method: "rewardRate()",
|
|
189
|
+
}); }), true);
|
|
190
|
+
return calls;
|
|
191
|
+
}
|
|
107
192
|
var CVX_MAX_SUPPLY = constants_1.WAD.mul(100000000);
|
|
108
193
|
var CVX_REDUCTION_PER_CLIFF = ethers_1.BigNumber.from(100000);
|
|
109
194
|
var CVX_TOTAL_CLIFFS = constants_1.WAD.mul(1000);
|
|
@@ -118,38 +203,32 @@ function getCVXMintAmount(crvAmount, cvxSupply) {
|
|
|
118
203
|
return ethers_1.BigNumber.from(0);
|
|
119
204
|
}
|
|
120
205
|
exports.getCVXMintAmount = getCVXMintAmount;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
method: "totalSupply()",
|
|
146
|
-
}
|
|
147
|
-
], extraPoolAddresses.map(function (extraPoolAddress) { return ({
|
|
148
|
-
address: extraPoolAddress,
|
|
149
|
-
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
150
|
-
method: "rewardRate()",
|
|
151
|
-
}); }), true);
|
|
152
|
-
return [2 /*return*/, (0, multicall_1.multicall)(calls, provider)];
|
|
153
|
-
});
|
|
206
|
+
var CURRENCY_LIST = {
|
|
207
|
+
stkcvxsteCRV: "WETH",
|
|
208
|
+
};
|
|
209
|
+
function calculateConvexAPY(_a) {
|
|
210
|
+
var basePoolRate = _a.basePoolRate, basePoolSupply = _a.basePoolSupply, vPrice = _a.vPrice, cvxSupply = _a.cvxSupply, extra = _a.extra, extraPoolAddresses = _a.extraPoolAddresses, poolParams = _a.poolParams, underlying = _a.underlying, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY, tokenList = _a.tokenList;
|
|
211
|
+
var currencySymbol = CURRENCY_LIST[poolParams.stakedToken];
|
|
212
|
+
var currency = currencySymbol && tokenList[currencySymbol || ""];
|
|
213
|
+
var cvxPrice = getTokenPrice(tokenList.CVX, currency);
|
|
214
|
+
var crvPrice = getTokenPrice(tokenList.CRV, currency);
|
|
215
|
+
var crvPerSecond = basePoolRate;
|
|
216
|
+
var virtualSupply = basePoolSupply.mul(vPrice).div(constants_1.WAD);
|
|
217
|
+
var crvPerUnderlying = crvPerSecond.mul(constants_1.WAD).div(virtualSupply);
|
|
218
|
+
var crvPerYear = crvPerUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
219
|
+
var cvxPerYear = getCVXMintAmount(crvPerYear, cvxSupply);
|
|
220
|
+
var crvAPY = crvPerYear.mul(crvPrice).div(constants_1.PRICE_DECIMALS);
|
|
221
|
+
var cvxAPY = cvxPerYear.mul(cvxPrice).div(constants_1.PRICE_DECIMALS);
|
|
222
|
+
var extraAPRs = extraPoolAddresses.map(function (_, index) {
|
|
223
|
+
var extraRewardSymbol = poolParams.extraRewards[index].rewardToken;
|
|
224
|
+
var extraPoolRate = extra[index];
|
|
225
|
+
var perUnderlying = extraPoolRate.mul(constants_1.WAD).div(virtualSupply);
|
|
226
|
+
var perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
227
|
+
var extraPrice = getTokenPrice(tokenList[extraRewardSymbol], currency);
|
|
228
|
+
var extraAPY = perYear.mul(extraPrice).div(constants_1.PRICE_DECIMALS);
|
|
229
|
+
return extraAPY;
|
|
154
230
|
});
|
|
231
|
+
var extraAPYTotal = extraAPRs.reduce(function (acc, apy) { return acc.add(apy); }, ethers_1.BigNumber.from(0));
|
|
232
|
+
var baseApyWAD = curveAPY[underlying];
|
|
233
|
+
return baseApyWAD.add(crvAPY).add(cvxAPY).add(extraAPYTotal);
|
|
155
234
|
}
|
|
@@ -2,7 +2,7 @@ import { BigNumber } from "ethers";
|
|
|
2
2
|
import { SupportedContract } from "../contracts/contracts";
|
|
3
3
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
4
4
|
export interface TxSerialized {
|
|
5
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards";
|
|
5
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens";
|
|
6
6
|
content: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class TxSerializer {
|
|
@@ -127,10 +127,10 @@ export declare class TxClaimNFT extends EVMTx {
|
|
|
127
127
|
toString(): string;
|
|
128
128
|
serialize(): TxSerialized;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
interface TxClaimGearRewardsProps extends EVMTxProps {
|
|
131
131
|
token: string;
|
|
132
132
|
amount: BigNumber;
|
|
133
|
-
}
|
|
133
|
+
}
|
|
134
134
|
export declare class TxClaimGearRewards extends EVMTx {
|
|
135
135
|
token: string;
|
|
136
136
|
amount: BigNumber;
|
|
@@ -165,4 +165,17 @@ export declare class TxApprove extends EVMTx {
|
|
|
165
165
|
toString(): string;
|
|
166
166
|
serialize(): TxSerialized;
|
|
167
167
|
}
|
|
168
|
+
interface TxEnableTokensProps extends EVMTxProps {
|
|
169
|
+
enabledTokens: Array<string>;
|
|
170
|
+
disabledTokens: Array<string>;
|
|
171
|
+
creditManager: string;
|
|
172
|
+
}
|
|
173
|
+
export declare class TxEnableTokens extends EVMTx {
|
|
174
|
+
readonly enabledTokens: Array<string>;
|
|
175
|
+
readonly disabledTokens: Array<string>;
|
|
176
|
+
readonly creditManager: string;
|
|
177
|
+
constructor(opts: TxEnableTokensProps);
|
|
178
|
+
toString(): string;
|
|
179
|
+
serialize(): TxSerialized;
|
|
180
|
+
}
|
|
168
181
|
export {};
|
package/lib/core/transactions.js
CHANGED
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
18
|
+
exports.TxEnableTokens = exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxClaimGearRewards = exports.TxClaimNFT = exports.TxClaimReward = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
19
19
|
var ethers_1 = require("ethers");
|
|
20
20
|
var contracts_1 = require("../contracts/contracts");
|
|
21
21
|
var contractsRegister_1 = require("../contracts/contractsRegister");
|
|
@@ -59,6 +59,8 @@ var TxSerializer = /** @class */ (function () {
|
|
|
59
59
|
return new TxClaimNFT(params);
|
|
60
60
|
case "TxClaimGearRewards":
|
|
61
61
|
return new TxClaimGearRewards(params);
|
|
62
|
+
case "TxEnableTokens":
|
|
63
|
+
return new TxEnableTokens(params);
|
|
62
64
|
default:
|
|
63
65
|
throw new Error("Unknown transaction for parsing: ".concat(e.type));
|
|
64
66
|
}
|
|
@@ -424,3 +426,43 @@ var TxApprove = /** @class */ (function (_super) {
|
|
|
424
426
|
return TxApprove;
|
|
425
427
|
}(eventOrTx_1.EVMTx));
|
|
426
428
|
exports.TxApprove = TxApprove;
|
|
429
|
+
var TxEnableTokens = /** @class */ (function (_super) {
|
|
430
|
+
__extends(TxEnableTokens, _super);
|
|
431
|
+
function TxEnableTokens(opts) {
|
|
432
|
+
var _this = _super.call(this, {
|
|
433
|
+
block: opts.block,
|
|
434
|
+
txHash: opts.txHash,
|
|
435
|
+
txStatus: opts.txStatus,
|
|
436
|
+
timestamp: opts.timestamp,
|
|
437
|
+
}) || this;
|
|
438
|
+
_this.enabledTokens = opts.enabledTokens;
|
|
439
|
+
_this.disabledTokens = opts.disabledTokens;
|
|
440
|
+
_this.creditManager = opts.creditManager;
|
|
441
|
+
return _this;
|
|
442
|
+
}
|
|
443
|
+
TxEnableTokens.prototype.toString = function () {
|
|
444
|
+
var enabledSymbols = this.enabledTokens.map(function (address) {
|
|
445
|
+
var tokenSymbol = (0, token_1.extractTokenData)(address)[0];
|
|
446
|
+
return tokenSymbol;
|
|
447
|
+
});
|
|
448
|
+
var disabledSymbols = this.disabledTokens.map(function (address) {
|
|
449
|
+
var tokenSymbol = (0, token_1.extractTokenData)(address)[0];
|
|
450
|
+
return tokenSymbol;
|
|
451
|
+
});
|
|
452
|
+
var currentSentences = [
|
|
453
|
+
enabledSymbols.length > 0 ? "enabled: ".concat(enabledSymbols.join(", ")) : "",
|
|
454
|
+
disabledSymbols.length > 0
|
|
455
|
+
? "disabled: ".concat(disabledSymbols.join(", "))
|
|
456
|
+
: "",
|
|
457
|
+
].filter(function (s) { return !!s; });
|
|
458
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": ").concat(currentSentences.join("; "));
|
|
459
|
+
};
|
|
460
|
+
TxEnableTokens.prototype.serialize = function () {
|
|
461
|
+
return {
|
|
462
|
+
type: "TxEnableTokens",
|
|
463
|
+
content: JSON.stringify(this),
|
|
464
|
+
};
|
|
465
|
+
};
|
|
466
|
+
return TxEnableTokens;
|
|
467
|
+
}(eventOrTx_1.EVMTx));
|
|
468
|
+
exports.TxEnableTokens = TxEnableTokens;
|