@0dotxyz/p0-ts-sdk 2.8.0-alpha.5 → 2.8.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 +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22623,7 +22623,7 @@ function dtoToBankConfig(bankConfigDto) {
|
|
|
22623
22623
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig),
|
|
22624
22624
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
22625
22625
|
fixedPrice: new BigNumber3(bankConfigDto.fixedPrice),
|
|
22626
|
-
scopeEntryIndex: bankConfigDto.scopeEntryIndex
|
|
22626
|
+
scopeEntryIndex: bankConfigDto.scopeEntryIndex
|
|
22627
22627
|
};
|
|
22628
22628
|
}
|
|
22629
22629
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
@@ -22737,7 +22737,7 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
22737
22737
|
interestRateConfig: bankConfigDto.interestRateConfig,
|
|
22738
22738
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
22739
22739
|
fixedPrice: bankConfigDto.fixedPrice,
|
|
22740
|
-
scopeEntryIndex: bankConfigDto.scopeEntryIndex
|
|
22740
|
+
scopeEntryIndex: bankConfigDto.scopeEntryIndex
|
|
22741
22741
|
};
|
|
22742
22742
|
}
|
|
22743
22743
|
function parseBankConfigRaw(bankConfigRaw) {
|
|
@@ -22777,7 +22777,7 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
22777
22777
|
};
|
|
22778
22778
|
const oracleMaxConfidence = bankConfigRaw.oracleMaxConfidence;
|
|
22779
22779
|
const fixedPrice = wrappedI80F48toBigNumber(bankConfigRaw.fixedPrice);
|
|
22780
|
-
const scopeEntryIndex = bankConfigRaw.scopeEntryIndex
|
|
22780
|
+
const scopeEntryIndex = bankConfigRaw.scopeEntryIndex;
|
|
22781
22781
|
return {
|
|
22782
22782
|
assetWeightInit,
|
|
22783
22783
|
assetWeightMaint,
|
|
@@ -81352,7 +81352,8 @@ async function fetchSingleCrossbarChunk(endpoint, swbFeedIdsChunk, isPrimary) {
|
|
|
81352
81352
|
}
|
|
81353
81353
|
var scopeRequestKey = (bank) => {
|
|
81354
81354
|
const oracleKey = bank.config.oracleKeys[0]?.toBase58();
|
|
81355
|
-
|
|
81355
|
+
const entryIndex = bank.config.scopeEntryIndex;
|
|
81356
|
+
return oracleKey && entryIndex !== void 0 ? `${oracleKey}:${entryIndex}` : void 0;
|
|
81356
81357
|
};
|
|
81357
81358
|
var fetchScopeOracleData = async (banks, opts) => {
|
|
81358
81359
|
const scopeBanks = banks.filter((bank) => getOracleSourceFromBank(bank).key === "scope");
|
|
@@ -81372,8 +81373,12 @@ var fetchScopeOracleData = async (banks, opts) => {
|
|
|
81372
81373
|
const uniqueRequestKeys = Array.from(
|
|
81373
81374
|
new Set(scopeBanks.map(scopeRequestKey).filter((key) => key !== void 0))
|
|
81374
81375
|
);
|
|
81375
|
-
let oraclePrices;
|
|
81376
|
-
if (
|
|
81376
|
+
let oraclePrices = {};
|
|
81377
|
+
if (!uniqueRequestKeys.length) {
|
|
81378
|
+
console.warn(
|
|
81379
|
+
"fetchScopeOracleData: no scope bank carries a scopeEntryIndex; all priced at zero"
|
|
81380
|
+
);
|
|
81381
|
+
} else if (opts.mode === "api") {
|
|
81377
81382
|
oraclePrices = await fetchScopeOraclePricesFromAPI(
|
|
81378
81383
|
uniqueRequestKeys,
|
|
81379
81384
|
opts.scopeOnchainData.endpoint,
|
|
@@ -82415,7 +82420,7 @@ async function addOracleToBanksIx({
|
|
|
82415
82420
|
groupAddress,
|
|
82416
82421
|
adminAddress
|
|
82417
82422
|
}) {
|
|
82418
|
-
if (setup === "Scope" /* Scope */ || setup === "PTPyth" /* PTPyth */ || setup === "PTFixed" /* PTFixed */) {
|
|
82423
|
+
if (setup === "Scope" /* Scope */ || setup === "PTPyth" /* PTPyth */ || setup === "PTFixed" /* PTFixed */ || setup === "Fixed" /* Fixed */ || setup === "FixedKamino" /* FixedKamino */ || setup === "FixedDrift" /* FixedDrift */ || setup === "FixedJuplend" /* FixedJuplend */) {
|
|
82419
82424
|
throw new Error(
|
|
82420
82425
|
`${setup} must be configured with ${setup === "Scope" /* Scope */ ? "configureScopeOracleIx" : "setOraclePriceIx"}`
|
|
82421
82426
|
);
|
|
@@ -82425,6 +82430,11 @@ async function addOracleToBanksIx({
|
|
|
82425
82430
|
if (expectedAccountCount !== void 0 && resolvedOracleAccounts.length !== expectedAccountCount) {
|
|
82426
82431
|
throw new Error(`${setup} requires ${expectedAccountCount} ordered oracle accounts`);
|
|
82427
82432
|
}
|
|
82433
|
+
if (expectedAccountCount !== void 0 && !resolvedOracleAccounts[0].equals(feedId)) {
|
|
82434
|
+
throw new Error(
|
|
82435
|
+
`${setup} requires oracleAccounts[0] to be the primary feed ${feedId.toBase58()}`
|
|
82436
|
+
);
|
|
82437
|
+
}
|
|
82428
82438
|
const ix = await instructions_default.makeLendingPoolConfigureBankOracleIx(
|
|
82429
82439
|
program,
|
|
82430
82440
|
{
|