@gearbox-protocol/sdk 3.0.0-vfour.375 → 3.0.0-vfour.377
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/cjs/sdk/accounts/CreditAccountsService.js +15 -19
- package/dist/cjs/sdk/chain/chains.js +1 -3
- package/dist/esm/sdk/accounts/CreditAccountsService.js +16 -20
- package/dist/esm/sdk/chain/chains.js +1 -3
- package/dist/types/sdk/accounts/CreditAccountsService.d.ts +2 -0
- package/package.json +1 -1
|
@@ -716,6 +716,8 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
716
716
|
}
|
|
717
717
|
/**
|
|
718
718
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
719
|
+
*
|
|
720
|
+
* This can be used by batch liquidator
|
|
719
721
|
* @param accounts
|
|
720
722
|
* @returns
|
|
721
723
|
*/
|
|
@@ -744,19 +746,11 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
744
746
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
745
747
|
}
|
|
746
748
|
async getUpdateForAccount(creditManager, creditAccount, desiredQuotas) {
|
|
747
|
-
const tokensByPool = /* @__PURE__ */ new Map();
|
|
748
|
-
const oracleByPool = /* @__PURE__ */ new Map();
|
|
749
749
|
const quotaRecord = desiredQuotas ? (0, import_router.assetsMap)(desiredQuotas) : desiredQuotas;
|
|
750
750
|
const caBalancesRecord = creditAccount ? (0, import_router.assetsMap)(creditAccount.tokens) : creditAccount;
|
|
751
751
|
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
752
752
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager).creditManager;
|
|
753
|
-
const
|
|
754
|
-
oracleByPool.set(pool, market.priceOracle);
|
|
755
|
-
const insertToken = (p, t) => {
|
|
756
|
-
const tokens = tokensByPool.get(p) ?? /* @__PURE__ */ new Set();
|
|
757
|
-
tokens.add(t);
|
|
758
|
-
tokensByPool.set(pool, tokens);
|
|
759
|
-
};
|
|
753
|
+
const tokens = /* @__PURE__ */ new Set([(0, import_viem.getAddress)(cm.underlying)]);
|
|
760
754
|
for (const t of cm.collateralTokens) {
|
|
761
755
|
if (creditAccount && caBalancesRecord && quotaRecord) {
|
|
762
756
|
const balanceAsset = caBalancesRecord.get(t);
|
|
@@ -765,28 +759,30 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
765
759
|
const isEnabled = (mask & creditAccount.enabledTokensMask) !== 0n;
|
|
766
760
|
const quotaAsset = quotaRecord.get(t);
|
|
767
761
|
const quotaBalance = quotaAsset?.balance || 0n;
|
|
768
|
-
if (balance > 10n && isEnabled || quotaBalance > 0)
|
|
769
|
-
|
|
762
|
+
if (balance > 10n && isEnabled || quotaBalance > 0) {
|
|
763
|
+
tokens.add((0, import_viem.getAddress)(t));
|
|
764
|
+
}
|
|
770
765
|
} else if (creditAccount && caBalancesRecord) {
|
|
771
766
|
const balanceAsset = caBalancesRecord.get(t);
|
|
772
767
|
const balance = balanceAsset?.balance || 0n;
|
|
773
768
|
const mask = balanceAsset?.mask || 0n;
|
|
774
769
|
const isEnabled = (mask & creditAccount.enabledTokensMask) !== 0n;
|
|
775
|
-
if (balance > 10n && isEnabled)
|
|
770
|
+
if (balance > 10n && isEnabled) {
|
|
771
|
+
tokens.add((0, import_viem.getAddress)(t));
|
|
772
|
+
}
|
|
776
773
|
} else if (quotaRecord) {
|
|
777
774
|
const quotaAsset = quotaRecord.get(t);
|
|
778
775
|
const quotaBalance = quotaAsset?.balance || 0n;
|
|
779
|
-
if (quotaBalance > 0)
|
|
776
|
+
if (quotaBalance > 0) {
|
|
777
|
+
tokens.add((0, import_viem.getAddress)(t));
|
|
778
|
+
}
|
|
780
779
|
}
|
|
781
780
|
}
|
|
782
|
-
const priceFeeds =
|
|
783
|
-
|
|
784
|
-
const tokens = Array.from(tokensByPool.get(pool2) ?? []);
|
|
785
|
-
priceFeeds.push(...oracle.priceFeedsForTokens(tokens));
|
|
786
|
-
}
|
|
781
|
+
const priceFeeds = market.priceOracle.priceFeedsForTokens(Array.from(tokens));
|
|
782
|
+
const tStr = Array.from(tokens).map((t) => this.labelAddress(t)).join(", ");
|
|
787
783
|
this.#logger?.debug(
|
|
788
784
|
{ account: creditAccount?.creditAccount, manager: cm.name },
|
|
789
|
-
`generating price feed updates for ${priceFeeds.length} price feeds`
|
|
785
|
+
`generating price feed updates for ${tStr} from ${priceFeeds.length} price feeds`
|
|
790
786
|
);
|
|
791
787
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
792
788
|
priceFeeds,
|
|
@@ -61,9 +61,7 @@ const chains = {
|
|
|
61
61
|
...import_chains.mainnet,
|
|
62
62
|
network: "Mainnet",
|
|
63
63
|
defaultMarketConfigurators: {
|
|
64
|
-
"0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
|
|
65
|
-
},
|
|
66
|
-
testMarketConfigurators: {
|
|
64
|
+
"0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs",
|
|
67
65
|
"0x4d427D418342d8CE89a7634c3a402851978B680A": "K3"
|
|
68
66
|
},
|
|
69
67
|
isPublic: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeFunctionData } from "viem";
|
|
1
|
+
import { encodeFunctionData, getAddress } from "viem";
|
|
2
2
|
import {
|
|
3
3
|
iCreditAccountCompressorAbi,
|
|
4
4
|
iPeripheryCompressorAbi,
|
|
@@ -720,6 +720,8 @@ class CreditAccountsService extends SDKConstruct {
|
|
|
720
720
|
}
|
|
721
721
|
/**
|
|
722
722
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
723
|
+
*
|
|
724
|
+
* This can be used by batch liquidator
|
|
723
725
|
* @param accounts
|
|
724
726
|
* @returns
|
|
725
727
|
*/
|
|
@@ -748,19 +750,11 @@ class CreditAccountsService extends SDKConstruct {
|
|
|
748
750
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
749
751
|
}
|
|
750
752
|
async getUpdateForAccount(creditManager, creditAccount, desiredQuotas) {
|
|
751
|
-
const tokensByPool = /* @__PURE__ */ new Map();
|
|
752
|
-
const oracleByPool = /* @__PURE__ */ new Map();
|
|
753
753
|
const quotaRecord = desiredQuotas ? assetsMap(desiredQuotas) : desiredQuotas;
|
|
754
754
|
const caBalancesRecord = creditAccount ? assetsMap(creditAccount.tokens) : creditAccount;
|
|
755
755
|
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
756
756
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager).creditManager;
|
|
757
|
-
const
|
|
758
|
-
oracleByPool.set(pool, market.priceOracle);
|
|
759
|
-
const insertToken = (p, t) => {
|
|
760
|
-
const tokens = tokensByPool.get(p) ?? /* @__PURE__ */ new Set();
|
|
761
|
-
tokens.add(t);
|
|
762
|
-
tokensByPool.set(pool, tokens);
|
|
763
|
-
};
|
|
757
|
+
const tokens = /* @__PURE__ */ new Set([getAddress(cm.underlying)]);
|
|
764
758
|
for (const t of cm.collateralTokens) {
|
|
765
759
|
if (creditAccount && caBalancesRecord && quotaRecord) {
|
|
766
760
|
const balanceAsset = caBalancesRecord.get(t);
|
|
@@ -769,28 +763,30 @@ class CreditAccountsService extends SDKConstruct {
|
|
|
769
763
|
const isEnabled = (mask & creditAccount.enabledTokensMask) !== 0n;
|
|
770
764
|
const quotaAsset = quotaRecord.get(t);
|
|
771
765
|
const quotaBalance = quotaAsset?.balance || 0n;
|
|
772
|
-
if (balance > 10n && isEnabled || quotaBalance > 0)
|
|
773
|
-
|
|
766
|
+
if (balance > 10n && isEnabled || quotaBalance > 0) {
|
|
767
|
+
tokens.add(getAddress(t));
|
|
768
|
+
}
|
|
774
769
|
} else if (creditAccount && caBalancesRecord) {
|
|
775
770
|
const balanceAsset = caBalancesRecord.get(t);
|
|
776
771
|
const balance = balanceAsset?.balance || 0n;
|
|
777
772
|
const mask = balanceAsset?.mask || 0n;
|
|
778
773
|
const isEnabled = (mask & creditAccount.enabledTokensMask) !== 0n;
|
|
779
|
-
if (balance > 10n && isEnabled)
|
|
774
|
+
if (balance > 10n && isEnabled) {
|
|
775
|
+
tokens.add(getAddress(t));
|
|
776
|
+
}
|
|
780
777
|
} else if (quotaRecord) {
|
|
781
778
|
const quotaAsset = quotaRecord.get(t);
|
|
782
779
|
const quotaBalance = quotaAsset?.balance || 0n;
|
|
783
|
-
if (quotaBalance > 0)
|
|
780
|
+
if (quotaBalance > 0) {
|
|
781
|
+
tokens.add(getAddress(t));
|
|
782
|
+
}
|
|
784
783
|
}
|
|
785
784
|
}
|
|
786
|
-
const priceFeeds =
|
|
787
|
-
|
|
788
|
-
const tokens = Array.from(tokensByPool.get(pool2) ?? []);
|
|
789
|
-
priceFeeds.push(...oracle.priceFeedsForTokens(tokens));
|
|
790
|
-
}
|
|
785
|
+
const priceFeeds = market.priceOracle.priceFeedsForTokens(Array.from(tokens));
|
|
786
|
+
const tStr = Array.from(tokens).map((t) => this.labelAddress(t)).join(", ");
|
|
791
787
|
this.#logger?.debug(
|
|
792
788
|
{ account: creditAccount?.creditAccount, manager: cm.name },
|
|
793
|
-
`generating price feed updates for ${priceFeeds.length} price feeds`
|
|
789
|
+
`generating price feed updates for ${tStr} from ${priceFeeds.length} price feeds`
|
|
794
790
|
);
|
|
795
791
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
796
792
|
priceFeeds,
|
|
@@ -42,9 +42,7 @@ const chains = {
|
|
|
42
42
|
...mainnet,
|
|
43
43
|
network: "Mainnet",
|
|
44
44
|
defaultMarketConfigurators: {
|
|
45
|
-
"0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
|
|
46
|
-
},
|
|
47
|
-
testMarketConfigurators: {
|
|
45
|
+
"0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs",
|
|
48
46
|
"0x4d427D418342d8CE89a7634c3a402851978B680A": "K3"
|
|
49
47
|
},
|
|
50
48
|
isPublic: true,
|
|
@@ -224,6 +224,8 @@ export declare class CreditAccountsService extends SDKConstruct {
|
|
|
224
224
|
openCA({ ethAmount, creditManager, collateral, permits, debt, withdrawDebt, referralCode, to, calls: openPathCalls, minQuota, averageQuota, }: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
225
225
|
/**
|
|
226
226
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
227
|
+
*
|
|
228
|
+
* This can be used by batch liquidator
|
|
227
229
|
* @param accounts
|
|
228
230
|
* @returns
|
|
229
231
|
*/
|