@gearbox-protocol/sdk 3.0.0-next.13 → 3.0.0-next.14
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.
|
@@ -54,7 +54,6 @@ export declare class CreditAccountData {
|
|
|
54
54
|
readonly schedultedWithdrawals: Array<ScheduledWithdrawal>;
|
|
55
55
|
constructor(payload: CreditAccountDataPayload);
|
|
56
56
|
setDeleteInProgress(d: boolean): void;
|
|
57
|
-
balancesSorted(prices: Record<string, bigint>, tokens: Record<string, TokenData>): Array<Asset>;
|
|
58
57
|
static sortBalances(balances: Record<string, bigint>, prices: Record<string, bigint>, tokens: Record<string, TokenData>): Array<[string, bigint]>;
|
|
59
58
|
static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1;
|
|
60
59
|
static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
|
|
@@ -105,9 +105,6 @@ class CreditAccountData {
|
|
|
105
105
|
setDeleteInProgress(d) {
|
|
106
106
|
this.isDeleting = d;
|
|
107
107
|
}
|
|
108
|
-
balancesSorted(prices, tokens) {
|
|
109
|
-
return CreditAccountData.sortBalances(this.balances, prices, tokens).map(([token, balance]) => ({ token, balance }));
|
|
110
|
-
}
|
|
111
108
|
static sortBalances(balances, prices, tokens) {
|
|
112
109
|
return Object.entries(balances).sort(([addr1, amount1], [addr2, amount2]) => {
|
|
113
110
|
const addr1Lc = addr1.toLowerCase();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
2
|
+
import { Asset } from "./assets";
|
|
2
3
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
3
4
|
export interface TxSerialized {
|
|
4
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens";
|
|
5
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimReward" | "TxClaimNFT" | "TxClaimGearRewards" | "TxEnableTokens" | "TxUpdateQuota";
|
|
5
6
|
content: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class TxSerializer {
|
|
@@ -190,4 +191,17 @@ export declare class TxEnableTokens extends EVMTx {
|
|
|
190
191
|
toString(): string;
|
|
191
192
|
serialize(): TxSerialized;
|
|
192
193
|
}
|
|
194
|
+
interface TxUpdateQuotaProps extends EVMTxProps {
|
|
195
|
+
updatedQuotas: Array<Asset>;
|
|
196
|
+
underlyingToken: string;
|
|
197
|
+
creditManager: string;
|
|
198
|
+
}
|
|
199
|
+
export declare class TxUpdateQuota extends EVMTx {
|
|
200
|
+
readonly updatedQuotas: Array<Asset>;
|
|
201
|
+
readonly underlyingToken: string;
|
|
202
|
+
readonly creditManager: string;
|
|
203
|
+
constructor(opts: TxUpdateQuotaProps);
|
|
204
|
+
toString(): string;
|
|
205
|
+
serialize(): TxSerialized;
|
|
206
|
+
}
|
|
193
207
|
export {};
|
package/lib/core/transactions.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.TxUpdateQuota = 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
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const contractsRegister_1 = require("../contracts/contractsRegister");
|
|
6
6
|
const formatter_1 = require("../utils/formatter");
|
|
7
|
+
const math_1 = require("../utils/math");
|
|
7
8
|
const eventOrTx_1 = require("./eventOrTx");
|
|
8
9
|
class TxSerializer {
|
|
9
10
|
static serialize(items) {
|
|
@@ -43,6 +44,8 @@ class TxSerializer {
|
|
|
43
44
|
return new TxClaimGearRewards(params);
|
|
44
45
|
case "TxEnableTokens":
|
|
45
46
|
return new TxEnableTokens(params);
|
|
47
|
+
case "TxUpdateQuota":
|
|
48
|
+
return new TxUpdateQuota(params);
|
|
46
49
|
default:
|
|
47
50
|
throw new Error(`Unknown transaction for parsing: ${e.type}`);
|
|
48
51
|
}
|
|
@@ -470,3 +473,36 @@ class TxEnableTokens extends eventOrTx_1.EVMTx {
|
|
|
470
473
|
}
|
|
471
474
|
}
|
|
472
475
|
exports.TxEnableTokens = TxEnableTokens;
|
|
476
|
+
class TxUpdateQuota extends eventOrTx_1.EVMTx {
|
|
477
|
+
updatedQuotas;
|
|
478
|
+
underlyingToken;
|
|
479
|
+
creditManager;
|
|
480
|
+
constructor(opts) {
|
|
481
|
+
super({
|
|
482
|
+
block: opts.block,
|
|
483
|
+
txHash: opts.txHash,
|
|
484
|
+
txStatus: opts.txStatus,
|
|
485
|
+
timestamp: opts.timestamp,
|
|
486
|
+
});
|
|
487
|
+
this.updatedQuotas = opts.updatedQuotas;
|
|
488
|
+
this.creditManager = opts.creditManager;
|
|
489
|
+
this.underlyingToken = opts.underlyingToken;
|
|
490
|
+
}
|
|
491
|
+
toString() {
|
|
492
|
+
const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(this.underlyingToken);
|
|
493
|
+
const quota = this.updatedQuotas.map(({ token, balance }) => {
|
|
494
|
+
const [tokenSymbol] = (0, sdk_gov_1.extractTokenData)(token);
|
|
495
|
+
const sign = balance < 0 ? "-" : "";
|
|
496
|
+
const amountString = (0, formatter_1.formatBN)(math_1.BigIntMath.abs(balance), underlyingDecimals || 18);
|
|
497
|
+
return `${tokenSymbol} by ${sign}${amountString}`;
|
|
498
|
+
});
|
|
499
|
+
return `Credit account ${(0, contractsRegister_1.getContractName)(this.creditManager)} quota updated: ${quota.join("; ")}`;
|
|
500
|
+
}
|
|
501
|
+
serialize() {
|
|
502
|
+
return {
|
|
503
|
+
type: "TxEnableTokens",
|
|
504
|
+
content: JSON.stringify(this),
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
exports.TxUpdateQuota = TxUpdateQuota;
|