@gearbox-protocol/sdk 1.8.3 → 1.8.4
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/core/trade.d.ts +4 -4
- package/lib/core/trade.js +35 -34
- package/lib/core/transactions.d.ts +19 -10
- package/lib/core/transactions.js +63 -31
- package/lib/tokens/token.d.ts +1 -0
- package/lib/tokens/token.js +7 -1
- package/package.json +1 -1
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { BigNumber, Signer } from "ethers";
|
|
2
2
|
import { AdapterInterface } from "../contracts/adapters";
|
|
3
|
-
import { PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
3
|
+
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
4
|
import { ICreditFacade } from "../types";
|
|
5
5
|
import { BaseAdapter } from "./adapter";
|
|
6
6
|
import { EVMTx } from "./eventOrTx";
|
|
7
|
-
import { TXSwap } from "./transactions";
|
|
8
7
|
interface BaseTradeInterface {
|
|
9
8
|
swapType: SwapOperation;
|
|
10
9
|
sourceAmount: BigNumber;
|
|
@@ -36,11 +35,12 @@ export declare class Trade implements BaseTradeInterface {
|
|
|
36
35
|
getContractAddress(): string;
|
|
37
36
|
getAdapterAddress(): string;
|
|
38
37
|
execute(signer: Signer): Promise<EVMTx>;
|
|
39
|
-
protected _executeOnSigner(call: PathFinderResult["calls"][0], signer: Signer): Promise<TXSwap>;
|
|
40
|
-
protected _executeOnCreditFacade(calls: PathFinderResult["calls"]): Promise<TXSwap>;
|
|
41
38
|
toString(): string;
|
|
42
39
|
getFromAmount(slippage: number): BigNumber;
|
|
43
40
|
getToAmount(slippage: number): BigNumber;
|
|
44
41
|
static getOperationName(tokenInAddress: string, tokenOutAddress: string): TradeOperations;
|
|
42
|
+
static executeMulticallPath(creditFacade: string | ICreditFacade, signer: Signer, calls: Array<MultiCall>): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
|
|
43
|
+
static executeOnSigner(call: MultiCall, signer: Signer): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
|
|
44
|
+
static executeOnCreditFacade(calls: Array<MultiCall>, creditFacade: ICreditFacade): Promise<import("ethers").ContractTransaction>;
|
|
45
45
|
}
|
|
46
46
|
export {};
|
package/lib/core/trade.js
CHANGED
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.Trade = void 0;
|
|
40
40
|
var decimals_1 = require("../tokens/decimals");
|
|
41
41
|
var token_1 = require("../tokens/token");
|
|
42
|
+
var types_1 = require("../types");
|
|
42
43
|
var formatter_1 = require("../utils/formatter");
|
|
43
44
|
var constants_1 = require("./constants");
|
|
44
45
|
var transactions_1 = require("./transactions");
|
|
@@ -74,44 +75,11 @@ var Trade = /** @class */ (function () {
|
|
|
74
75
|
return this.helper.adapterAddress;
|
|
75
76
|
};
|
|
76
77
|
Trade.prototype.execute = function (signer) {
|
|
77
|
-
if (this.tradePath.calls.length < 1)
|
|
78
|
-
throw new Error("No path to execute");
|
|
79
|
-
return this.tradePath.calls.length === 1
|
|
80
|
-
? this._executeOnSigner(this.tradePath.calls[0], signer)
|
|
81
|
-
: this._executeOnCreditFacade(this.tradePath.calls);
|
|
82
|
-
};
|
|
83
|
-
Trade.prototype._executeOnSigner = function (call, signer) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var receipt;
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
switch (_a.label) {
|
|
88
|
-
case 0: return [4 /*yield*/, signer.sendTransaction({
|
|
89
|
-
to: call.target,
|
|
90
|
-
data: call.callData,
|
|
91
|
-
})];
|
|
92
|
-
case 1:
|
|
93
|
-
receipt = _a.sent();
|
|
94
|
-
return [2 /*return*/, new transactions_1.TXSwap({
|
|
95
|
-
txHash: receipt.hash,
|
|
96
|
-
protocol: this.helper.contractAddress,
|
|
97
|
-
operation: OPERATION_NAMES[this.operationName],
|
|
98
|
-
amountFrom: this.sourceAmount,
|
|
99
|
-
amountTo: this.expectedAmount,
|
|
100
|
-
tokenFrom: this.tokenFrom,
|
|
101
|
-
tokenTo: this.tokenTo,
|
|
102
|
-
creditManager: this.helper.creditManager,
|
|
103
|
-
timestamp: 0,
|
|
104
|
-
})];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
Trade.prototype._executeOnCreditFacade = function (calls) {
|
|
110
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
111
79
|
var receipt;
|
|
112
80
|
return __generator(this, function (_a) {
|
|
113
81
|
switch (_a.label) {
|
|
114
|
-
case 0: return [4 /*yield*/, this.creditFacade.
|
|
82
|
+
case 0: return [4 /*yield*/, Trade.executeMulticallPath(this.creditFacade, signer, this.tradePath.calls)];
|
|
115
83
|
case 1:
|
|
116
84
|
receipt = _a.sent();
|
|
117
85
|
return [2 /*return*/, new transactions_1.TXSwap({
|
|
@@ -167,6 +135,39 @@ var Trade = /** @class */ (function () {
|
|
|
167
135
|
return "swap";
|
|
168
136
|
return "unknownOperation";
|
|
169
137
|
};
|
|
138
|
+
Trade.executeMulticallPath = function (creditFacade, signer, calls) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
+
var safeCreditFacade;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
if (calls.length < 1)
|
|
143
|
+
throw new Error("No path to execute");
|
|
144
|
+
if (calls.length === 1) {
|
|
145
|
+
return [2 /*return*/, this.executeOnSigner(calls[0], signer)];
|
|
146
|
+
}
|
|
147
|
+
safeCreditFacade = typeof creditFacade === "string"
|
|
148
|
+
? types_1.ICreditFacade__factory.connect(creditFacade, signer)
|
|
149
|
+
: creditFacade;
|
|
150
|
+
return [2 /*return*/, this.executeOnCreditFacade(calls, safeCreditFacade)];
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
Trade.executeOnSigner = function (call, signer) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
return [2 /*return*/, signer.sendTransaction({
|
|
158
|
+
to: call.target,
|
|
159
|
+
data: call.callData,
|
|
160
|
+
})];
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
Trade.executeOnCreditFacade = function (calls, creditFacade) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
return [2 /*return*/, creditFacade.multicall(calls)];
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
170
171
|
return Trade;
|
|
171
172
|
}());
|
|
172
173
|
exports.Trade = Trade;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BigNumber } from "ethers";
|
|
2
|
-
import {
|
|
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";
|
|
5
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward";
|
|
6
6
|
content: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class TxSerializer {
|
|
@@ -19,7 +19,7 @@ export declare class TxAddLiquidity extends EVMTx {
|
|
|
19
19
|
readonly underlyingToken: string;
|
|
20
20
|
readonly pool: string;
|
|
21
21
|
constructor(opts: AddLiquidityProps);
|
|
22
|
-
toString(
|
|
22
|
+
toString(): string;
|
|
23
23
|
serialize(): TxSerialized;
|
|
24
24
|
}
|
|
25
25
|
interface RemoveLiquidityProps extends EVMTxProps {
|
|
@@ -32,7 +32,7 @@ export declare class TxRemoveLiquidity extends EVMTx {
|
|
|
32
32
|
readonly dieselToken: string;
|
|
33
33
|
readonly pool: string;
|
|
34
34
|
constructor(opts: RemoveLiquidityProps);
|
|
35
|
-
toString(
|
|
35
|
+
toString(): string;
|
|
36
36
|
serialize(): TxSerialized;
|
|
37
37
|
}
|
|
38
38
|
interface SwapProps extends EVMTxProps {
|
|
@@ -53,7 +53,7 @@ export declare class TXSwap extends EVMTx {
|
|
|
53
53
|
readonly tokenTo?: string;
|
|
54
54
|
readonly creditManager: string;
|
|
55
55
|
constructor(opts: SwapProps);
|
|
56
|
-
toString(
|
|
56
|
+
toString(): string;
|
|
57
57
|
serialize(): TxSerialized;
|
|
58
58
|
}
|
|
59
59
|
interface AddCollateralProps extends EVMTxProps {
|
|
@@ -66,7 +66,7 @@ export declare class TxAddCollateral extends EVMTx {
|
|
|
66
66
|
readonly addedToken: string;
|
|
67
67
|
readonly creditManager: string;
|
|
68
68
|
constructor(opts: AddCollateralProps);
|
|
69
|
-
toString(
|
|
69
|
+
toString(): string;
|
|
70
70
|
serialize(): TxSerialized;
|
|
71
71
|
}
|
|
72
72
|
interface IncreaseBorrowAmountProps extends EVMTxProps {
|
|
@@ -79,7 +79,7 @@ export declare class TxIncreaseBorrowAmount extends EVMTx {
|
|
|
79
79
|
readonly underlyingToken: string;
|
|
80
80
|
readonly creditManager: string;
|
|
81
81
|
constructor(opts: IncreaseBorrowAmountProps);
|
|
82
|
-
toString(
|
|
82
|
+
toString(): string;
|
|
83
83
|
serialize(): TxSerialized;
|
|
84
84
|
}
|
|
85
85
|
interface OpenAccountProps extends EVMTxProps {
|
|
@@ -94,7 +94,7 @@ export declare class TxOpenAccount extends EVMTx {
|
|
|
94
94
|
readonly leverage: number;
|
|
95
95
|
readonly creditManager: string;
|
|
96
96
|
constructor(opts: OpenAccountProps);
|
|
97
|
-
toString(
|
|
97
|
+
toString(): string;
|
|
98
98
|
serialize(): TxSerialized;
|
|
99
99
|
}
|
|
100
100
|
interface TxOpenMultitokenAccountProps extends EVMTxProps {
|
|
@@ -109,7 +109,16 @@ export declare class TxOpenMultitokenAccount extends EVMTx {
|
|
|
109
109
|
readonly underlyingToken: string;
|
|
110
110
|
readonly assets: Array<string>;
|
|
111
111
|
constructor(opts: TxOpenMultitokenAccountProps);
|
|
112
|
-
toString(
|
|
112
|
+
toString(): string;
|
|
113
|
+
serialize(): TxSerialized;
|
|
114
|
+
}
|
|
115
|
+
interface TxClaimRewardProps extends EVMTxProps {
|
|
116
|
+
contracts: Array<SupportedContract>;
|
|
117
|
+
}
|
|
118
|
+
export declare class TxClaimReward extends EVMTx {
|
|
119
|
+
readonly contracts: Array<SupportedContract>;
|
|
120
|
+
constructor(opts: TxClaimRewardProps);
|
|
121
|
+
toString(): string;
|
|
113
122
|
serialize(): TxSerialized;
|
|
114
123
|
}
|
|
115
124
|
interface RepayAccountProps extends EVMTxProps {
|
|
@@ -136,7 +145,7 @@ interface ApproveProps extends EVMTxProps {
|
|
|
136
145
|
export declare class TxApprove extends EVMTx {
|
|
137
146
|
readonly token: string;
|
|
138
147
|
constructor(opts: ApproveProps);
|
|
139
|
-
toString(
|
|
148
|
+
toString(): string;
|
|
140
149
|
serialize(): TxSerialized;
|
|
141
150
|
}
|
|
142
151
|
export {};
|
package/lib/core/transactions.js
CHANGED
|
@@ -15,9 +15,11 @@ 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.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
18
|
+
exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = 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
|
+
var contracts_1 = require("../contracts/contracts");
|
|
20
21
|
var contractsRegister_1 = require("../contracts/contractsRegister");
|
|
22
|
+
var token_1 = require("../tokens/token");
|
|
21
23
|
var formatter_1 = require("../utils/formatter");
|
|
22
24
|
var constants_1 = require("./constants");
|
|
23
25
|
var eventOrTx_1 = require("./eventOrTx");
|
|
@@ -51,6 +53,8 @@ var TxSerializer = /** @class */ (function () {
|
|
|
51
53
|
return new TxApprove(params);
|
|
52
54
|
case "TxOpenMultitokenAccount":
|
|
53
55
|
return new TxOpenMultitokenAccount(params);
|
|
56
|
+
case "TxClaimReward":
|
|
57
|
+
return new TxClaimReward(params);
|
|
54
58
|
default:
|
|
55
59
|
throw new Error("Unknown transaction for parsing");
|
|
56
60
|
}
|
|
@@ -73,9 +77,9 @@ var TxAddLiquidity = /** @class */ (function (_super) {
|
|
|
73
77
|
_this.pool = opts.pool;
|
|
74
78
|
return _this;
|
|
75
79
|
}
|
|
76
|
-
TxAddLiquidity.prototype.toString = function (
|
|
77
|
-
var
|
|
78
|
-
return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Deposit ").concat((0, formatter_1.formatBN)(this.amount,
|
|
80
|
+
TxAddLiquidity.prototype.toString = function () {
|
|
81
|
+
var _a = (0, token_1.extractTokenData)(this.underlyingToken), underlyingSymbol = _a[0], underlyingDecimals = _a[1];
|
|
82
|
+
return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Deposit ").concat((0, formatter_1.formatBN)(this.amount, underlyingDecimals || 18), " ").concat(underlyingSymbol);
|
|
79
83
|
};
|
|
80
84
|
TxAddLiquidity.prototype.serialize = function () {
|
|
81
85
|
return {
|
|
@@ -100,9 +104,9 @@ var TxRemoveLiquidity = /** @class */ (function (_super) {
|
|
|
100
104
|
_this.pool = opts.pool;
|
|
101
105
|
return _this;
|
|
102
106
|
}
|
|
103
|
-
TxRemoveLiquidity.prototype.toString = function (
|
|
104
|
-
var
|
|
105
|
-
return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Withdraw ").concat((0, formatter_1.formatBN)(this.amount,
|
|
107
|
+
TxRemoveLiquidity.prototype.toString = function () {
|
|
108
|
+
var _a = (0, token_1.extractTokenData)(this.dieselToken), dSymbol = _a[0], dDecimals = _a[1];
|
|
109
|
+
return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Withdraw ").concat((0, formatter_1.formatBN)(this.amount, dDecimals || 18), " ").concat(dSymbol);
|
|
106
110
|
};
|
|
107
111
|
TxRemoveLiquidity.prototype.serialize = function () {
|
|
108
112
|
return {
|
|
@@ -131,14 +135,14 @@ var TXSwap = /** @class */ (function (_super) {
|
|
|
131
135
|
_this.creditManager = opts.creditManager;
|
|
132
136
|
return _this;
|
|
133
137
|
}
|
|
134
|
-
TXSwap.prototype.toString = function (
|
|
135
|
-
var tokenFrom = tokenData[this.tokenFrom.toLowerCase()];
|
|
138
|
+
TXSwap.prototype.toString = function () {
|
|
136
139
|
var toPart = "";
|
|
137
140
|
if (this.tokenTo && this.amountTo) {
|
|
138
|
-
var
|
|
139
|
-
toPart = " \u21D2 ".concat((0, formatter_1.formatBN)(this.amountTo,
|
|
141
|
+
var _a = (0, token_1.extractTokenData)(this.tokenTo), toSymbol = _a[0], toDecimals = _a[1];
|
|
142
|
+
toPart = " \u21D2 ".concat((0, formatter_1.formatBN)(this.amountTo, toDecimals || 18), " ").concat(toSymbol);
|
|
140
143
|
}
|
|
141
|
-
|
|
144
|
+
var _b = (0, token_1.extractTokenData)(this.tokenFrom), fromSymbol = _b[0], fromDecimals = _b[1];
|
|
145
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": ").concat(this.operation, " ").concat((0, formatter_1.formatBN)(this.amountFrom, fromDecimals || 18), " ").concat(fromSymbol, " ").concat(toPart, " on ").concat((0, contractsRegister_1.getContractName)(this.protocol));
|
|
142
146
|
};
|
|
143
147
|
TXSwap.prototype.serialize = function () {
|
|
144
148
|
return {
|
|
@@ -163,9 +167,9 @@ var TxAddCollateral = /** @class */ (function (_super) {
|
|
|
163
167
|
_this.creditManager = opts.creditManager;
|
|
164
168
|
return _this;
|
|
165
169
|
}
|
|
166
|
-
TxAddCollateral.prototype.toString = function (
|
|
167
|
-
var
|
|
168
|
-
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Added ").concat((0, formatter_1.formatBN)(this.amount,
|
|
170
|
+
TxAddCollateral.prototype.toString = function () {
|
|
171
|
+
var _a = (0, token_1.extractTokenData)(this.addedToken), addedSymbol = _a[0], addedDecimals = _a[1];
|
|
172
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Added ").concat((0, formatter_1.formatBN)(this.amount, addedDecimals || 18), " ").concat(addedSymbol, " as collateral");
|
|
169
173
|
};
|
|
170
174
|
TxAddCollateral.prototype.serialize = function () {
|
|
171
175
|
return {
|
|
@@ -190,9 +194,9 @@ var TxIncreaseBorrowAmount = /** @class */ (function (_super) {
|
|
|
190
194
|
_this.creditManager = opts.creditManager;
|
|
191
195
|
return _this;
|
|
192
196
|
}
|
|
193
|
-
TxIncreaseBorrowAmount.prototype.toString = function (
|
|
194
|
-
var
|
|
195
|
-
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Borrowed amount was increased for ").concat((0, formatter_1.formatBN)(this.amount,
|
|
197
|
+
TxIncreaseBorrowAmount.prototype.toString = function () {
|
|
198
|
+
var _a = (0, token_1.extractTokenData)(this.underlyingToken), tokenSymbol = _a[0], tokenDecimals = _a[1];
|
|
199
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Borrowed amount was increased for ").concat((0, formatter_1.formatBN)(this.amount, tokenDecimals || 18), " ").concat(tokenSymbol);
|
|
196
200
|
};
|
|
197
201
|
TxIncreaseBorrowAmount.prototype.serialize = function () {
|
|
198
202
|
return {
|
|
@@ -218,11 +222,11 @@ var TxOpenAccount = /** @class */ (function (_super) {
|
|
|
218
222
|
_this.creditManager = opts.creditManager;
|
|
219
223
|
return _this;
|
|
220
224
|
}
|
|
221
|
-
TxOpenAccount.prototype.toString = function (
|
|
222
|
-
var
|
|
223
|
-
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening ").concat((0, formatter_1.formatBN)(this.amount,
|
|
225
|
+
TxOpenAccount.prototype.toString = function () {
|
|
226
|
+
var _a = (0, token_1.extractTokenData)(this.underlyingToken), tokenSymbol = _a[0], tokenDecimals = _a[1];
|
|
227
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening ").concat((0, formatter_1.formatBN)(this.amount, tokenDecimals || 18), " ").concat(tokenSymbol, " x ").concat(this.leverage.toFixed(2), " \u21D2 \n ").concat((0, formatter_1.formatBN)(this.amount
|
|
224
228
|
.mul(Math.floor(this.leverage * constants_1.LEVERAGE_DECIMALS))
|
|
225
|
-
.div(constants_1.LEVERAGE_DECIMALS),
|
|
229
|
+
.div(constants_1.LEVERAGE_DECIMALS), tokenDecimals || 18), " ").concat(tokenSymbol);
|
|
226
230
|
};
|
|
227
231
|
TxOpenAccount.prototype.serialize = function () {
|
|
228
232
|
return {
|
|
@@ -248,15 +252,15 @@ var TxOpenMultitokenAccount = /** @class */ (function (_super) {
|
|
|
248
252
|
_this.assets = opts.assets;
|
|
249
253
|
return _this;
|
|
250
254
|
}
|
|
251
|
-
TxOpenMultitokenAccount.prototype.toString = function (
|
|
252
|
-
var underlyingToken = tokenData[this.underlyingToken.toLowerCase()];
|
|
255
|
+
TxOpenMultitokenAccount.prototype.toString = function () {
|
|
253
256
|
var assetSymbols = this.assets.reduce(function (acc, assetAddress) {
|
|
254
|
-
var
|
|
255
|
-
if (
|
|
256
|
-
acc.push(
|
|
257
|
+
var tokenSymbol = (0, token_1.extractTokenData)(assetAddress)[0];
|
|
258
|
+
if (tokenSymbol)
|
|
259
|
+
acc.push(tokenSymbol);
|
|
257
260
|
return acc;
|
|
258
261
|
}, []);
|
|
259
|
-
|
|
262
|
+
var _a = (0, token_1.extractTokenData)(this.underlyingToken), symbol = _a[0], underlyingDecimals = _a[1];
|
|
263
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening. Borrowed amount: ").concat((0, formatter_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18), " ").concat(symbol, "; assets: ").concat(assetSymbols.join(", "));
|
|
260
264
|
};
|
|
261
265
|
TxOpenMultitokenAccount.prototype.serialize = function () {
|
|
262
266
|
return {
|
|
@@ -267,6 +271,34 @@ var TxOpenMultitokenAccount = /** @class */ (function (_super) {
|
|
|
267
271
|
return TxOpenMultitokenAccount;
|
|
268
272
|
}(eventOrTx_1.EVMTx));
|
|
269
273
|
exports.TxOpenMultitokenAccount = TxOpenMultitokenAccount;
|
|
274
|
+
var TxClaimReward = /** @class */ (function (_super) {
|
|
275
|
+
__extends(TxClaimReward, _super);
|
|
276
|
+
function TxClaimReward(opts) {
|
|
277
|
+
var _this = _super.call(this, {
|
|
278
|
+
block: opts.block,
|
|
279
|
+
txHash: opts.txHash,
|
|
280
|
+
txStatus: opts.txStatus,
|
|
281
|
+
timestamp: opts.timestamp,
|
|
282
|
+
}) || this;
|
|
283
|
+
_this.contracts = opts.contracts;
|
|
284
|
+
return _this;
|
|
285
|
+
}
|
|
286
|
+
TxClaimReward.prototype.toString = function () {
|
|
287
|
+
var contractNames = this.contracts.map(function (contract) {
|
|
288
|
+
var contractInfo = contracts_1.contractParams[contract];
|
|
289
|
+
return contractInfo.name;
|
|
290
|
+
});
|
|
291
|
+
return "Pools reward claimed: ".concat(contractNames.join(", "));
|
|
292
|
+
};
|
|
293
|
+
TxClaimReward.prototype.serialize = function () {
|
|
294
|
+
return {
|
|
295
|
+
type: "TxClaimReward",
|
|
296
|
+
content: JSON.stringify(this),
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
return TxClaimReward;
|
|
300
|
+
}(eventOrTx_1.EVMTx));
|
|
301
|
+
exports.TxClaimReward = TxClaimReward;
|
|
270
302
|
var TxRepayAccount = /** @class */ (function (_super) {
|
|
271
303
|
__extends(TxRepayAccount, _super);
|
|
272
304
|
function TxRepayAccount(opts) {
|
|
@@ -327,9 +359,9 @@ var TxApprove = /** @class */ (function (_super) {
|
|
|
327
359
|
_this.token = opts.token;
|
|
328
360
|
return _this;
|
|
329
361
|
}
|
|
330
|
-
TxApprove.prototype.toString = function (
|
|
331
|
-
var
|
|
332
|
-
return "Approve ".concat(
|
|
362
|
+
TxApprove.prototype.toString = function () {
|
|
363
|
+
var symbol = (0, token_1.extractTokenData)(this.token)[0];
|
|
364
|
+
return "Approve ".concat(symbol);
|
|
333
365
|
};
|
|
334
366
|
TxApprove.prototype.serialize = function () {
|
|
335
367
|
return {
|
package/lib/tokens/token.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export declare const tokenSymbolByAddress: Record<string, SupportedToken>;
|
|
|
19
19
|
export declare const isSupportedToken: (t: unknown) => t is SupportedToken;
|
|
20
20
|
export declare const isLPToken: (t: unknown) => t is LPTokens;
|
|
21
21
|
export declare function getDecimals(token: SupportedToken | string): number;
|
|
22
|
+
export declare function extractTokenData(tokenAddress: string): [SupportedToken | undefined, number | undefined];
|
package/lib/tokens/token.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getDecimals = exports.isLPToken = exports.isSupportedToken = exports.tokenSymbolByAddress = exports.tokenDataByNetwork = exports.supportedTokens = exports.lpTokens = void 0;
|
|
14
|
+
exports.extractTokenData = exports.getDecimals = exports.isLPToken = exports.isSupportedToken = exports.tokenSymbolByAddress = exports.tokenDataByNetwork = exports.supportedTokens = exports.lpTokens = void 0;
|
|
15
15
|
var mappers_1 = require("../utils/mappers");
|
|
16
16
|
var convex_1 = require("./convex");
|
|
17
17
|
var curveLP_1 = require("./curveLP");
|
|
@@ -177,3 +177,9 @@ function getDecimals(token) {
|
|
|
177
177
|
return dec;
|
|
178
178
|
}
|
|
179
179
|
exports.getDecimals = getDecimals;
|
|
180
|
+
function extractTokenData(tokenAddress) {
|
|
181
|
+
var underlyingSymbol = exports.tokenSymbolByAddress[tokenAddress.toLowerCase()];
|
|
182
|
+
var underlyingDecimals = decimals_1.decimals[underlyingSymbol || ""];
|
|
183
|
+
return [underlyingSymbol, underlyingDecimals];
|
|
184
|
+
}
|
|
185
|
+
exports.extractTokenData = extractTokenData;
|