@gearbox-protocol/sdk 4.1.7 → 4.1.8
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.
|
@@ -512,7 +512,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
512
512
|
});
|
|
513
513
|
return acc;
|
|
514
514
|
}
|
|
515
|
-
#getCollateralQuota(cm, collateral,
|
|
515
|
+
#getCollateralQuota(cm, collateral, collateralAmount, debt, logger) {
|
|
516
516
|
const {
|
|
517
517
|
underlying,
|
|
518
518
|
creditManager: { liquidationThresholds }
|
|
@@ -532,6 +532,10 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
532
532
|
`quota exceeded for asset ${this.labelAddress(collateral)} in ${cm.name}`
|
|
533
533
|
);
|
|
534
534
|
}
|
|
535
|
+
const oracle = this.sdk.marketRegister.findByCreditManager(
|
|
536
|
+
cm.creditManager.address
|
|
537
|
+
).priceOracle;
|
|
538
|
+
const amount = oracle.convert(collateral, underlying, collateralAmount);
|
|
535
539
|
const desiredQuota = this.#calcQuota(amount, debt, collateralLT);
|
|
536
540
|
logger?.debug(
|
|
537
541
|
{
|
|
@@ -540,6 +544,10 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
540
544
|
underlying,
|
|
541
545
|
availableQuota
|
|
542
546
|
),
|
|
547
|
+
collateralAmount: this.sdk.tokensMeta.formatBN(
|
|
548
|
+
collateral,
|
|
549
|
+
collateralAmount
|
|
550
|
+
),
|
|
543
551
|
amount: this.sdk.tokensMeta.formatBN(underlying, amount),
|
|
544
552
|
debt: this.sdk.tokensMeta.formatBN(underlying, debt),
|
|
545
553
|
lt: Number(collateralLT)
|
|
@@ -498,7 +498,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
498
498
|
});
|
|
499
499
|
return acc;
|
|
500
500
|
}
|
|
501
|
-
#getCollateralQuota(cm, collateral,
|
|
501
|
+
#getCollateralQuota(cm, collateral, collateralAmount, debt, logger) {
|
|
502
502
|
const {
|
|
503
503
|
underlying,
|
|
504
504
|
creditManager: { liquidationThresholds }
|
|
@@ -518,6 +518,10 @@ class AccountOpener extends SDKConstruct {
|
|
|
518
518
|
`quota exceeded for asset ${this.labelAddress(collateral)} in ${cm.name}`
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
|
+
const oracle = this.sdk.marketRegister.findByCreditManager(
|
|
522
|
+
cm.creditManager.address
|
|
523
|
+
).priceOracle;
|
|
524
|
+
const amount = oracle.convert(collateral, underlying, collateralAmount);
|
|
521
525
|
const desiredQuota = this.#calcQuota(amount, debt, collateralLT);
|
|
522
526
|
logger?.debug(
|
|
523
527
|
{
|
|
@@ -526,6 +530,10 @@ class AccountOpener extends SDKConstruct {
|
|
|
526
530
|
underlying,
|
|
527
531
|
availableQuota
|
|
528
532
|
),
|
|
533
|
+
collateralAmount: this.sdk.tokensMeta.formatBN(
|
|
534
|
+
collateral,
|
|
535
|
+
collateralAmount
|
|
536
|
+
),
|
|
529
537
|
amount: this.sdk.tokensMeta.formatBN(underlying, amount),
|
|
530
538
|
debt: this.sdk.tokensMeta.formatBN(underlying, debt),
|
|
531
539
|
lt: Number(collateralLT)
|