@0dotxyz/p0-ts-sdk 2.7.4 → 2.8.0-alpha.1
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 +640 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -8
- package/dist/index.d.ts +101 -8
- package/dist/index.js +633 -41
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-DJqANTTA.d.cts → types-6tM8iZUV.d.cts} +87 -9
- package/dist/{types-sisv3J7l.d.ts → types-SY3xiGG8.d.ts} +87 -9
- package/dist/types-cfCsUNXw.d.cts +230 -0
- package/dist/types-cfCsUNXw.d.ts +230 -0
- package/dist/vendor.cjs +100 -9
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +6880 -6981
- package/dist/vendor.d.ts +6880 -6981
- package/dist/vendor.js +81 -3
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
- package/dist/types-DLZaKA17.d.cts +0 -88
- package/dist/types-DLZaKA17.d.ts +0 -88
package/dist/index.cjs
CHANGED
|
@@ -13265,6 +13265,26 @@ var marginfi_0_1_10_default = {
|
|
|
13265
13265
|
code: 6604,
|
|
13266
13266
|
name: "CircuitBreakerPriceJump",
|
|
13267
13267
|
msg: "Oracle price deviates too far from the circuit breaker reference; action rejected"
|
|
13268
|
+
},
|
|
13269
|
+
{
|
|
13270
|
+
code: 6700,
|
|
13271
|
+
name: "ScopeInvalidAccount",
|
|
13272
|
+
msg: "Scope oracle account is not owned by the Scope program or is malformed"
|
|
13273
|
+
},
|
|
13274
|
+
{
|
|
13275
|
+
code: 6701,
|
|
13276
|
+
name: "ScopeInvalidEntry",
|
|
13277
|
+
msg: "Scope entry index is out of range or the entry has never been refreshed"
|
|
13278
|
+
},
|
|
13279
|
+
{
|
|
13280
|
+
code: 6702,
|
|
13281
|
+
name: "ScopeStalePrice",
|
|
13282
|
+
msg: "Scope price is stale"
|
|
13283
|
+
},
|
|
13284
|
+
{
|
|
13285
|
+
code: 6703,
|
|
13286
|
+
name: "UseConfigureBankOracleScope",
|
|
13287
|
+
msg: "Use lending_pool_configure_bank_oracle_scope; Scope requires an entry index"
|
|
13268
13288
|
}
|
|
13269
13289
|
],
|
|
13270
13290
|
types: [
|
|
@@ -14354,13 +14374,13 @@ var marginfi_0_1_10_default = {
|
|
|
14354
14374
|
type: "u16"
|
|
14355
14375
|
},
|
|
14356
14376
|
{
|
|
14357
|
-
name: "
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14377
|
+
name: "scope_entry_index",
|
|
14378
|
+
docs: [
|
|
14379
|
+
"Entry index into the Scope OraclePrices price list. Only read when",
|
|
14380
|
+
"oracle_setup == OracleSetup::Scope; ignored (and zero) for every other setup.",
|
|
14381
|
+
"Occupies what was previously _padding0, so the layout is unchanged."
|
|
14382
|
+
],
|
|
14383
|
+
type: "u16"
|
|
14364
14384
|
},
|
|
14365
14385
|
{
|
|
14366
14386
|
name: "oracle_max_confidence",
|
|
@@ -19311,6 +19331,144 @@ var marginfi_0_1_10_default = {
|
|
|
19311
19331
|
},
|
|
19312
19332
|
{
|
|
19313
19333
|
name: "FixedJuplend"
|
|
19334
|
+
},
|
|
19335
|
+
{
|
|
19336
|
+
name: "Scope"
|
|
19337
|
+
},
|
|
19338
|
+
{
|
|
19339
|
+
name: "PythMSOL"
|
|
19340
|
+
},
|
|
19341
|
+
{
|
|
19342
|
+
name: "KaminoMSOL"
|
|
19343
|
+
},
|
|
19344
|
+
{
|
|
19345
|
+
name: "JuplendMSOL"
|
|
19346
|
+
},
|
|
19347
|
+
{
|
|
19348
|
+
name: "PythLST"
|
|
19349
|
+
},
|
|
19350
|
+
{
|
|
19351
|
+
name: "KaminoLST"
|
|
19352
|
+
},
|
|
19353
|
+
{
|
|
19354
|
+
name: "JuplendLST"
|
|
19355
|
+
},
|
|
19356
|
+
{
|
|
19357
|
+
name: "PTPyth"
|
|
19358
|
+
},
|
|
19359
|
+
{
|
|
19360
|
+
name: "PTFixed"
|
|
19361
|
+
},
|
|
19362
|
+
{
|
|
19363
|
+
name: "Reserved27"
|
|
19364
|
+
},
|
|
19365
|
+
{
|
|
19366
|
+
name: "Reserved28"
|
|
19367
|
+
},
|
|
19368
|
+
{
|
|
19369
|
+
name: "Reserved29"
|
|
19370
|
+
},
|
|
19371
|
+
{
|
|
19372
|
+
name: "Reserved30"
|
|
19373
|
+
},
|
|
19374
|
+
{
|
|
19375
|
+
name: "Reserved31"
|
|
19376
|
+
},
|
|
19377
|
+
{
|
|
19378
|
+
name: "Reserved32"
|
|
19379
|
+
},
|
|
19380
|
+
{
|
|
19381
|
+
name: "Reserved33"
|
|
19382
|
+
},
|
|
19383
|
+
{
|
|
19384
|
+
name: "Reserved34"
|
|
19385
|
+
},
|
|
19386
|
+
{
|
|
19387
|
+
name: "Reserved35"
|
|
19388
|
+
},
|
|
19389
|
+
{
|
|
19390
|
+
name: "Reserved36"
|
|
19391
|
+
},
|
|
19392
|
+
{
|
|
19393
|
+
name: "Reserved37"
|
|
19394
|
+
},
|
|
19395
|
+
{
|
|
19396
|
+
name: "Reserved38"
|
|
19397
|
+
},
|
|
19398
|
+
{
|
|
19399
|
+
name: "Reserved39"
|
|
19400
|
+
},
|
|
19401
|
+
{
|
|
19402
|
+
name: "Reserved40"
|
|
19403
|
+
},
|
|
19404
|
+
{
|
|
19405
|
+
name: "Reserved41"
|
|
19406
|
+
},
|
|
19407
|
+
{
|
|
19408
|
+
name: "Reserved42"
|
|
19409
|
+
},
|
|
19410
|
+
{
|
|
19411
|
+
name: "Reserved43"
|
|
19412
|
+
},
|
|
19413
|
+
{
|
|
19414
|
+
name: "Reserved44"
|
|
19415
|
+
},
|
|
19416
|
+
{
|
|
19417
|
+
name: "Reserved45"
|
|
19418
|
+
},
|
|
19419
|
+
{
|
|
19420
|
+
name: "Reserved46"
|
|
19421
|
+
},
|
|
19422
|
+
{
|
|
19423
|
+
name: "Reserved47"
|
|
19424
|
+
},
|
|
19425
|
+
{
|
|
19426
|
+
name: "Reserved48"
|
|
19427
|
+
},
|
|
19428
|
+
{
|
|
19429
|
+
name: "Reserved49"
|
|
19430
|
+
},
|
|
19431
|
+
{
|
|
19432
|
+
name: "Reserved50"
|
|
19433
|
+
},
|
|
19434
|
+
{
|
|
19435
|
+
name: "Reserved51"
|
|
19436
|
+
},
|
|
19437
|
+
{
|
|
19438
|
+
name: "Reserved52"
|
|
19439
|
+
},
|
|
19440
|
+
{
|
|
19441
|
+
name: "Reserved53"
|
|
19442
|
+
},
|
|
19443
|
+
{
|
|
19444
|
+
name: "Reserved54"
|
|
19445
|
+
},
|
|
19446
|
+
{
|
|
19447
|
+
name: "Reserved55"
|
|
19448
|
+
},
|
|
19449
|
+
{
|
|
19450
|
+
name: "Reserved56"
|
|
19451
|
+
},
|
|
19452
|
+
{
|
|
19453
|
+
name: "Reserved57"
|
|
19454
|
+
},
|
|
19455
|
+
{
|
|
19456
|
+
name: "Reserved58"
|
|
19457
|
+
},
|
|
19458
|
+
{
|
|
19459
|
+
name: "Reserved59"
|
|
19460
|
+
},
|
|
19461
|
+
{
|
|
19462
|
+
name: "Reserved60"
|
|
19463
|
+
},
|
|
19464
|
+
{
|
|
19465
|
+
name: "Reserved61"
|
|
19466
|
+
},
|
|
19467
|
+
{
|
|
19468
|
+
name: "Reserved62"
|
|
19469
|
+
},
|
|
19470
|
+
{
|
|
19471
|
+
name: "Reserved63"
|
|
19314
19472
|
}
|
|
19315
19473
|
]
|
|
19316
19474
|
}
|
|
@@ -20731,6 +20889,16 @@ var OracleSetup = /* @__PURE__ */ ((OracleSetup3) => {
|
|
|
20731
20889
|
OracleSetup3["JuplendPythPull"] = "JuplendPythPull";
|
|
20732
20890
|
OracleSetup3["JuplendSwitchboardPull"] = "JuplendSwitchboardPull";
|
|
20733
20891
|
OracleSetup3["FixedJuplend"] = "FixedJuplend";
|
|
20892
|
+
OracleSetup3["Scope"] = "Scope";
|
|
20893
|
+
OracleSetup3["PythMSOL"] = "PythMSOL";
|
|
20894
|
+
OracleSetup3["KaminoMSOL"] = "KaminoMSOL";
|
|
20895
|
+
OracleSetup3["JuplendMSOL"] = "JuplendMSOL";
|
|
20896
|
+
OracleSetup3["PythLST"] = "PythLST";
|
|
20897
|
+
OracleSetup3["KaminoLST"] = "KaminoLST";
|
|
20898
|
+
OracleSetup3["JuplendLST"] = "JuplendLST";
|
|
20899
|
+
OracleSetup3["PTPyth"] = "PTPyth";
|
|
20900
|
+
OracleSetup3["PTFixed"] = "PTFixed";
|
|
20901
|
+
OracleSetup3["Unknown"] = "Unknown";
|
|
20734
20902
|
return OracleSetup3;
|
|
20735
20903
|
})(OracleSetup || {});
|
|
20736
20904
|
var AssetTag = /* @__PURE__ */ ((AssetTag3) => {
|
|
@@ -21792,8 +21960,26 @@ function serializeOracleSetupToIndex(oracleSetup) {
|
|
|
21792
21960
|
return 16;
|
|
21793
21961
|
case "FixedJuplend" /* FixedJuplend */:
|
|
21794
21962
|
return 17;
|
|
21963
|
+
case "Scope" /* Scope */:
|
|
21964
|
+
return 18;
|
|
21965
|
+
case "PythMSOL" /* PythMSOL */:
|
|
21966
|
+
return 19;
|
|
21967
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
21968
|
+
return 20;
|
|
21969
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
21970
|
+
return 21;
|
|
21971
|
+
case "PythLST" /* PythLST */:
|
|
21972
|
+
return 22;
|
|
21973
|
+
case "KaminoLST" /* KaminoLST */:
|
|
21974
|
+
return 23;
|
|
21975
|
+
case "JuplendLST" /* JuplendLST */:
|
|
21976
|
+
return 24;
|
|
21977
|
+
case "PTPyth" /* PTPyth */:
|
|
21978
|
+
return 25;
|
|
21979
|
+
case "PTFixed" /* PTFixed */:
|
|
21980
|
+
return 26;
|
|
21795
21981
|
default:
|
|
21796
|
-
|
|
21982
|
+
throw new Error(`Cannot serialize oracle setup "${oracleSetup}"`);
|
|
21797
21983
|
}
|
|
21798
21984
|
}
|
|
21799
21985
|
function serializeOracleSetup(oracleSetup) {
|
|
@@ -21834,6 +22020,24 @@ function serializeOracleSetup(oracleSetup) {
|
|
|
21834
22020
|
return { juplendSwitchboardPull: {} };
|
|
21835
22021
|
case "FixedJuplend" /* FixedJuplend */:
|
|
21836
22022
|
return { fixedJuplend: {} };
|
|
22023
|
+
case "Scope" /* Scope */:
|
|
22024
|
+
return { scope: {} };
|
|
22025
|
+
case "PythMSOL" /* PythMSOL */:
|
|
22026
|
+
return { pythMsol: {} };
|
|
22027
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
22028
|
+
return { kaminoMsol: {} };
|
|
22029
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
22030
|
+
return { juplendMsol: {} };
|
|
22031
|
+
case "PythLST" /* PythLST */:
|
|
22032
|
+
return { pythLst: {} };
|
|
22033
|
+
case "KaminoLST" /* KaminoLST */:
|
|
22034
|
+
return { kaminoLst: {} };
|
|
22035
|
+
case "JuplendLST" /* JuplendLST */:
|
|
22036
|
+
return { juplendLst: {} };
|
|
22037
|
+
case "PTPyth" /* PTPyth */:
|
|
22038
|
+
return { ptPyth: {} };
|
|
22039
|
+
case "PTFixed" /* PTFixed */:
|
|
22040
|
+
return { ptFixed: {} };
|
|
21837
22041
|
default:
|
|
21838
22042
|
throw new Error(`Invalid oracle setup "${oracleSetup}"`);
|
|
21839
22043
|
}
|
|
@@ -21947,7 +22151,8 @@ function toBankConfigDto(bankConfig) {
|
|
|
21947
22151
|
interestRateConfig: toInterestRateConfigDto(bankConfig.interestRateConfig),
|
|
21948
22152
|
configFlags: bankConfig.configFlags,
|
|
21949
22153
|
oracleMaxConfidence: bankConfig.oracleMaxConfidence,
|
|
21950
|
-
fixedPrice: bankConfig.fixedPrice.toString()
|
|
22154
|
+
fixedPrice: bankConfig.fixedPrice.toString(),
|
|
22155
|
+
scopeEntryIndex: bankConfig.scopeEntryIndex
|
|
21951
22156
|
};
|
|
21952
22157
|
}
|
|
21953
22158
|
function toInterestRateConfigDto(interestRateConfig) {
|
|
@@ -22053,7 +22258,8 @@ function bankConfigToBankConfigRaw(config) {
|
|
|
22053
22258
|
totalAssetValueInitLimit: new BN9__default.default(config.totalAssetValueInitLimit.toString()),
|
|
22054
22259
|
oracleMaxAge: config.oracleMaxAge,
|
|
22055
22260
|
oracleMaxConfidence: config.oracleMaxConfidence,
|
|
22056
|
-
fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice)
|
|
22261
|
+
fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice),
|
|
22262
|
+
scopeEntryIndex: config.scopeEntryIndex
|
|
22057
22263
|
};
|
|
22058
22264
|
}
|
|
22059
22265
|
function bankConfigRawToDto(bankConfigRaw) {
|
|
@@ -22074,7 +22280,8 @@ function bankConfigRawToDto(bankConfigRaw) {
|
|
|
22074
22280
|
interestRateConfig: bankConfigRaw.interestRateConfig,
|
|
22075
22281
|
configFlags: bankConfigRaw.configFlags,
|
|
22076
22282
|
oracleMaxConfidence: bankConfigRaw.oracleMaxConfidence,
|
|
22077
|
-
fixedPrice: bankConfigRaw.fixedPrice
|
|
22283
|
+
fixedPrice: bankConfigRaw.fixedPrice,
|
|
22284
|
+
scopeEntryIndex: bankConfigRaw.scopeEntryIndex
|
|
22078
22285
|
};
|
|
22079
22286
|
}
|
|
22080
22287
|
|
|
@@ -22362,7 +22569,8 @@ function dtoToBankConfig(bankConfigDto) {
|
|
|
22362
22569
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
22363
22570
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig),
|
|
22364
22571
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
22365
|
-
fixedPrice: new BigNumber3__default.default(bankConfigDto.fixedPrice)
|
|
22572
|
+
fixedPrice: new BigNumber3__default.default(bankConfigDto.fixedPrice),
|
|
22573
|
+
scopeEntryIndex: bankConfigDto.scopeEntryIndex ?? 0
|
|
22366
22574
|
};
|
|
22367
22575
|
}
|
|
22368
22576
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
@@ -22475,7 +22683,8 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
22475
22683
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
22476
22684
|
interestRateConfig: bankConfigDto.interestRateConfig,
|
|
22477
22685
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
22478
|
-
fixedPrice: bankConfigDto.fixedPrice
|
|
22686
|
+
fixedPrice: bankConfigDto.fixedPrice,
|
|
22687
|
+
scopeEntryIndex: bankConfigDto.scopeEntryIndex ?? 0
|
|
22479
22688
|
};
|
|
22480
22689
|
}
|
|
22481
22690
|
function parseBankConfigRaw(bankConfigRaw) {
|
|
@@ -22492,7 +22701,7 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
22492
22701
|
const configFlags = bankConfigRaw.configFlags;
|
|
22493
22702
|
const oracleSetup = parseOracleSetup(bankConfigRaw.oracleSetup);
|
|
22494
22703
|
const oracleKeys = bankConfigRaw.oracleKeys;
|
|
22495
|
-
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 ? DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
22704
|
+
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 && oracleSetup !== "Scope" /* Scope */ ? DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
22496
22705
|
const interestRateConfig = {
|
|
22497
22706
|
insuranceFeeFixedApr: wrappedI80F48toBigNumber(
|
|
22498
22707
|
bankConfigRaw.interestRateConfig.insuranceFeeFixedApr
|
|
@@ -22515,6 +22724,7 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
22515
22724
|
};
|
|
22516
22725
|
const oracleMaxConfidence = bankConfigRaw.oracleMaxConfidence;
|
|
22517
22726
|
const fixedPrice = wrappedI80F48toBigNumber(bankConfigRaw.fixedPrice);
|
|
22727
|
+
const scopeEntryIndex = bankConfigRaw.scopeEntryIndex ?? 0;
|
|
22518
22728
|
return {
|
|
22519
22729
|
assetWeightInit,
|
|
22520
22730
|
assetWeightMaint,
|
|
@@ -22532,7 +22742,8 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
22532
22742
|
oracleMaxAge,
|
|
22533
22743
|
interestRateConfig,
|
|
22534
22744
|
oracleMaxConfidence,
|
|
22535
|
-
fixedPrice
|
|
22745
|
+
fixedPrice,
|
|
22746
|
+
scopeEntryIndex
|
|
22536
22747
|
};
|
|
22537
22748
|
}
|
|
22538
22749
|
function parseRiskTier(riskTierRaw) {
|
|
@@ -22594,18 +22805,36 @@ function parseOracleSetup(oracleSetupRaw) {
|
|
|
22594
22805
|
return "SolendPythPull" /* SolendPythPull */;
|
|
22595
22806
|
case "solendswitchboardpull":
|
|
22596
22807
|
return "SolendSwitchboardPull" /* SolendSwitchboardPull */;
|
|
22597
|
-
case "
|
|
22808
|
+
case "fixedkamino":
|
|
22598
22809
|
return "FixedKamino" /* FixedKamino */;
|
|
22599
|
-
case "
|
|
22810
|
+
case "fixeddrift":
|
|
22600
22811
|
return "FixedDrift" /* FixedDrift */;
|
|
22601
22812
|
case "juplendpythpull":
|
|
22602
22813
|
return "JuplendPythPull" /* JuplendPythPull */;
|
|
22603
22814
|
case "juplendswitchboardpull":
|
|
22604
22815
|
return "JuplendSwitchboardPull" /* JuplendSwitchboardPull */;
|
|
22605
|
-
case "
|
|
22816
|
+
case "fixedjuplend":
|
|
22606
22817
|
return "FixedJuplend" /* FixedJuplend */;
|
|
22818
|
+
case "scope":
|
|
22819
|
+
return "Scope" /* Scope */;
|
|
22820
|
+
case "pythmsol":
|
|
22821
|
+
return "PythMSOL" /* PythMSOL */;
|
|
22822
|
+
case "kaminomsol":
|
|
22823
|
+
return "KaminoMSOL" /* KaminoMSOL */;
|
|
22824
|
+
case "juplendmsol":
|
|
22825
|
+
return "JuplendMSOL" /* JuplendMSOL */;
|
|
22826
|
+
case "pythlst":
|
|
22827
|
+
return "PythLST" /* PythLST */;
|
|
22828
|
+
case "kaminolst":
|
|
22829
|
+
return "KaminoLST" /* KaminoLST */;
|
|
22830
|
+
case "juplendlst":
|
|
22831
|
+
return "JuplendLST" /* JuplendLST */;
|
|
22832
|
+
case "ptpyth":
|
|
22833
|
+
return "PTPyth" /* PTPyth */;
|
|
22834
|
+
case "ptfixed":
|
|
22835
|
+
return "PTFixed" /* PTFixed */;
|
|
22607
22836
|
default:
|
|
22608
|
-
return "
|
|
22837
|
+
return "Unknown" /* Unknown */;
|
|
22609
22838
|
}
|
|
22610
22839
|
}
|
|
22611
22840
|
function getActiveEmodeFlags(flags) {
|
|
@@ -25736,6 +25965,17 @@ var categorizePythBanks = (banks) => {
|
|
|
25736
25965
|
const juplendPythPullBanks = banks.filter(
|
|
25737
25966
|
(bank) => bank.config.oracleSetup === "JuplendPythPull" /* JuplendPythPull */
|
|
25738
25967
|
);
|
|
25968
|
+
const pythMultipliedBanks = banks.filter(
|
|
25969
|
+
(bank) => [
|
|
25970
|
+
"PythMSOL" /* PythMSOL */,
|
|
25971
|
+
"KaminoMSOL" /* KaminoMSOL */,
|
|
25972
|
+
"JuplendMSOL" /* JuplendMSOL */,
|
|
25973
|
+
"PythLST" /* PythLST */,
|
|
25974
|
+
"KaminoLST" /* KaminoLST */,
|
|
25975
|
+
"JuplendLST" /* JuplendLST */,
|
|
25976
|
+
"PTPyth" /* PTPyth */
|
|
25977
|
+
].includes(bank.config.oracleSetup)
|
|
25978
|
+
);
|
|
25739
25979
|
return {
|
|
25740
25980
|
pythLegacyBanks,
|
|
25741
25981
|
pythPushBanks,
|
|
@@ -25743,7 +25983,8 @@ var categorizePythBanks = (banks) => {
|
|
|
25743
25983
|
pythPushKaminosBanks,
|
|
25744
25984
|
driftPythPullBanks,
|
|
25745
25985
|
solendPythPullBanks,
|
|
25746
|
-
juplendPythPullBanks
|
|
25986
|
+
juplendPythPullBanks,
|
|
25987
|
+
pythMultipliedBanks
|
|
25747
25988
|
};
|
|
25748
25989
|
};
|
|
25749
25990
|
var convertVoteAccCoeffsToBankCoeffs = (pythStakedCollateralBanks, validatorVoteAccountByBank, voteAccCoeffs) => {
|
|
@@ -25760,7 +26001,7 @@ var extractPythOracleKeys = (pythBanks) => {
|
|
|
25760
26001
|
const keys = pythBanks.map((bank) => bank.config.oracleKeys[0].toBase58());
|
|
25761
26002
|
return [...keys];
|
|
25762
26003
|
};
|
|
25763
|
-
var mapPythBanksToOraclePrices = (pythPushBanks,
|
|
26004
|
+
var mapPythBanksToOraclePrices = (pythPushBanks, multipliedBanks, oraclePrices, priceCoeffByBank) => {
|
|
25764
26005
|
const bankOraclePriceMap = /* @__PURE__ */ new Map();
|
|
25765
26006
|
pythPushBanks.forEach((bank) => {
|
|
25766
26007
|
const oracleKey = bank.config.oracleKeys[0].toBase58();
|
|
@@ -25769,7 +26010,7 @@ var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, orac
|
|
|
25769
26010
|
bankOraclePriceMap.set(bank.address.toBase58(), oraclePrice);
|
|
25770
26011
|
}
|
|
25771
26012
|
});
|
|
25772
|
-
|
|
26013
|
+
multipliedBanks.forEach((bank) => {
|
|
25773
26014
|
const priceCoeff = priceCoeffByBank[bank.address.toBase58()];
|
|
25774
26015
|
const oracleKey = bank.config.oracleKeys[0]?.toBase58();
|
|
25775
26016
|
if (oracleKey && priceCoeff !== void 0) {
|
|
@@ -25787,7 +26028,7 @@ var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, orac
|
|
|
25787
26028
|
};
|
|
25788
26029
|
var adjustPriceComponent = (priceComponent, priceCoeff) => ({
|
|
25789
26030
|
price: priceComponent.price.multipliedBy(priceCoeff),
|
|
25790
|
-
confidence: priceComponent.confidence,
|
|
26031
|
+
confidence: priceComponent.confidence.multipliedBy(priceCoeff),
|
|
25791
26032
|
lowestPrice: priceComponent.lowestPrice.multipliedBy(priceCoeff),
|
|
25792
26033
|
highestPrice: priceComponent.highestPrice.multipliedBy(priceCoeff)
|
|
25793
26034
|
});
|
|
@@ -25839,6 +26080,7 @@ var ORACLE_SOURCES = {
|
|
|
25839
26080
|
switchboard: "Switchboard",
|
|
25840
26081
|
pyth: "Pyth",
|
|
25841
26082
|
fixed: "Fixed",
|
|
26083
|
+
scope: "Scope",
|
|
25842
26084
|
unknown: "Unknown"
|
|
25843
26085
|
};
|
|
25844
26086
|
function getOracleSourceNameFromKey(oracleSourceKey) {
|
|
@@ -25865,14 +26107,25 @@ function getOracleSourceFromOracleSetup(oracleSetup) {
|
|
|
25865
26107
|
case "DriftPythPull" /* DriftPythPull */:
|
|
25866
26108
|
case "SolendPythPull" /* SolendPythPull */:
|
|
25867
26109
|
case "JuplendPythPull" /* JuplendPythPull */:
|
|
26110
|
+
case "PythMSOL" /* PythMSOL */:
|
|
26111
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
26112
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
26113
|
+
case "PythLST" /* PythLST */:
|
|
26114
|
+
case "KaminoLST" /* KaminoLST */:
|
|
26115
|
+
case "JuplendLST" /* JuplendLST */:
|
|
26116
|
+
case "PTPyth" /* PTPyth */:
|
|
25868
26117
|
oracleSourceKey = "pyth";
|
|
25869
26118
|
break;
|
|
25870
26119
|
case "Fixed" /* Fixed */:
|
|
25871
26120
|
case "FixedKamino" /* FixedKamino */:
|
|
25872
26121
|
case "FixedDrift" /* FixedDrift */:
|
|
25873
26122
|
case "FixedJuplend" /* FixedJuplend */:
|
|
26123
|
+
case "PTFixed" /* PTFixed */:
|
|
25874
26124
|
oracleSourceKey = "fixed";
|
|
25875
26125
|
break;
|
|
26126
|
+
case "Scope" /* Scope */:
|
|
26127
|
+
oracleSourceKey = "scope";
|
|
26128
|
+
break;
|
|
25876
26129
|
default:
|
|
25877
26130
|
oracleSourceKey = "unknown";
|
|
25878
26131
|
break;
|
|
@@ -27347,6 +27600,19 @@ function computeBankRiskAccountKeys(bank) {
|
|
|
27347
27600
|
if (bank.config.assetTag === 3 /* KAMINO */ || bank.config.assetTag === 4 /* DRIFT */ || bank.config.assetTag === 5 /* SOLEND */ || bank.config.assetTag === 6 /* JUPLEND */) {
|
|
27348
27601
|
keys.push(bank.config.oracleKeys[1]);
|
|
27349
27602
|
}
|
|
27603
|
+
switch (bank.config.oracleSetup) {
|
|
27604
|
+
case "PythMSOL" /* PythMSOL */:
|
|
27605
|
+
case "PythLST" /* PythLST */:
|
|
27606
|
+
case "PTPyth" /* PTPyth */:
|
|
27607
|
+
keys.push(bank.config.oracleKeys[1]);
|
|
27608
|
+
break;
|
|
27609
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
27610
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
27611
|
+
case "KaminoLST" /* KaminoLST */:
|
|
27612
|
+
case "JuplendLST" /* JuplendLST */:
|
|
27613
|
+
keys.push(bank.config.oracleKeys[2]);
|
|
27614
|
+
break;
|
|
27615
|
+
}
|
|
27350
27616
|
if (bank.config.assetTag === 2 /* STAKED */) {
|
|
27351
27617
|
keys.push(bank.config.oracleKeys[1], bank.config.oracleKeys[2]);
|
|
27352
27618
|
const onrampKey = bank.config.oracleKeys[3];
|
|
@@ -72101,7 +72367,9 @@ function decodeExponentVault(data) {
|
|
|
72101
72367
|
finalSyExchangeRate: exponentNumberToBigNumber(
|
|
72102
72368
|
get("final_sy_exchange_rate", "finalSyExchangeRate")
|
|
72103
72369
|
),
|
|
72104
|
-
status: Number(get("status", "status") ?? 0)
|
|
72370
|
+
status: Number(get("status", "status") ?? 0),
|
|
72371
|
+
startTs: Number(get("start_ts", "startTs") ?? 0),
|
|
72372
|
+
duration: Number(get("duration", "duration") ?? 0)
|
|
72105
72373
|
};
|
|
72106
72374
|
}
|
|
72107
72375
|
function decodeExponentMarketVault(data) {
|
|
@@ -74970,6 +75238,82 @@ function makeRefreshIntegrationBanksIxs(marginfiAccount, bankMap, banksToExclude
|
|
|
74970
75238
|
keys: [...kaminoRefreshIxs.keys, ...updateDriftMarketIxs.keys, ...updateJupLendRateIxs.keys]
|
|
74971
75239
|
};
|
|
74972
75240
|
}
|
|
75241
|
+
new web3_js.PublicKey("HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ");
|
|
75242
|
+
var SCOPE_ORACLE_PRICES_DISCRIMINATOR = Buffer.from([89, 128, 118, 221, 6, 72, 180, 146]);
|
|
75243
|
+
var SCOPE_MAX_ENTRIES = 512;
|
|
75244
|
+
var ENTRIES_OFFSET = 40;
|
|
75245
|
+
var DATED_PRICE_SIZE = 56;
|
|
75246
|
+
var SCOPE_ORACLE_PRICES_SIZE = ENTRIES_OFFSET + SCOPE_MAX_ENTRIES * DATED_PRICE_SIZE;
|
|
75247
|
+
function decodeScopePriceAtIndex(data, entryIndex) {
|
|
75248
|
+
if (data.length !== SCOPE_ORACLE_PRICES_SIZE) {
|
|
75249
|
+
throw new Error(`Invalid Scope OraclePrices account size: ${data.length}`);
|
|
75250
|
+
}
|
|
75251
|
+
if (!data.subarray(0, 8).equals(SCOPE_ORACLE_PRICES_DISCRIMINATOR)) {
|
|
75252
|
+
throw new Error("Invalid Scope OraclePrices discriminator");
|
|
75253
|
+
}
|
|
75254
|
+
if (entryIndex < 0 || entryIndex >= SCOPE_MAX_ENTRIES) {
|
|
75255
|
+
throw new Error(`Scope entry index out of range: ${entryIndex}`);
|
|
75256
|
+
}
|
|
75257
|
+
const offset = ENTRIES_OFFSET + entryIndex * DATED_PRICE_SIZE;
|
|
75258
|
+
const value = data.readBigUInt64LE(offset);
|
|
75259
|
+
const exp = data.readBigUInt64LE(offset + 8);
|
|
75260
|
+
const lastUpdatedSlot = data.readBigUInt64LE(offset + 16);
|
|
75261
|
+
const unixTimestamp = data.readBigUInt64LE(offset + 24);
|
|
75262
|
+
const price = new BigNumber3__default.default(value.toString()).shiftedBy(-Number(exp));
|
|
75263
|
+
return {
|
|
75264
|
+
price,
|
|
75265
|
+
lastUpdatedSlot: Number(lastUpdatedSlot),
|
|
75266
|
+
unixTimestamp: Number(unixTimestamp)
|
|
75267
|
+
};
|
|
75268
|
+
}
|
|
75269
|
+
new web3_js.PublicKey("MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD");
|
|
75270
|
+
var MARINADE_STATE_SIZE = 520;
|
|
75271
|
+
var MSOL_PRICE_OFFSET = 512;
|
|
75272
|
+
var MSOL_PRICE_PRECISION = new BigNumber3__default.default(2).pow(32);
|
|
75273
|
+
function decodeMarinadeState(data) {
|
|
75274
|
+
if (data.length !== MARINADE_STATE_SIZE) {
|
|
75275
|
+
throw new Error(`Invalid Marinade State account size: ${data.length}`);
|
|
75276
|
+
}
|
|
75277
|
+
const msolPriceRaw = data.readBigUInt64LE(MSOL_PRICE_OFFSET);
|
|
75278
|
+
return {
|
|
75279
|
+
msolPrice: new BigNumber3__default.default(msolPriceRaw.toString()).div(MSOL_PRICE_PRECISION)
|
|
75280
|
+
};
|
|
75281
|
+
}
|
|
75282
|
+
new web3_js.PublicKey(
|
|
75283
|
+
"SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy"
|
|
75284
|
+
);
|
|
75285
|
+
new web3_js.PublicKey(
|
|
75286
|
+
"SP12tWFxD9oJsVWNavTTBZvMbA6gkAmxtVgxdqvyvhY"
|
|
75287
|
+
);
|
|
75288
|
+
new web3_js.PublicKey(
|
|
75289
|
+
"SPMBzsVUuoHA4Jm6KunbsotaahvVikZs1JyTW6iJvbn"
|
|
75290
|
+
);
|
|
75291
|
+
var ACCOUNT_TYPE_STAKE_POOL = 1;
|
|
75292
|
+
var TOTAL_LAMPORTS_OFFSET = 258;
|
|
75293
|
+
var POOL_TOKEN_SUPPLY_OFFSET = 266;
|
|
75294
|
+
var LAST_UPDATE_EPOCH_OFFSET = 274;
|
|
75295
|
+
function decodeStakePool(data) {
|
|
75296
|
+
if (data.length < LAST_UPDATE_EPOCH_OFFSET + 8) {
|
|
75297
|
+
throw new Error(`Invalid StakePool account size: ${data.length}`);
|
|
75298
|
+
}
|
|
75299
|
+
if (data[0] !== ACCOUNT_TYPE_STAKE_POOL) {
|
|
75300
|
+
throw new Error(`Invalid StakePool account type: ${data[0]}`);
|
|
75301
|
+
}
|
|
75302
|
+
const totalLamports = data.readBigUInt64LE(TOTAL_LAMPORTS_OFFSET);
|
|
75303
|
+
const poolTokenSupply = data.readBigUInt64LE(POOL_TOKEN_SUPPLY_OFFSET);
|
|
75304
|
+
const lastUpdateEpoch = Number(data.readBigUInt64LE(LAST_UPDATE_EPOCH_OFFSET));
|
|
75305
|
+
if (poolTokenSupply === 0n) {
|
|
75306
|
+
throw new Error("StakePool has zero token supply");
|
|
75307
|
+
}
|
|
75308
|
+
return {
|
|
75309
|
+
totalLamports,
|
|
75310
|
+
poolTokenSupply,
|
|
75311
|
+
lastUpdateEpoch,
|
|
75312
|
+
exchangeRate: new BigNumber3__default.default(totalLamports.toString()).div(
|
|
75313
|
+
new BigNumber3__default.default(poolTokenSupply.toString())
|
|
75314
|
+
)
|
|
75315
|
+
};
|
|
75316
|
+
}
|
|
74973
75317
|
var GAMMA_VAULT_PROGRAM_ID = new web3_js.PublicKey(
|
|
74974
75318
|
"GaMmanX9i4jGmqDZZD2tbD6B2v9p21btenPneMXnTczV"
|
|
74975
75319
|
);
|
|
@@ -80577,16 +80921,17 @@ function chunkArray(array4, chunkSize) {
|
|
|
80577
80921
|
}
|
|
80578
80922
|
|
|
80579
80923
|
// src/services/price/services/pyth-oracle.service.ts
|
|
80580
|
-
var fetchPythOracleData = async (banks, opts) => {
|
|
80924
|
+
var fetchPythOracleData = async (banks, opts, priceCoeffByBank = {}) => {
|
|
80581
80925
|
const {
|
|
80582
80926
|
pythPushBanks,
|
|
80583
80927
|
pythStakedCollateralBanks,
|
|
80584
80928
|
pythPushKaminosBanks,
|
|
80585
80929
|
driftPythPullBanks,
|
|
80586
80930
|
solendPythPullBanks,
|
|
80587
|
-
juplendPythPullBanks
|
|
80931
|
+
juplendPythPullBanks,
|
|
80932
|
+
pythMultipliedBanks
|
|
80588
80933
|
} = categorizePythBanks(banks);
|
|
80589
|
-
if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length && !driftPythPullBanks.length && !solendPythPullBanks.length && !juplendPythPullBanks.length) {
|
|
80934
|
+
if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length && !driftPythPullBanks.length && !solendPythPullBanks.length && !juplendPythPullBanks.length && !pythMultipliedBanks.length) {
|
|
80590
80935
|
return {
|
|
80591
80936
|
bankOraclePriceMap: /* @__PURE__ */ new Map()
|
|
80592
80937
|
};
|
|
@@ -80597,9 +80942,9 @@ var fetchPythOracleData = async (banks, opts) => {
|
|
|
80597
80942
|
...pythPushKaminosBanks,
|
|
80598
80943
|
...driftPythPullBanks,
|
|
80599
80944
|
...solendPythPullBanks,
|
|
80600
|
-
...juplendPythPullBanks
|
|
80945
|
+
...juplendPythPullBanks,
|
|
80946
|
+
...pythMultipliedBanks
|
|
80601
80947
|
];
|
|
80602
|
-
const priceCoeffByBank = {};
|
|
80603
80948
|
const pythOracleKeys = extractPythOracleKeys(combinedPythBanks);
|
|
80604
80949
|
const uniquePythOracleKeys = Array.from(new Set(pythOracleKeys));
|
|
80605
80950
|
let oraclePrices;
|
|
@@ -80614,10 +80959,15 @@ var fetchPythOracleData = async (banks, opts) => {
|
|
|
80614
80959
|
}
|
|
80615
80960
|
const bankOraclePriceMap = mapPythBanksToOraclePrices(
|
|
80616
80961
|
combinedPythBanks,
|
|
80617
|
-
pythStakedCollateralBanks,
|
|
80962
|
+
[...pythStakedCollateralBanks, ...pythMultipliedBanks],
|
|
80618
80963
|
oraclePrices,
|
|
80619
80964
|
priceCoeffByBank
|
|
80620
80965
|
);
|
|
80966
|
+
pythMultipliedBanks.forEach((bank) => {
|
|
80967
|
+
if (priceCoeffByBank[bank.address.toBase58()] === void 0) {
|
|
80968
|
+
bankOraclePriceMap.delete(bank.address.toBase58());
|
|
80969
|
+
}
|
|
80970
|
+
});
|
|
80621
80971
|
return {
|
|
80622
80972
|
bankOraclePriceMap
|
|
80623
80973
|
};
|
|
@@ -80889,16 +81239,242 @@ async function fetchSingleCrossbarChunk(endpoint, swbFeedIdsChunk, isPrimary) {
|
|
|
80889
81239
|
throw error;
|
|
80890
81240
|
}
|
|
80891
81241
|
}
|
|
81242
|
+
var scopeRequestKey = (bank) => `${bank.config.oracleKeys[0].toBase58()}:${bank.config.scopeEntryIndex}`;
|
|
81243
|
+
var fetchScopeOracleData = async (banks, opts) => {
|
|
81244
|
+
const scopeBanks = banks.filter((bank) => getOracleSourceFromBank(bank).key === "scope");
|
|
81245
|
+
if (!scopeBanks.length) {
|
|
81246
|
+
return {
|
|
81247
|
+
bankOraclePriceMap: /* @__PURE__ */ new Map()
|
|
81248
|
+
};
|
|
81249
|
+
}
|
|
81250
|
+
const uniqueRequestKeys = Array.from(new Set(scopeBanks.map(scopeRequestKey)));
|
|
81251
|
+
let oraclePrices;
|
|
81252
|
+
if (opts.mode === "api") {
|
|
81253
|
+
oraclePrices = await fetchScopeOraclePricesFromAPI(
|
|
81254
|
+
uniqueRequestKeys,
|
|
81255
|
+
opts.scopeOnchainData.endpoint,
|
|
81256
|
+
{ queryKey: opts.scopeOnchainData.queryKey }
|
|
81257
|
+
);
|
|
81258
|
+
} else {
|
|
81259
|
+
oraclePrices = await fetchScopeOraclePricesFromChain(uniqueRequestKeys, opts.connection);
|
|
81260
|
+
}
|
|
81261
|
+
const bankOraclePriceMap = /* @__PURE__ */ new Map();
|
|
81262
|
+
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
81263
|
+
scopeBanks.forEach((bank) => {
|
|
81264
|
+
let oraclePrice = oraclePrices[scopeRequestKey(bank)];
|
|
81265
|
+
const isStale = !oraclePrice || nowSeconds - oraclePrice.timestamp.toNumber() > bank.config.oracleMaxAge;
|
|
81266
|
+
if (isStale) {
|
|
81267
|
+
oraclePrice = {
|
|
81268
|
+
priceRealtime: {
|
|
81269
|
+
price: new BigNumber3__default.default(0),
|
|
81270
|
+
confidence: new BigNumber3__default.default(0),
|
|
81271
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
81272
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
81273
|
+
},
|
|
81274
|
+
priceWeighted: {
|
|
81275
|
+
price: new BigNumber3__default.default(0),
|
|
81276
|
+
confidence: new BigNumber3__default.default(0),
|
|
81277
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
81278
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
81279
|
+
},
|
|
81280
|
+
timestamp: oraclePrice?.timestamp ?? new BigNumber3__default.default(0)
|
|
81281
|
+
};
|
|
81282
|
+
}
|
|
81283
|
+
bankOraclePriceMap.set(bank.address.toBase58(), oraclePrice);
|
|
81284
|
+
});
|
|
81285
|
+
return {
|
|
81286
|
+
bankOraclePriceMap
|
|
81287
|
+
};
|
|
81288
|
+
};
|
|
81289
|
+
var fetchScopeOraclePricesFromAPI = async (requestKeys, apiEndpoint, opts) => {
|
|
81290
|
+
const queryKey = opts?.queryKey ?? "scopeKeys";
|
|
81291
|
+
const response = await fetch(`${apiEndpoint}?${queryKey}=${requestKeys.join(",")}`);
|
|
81292
|
+
if (!response.ok) {
|
|
81293
|
+
throw new Error("Failed to fetch scope oracle data");
|
|
81294
|
+
}
|
|
81295
|
+
const { data } = await response.json();
|
|
81296
|
+
return Object.fromEntries(
|
|
81297
|
+
Object.entries(data).map(([key, oraclePrice]) => [
|
|
81298
|
+
key,
|
|
81299
|
+
{
|
|
81300
|
+
priceRealtime: {
|
|
81301
|
+
price: BigNumber3__default.default(oraclePrice.priceRealtime.price),
|
|
81302
|
+
confidence: BigNumber3__default.default(oraclePrice.priceRealtime.confidence),
|
|
81303
|
+
lowestPrice: BigNumber3__default.default(oraclePrice.priceRealtime.lowestPrice),
|
|
81304
|
+
highestPrice: BigNumber3__default.default(oraclePrice.priceRealtime.highestPrice)
|
|
81305
|
+
},
|
|
81306
|
+
priceWeighted: {
|
|
81307
|
+
price: BigNumber3__default.default(oraclePrice.priceWeighted.price),
|
|
81308
|
+
confidence: BigNumber3__default.default(oraclePrice.priceWeighted.confidence),
|
|
81309
|
+
lowestPrice: BigNumber3__default.default(oraclePrice.priceWeighted.lowestPrice),
|
|
81310
|
+
highestPrice: BigNumber3__default.default(oraclePrice.priceWeighted.highestPrice)
|
|
81311
|
+
},
|
|
81312
|
+
timestamp: BigNumber3__default.default(oraclePrice.timestamp)
|
|
81313
|
+
}
|
|
81314
|
+
])
|
|
81315
|
+
);
|
|
81316
|
+
};
|
|
81317
|
+
var fetchScopeOraclePricesFromChain = async (requestKeys, connection) => {
|
|
81318
|
+
const uniqueOracleKeys = Array.from(new Set(requestKeys.map((key) => key.split(":")[0])));
|
|
81319
|
+
const oracleAis = await chunkedGetRawMultipleAccountInfoOrdered(connection, uniqueOracleKeys);
|
|
81320
|
+
const accountDataByKey = {};
|
|
81321
|
+
uniqueOracleKeys.forEach((oracleKey, index) => {
|
|
81322
|
+
accountDataByKey[oracleKey] = oracleAis[index]?.data;
|
|
81323
|
+
});
|
|
81324
|
+
const oraclePriceByRequestKey = {};
|
|
81325
|
+
for (const requestKey of requestKeys) {
|
|
81326
|
+
const [oracleKey, entryIndexRaw] = requestKey.split(":");
|
|
81327
|
+
const data = accountDataByKey[oracleKey];
|
|
81328
|
+
let price = new BigNumber3__default.default(0);
|
|
81329
|
+
let timestamp = new BigNumber3__default.default(0);
|
|
81330
|
+
if (data) {
|
|
81331
|
+
try {
|
|
81332
|
+
const entry = decodeScopePriceAtIndex(data, Number(entryIndexRaw));
|
|
81333
|
+
price = entry.price;
|
|
81334
|
+
timestamp = new BigNumber3__default.default(entry.unixTimestamp);
|
|
81335
|
+
} catch (e) {
|
|
81336
|
+
console.error(`Failed to decode scope entry ${requestKey}`, e);
|
|
81337
|
+
}
|
|
81338
|
+
}
|
|
81339
|
+
oraclePriceByRequestKey[requestKey] = {
|
|
81340
|
+
priceRealtime: {
|
|
81341
|
+
price,
|
|
81342
|
+
confidence: new BigNumber3__default.default(0),
|
|
81343
|
+
lowestPrice: price,
|
|
81344
|
+
highestPrice: price
|
|
81345
|
+
},
|
|
81346
|
+
priceWeighted: {
|
|
81347
|
+
price,
|
|
81348
|
+
confidence: new BigNumber3__default.default(0),
|
|
81349
|
+
lowestPrice: price,
|
|
81350
|
+
highestPrice: price
|
|
81351
|
+
},
|
|
81352
|
+
timestamp
|
|
81353
|
+
};
|
|
81354
|
+
}
|
|
81355
|
+
return oraclePriceByRequestKey;
|
|
81356
|
+
};
|
|
81357
|
+
function multiplierAccountKey(bank) {
|
|
81358
|
+
switch (bank.config.oracleSetup) {
|
|
81359
|
+
case "PythMSOL" /* PythMSOL */:
|
|
81360
|
+
case "PythLST" /* PythLST */:
|
|
81361
|
+
case "PTPyth" /* PTPyth */:
|
|
81362
|
+
return bank.config.oracleKeys[1];
|
|
81363
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
81364
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
81365
|
+
case "KaminoLST" /* KaminoLST */:
|
|
81366
|
+
case "JuplendLST" /* JuplendLST */:
|
|
81367
|
+
return bank.config.oracleKeys[2];
|
|
81368
|
+
case "PTFixed" /* PTFixed */:
|
|
81369
|
+
return bank.config.oracleKeys[0];
|
|
81370
|
+
default:
|
|
81371
|
+
return void 0;
|
|
81372
|
+
}
|
|
81373
|
+
}
|
|
81374
|
+
function computePtMultiplier(vault, startPrice, nowSeconds) {
|
|
81375
|
+
const maturity = vault.startTs + vault.duration;
|
|
81376
|
+
let expectedRate;
|
|
81377
|
+
if (vault.duration <= 0 || nowSeconds <= vault.startTs) {
|
|
81378
|
+
expectedRate = startPrice;
|
|
81379
|
+
} else if (nowSeconds >= maturity) {
|
|
81380
|
+
expectedRate = new BigNumber3__default.default(1);
|
|
81381
|
+
} else {
|
|
81382
|
+
const progress = new BigNumber3__default.default(nowSeconds - vault.startTs).div(vault.duration);
|
|
81383
|
+
expectedRate = startPrice.plus(new BigNumber3__default.default(1).minus(startPrice).times(progress));
|
|
81384
|
+
}
|
|
81385
|
+
if (vault.ptSupply === 0n) {
|
|
81386
|
+
throw new Error("Exponent vault has zero PT supply");
|
|
81387
|
+
}
|
|
81388
|
+
const syPerPt = new BigNumber3__default.default(vault.syForPt.toString()).div(
|
|
81389
|
+
new BigNumber3__default.default(vault.ptSupply.toString())
|
|
81390
|
+
);
|
|
81391
|
+
const redemptionCap = syPerPt.times(vault.lastSeenSyExchangeRate);
|
|
81392
|
+
return BigNumber3__default.default.min(expectedRate, redemptionCap);
|
|
81393
|
+
}
|
|
81394
|
+
var fetchOracleMultipliers = async (banks, opts) => {
|
|
81395
|
+
const multipliedBanks = banks.filter((bank) => multiplierAccountKey(bank) !== void 0);
|
|
81396
|
+
if (!multipliedBanks.length) {
|
|
81397
|
+
return {};
|
|
81398
|
+
}
|
|
81399
|
+
if (opts.mode === "api") {
|
|
81400
|
+
return fetchOracleMultipliersFromAPI(
|
|
81401
|
+
multipliedBanks.map((bank) => bank.address.toBase58()),
|
|
81402
|
+
opts.multiplierData.endpoint,
|
|
81403
|
+
{ queryKey: opts.multiplierData.queryKey }
|
|
81404
|
+
);
|
|
81405
|
+
}
|
|
81406
|
+
return fetchOracleMultipliersFromChain(multipliedBanks, opts.connection);
|
|
81407
|
+
};
|
|
81408
|
+
var fetchOracleMultipliersFromAPI = async (bankAddresses, apiEndpoint, opts) => {
|
|
81409
|
+
const queryKey = opts?.queryKey ?? "bankAddresses";
|
|
81410
|
+
const response = await fetch(`${apiEndpoint}?${queryKey}=${bankAddresses.join(",")}`);
|
|
81411
|
+
if (!response.ok) {
|
|
81412
|
+
throw new Error("Failed to fetch price multiplier data");
|
|
81413
|
+
}
|
|
81414
|
+
const { data } = await response.json();
|
|
81415
|
+
return Object.fromEntries(
|
|
81416
|
+
Object.entries(data).map(([bankAddress, multiplier]) => [bankAddress, Number(multiplier)])
|
|
81417
|
+
);
|
|
81418
|
+
};
|
|
81419
|
+
var fetchOracleMultipliersFromChain = async (multipliedBanks, connection) => {
|
|
81420
|
+
const accountKeyByBank = new Map(
|
|
81421
|
+
multipliedBanks.map((bank) => [bank.address.toBase58(), multiplierAccountKey(bank).toBase58()])
|
|
81422
|
+
);
|
|
81423
|
+
const uniqueAccountKeys = Array.from(new Set(accountKeyByBank.values()));
|
|
81424
|
+
const accountAis = await chunkedGetRawMultipleAccountInfoOrdered(connection, uniqueAccountKeys);
|
|
81425
|
+
const accountDataByKey = {};
|
|
81426
|
+
uniqueAccountKeys.forEach((accountKey, index) => {
|
|
81427
|
+
accountDataByKey[accountKey] = accountAis[index]?.data;
|
|
81428
|
+
});
|
|
81429
|
+
const multiplierByBank = {};
|
|
81430
|
+
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
81431
|
+
for (const bank of multipliedBanks) {
|
|
81432
|
+
const bankAddress = bank.address.toBase58();
|
|
81433
|
+
const data = accountDataByKey[accountKeyByBank.get(bankAddress)];
|
|
81434
|
+
if (!data) {
|
|
81435
|
+
console.error(`Missing multiplier account for bank ${bankAddress}`);
|
|
81436
|
+
continue;
|
|
81437
|
+
}
|
|
81438
|
+
try {
|
|
81439
|
+
switch (bank.config.oracleSetup) {
|
|
81440
|
+
case "PythMSOL" /* PythMSOL */:
|
|
81441
|
+
case "KaminoMSOL" /* KaminoMSOL */:
|
|
81442
|
+
case "JuplendMSOL" /* JuplendMSOL */:
|
|
81443
|
+
multiplierByBank[bankAddress] = decodeMarinadeState(data).msolPrice.toNumber();
|
|
81444
|
+
break;
|
|
81445
|
+
case "PythLST" /* PythLST */:
|
|
81446
|
+
case "KaminoLST" /* KaminoLST */:
|
|
81447
|
+
case "JuplendLST" /* JuplendLST */:
|
|
81448
|
+
multiplierByBank[bankAddress] = decodeStakePool(data).exchangeRate.toNumber();
|
|
81449
|
+
break;
|
|
81450
|
+
case "PTPyth" /* PTPyth */:
|
|
81451
|
+
case "PTFixed" /* PTFixed */:
|
|
81452
|
+
multiplierByBank[bankAddress] = computePtMultiplier(
|
|
81453
|
+
decodeExponentVault(data),
|
|
81454
|
+
bank.config.fixedPrice,
|
|
81455
|
+
nowSeconds
|
|
81456
|
+
).toNumber();
|
|
81457
|
+
break;
|
|
81458
|
+
}
|
|
81459
|
+
} catch (e) {
|
|
81460
|
+
console.error(`Failed to compute multiplier for bank ${bankAddress}`, e);
|
|
81461
|
+
}
|
|
81462
|
+
}
|
|
81463
|
+
return multiplierByBank;
|
|
81464
|
+
};
|
|
80892
81465
|
var fetchOracleData = async (banks, opts) => {
|
|
80893
81466
|
const { zeroOracleBanks, isolatedAssetBanks, collateralAssetBanks, fixedAssetBanks } = classifyBanksForOracleStrategy(banks);
|
|
80894
81467
|
const zeroResults = handleZeroOracleBanks(zeroOracleBanks);
|
|
80895
81468
|
const fetchIsolatedPrice = opts?.isolatedBanksOpts?.fetchPrices ?? false;
|
|
80896
81469
|
const isolatedResults = fetchIsolatedPrice ? handleIsolatedAssetBanks(isolatedAssetBanks, opts?.isolatedBanksOpts?.staticPricesByBank) : /* @__PURE__ */ new Map();
|
|
80897
|
-
const
|
|
81470
|
+
const multiplierByBank = await fetchOracleMultipliers(banks, opts.oracleMultiplierOpts);
|
|
81471
|
+
const fixedResults = handleFixedOracleBanks(fixedAssetBanks, multiplierByBank);
|
|
80898
81472
|
const assetBanks = [...collateralAssetBanks, ...fetchIsolatedPrice ? isolatedAssetBanks : []];
|
|
80899
81473
|
const assetResults = await handleAssetBanks(assetBanks, {
|
|
80900
81474
|
pythOpts: opts.pythOpts,
|
|
80901
|
-
swbOpts: opts.swbOpts
|
|
81475
|
+
swbOpts: opts.swbOpts,
|
|
81476
|
+
scopeOpts: opts.scopeOpts,
|
|
81477
|
+
priceCoeffByBank: multiplierByBank
|
|
80902
81478
|
});
|
|
80903
81479
|
return mergeOracleResults([zeroResults, isolatedResults, assetResults, fixedResults], banks);
|
|
80904
81480
|
};
|
|
@@ -80932,10 +81508,11 @@ function classifyBanksForOracleStrategy(banks) {
|
|
|
80932
81508
|
fixedAssetBanks
|
|
80933
81509
|
};
|
|
80934
81510
|
}
|
|
80935
|
-
function handleFixedOracleBanks(banks) {
|
|
81511
|
+
function handleFixedOracleBanks(banks, multiplierByBank) {
|
|
80936
81512
|
const oracleMap = /* @__PURE__ */ new Map();
|
|
80937
81513
|
banks.forEach((bank) => {
|
|
80938
|
-
const
|
|
81514
|
+
const multiplier = multiplierByBank[bank.address.toBase58()];
|
|
81515
|
+
const fixedPrice = bank.config.oracleSetup === "PTFixed" /* PTFixed */ && multiplier !== void 0 ? BigNumber3__default.default(multiplier) : bank.config.fixedPrice;
|
|
80939
81516
|
const fixedOraclePrice = {
|
|
80940
81517
|
priceRealtime: {
|
|
80941
81518
|
price: fixedPrice,
|
|
@@ -81004,9 +81581,10 @@ async function handleAssetBanks(banks, opts) {
|
|
|
81004
81581
|
if (banks.length === 0) {
|
|
81005
81582
|
return /* @__PURE__ */ new Map();
|
|
81006
81583
|
}
|
|
81007
|
-
const [pythData, swbData] = await Promise.all([
|
|
81008
|
-
fetchPythOracleData(banks, opts.pythOpts),
|
|
81009
|
-
fetchSwbOracleData(banks, opts.swbOpts)
|
|
81584
|
+
const [pythData, swbData, scopeData] = await Promise.all([
|
|
81585
|
+
fetchPythOracleData(banks, opts.pythOpts, opts.priceCoeffByBank),
|
|
81586
|
+
fetchSwbOracleData(banks, opts.swbOpts),
|
|
81587
|
+
fetchScopeOracleData(banks, opts.scopeOpts)
|
|
81010
81588
|
]);
|
|
81011
81589
|
const bankOraclePriceMap = /* @__PURE__ */ new Map();
|
|
81012
81590
|
pythData.bankOraclePriceMap.forEach((oraclePrice, bankAddress) => {
|
|
@@ -81015,6 +81593,9 @@ async function handleAssetBanks(banks, opts) {
|
|
|
81015
81593
|
swbData.bankOraclePriceMap.forEach((oraclePrice, bankAddress) => {
|
|
81016
81594
|
bankOraclePriceMap.set(bankAddress, oraclePrice);
|
|
81017
81595
|
});
|
|
81596
|
+
scopeData.bankOraclePriceMap.forEach((oraclePrice, bankAddress) => {
|
|
81597
|
+
bankOraclePriceMap.set(bankAddress, oraclePrice);
|
|
81598
|
+
});
|
|
81018
81599
|
banks.forEach((bank) => {
|
|
81019
81600
|
const bankAddress = bank.address.toBase58();
|
|
81020
81601
|
const oraclePrice = bankOraclePriceMap.get(bankAddress);
|
|
@@ -83397,7 +83978,8 @@ var Bank = class _Bank {
|
|
|
83397
83978
|
bankType.config.operationalState,
|
|
83398
83979
|
bankType.config.oracleMaxConfidence,
|
|
83399
83980
|
bankType.config.fixedPrice,
|
|
83400
|
-
bankType.config.configFlags
|
|
83981
|
+
bankType.config.configFlags,
|
|
83982
|
+
bankType.config.scopeEntryIndex
|
|
83401
83983
|
);
|
|
83402
83984
|
return new _Bank(
|
|
83403
83985
|
bankType.address,
|
|
@@ -83566,7 +84148,7 @@ var Bank = class _Bank {
|
|
|
83566
84148
|
}
|
|
83567
84149
|
};
|
|
83568
84150
|
var BankConfig = class _BankConfig {
|
|
83569
|
-
constructor(assetWeightInit, assetWeightMaint, liabilityWeightInit, liabilityWeightMaint, depositLimit, borrowLimit, riskTier, totalAssetValueInitLimit, assetTag, oracleSetup, oracleKeys, oracleMaxAge, interestRateConfig, operationalState, oracleMaxConfidence, fixedPrice, configFlags) {
|
|
84151
|
+
constructor(assetWeightInit, assetWeightMaint, liabilityWeightInit, liabilityWeightMaint, depositLimit, borrowLimit, riskTier, totalAssetValueInitLimit, assetTag, oracleSetup, oracleKeys, oracleMaxAge, interestRateConfig, operationalState, oracleMaxConfidence, fixedPrice, configFlags, scopeEntryIndex = 0) {
|
|
83570
84152
|
this.assetWeightInit = assetWeightInit;
|
|
83571
84153
|
this.assetWeightMaint = assetWeightMaint;
|
|
83572
84154
|
this.liabilityWeightInit = liabilityWeightInit;
|
|
@@ -83584,6 +84166,7 @@ var BankConfig = class _BankConfig {
|
|
|
83584
84166
|
this.oracleMaxConfidence = oracleMaxConfidence;
|
|
83585
84167
|
this.fixedPrice = fixedPrice;
|
|
83586
84168
|
this.configFlags = configFlags;
|
|
84169
|
+
this.scopeEntryIndex = scopeEntryIndex;
|
|
83587
84170
|
}
|
|
83588
84171
|
static fromAccountParsed(bankConfigRaw) {
|
|
83589
84172
|
const bankConfig = parseBankConfigRaw(bankConfigRaw);
|
|
@@ -83604,7 +84187,8 @@ var BankConfig = class _BankConfig {
|
|
|
83604
84187
|
bankConfig.operationalState,
|
|
83605
84188
|
bankConfig.oracleMaxConfidence,
|
|
83606
84189
|
bankConfig.fixedPrice,
|
|
83607
|
-
bankConfig.configFlags
|
|
84190
|
+
bankConfig.configFlags,
|
|
84191
|
+
bankConfig.scopeEntryIndex
|
|
83608
84192
|
);
|
|
83609
84193
|
}
|
|
83610
84194
|
};
|
|
@@ -84783,6 +85367,14 @@ var Project0Client = class _Project0Client {
|
|
|
84783
85367
|
mode: "on-chain",
|
|
84784
85368
|
connection
|
|
84785
85369
|
},
|
|
85370
|
+
scopeOpts: {
|
|
85371
|
+
mode: "on-chain",
|
|
85372
|
+
connection
|
|
85373
|
+
},
|
|
85374
|
+
oracleMultiplierOpts: {
|
|
85375
|
+
mode: "on-chain",
|
|
85376
|
+
connection
|
|
85377
|
+
},
|
|
84786
85378
|
isolatedBanksOpts: {
|
|
84787
85379
|
fetchPrices: true
|
|
84788
85380
|
}
|
|
@@ -85054,6 +85646,7 @@ exports.computeBankMetrics = computeBankMetrics;
|
|
|
85054
85646
|
exports.computeBankPoolSize = computeBankPoolSize;
|
|
85055
85647
|
exports.computeBankProjectedAvailableLiquidity = computeBankProjectedAvailableLiquidity;
|
|
85056
85648
|
exports.computeBankRateLimitRemaining = computeBankRateLimitRemaining;
|
|
85649
|
+
exports.computeBankRiskAccountKeys = computeBankRiskAccountKeys;
|
|
85057
85650
|
exports.computeBankSupplyApy = computeBankSupplyApy;
|
|
85058
85651
|
exports.computeBankTotalBorrows = computeBankTotalBorrows;
|
|
85059
85652
|
exports.computeBankTotalBorrowsUsd = computeBankTotalBorrowsUsd;
|
|
@@ -85087,6 +85680,7 @@ exports.computeMaxWithdrawForBank = computeMaxWithdrawForBank;
|
|
|
85087
85680
|
exports.computeNetApy = computeNetApy;
|
|
85088
85681
|
exports.computeProjectedActiveBalancesNoCpi = computeProjectedActiveBalancesNoCpi;
|
|
85089
85682
|
exports.computeProjectedActiveBanksNoCpi = computeProjectedActiveBanksNoCpi;
|
|
85683
|
+
exports.computePtMultiplier = computePtMultiplier;
|
|
85090
85684
|
exports.computeQuantity = computeQuantity;
|
|
85091
85685
|
exports.computeQuantityUi = computeQuantityUi;
|
|
85092
85686
|
exports.computeRateLimitWindowRemainingCapacity = computeRateLimitWindowRemainingCapacity;
|
|
@@ -85151,10 +85745,16 @@ exports.fetchMarginfiAccountData = fetchMarginfiAccountData;
|
|
|
85151
85745
|
exports.fetchMultipleBanks = fetchMultipleBanks;
|
|
85152
85746
|
exports.fetchNativeStakeAccounts = fetchNativeStakeAccounts;
|
|
85153
85747
|
exports.fetchOracleData = fetchOracleData;
|
|
85748
|
+
exports.fetchOracleMultipliers = fetchOracleMultipliers;
|
|
85749
|
+
exports.fetchOracleMultipliersFromAPI = fetchOracleMultipliersFromAPI;
|
|
85750
|
+
exports.fetchOracleMultipliersFromChain = fetchOracleMultipliersFromChain;
|
|
85154
85751
|
exports.fetchProgramForMints = fetchProgramForMints;
|
|
85155
85752
|
exports.fetchPythOracleData = fetchPythOracleData;
|
|
85156
85753
|
exports.fetchPythOraclePricesFromAPI = fetchPythOraclePricesFromAPI;
|
|
85157
85754
|
exports.fetchPythOraclePricesFromChain = fetchPythOraclePricesFromChain;
|
|
85755
|
+
exports.fetchScopeOracleData = fetchScopeOracleData;
|
|
85756
|
+
exports.fetchScopeOraclePricesFromAPI = fetchScopeOraclePricesFromAPI;
|
|
85757
|
+
exports.fetchScopeOraclePricesFromChain = fetchScopeOraclePricesFromChain;
|
|
85158
85758
|
exports.fetchStakeAccount = fetchStakeAccount;
|
|
85159
85759
|
exports.fetchStakePoolActiveStates = fetchStakePoolActiveStates;
|
|
85160
85760
|
exports.fetchStakePoolMev = fetchStakePoolMev;
|