@gearbox-protocol/sdk 3.0.0-next.90 → 3.0.0-next.91
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 +2 -1
- package/lib/core/trade.js +4 -2
- package/lib/core/transactions.d.ts +47 -13
- package/lib/core/transactions.js +39 -13
- package/package.json +1 -1
package/lib/core/trade.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface Info {
|
|
|
5
5
|
name: string;
|
|
6
6
|
contractAddress: string;
|
|
7
7
|
creditManager: string;
|
|
8
|
+
creditManagerName: string;
|
|
8
9
|
}
|
|
9
10
|
export type TradeOperations = "farmWithdraw" | "farmDeposit" | "swap";
|
|
10
11
|
export interface GetTradesProps {
|
|
@@ -32,7 +33,7 @@ export declare class Trade {
|
|
|
32
33
|
getName(): string;
|
|
33
34
|
toString(): string;
|
|
34
35
|
static getTrades({ tokenIn, tokenOut, amount, results, creditManager, currentContracts, swapOperation, swapName, }: GetTradesProps): Trade[];
|
|
35
|
-
static getCallInfo(calls: Array<MultiCall>, creditManager: string, currentContracts: Record<SupportedContract, string
|
|
36
|
+
static getCallInfo(calls: Array<MultiCall>, creditManager: string, currentContracts: Record<SupportedContract, string>, creditManagerName: string): Info[];
|
|
36
37
|
private static getContractSymbol;
|
|
37
38
|
static sortTrades(trades: Array<Trade>, swapStrategy: string): Trade[];
|
|
38
39
|
}
|
package/lib/core/trade.js
CHANGED
|
@@ -44,13 +44,14 @@ class Trade {
|
|
|
44
44
|
static getTrades({ tokenIn, tokenOut, amount, results, creditManager, currentContracts, swapOperation, swapName, }) {
|
|
45
45
|
const trades = results.reduce((acc, tradePath) => {
|
|
46
46
|
const { calls } = tradePath;
|
|
47
|
-
const callInfo = Trade.getCallInfo(calls, creditManager.address, currentContracts);
|
|
47
|
+
const callInfo = Trade.getCallInfo(calls, creditManager.address, currentContracts, creditManager.name);
|
|
48
48
|
const trade = new Trade({
|
|
49
49
|
tradePath,
|
|
50
50
|
adapter: callInfo[0] || {
|
|
51
51
|
name: "unknown",
|
|
52
52
|
contractAddress: calls[0]?.target || "",
|
|
53
53
|
creditManager: creditManager.address,
|
|
54
|
+
creditManagerName: creditManager.name,
|
|
54
55
|
},
|
|
55
56
|
swapOperation,
|
|
56
57
|
sourceAmount: amount,
|
|
@@ -65,7 +66,7 @@ class Trade {
|
|
|
65
66
|
}, []);
|
|
66
67
|
return trades;
|
|
67
68
|
}
|
|
68
|
-
static getCallInfo(calls, creditManager, currentContracts) {
|
|
69
|
+
static getCallInfo(calls, creditManager, currentContracts, creditManagerName) {
|
|
69
70
|
const callAdapters = calls.reduce((acc, call) => {
|
|
70
71
|
const contractSymbol = this.getContractSymbol(call.target.toLowerCase());
|
|
71
72
|
if (!(0, sdk_gov_1.isSupportedContract)(contractSymbol)) {
|
|
@@ -77,6 +78,7 @@ class Trade {
|
|
|
77
78
|
name,
|
|
78
79
|
contractAddress,
|
|
79
80
|
creditManager,
|
|
81
|
+
creditManagerName,
|
|
80
82
|
});
|
|
81
83
|
return acc;
|
|
82
84
|
}, []);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
2
2
|
import { Asset } from "./assets";
|
|
3
3
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
4
|
+
interface CMEvent {
|
|
5
|
+
readonly creditManager: string;
|
|
6
|
+
readonly creditManagerName?: string;
|
|
7
|
+
}
|
|
8
|
+
interface PoolEvent {
|
|
9
|
+
readonly pool: string;
|
|
10
|
+
readonly poolName?: string;
|
|
11
|
+
}
|
|
4
12
|
export interface TxSerialized {
|
|
5
13
|
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral";
|
|
6
14
|
content: string;
|
|
@@ -13,11 +21,13 @@ interface AddLiquidityProps extends EVMTxProps {
|
|
|
13
21
|
amount: bigint;
|
|
14
22
|
underlyingToken: string;
|
|
15
23
|
pool: string;
|
|
24
|
+
poolName?: string;
|
|
16
25
|
}
|
|
17
|
-
export declare class TxAddLiquidity extends EVMTx {
|
|
26
|
+
export declare class TxAddLiquidity extends EVMTx implements PoolEvent {
|
|
18
27
|
readonly amount: bigint;
|
|
19
28
|
readonly underlyingToken: string;
|
|
20
29
|
readonly pool: string;
|
|
30
|
+
readonly poolName?: string;
|
|
21
31
|
constructor(opts: AddLiquidityProps);
|
|
22
32
|
toString(): string;
|
|
23
33
|
serialize(): TxSerialized;
|
|
@@ -26,11 +36,13 @@ interface RemoveLiquidityProps extends EVMTxProps {
|
|
|
26
36
|
amount: bigint;
|
|
27
37
|
dieselToken: string;
|
|
28
38
|
pool: string;
|
|
39
|
+
poolName?: string;
|
|
29
40
|
}
|
|
30
|
-
export declare class TxRemoveLiquidity extends EVMTx {
|
|
41
|
+
export declare class TxRemoveLiquidity extends EVMTx implements PoolEvent {
|
|
31
42
|
readonly amount: bigint;
|
|
32
43
|
readonly dieselToken: string;
|
|
33
44
|
readonly pool: string;
|
|
45
|
+
readonly poolName?: string;
|
|
34
46
|
constructor(opts: RemoveLiquidityProps);
|
|
35
47
|
toString(): string;
|
|
36
48
|
serialize(): TxSerialized;
|
|
@@ -43,8 +55,9 @@ interface SwapProps extends EVMTxProps {
|
|
|
43
55
|
tokenFrom: string;
|
|
44
56
|
tokenTo?: string;
|
|
45
57
|
creditManager: string;
|
|
58
|
+
creditManagerName?: string;
|
|
46
59
|
}
|
|
47
|
-
export declare class TXSwap extends EVMTx {
|
|
60
|
+
export declare class TXSwap extends EVMTx implements CMEvent {
|
|
48
61
|
readonly protocol: string;
|
|
49
62
|
readonly operation: string;
|
|
50
63
|
readonly amountFrom: bigint;
|
|
@@ -52,6 +65,7 @@ export declare class TXSwap extends EVMTx {
|
|
|
52
65
|
readonly tokenFrom: string;
|
|
53
66
|
readonly tokenTo?: string;
|
|
54
67
|
readonly creditManager: string;
|
|
68
|
+
readonly creditManagerName?: string;
|
|
55
69
|
constructor(opts: SwapProps);
|
|
56
70
|
toString(): string;
|
|
57
71
|
serialize(): TxSerialized;
|
|
@@ -60,11 +74,13 @@ interface AddCollateralProps extends EVMTxProps {
|
|
|
60
74
|
amount: bigint;
|
|
61
75
|
addedToken: string;
|
|
62
76
|
creditManager: string;
|
|
77
|
+
creditManagerName?: string;
|
|
63
78
|
}
|
|
64
|
-
export declare class TxAddCollateral extends EVMTx {
|
|
79
|
+
export declare class TxAddCollateral extends EVMTx implements CMEvent {
|
|
65
80
|
readonly amount: bigint;
|
|
66
81
|
readonly addedToken: string;
|
|
67
82
|
readonly creditManager: string;
|
|
83
|
+
readonly creditManagerName?: string;
|
|
68
84
|
constructor(opts: AddCollateralProps);
|
|
69
85
|
toString(): string;
|
|
70
86
|
serialize(): TxSerialized;
|
|
@@ -73,11 +89,13 @@ interface IncreaseBorrowAmountProps extends EVMTxProps {
|
|
|
73
89
|
amount: bigint;
|
|
74
90
|
underlyingToken: string;
|
|
75
91
|
creditManager: string;
|
|
92
|
+
creditManagerName?: string;
|
|
76
93
|
}
|
|
77
|
-
export declare class TxIncreaseBorrowAmount extends EVMTx {
|
|
94
|
+
export declare class TxIncreaseBorrowAmount extends EVMTx implements CMEvent {
|
|
78
95
|
readonly amount: bigint;
|
|
79
96
|
readonly underlyingToken: string;
|
|
80
97
|
readonly creditManager: string;
|
|
98
|
+
readonly creditManagerName?: string;
|
|
81
99
|
constructor(opts: IncreaseBorrowAmountProps);
|
|
82
100
|
toString(): string;
|
|
83
101
|
serialize(): TxSerialized;
|
|
@@ -86,11 +104,13 @@ interface DecreaseBorrowAmountProps extends EVMTxProps {
|
|
|
86
104
|
amount: bigint;
|
|
87
105
|
underlyingToken: string;
|
|
88
106
|
creditManager: string;
|
|
107
|
+
creditManagerName?: string;
|
|
89
108
|
}
|
|
90
|
-
export declare class TxDecreaseBorrowAmount extends EVMTx {
|
|
109
|
+
export declare class TxDecreaseBorrowAmount extends EVMTx implements CMEvent {
|
|
91
110
|
readonly amount: bigint;
|
|
92
111
|
readonly underlyingToken: string;
|
|
93
112
|
readonly creditManager: string;
|
|
113
|
+
readonly creditManagerName?: string;
|
|
94
114
|
constructor(opts: DecreaseBorrowAmountProps);
|
|
95
115
|
toString(): string;
|
|
96
116
|
serialize(): TxSerialized;
|
|
@@ -100,12 +120,14 @@ interface OpenAccountProps extends EVMTxProps {
|
|
|
100
120
|
underlyingToken: string;
|
|
101
121
|
leverage: number;
|
|
102
122
|
creditManager: string;
|
|
123
|
+
creditManagerName?: string;
|
|
103
124
|
}
|
|
104
|
-
export declare class TxOpenAccount extends EVMTx {
|
|
125
|
+
export declare class TxOpenAccount extends EVMTx implements CMEvent {
|
|
105
126
|
readonly amount: bigint;
|
|
106
127
|
readonly underlyingToken: string;
|
|
107
128
|
readonly leverage: number;
|
|
108
129
|
readonly creditManager: string;
|
|
130
|
+
readonly creditManagerName?: string;
|
|
109
131
|
constructor(opts: OpenAccountProps);
|
|
110
132
|
toString(): string;
|
|
111
133
|
serialize(): TxSerialized;
|
|
@@ -113,12 +135,14 @@ export declare class TxOpenAccount extends EVMTx {
|
|
|
113
135
|
interface TxOpenMultitokenAccountProps extends EVMTxProps {
|
|
114
136
|
borrowedAmount: bigint;
|
|
115
137
|
creditManager: string;
|
|
138
|
+
creditManagerName?: string;
|
|
116
139
|
underlyingToken: string;
|
|
117
140
|
assets: Array<string>;
|
|
118
141
|
}
|
|
119
|
-
export declare class TxOpenMultitokenAccount extends EVMTx {
|
|
142
|
+
export declare class TxOpenMultitokenAccount extends EVMTx implements CMEvent {
|
|
120
143
|
readonly borrowedAmount: bigint;
|
|
121
144
|
readonly creditManager: string;
|
|
145
|
+
readonly creditManagerName?: string;
|
|
122
146
|
readonly underlyingToken: string;
|
|
123
147
|
readonly assets: Array<string>;
|
|
124
148
|
constructor(opts: TxOpenMultitokenAccountProps);
|
|
@@ -151,18 +175,22 @@ export declare class TxClaimGearRewards extends EVMTx {
|
|
|
151
175
|
}
|
|
152
176
|
interface RepayAccountProps extends EVMTxProps {
|
|
153
177
|
creditManager: string;
|
|
178
|
+
creditManagerName?: string;
|
|
154
179
|
}
|
|
155
|
-
export declare class TxRepayAccount extends EVMTx {
|
|
180
|
+
export declare class TxRepayAccount extends EVMTx implements CMEvent {
|
|
156
181
|
readonly creditManager: string;
|
|
182
|
+
readonly creditManagerName?: string;
|
|
157
183
|
constructor(opts: RepayAccountProps);
|
|
158
184
|
toString(): string;
|
|
159
185
|
serialize(): TxSerialized;
|
|
160
186
|
}
|
|
161
187
|
interface CloseAccountProps extends EVMTxProps {
|
|
162
188
|
creditManager: string;
|
|
189
|
+
creditManagerName?: string;
|
|
163
190
|
}
|
|
164
|
-
export declare class TxCloseAccount extends EVMTx {
|
|
191
|
+
export declare class TxCloseAccount extends EVMTx implements CMEvent {
|
|
165
192
|
readonly creditManager: string;
|
|
193
|
+
readonly creditManagerName?: string;
|
|
166
194
|
constructor(opts: CloseAccountProps);
|
|
167
195
|
toString(): string;
|
|
168
196
|
serialize(): TxSerialized;
|
|
@@ -180,11 +208,13 @@ interface TxEnableTokensProps extends EVMTxProps {
|
|
|
180
208
|
enabledTokens: Array<string>;
|
|
181
209
|
disabledTokens: Array<string>;
|
|
182
210
|
creditManager: string;
|
|
211
|
+
creditManagerName?: string;
|
|
183
212
|
}
|
|
184
|
-
export declare class TxEnableTokens extends EVMTx {
|
|
213
|
+
export declare class TxEnableTokens extends EVMTx implements CMEvent {
|
|
185
214
|
readonly enabledTokens: Array<string>;
|
|
186
215
|
readonly disabledTokens: Array<string>;
|
|
187
216
|
readonly creditManager: string;
|
|
217
|
+
readonly creditManagerName?: string;
|
|
188
218
|
constructor(opts: TxEnableTokensProps);
|
|
189
219
|
toString(): string;
|
|
190
220
|
serialize(): TxSerialized;
|
|
@@ -193,11 +223,13 @@ interface TxUpdateQuotaProps extends EVMTxProps {
|
|
|
193
223
|
updatedQuotas: Array<Asset>;
|
|
194
224
|
underlyingToken: string;
|
|
195
225
|
creditManager: string;
|
|
226
|
+
creditManagerName?: string;
|
|
196
227
|
}
|
|
197
|
-
export declare class TxUpdateQuota extends EVMTx {
|
|
228
|
+
export declare class TxUpdateQuota extends EVMTx implements CMEvent {
|
|
198
229
|
readonly updatedQuotas: Array<Asset>;
|
|
199
230
|
readonly underlyingToken: string;
|
|
200
231
|
readonly creditManager: string;
|
|
232
|
+
readonly creditManagerName?: string;
|
|
201
233
|
constructor(opts: TxUpdateQuotaProps);
|
|
202
234
|
toString(): string;
|
|
203
235
|
serialize(): TxSerialized;
|
|
@@ -242,12 +274,14 @@ interface WithdrawCollateralProps extends EVMTxProps {
|
|
|
242
274
|
token: string;
|
|
243
275
|
to: string;
|
|
244
276
|
creditManager: string;
|
|
277
|
+
creditManagerName?: string;
|
|
245
278
|
}
|
|
246
|
-
export declare class TxWithdrawCollateral extends EVMTx {
|
|
279
|
+
export declare class TxWithdrawCollateral extends EVMTx implements CMEvent {
|
|
247
280
|
readonly amount: bigint;
|
|
248
281
|
readonly token: string;
|
|
249
282
|
readonly to: string;
|
|
250
283
|
readonly creditManager: string;
|
|
284
|
+
readonly creditManagerName?: string;
|
|
251
285
|
constructor(opts: WithdrawCollateralProps);
|
|
252
286
|
toString(): string;
|
|
253
287
|
serialize(): TxSerialized;
|
package/lib/core/transactions.js
CHANGED
|
@@ -66,15 +66,17 @@ class TxAddLiquidity extends eventOrTx_1.EVMTx {
|
|
|
66
66
|
amount;
|
|
67
67
|
underlyingToken;
|
|
68
68
|
pool;
|
|
69
|
+
poolName;
|
|
69
70
|
constructor(opts) {
|
|
70
71
|
super(opts);
|
|
71
72
|
this.amount = opts.amount;
|
|
72
73
|
this.underlyingToken = opts.underlyingToken;
|
|
73
74
|
this.pool = opts.pool;
|
|
75
|
+
this.poolName = opts.poolName;
|
|
74
76
|
}
|
|
75
77
|
toString() {
|
|
76
78
|
const [underlyingSymbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
77
|
-
return `${(0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, sdk_gov_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
|
|
79
|
+
return `${this.poolName || (0, contractsRegister_1.getContractName)(this.pool)}: Deposit ${(0, sdk_gov_1.formatBN)(this.amount, underlyingDecimals || 18)} ${underlyingSymbol}`;
|
|
78
80
|
}
|
|
79
81
|
serialize() {
|
|
80
82
|
return {
|
|
@@ -88,15 +90,17 @@ class TxRemoveLiquidity extends eventOrTx_1.EVMTx {
|
|
|
88
90
|
amount;
|
|
89
91
|
dieselToken;
|
|
90
92
|
pool;
|
|
93
|
+
poolName;
|
|
91
94
|
constructor(opts) {
|
|
92
95
|
super(opts);
|
|
93
96
|
this.amount = opts.amount;
|
|
94
97
|
this.dieselToken = opts.dieselToken;
|
|
95
98
|
this.pool = opts.pool;
|
|
99
|
+
this.poolName = opts.poolName;
|
|
96
100
|
}
|
|
97
101
|
toString() {
|
|
98
102
|
const [dSymbol, dDecimals] = (0, sdk_gov_1.extractTokenData)(this.dieselToken);
|
|
99
|
-
return `${(0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, sdk_gov_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
|
|
103
|
+
return `${this.poolName || (0, contractsRegister_1.getContractName)(this.pool)}: Withdraw ${(0, sdk_gov_1.formatBN)(this.amount, dDecimals || 18)} ${dSymbol}`;
|
|
100
104
|
}
|
|
101
105
|
serialize() {
|
|
102
106
|
return {
|
|
@@ -114,6 +118,7 @@ class TXSwap extends eventOrTx_1.EVMTx {
|
|
|
114
118
|
tokenFrom;
|
|
115
119
|
tokenTo;
|
|
116
120
|
creditManager;
|
|
121
|
+
creditManagerName;
|
|
117
122
|
constructor(opts) {
|
|
118
123
|
super(opts);
|
|
119
124
|
this.protocol = opts.protocol;
|
|
@@ -123,6 +128,7 @@ class TXSwap extends eventOrTx_1.EVMTx {
|
|
|
123
128
|
this.tokenFrom = opts.tokenFrom;
|
|
124
129
|
this.tokenTo = opts.tokenTo;
|
|
125
130
|
this.creditManager = opts.creditManager;
|
|
131
|
+
this.creditManagerName = opts.creditManager;
|
|
126
132
|
}
|
|
127
133
|
toString() {
|
|
128
134
|
let toPart = "";
|
|
@@ -131,7 +137,7 @@ class TXSwap extends eventOrTx_1.EVMTx {
|
|
|
131
137
|
toPart = ` ⇒ ${(0, sdk_gov_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
|
|
132
138
|
}
|
|
133
139
|
const [fromSymbol, fromDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenFrom);
|
|
134
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, sdk_gov_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${(0, contractsRegister_1.getContractName)(this.protocol)}`;
|
|
140
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, sdk_gov_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${(0, contractsRegister_1.getContractName)(this.protocol)}`;
|
|
135
141
|
}
|
|
136
142
|
serialize() {
|
|
137
143
|
return {
|
|
@@ -145,15 +151,17 @@ class TxAddCollateral extends eventOrTx_1.EVMTx {
|
|
|
145
151
|
amount;
|
|
146
152
|
addedToken;
|
|
147
153
|
creditManager;
|
|
154
|
+
creditManagerName;
|
|
148
155
|
constructor(opts) {
|
|
149
156
|
super(opts);
|
|
150
157
|
this.amount = opts.amount;
|
|
151
158
|
this.addedToken = opts.addedToken;
|
|
152
159
|
this.creditManager = opts.creditManager;
|
|
160
|
+
this.creditManagerName = opts.creditManager;
|
|
153
161
|
}
|
|
154
162
|
toString() {
|
|
155
163
|
const [addedSymbol, addedDecimals] = (0, sdk_gov_1.extractTokenData)(this.addedToken);
|
|
156
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, sdk_gov_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
|
|
164
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: Added ${(0, sdk_gov_1.formatBN)(this.amount, addedDecimals || 18)} ${addedSymbol} as collateral`;
|
|
157
165
|
}
|
|
158
166
|
serialize() {
|
|
159
167
|
return {
|
|
@@ -167,15 +175,17 @@ class TxIncreaseBorrowAmount extends eventOrTx_1.EVMTx {
|
|
|
167
175
|
amount;
|
|
168
176
|
underlyingToken;
|
|
169
177
|
creditManager;
|
|
178
|
+
creditManagerName;
|
|
170
179
|
constructor(opts) {
|
|
171
180
|
super(opts);
|
|
172
181
|
this.amount = opts.amount;
|
|
173
182
|
this.underlyingToken = opts.underlyingToken;
|
|
174
183
|
this.creditManager = opts.creditManager;
|
|
184
|
+
this.creditManagerName = opts.creditManager;
|
|
175
185
|
}
|
|
176
186
|
toString() {
|
|
177
187
|
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
178
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
188
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was increased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
179
189
|
}
|
|
180
190
|
serialize() {
|
|
181
191
|
return {
|
|
@@ -189,15 +199,17 @@ class TxDecreaseBorrowAmount extends eventOrTx_1.EVMTx {
|
|
|
189
199
|
amount;
|
|
190
200
|
underlyingToken;
|
|
191
201
|
creditManager;
|
|
202
|
+
creditManagerName;
|
|
192
203
|
constructor(opts) {
|
|
193
204
|
super(opts);
|
|
194
205
|
this.amount = opts.amount;
|
|
195
206
|
this.underlyingToken = opts.underlyingToken;
|
|
196
207
|
this.creditManager = opts.creditManager;
|
|
208
|
+
this.creditManagerName = opts.creditManager;
|
|
197
209
|
}
|
|
198
210
|
toString() {
|
|
199
211
|
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
200
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
212
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: Borrowed amount was decreased for ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
201
213
|
}
|
|
202
214
|
serialize() {
|
|
203
215
|
return {
|
|
@@ -212,16 +224,18 @@ class TxOpenAccount extends eventOrTx_1.EVMTx {
|
|
|
212
224
|
underlyingToken;
|
|
213
225
|
leverage;
|
|
214
226
|
creditManager;
|
|
227
|
+
creditManagerName;
|
|
215
228
|
constructor(opts) {
|
|
216
229
|
super(opts);
|
|
217
230
|
this.amount = opts.amount;
|
|
218
231
|
this.underlyingToken = opts.underlyingToken;
|
|
219
232
|
this.leverage = opts.leverage;
|
|
220
233
|
this.creditManager = opts.creditManager;
|
|
234
|
+
this.creditManagerName = opts.creditManager;
|
|
221
235
|
}
|
|
222
236
|
toString() {
|
|
223
237
|
const [tokenSymbol, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
224
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
|
|
238
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: opening ${(0, sdk_gov_1.formatBN)(this.amount, tokenDecimals || 18)} ${tokenSymbol} x ${this.leverage.toFixed(2)} ⇒
|
|
225
239
|
${(0, sdk_gov_1.formatBN)((this.amount *
|
|
226
240
|
BigInt(Math.floor(this.leverage * Number(sdk_gov_1.LEVERAGE_DECIMALS)))) /
|
|
227
241
|
sdk_gov_1.LEVERAGE_DECIMALS, tokenDecimals || 18)} ${tokenSymbol}`;
|
|
@@ -237,6 +251,7 @@ exports.TxOpenAccount = TxOpenAccount;
|
|
|
237
251
|
class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
|
|
238
252
|
borrowedAmount;
|
|
239
253
|
creditManager;
|
|
254
|
+
creditManagerName;
|
|
240
255
|
underlyingToken;
|
|
241
256
|
assets;
|
|
242
257
|
constructor(opts) {
|
|
@@ -244,6 +259,7 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
|
|
|
244
259
|
this.borrowedAmount = opts.borrowedAmount;
|
|
245
260
|
this.underlyingToken = opts.underlyingToken;
|
|
246
261
|
this.creditManager = opts.creditManager;
|
|
262
|
+
this.creditManagerName = opts.creditManager;
|
|
247
263
|
this.assets = opts.assets;
|
|
248
264
|
}
|
|
249
265
|
toString() {
|
|
@@ -254,7 +270,7 @@ class TxOpenMultitokenAccount extends eventOrTx_1.EVMTx {
|
|
|
254
270
|
return acc;
|
|
255
271
|
}, []);
|
|
256
272
|
const [symbol, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
257
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, sdk_gov_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
|
|
273
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: opening. Borrowed amount: ${(0, sdk_gov_1.formatBN)(this.borrowedAmount, underlyingDecimals || 18)} ${symbol}; assets: ${assetSymbols.join(", ")}`;
|
|
258
274
|
}
|
|
259
275
|
serialize() {
|
|
260
276
|
return {
|
|
@@ -319,12 +335,14 @@ class TxClaimGearRewards extends eventOrTx_1.EVMTx {
|
|
|
319
335
|
exports.TxClaimGearRewards = TxClaimGearRewards;
|
|
320
336
|
class TxRepayAccount extends eventOrTx_1.EVMTx {
|
|
321
337
|
creditManager;
|
|
338
|
+
creditManagerName;
|
|
322
339
|
constructor(opts) {
|
|
323
340
|
super(opts);
|
|
324
341
|
this.creditManager = opts.creditManager;
|
|
342
|
+
this.creditManagerName = opts.creditManager;
|
|
325
343
|
}
|
|
326
344
|
toString() {
|
|
327
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Repaying account`;
|
|
345
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: Repaying account`;
|
|
328
346
|
}
|
|
329
347
|
serialize() {
|
|
330
348
|
return {
|
|
@@ -336,12 +354,14 @@ class TxRepayAccount extends eventOrTx_1.EVMTx {
|
|
|
336
354
|
exports.TxRepayAccount = TxRepayAccount;
|
|
337
355
|
class TxCloseAccount extends eventOrTx_1.EVMTx {
|
|
338
356
|
creditManager;
|
|
357
|
+
creditManagerName;
|
|
339
358
|
constructor(opts) {
|
|
340
359
|
super(opts);
|
|
341
360
|
this.creditManager = opts.creditManager;
|
|
361
|
+
this.creditManagerName = opts.creditManager;
|
|
342
362
|
}
|
|
343
363
|
toString() {
|
|
344
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: Closing account`;
|
|
364
|
+
return `Credit Account ${this.creditManager || (0, contractsRegister_1.getContractName)(this.creditManager)}: Closing account`;
|
|
345
365
|
}
|
|
346
366
|
serialize() {
|
|
347
367
|
return {
|
|
@@ -373,11 +393,13 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
|
|
|
373
393
|
enabledTokens;
|
|
374
394
|
disabledTokens;
|
|
375
395
|
creditManager;
|
|
396
|
+
creditManagerName;
|
|
376
397
|
constructor(opts) {
|
|
377
398
|
super(opts);
|
|
378
399
|
this.enabledTokens = opts.enabledTokens;
|
|
379
400
|
this.disabledTokens = opts.disabledTokens;
|
|
380
401
|
this.creditManager = opts.creditManager;
|
|
402
|
+
this.creditManagerName = opts.creditManager;
|
|
381
403
|
}
|
|
382
404
|
toString() {
|
|
383
405
|
const enabledSymbols = this.enabledTokens.map(address => {
|
|
@@ -394,7 +416,7 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
|
|
|
394
416
|
? `disabled: ${disabledSymbols.join(", ")}`
|
|
395
417
|
: "",
|
|
396
418
|
].filter(s => !!s);
|
|
397
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: ${currentSentences.join("; ")}`;
|
|
419
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: ${currentSentences.join("; ")}`;
|
|
398
420
|
}
|
|
399
421
|
serialize() {
|
|
400
422
|
return {
|
|
@@ -408,10 +430,12 @@ class TxUpdateQuota extends eventOrTx_1.EVMTx {
|
|
|
408
430
|
updatedQuotas;
|
|
409
431
|
underlyingToken;
|
|
410
432
|
creditManager;
|
|
433
|
+
creditManagerName;
|
|
411
434
|
constructor(opts) {
|
|
412
435
|
super(opts);
|
|
413
436
|
this.updatedQuotas = opts.updatedQuotas;
|
|
414
437
|
this.creditManager = opts.creditManager;
|
|
438
|
+
this.creditManagerName = opts.creditManagerName;
|
|
415
439
|
this.underlyingToken = opts.underlyingToken;
|
|
416
440
|
}
|
|
417
441
|
toString() {
|
|
@@ -422,7 +446,7 @@ class TxUpdateQuota extends eventOrTx_1.EVMTx {
|
|
|
422
446
|
const amountString = (0, sdk_gov_1.formatBN)(math_1.BigIntMath.abs(balance), underlyingDecimals || 18);
|
|
423
447
|
return `${tokenSymbol} by ${sign}${amountString}`;
|
|
424
448
|
});
|
|
425
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)} quota updated: ${quota.join("; ")}`;
|
|
449
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)} quota updated: ${quota.join("; ")}`;
|
|
426
450
|
}
|
|
427
451
|
serialize() {
|
|
428
452
|
return {
|
|
@@ -508,16 +532,18 @@ class TxWithdrawCollateral extends eventOrTx_1.EVMTx {
|
|
|
508
532
|
token;
|
|
509
533
|
to;
|
|
510
534
|
creditManager;
|
|
535
|
+
creditManagerName;
|
|
511
536
|
constructor(opts) {
|
|
512
537
|
super(opts);
|
|
513
538
|
this.amount = opts.amount;
|
|
514
539
|
this.token = opts.token;
|
|
515
540
|
this.to = opts.to;
|
|
516
541
|
this.creditManager = opts.creditManager;
|
|
542
|
+
this.creditManagerName = opts.creditManagerName;
|
|
517
543
|
}
|
|
518
544
|
toString() {
|
|
519
545
|
const [symbol, decimals] = (0, sdk_gov_1.extractTokenData)(this.token);
|
|
520
|
-
return `Credit Account ${(0, contractsRegister_1.getContractName)(this.creditManager)}: withdrawn ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol}`;
|
|
546
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: withdrawn ${(0, sdk_gov_1.formatBN)(this.amount, decimals || 18)} ${symbol}`;
|
|
521
547
|
}
|
|
522
548
|
serialize() {
|
|
523
549
|
return {
|