@pyron-finance/pyron-client 2.6.0 → 2.7.0
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/dist/index.cjs +34 -11
- package/dist/index.js +34 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23658,7 +23658,12 @@ var LendrAccount = class _LendrAccount {
|
|
|
23658
23658
|
if (!liabilityBank) throw Error(`Bank ${liabilityBankAddress.toBase58()} not found`);
|
|
23659
23659
|
const liabilityPriceInfo = oraclePrices.get(liabilityBankAddress.toBase58());
|
|
23660
23660
|
if (!liabilityPriceInfo) throw Error(`Price info for ${liabilityBankAddress.toBase58()} not found`);
|
|
23661
|
-
|
|
23661
|
+
let { assets, liabilities } = this.computeHealthComponents(1 /* Maintenance */);
|
|
23662
|
+
if (assets.isZero() && liabilities.isZero()) {
|
|
23663
|
+
const legacy = this.computeHealthComponentsLegacy(banks, oraclePrices, 1 /* Maintenance */);
|
|
23664
|
+
assets = legacy.assets;
|
|
23665
|
+
liabilities = legacy.liabilities;
|
|
23666
|
+
}
|
|
23662
23667
|
const currentHealth = assets.minus(liabilities);
|
|
23663
23668
|
const priceAssetLower = getPrice(assetPriceInfo, 0 /* Lowest */, false);
|
|
23664
23669
|
const priceAssetMarket = getPrice(assetPriceInfo, 1 /* None */, false);
|
|
@@ -24256,7 +24261,6 @@ var LendrAccount = class _LendrAccount {
|
|
|
24256
24261
|
liquidateeLendrAccount: liquidateeLendrAccount.address,
|
|
24257
24262
|
tokenProgram: liabilityMintData.tokenProgram
|
|
24258
24263
|
},
|
|
24259
|
-
//Check: need to handle liquidateAll later, for now just use default value of false for backward compatibility
|
|
24260
24264
|
{
|
|
24261
24265
|
assetAmount: uiToNative(assetQuantityUi, assetBank.mintDecimals),
|
|
24262
24266
|
liquidateeAccounts: liquidateeHealthAccounts.length,
|
|
@@ -24526,15 +24530,34 @@ var LendrAccountWrapper = class _LendrAccountWrapper {
|
|
|
24526
24530
|
return new _LendrAccountWrapper(this.address, this.client, account);
|
|
24527
24531
|
}
|
|
24528
24532
|
canBeLiquidated() {
|
|
24529
|
-
|
|
24530
|
-
|
|
24531
|
-
|
|
24532
|
-
|
|
24533
|
-
|
|
24534
|
-
|
|
24535
|
-
|
|
24536
|
-
|
|
24537
|
-
|
|
24533
|
+
let { assets, liabilities } = this._lendrAccount.computeHealthComponents(1 /* Maintenance */);
|
|
24534
|
+
if (assets.isZero() && liabilities.isZero()) {
|
|
24535
|
+
const legacy = this._lendrAccount.computeHealthComponentsLegacy(
|
|
24536
|
+
this.client.banks,
|
|
24537
|
+
this.client.oraclePrices,
|
|
24538
|
+
1 /* Maintenance */
|
|
24539
|
+
);
|
|
24540
|
+
assets = legacy.assets;
|
|
24541
|
+
liabilities = legacy.liabilities;
|
|
24542
|
+
this.client.logger.debug(
|
|
24543
|
+
{
|
|
24544
|
+
address: this.address.toBase58(),
|
|
24545
|
+
assets,
|
|
24546
|
+
liabilities,
|
|
24547
|
+
usedLegacy: true
|
|
24548
|
+
},
|
|
24549
|
+
"[lendr:lendr-account:canBeLiquidated]"
|
|
24550
|
+
);
|
|
24551
|
+
} else {
|
|
24552
|
+
this.client.logger.debug(
|
|
24553
|
+
{
|
|
24554
|
+
address: this.address.toBase58(),
|
|
24555
|
+
assets,
|
|
24556
|
+
liabilities
|
|
24557
|
+
},
|
|
24558
|
+
"[lendr:lendr-account:canBeLiquidated]"
|
|
24559
|
+
);
|
|
24560
|
+
}
|
|
24538
24561
|
return assets.lt(liabilities);
|
|
24539
24562
|
}
|
|
24540
24563
|
computeHealthComponents(lendrRequirement) {
|
package/dist/index.js
CHANGED
|
@@ -23482,7 +23482,12 @@ var LendrAccount = class _LendrAccount {
|
|
|
23482
23482
|
if (!liabilityBank) throw Error(`Bank ${liabilityBankAddress.toBase58()} not found`);
|
|
23483
23483
|
const liabilityPriceInfo = oraclePrices.get(liabilityBankAddress.toBase58());
|
|
23484
23484
|
if (!liabilityPriceInfo) throw Error(`Price info for ${liabilityBankAddress.toBase58()} not found`);
|
|
23485
|
-
|
|
23485
|
+
let { assets, liabilities } = this.computeHealthComponents(1 /* Maintenance */);
|
|
23486
|
+
if (assets.isZero() && liabilities.isZero()) {
|
|
23487
|
+
const legacy = this.computeHealthComponentsLegacy(banks, oraclePrices, 1 /* Maintenance */);
|
|
23488
|
+
assets = legacy.assets;
|
|
23489
|
+
liabilities = legacy.liabilities;
|
|
23490
|
+
}
|
|
23486
23491
|
const currentHealth = assets.minus(liabilities);
|
|
23487
23492
|
const priceAssetLower = getPrice(assetPriceInfo, 0 /* Lowest */, false);
|
|
23488
23493
|
const priceAssetMarket = getPrice(assetPriceInfo, 1 /* None */, false);
|
|
@@ -24080,7 +24085,6 @@ var LendrAccount = class _LendrAccount {
|
|
|
24080
24085
|
liquidateeLendrAccount: liquidateeLendrAccount.address,
|
|
24081
24086
|
tokenProgram: liabilityMintData.tokenProgram
|
|
24082
24087
|
},
|
|
24083
|
-
//Check: need to handle liquidateAll later, for now just use default value of false for backward compatibility
|
|
24084
24088
|
{
|
|
24085
24089
|
assetAmount: uiToNative(assetQuantityUi, assetBank.mintDecimals),
|
|
24086
24090
|
liquidateeAccounts: liquidateeHealthAccounts.length,
|
|
@@ -24369,15 +24373,34 @@ var LendrAccountWrapper = class _LendrAccountWrapper {
|
|
|
24369
24373
|
return new _LendrAccountWrapper(this.address, this.client, account);
|
|
24370
24374
|
}
|
|
24371
24375
|
canBeLiquidated() {
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
|
|
24376
|
+
let { assets, liabilities } = this._lendrAccount.computeHealthComponents(1 /* Maintenance */);
|
|
24377
|
+
if (assets.isZero() && liabilities.isZero()) {
|
|
24378
|
+
const legacy = this._lendrAccount.computeHealthComponentsLegacy(
|
|
24379
|
+
this.client.banks,
|
|
24380
|
+
this.client.oraclePrices,
|
|
24381
|
+
1 /* Maintenance */
|
|
24382
|
+
);
|
|
24383
|
+
assets = legacy.assets;
|
|
24384
|
+
liabilities = legacy.liabilities;
|
|
24385
|
+
this.client.logger.debug(
|
|
24386
|
+
{
|
|
24387
|
+
address: this.address.toBase58(),
|
|
24388
|
+
assets,
|
|
24389
|
+
liabilities,
|
|
24390
|
+
usedLegacy: true
|
|
24391
|
+
},
|
|
24392
|
+
"[lendr:lendr-account:canBeLiquidated]"
|
|
24393
|
+
);
|
|
24394
|
+
} else {
|
|
24395
|
+
this.client.logger.debug(
|
|
24396
|
+
{
|
|
24397
|
+
address: this.address.toBase58(),
|
|
24398
|
+
assets,
|
|
24399
|
+
liabilities
|
|
24400
|
+
},
|
|
24401
|
+
"[lendr:lendr-account:canBeLiquidated]"
|
|
24402
|
+
);
|
|
24403
|
+
}
|
|
24381
24404
|
return assets.lt(liabilities);
|
|
24382
24405
|
}
|
|
24383
24406
|
computeHealthComponents(lendrRequirement) {
|