@0dotxyz/p0-ts-sdk 2.3.2 → 2.4.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/dto-rate-model.types-DWB7J91n.d.cts +860 -0
- package/dist/dto-rate-model.types-DWB7J91n.d.ts +860 -0
- package/dist/index.cjs +353 -738
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -20
- package/dist/index.d.ts +99 -20
- package/dist/index.js +345 -737
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +2 -2
- package/dist/instructions.d.ts +2 -2
- package/dist/{types-Cxl2AUvk.d.ts → types-DDP4jEc9.d.cts} +10 -10
- package/dist/{types-DtUR-yHt.d.cts → types-rBQYamIi.d.ts} +10 -10
- package/dist/vendor.cjs +256 -722
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +605 -26
- package/dist/vendor.d.ts +605 -26
- package/dist/vendor.js +247 -713
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
- package/dist/dto-rate-model.types-DveIB9Ll.d.cts +0 -1726
- package/dist/dto-rate-model.types-DveIB9Ll.d.ts +0 -1726
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
4
|
var superstruct = require('superstruct');
|
|
5
5
|
var BigNumber3 = require('bignumber.js');
|
|
6
|
-
var
|
|
6
|
+
var BN8 = require('bn.js');
|
|
7
7
|
var Decimal3 = require('decimal.js');
|
|
8
8
|
var anchor = require('@coral-xyz/anchor');
|
|
9
9
|
var bufferLayout = require('@solana/buffer-layout');
|
|
@@ -38,7 +38,7 @@ function _interopNamespace(e) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
var BigNumber3__default = /*#__PURE__*/_interopDefault(BigNumber3);
|
|
41
|
-
var
|
|
41
|
+
var BN8__default = /*#__PURE__*/_interopDefault(BN8);
|
|
42
42
|
var Decimal3__default = /*#__PURE__*/_interopDefault(Decimal3);
|
|
43
43
|
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
44
44
|
var borsh__namespace = /*#__PURE__*/_interopNamespace(borsh);
|
|
@@ -231,6 +231,15 @@ var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
|
231
231
|
return new _TransactionBuildingError(code, message, details);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
+
var DECOMPOSABLE_SWAP_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
235
|
+
"SWAP_SIZE_EXCEEDED_LOOP" /* SWAP_SIZE_EXCEEDED_LOOP */,
|
|
236
|
+
"SWAP_SIZE_EXCEEDED_REPAY" /* SWAP_SIZE_EXCEEDED_REPAY */,
|
|
237
|
+
"SWAP_SIZE_EXCEEDED_POSITION_SWAP" /* SWAP_SIZE_EXCEEDED_POSITION_SWAP */,
|
|
238
|
+
"SWAP_QUOTE_FAILED" /* SWAP_QUOTE_FAILED */
|
|
239
|
+
]);
|
|
240
|
+
function isDecomposableSwapError(e) {
|
|
241
|
+
return e instanceof TransactionBuildingError && DECOMPOSABLE_SWAP_ERROR_CODES.has(e.code);
|
|
242
|
+
}
|
|
234
243
|
var PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED = Buffer.from("liquidity_vault_auth");
|
|
235
244
|
var PDA_BANK_INSURANCE_VAULT_AUTH_SEED = Buffer.from("insurance_vault_auth");
|
|
236
245
|
var PDA_BANK_FEE_VAULT_AUTH_SEED = Buffer.from("fee_vault_auth");
|
|
@@ -423,7 +432,7 @@ function bigNumberToWrappedI80F48(value) {
|
|
|
423
432
|
let decimalValue = new Decimal3.Decimal(value.toString());
|
|
424
433
|
const isNegative = decimalValue.isNegative();
|
|
425
434
|
decimalValue = decimalValue.times(I80F48_DIVISOR);
|
|
426
|
-
let wrappedValue = new
|
|
435
|
+
let wrappedValue = new BN8__default.default(decimalValue.round().toFixed()).toArray();
|
|
427
436
|
if (wrappedValue.length < I80F48_TOTAL_BYTES) {
|
|
428
437
|
const padding = Array(I80F48_TOTAL_BYTES - wrappedValue.length).fill(0);
|
|
429
438
|
wrappedValue.unshift(...padding);
|
|
@@ -457,7 +466,7 @@ function toBigNumber(amount) {
|
|
|
457
466
|
}
|
|
458
467
|
function uiToNative(amount, decimals) {
|
|
459
468
|
let amt = toBigNumber(amount);
|
|
460
|
-
return new
|
|
469
|
+
return new BN8__default.default(amt.times(10 ** decimals).toFixed(0, BigNumber3__default.default.ROUND_FLOOR));
|
|
461
470
|
}
|
|
462
471
|
function uiToNativeBigNumber(amount, decimals) {
|
|
463
472
|
let amt = toBigNumber(amount);
|
|
@@ -15798,7 +15807,7 @@ async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remain
|
|
|
15798
15807
|
tokenProgram = TOKEN_PROGRAM_ID,
|
|
15799
15808
|
...optionalAccounts
|
|
15800
15809
|
} = accounts;
|
|
15801
|
-
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new
|
|
15810
|
+
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN8__default.default(0)).accounts({
|
|
15802
15811
|
stakedSettings,
|
|
15803
15812
|
feePayer,
|
|
15804
15813
|
bankMint,
|
|
@@ -15862,7 +15871,7 @@ var instructions = {
|
|
|
15862
15871
|
var instructions_default = instructions;
|
|
15863
15872
|
function serializeBankConfigOpt(bankConfigOpt) {
|
|
15864
15873
|
const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
|
|
15865
|
-
const toBN = (value) => value && new
|
|
15874
|
+
const toBN = (value) => value && new BN8__default.default(value.toString());
|
|
15866
15875
|
return {
|
|
15867
15876
|
assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
|
|
15868
15877
|
assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
|
|
@@ -16215,16 +16224,16 @@ function bankConfigToBankConfigRaw(config) {
|
|
|
16215
16224
|
assetWeightMaint: bigNumberToWrappedI80F48(config.assetWeightMaint),
|
|
16216
16225
|
liabilityWeightInit: bigNumberToWrappedI80F48(config.liabilityWeightInit),
|
|
16217
16226
|
liabilityWeightMaint: bigNumberToWrappedI80F48(config.liabilityWeightMaint),
|
|
16218
|
-
depositLimit: new
|
|
16227
|
+
depositLimit: new BN8__default.default(config.depositLimit.toString()),
|
|
16219
16228
|
interestRateConfig: serializeInterestRateConfig(config.interestRateConfig),
|
|
16220
16229
|
operationalState: serializeOperationalState(config.operationalState),
|
|
16221
16230
|
oracleSetup: serializeOracleSetup(config.oracleSetup),
|
|
16222
16231
|
oracleKeys: config.oracleKeys,
|
|
16223
16232
|
configFlags: config.configFlags,
|
|
16224
|
-
borrowLimit: new
|
|
16233
|
+
borrowLimit: new BN8__default.default(config.borrowLimit.toString()),
|
|
16225
16234
|
riskTier: serializeRiskTier(config.riskTier),
|
|
16226
16235
|
assetTag: config.assetTag,
|
|
16227
|
-
totalAssetValueInitLimit: new
|
|
16236
|
+
totalAssetValueInitLimit: new BN8__default.default(config.totalAssetValueInitLimit.toString()),
|
|
16228
16237
|
oracleMaxAge: config.oracleMaxAge,
|
|
16229
16238
|
oracleMaxConfidence: config.oracleMaxConfidence,
|
|
16230
16239
|
fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice)
|
|
@@ -16556,12 +16565,12 @@ function dtoToBankRaw(bankDto) {
|
|
|
16556
16565
|
feeVaultBump: bankDto.feeVaultBump,
|
|
16557
16566
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
16558
16567
|
collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
|
|
16559
|
-
lastUpdate: new
|
|
16568
|
+
lastUpdate: new BN8__default.default(bankDto.lastUpdate),
|
|
16560
16569
|
config: dtoToBankConfigRaw(bankDto.config),
|
|
16561
16570
|
totalAssetShares: bankDto.totalAssetShares,
|
|
16562
16571
|
totalLiabilityShares: bankDto.totalLiabilityShares,
|
|
16563
|
-
flags: new
|
|
16564
|
-
emissionsRate: new
|
|
16572
|
+
flags: new BN8__default.default(bankDto.flags),
|
|
16573
|
+
emissionsRate: new BN8__default.default(bankDto.emissionsRate),
|
|
16565
16574
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
16566
16575
|
emissionsMint: new web3_js.PublicKey(bankDto.emissionsMint),
|
|
16567
16576
|
collectedProgramFeesOutstanding: bankDto.collectedProgramFeesOutstanding,
|
|
@@ -16577,11 +16586,11 @@ function dtoToBankRaw(bankDto) {
|
|
|
16577
16586
|
}
|
|
16578
16587
|
function dtoToRateLimitWindowRaw(window) {
|
|
16579
16588
|
return {
|
|
16580
|
-
maxOutflow: new
|
|
16581
|
-
windowDuration: new
|
|
16582
|
-
windowStart: new
|
|
16583
|
-
prevWindowOutflow: new
|
|
16584
|
-
curWindowOutflow: new
|
|
16589
|
+
maxOutflow: new BN8__default.default(window.maxOutflow),
|
|
16590
|
+
windowDuration: new BN8__default.default(window.windowDuration),
|
|
16591
|
+
windowStart: new BN8__default.default(window.windowStart),
|
|
16592
|
+
prevWindowOutflow: new BN8__default.default(window.prevWindowOutflow),
|
|
16593
|
+
curWindowOutflow: new BN8__default.default(window.curWindowOutflow)
|
|
16585
16594
|
};
|
|
16586
16595
|
}
|
|
16587
16596
|
function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
@@ -16593,8 +16602,8 @@ function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
|
16593
16602
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
16594
16603
|
return {
|
|
16595
16604
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
16596
|
-
timestamp: new
|
|
16597
|
-
flags: new
|
|
16605
|
+
timestamp: new BN8__default.default(emodeSettingsDto.timestamp),
|
|
16606
|
+
flags: new BN8__default.default(emodeSettingsDto.flags),
|
|
16598
16607
|
emodeConfig: {
|
|
16599
16608
|
entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
|
|
16600
16609
|
return {
|
|
@@ -16613,11 +16622,11 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
16613
16622
|
assetWeightMaint: bankConfigDto.assetWeightMaint,
|
|
16614
16623
|
liabilityWeightInit: bankConfigDto.liabilityWeightInit,
|
|
16615
16624
|
liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
|
|
16616
|
-
depositLimit: new
|
|
16617
|
-
borrowLimit: new
|
|
16625
|
+
depositLimit: new BN8__default.default(bankConfigDto.depositLimit),
|
|
16626
|
+
borrowLimit: new BN8__default.default(bankConfigDto.borrowLimit),
|
|
16618
16627
|
riskTier: bankConfigDto.riskTier,
|
|
16619
16628
|
operationalState: bankConfigDto.operationalState,
|
|
16620
|
-
totalAssetValueInitLimit: new
|
|
16629
|
+
totalAssetValueInitLimit: new BN8__default.default(bankConfigDto.totalAssetValueInitLimit),
|
|
16621
16630
|
assetTag: bankConfigDto.assetTag,
|
|
16622
16631
|
configFlags: bankConfigDto.configFlags,
|
|
16623
16632
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
@@ -16765,7 +16774,7 @@ function getActiveEmodeFlags(flags) {
|
|
|
16765
16774
|
return activeFlags;
|
|
16766
16775
|
}
|
|
16767
16776
|
function hasEmodeFlag(flags, flag) {
|
|
16768
|
-
return !flags.and(new
|
|
16777
|
+
return !flags.and(new BN8__default.default(flag)).isZero();
|
|
16769
16778
|
}
|
|
16770
16779
|
function getActiveEmodeEntryFlags(flags) {
|
|
16771
16780
|
const activeFlags = [];
|
|
@@ -19754,8 +19763,8 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
|
|
|
19754
19763
|
const crossbarData = crossbarResponse[oracleFeed]?.results;
|
|
19755
19764
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19756
19765
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19757
|
-
crossbarData ?? new
|
|
19758
|
-
new
|
|
19766
|
+
crossbarData ?? new BN8__default.default(oracleData.rawPrice),
|
|
19767
|
+
new BN8__default.default(oracleData.stdev),
|
|
19759
19768
|
timestamp,
|
|
19760
19769
|
oracleData
|
|
19761
19770
|
);
|
|
@@ -19781,7 +19790,7 @@ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse
|
|
|
19781
19790
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19782
19791
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19783
19792
|
[birdeyeData],
|
|
19784
|
-
new
|
|
19793
|
+
new BN8__default.default(oracleData.stdev),
|
|
19785
19794
|
timestamp,
|
|
19786
19795
|
oracleData
|
|
19787
19796
|
);
|
|
@@ -20397,7 +20406,7 @@ var EMPTY_HEALTH_CACHE = {
|
|
|
20397
20406
|
liabilityValue: {
|
|
20398
20407
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
20399
20408
|
},
|
|
20400
|
-
timestamp: new
|
|
20409
|
+
timestamp: new BN8__default.default(0),
|
|
20401
20410
|
flags: 0,
|
|
20402
20411
|
prices: [],
|
|
20403
20412
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
@@ -20484,7 +20493,7 @@ function getActiveAccountFlags(flags) {
|
|
|
20484
20493
|
return activeFlags;
|
|
20485
20494
|
}
|
|
20486
20495
|
function hasAccountFlag(flags, flag) {
|
|
20487
|
-
return !flags.and(new
|
|
20496
|
+
return !flags.and(new BN8__default.default(flag)).isZero();
|
|
20488
20497
|
}
|
|
20489
20498
|
function getActiveHealthCacheFlags(flags) {
|
|
20490
20499
|
const activeFlags = [];
|
|
@@ -20554,7 +20563,7 @@ function dtoToHealthCache(healthCacheDto) {
|
|
|
20554
20563
|
};
|
|
20555
20564
|
}
|
|
20556
20565
|
function accountFlagToBN(flag) {
|
|
20557
|
-
return new
|
|
20566
|
+
return new BN8__default.default(flag);
|
|
20558
20567
|
}
|
|
20559
20568
|
function marginfiAccountToDto(marginfiAccount) {
|
|
20560
20569
|
return {
|
|
@@ -35744,23 +35753,23 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35744
35753
|
authority: new web3_js.PublicKey(userStatsDto.authority),
|
|
35745
35754
|
referrer: new web3_js.PublicKey(userStatsDto.referrer),
|
|
35746
35755
|
fees: {
|
|
35747
|
-
totalFeePaid: new
|
|
35748
|
-
totalFeeRebate: new
|
|
35749
|
-
totalTokenDiscount: new
|
|
35750
|
-
totalRefereeDiscount: new
|
|
35751
|
-
totalReferrerReward: new
|
|
35752
|
-
currentEpochReferrerReward: new
|
|
35756
|
+
totalFeePaid: new BN8__default.default(userStatsDto.fees.totalFeePaid),
|
|
35757
|
+
totalFeeRebate: new BN8__default.default(userStatsDto.fees.totalFeeRebate),
|
|
35758
|
+
totalTokenDiscount: new BN8__default.default(userStatsDto.fees.totalTokenDiscount),
|
|
35759
|
+
totalRefereeDiscount: new BN8__default.default(userStatsDto.fees.totalRefereeDiscount),
|
|
35760
|
+
totalReferrerReward: new BN8__default.default(userStatsDto.fees.totalReferrerReward),
|
|
35761
|
+
currentEpochReferrerReward: new BN8__default.default(
|
|
35753
35762
|
userStatsDto.fees.currentEpochReferrerReward
|
|
35754
35763
|
)
|
|
35755
35764
|
},
|
|
35756
|
-
nextEpochTs: new
|
|
35757
|
-
makerVolume30d: new
|
|
35758
|
-
takerVolume30d: new
|
|
35759
|
-
fillerVolume30d: new
|
|
35760
|
-
lastMakerVolume30dTs: new
|
|
35761
|
-
lastTakerVolume30dTs: new
|
|
35762
|
-
lastFillerVolume30dTs: new
|
|
35763
|
-
ifStakedQuoteAssetAmount: new
|
|
35765
|
+
nextEpochTs: new BN8__default.default(userStatsDto.nextEpochTs),
|
|
35766
|
+
makerVolume30d: new BN8__default.default(userStatsDto.makerVolume30d),
|
|
35767
|
+
takerVolume30d: new BN8__default.default(userStatsDto.takerVolume30d),
|
|
35768
|
+
fillerVolume30d: new BN8__default.default(userStatsDto.fillerVolume30d),
|
|
35769
|
+
lastMakerVolume30dTs: new BN8__default.default(userStatsDto.lastMakerVolume30dTs),
|
|
35770
|
+
lastTakerVolume30dTs: new BN8__default.default(userStatsDto.lastTakerVolume30dTs),
|
|
35771
|
+
lastFillerVolume30dTs: new BN8__default.default(userStatsDto.lastFillerVolume30dTs),
|
|
35772
|
+
ifStakedQuoteAssetAmount: new BN8__default.default(userStatsDto.ifStakedQuoteAssetAmount),
|
|
35764
35773
|
numberOfSubAccounts: userStatsDto.numberOfSubAccounts,
|
|
35765
35774
|
numberOfSubAccountsCreated: userStatsDto.numberOfSubAccountsCreated,
|
|
35766
35775
|
referrerStatus: userStatsDto.referrerStatus,
|
|
@@ -35773,7 +35782,7 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35773
35782
|
fuelPositions: userStatsDto.fuelPositions,
|
|
35774
35783
|
fuelTaker: userStatsDto.fuelTaker,
|
|
35775
35784
|
fuelMaker: userStatsDto.fuelMaker,
|
|
35776
|
-
ifStakedGovTokenAmount: new
|
|
35785
|
+
ifStakedGovTokenAmount: new BN8__default.default(userStatsDto.ifStakedGovTokenAmount),
|
|
35777
35786
|
lastFuelIfBonusUpdateTs: userStatsDto.lastFuelIfBonusUpdateTs,
|
|
35778
35787
|
padding: userStatsDto.padding
|
|
35779
35788
|
};
|
|
@@ -35782,10 +35791,10 @@ function dtoToDriftUserRaw(userDto) {
|
|
|
35782
35791
|
return {
|
|
35783
35792
|
authority: new web3_js.PublicKey(userDto.authority),
|
|
35784
35793
|
spotPositions: userDto.spotPositions.map((p) => ({
|
|
35785
|
-
scaledBalance: new
|
|
35786
|
-
openBids: new
|
|
35787
|
-
openAsks: new
|
|
35788
|
-
cumulativeDeposits: new
|
|
35794
|
+
scaledBalance: new BN8__default.default(p.scaledBalance),
|
|
35795
|
+
openBids: new BN8__default.default(p.openBids),
|
|
35796
|
+
openAsks: new BN8__default.default(p.openAsks),
|
|
35797
|
+
cumulativeDeposits: new BN8__default.default(p.cumulativeDeposits),
|
|
35789
35798
|
marketIndex: p.marketIndex,
|
|
35790
35799
|
balanceType: p.balanceType,
|
|
35791
35800
|
openOrders: p.openOrders,
|
|
@@ -35800,10 +35809,10 @@ function dtoToDriftRewardsRaw(rewardsDto) {
|
|
|
35800
35809
|
spotMarket: new web3_js.PublicKey(rewardsDto.spotMarket),
|
|
35801
35810
|
mint: new web3_js.PublicKey(rewardsDto.mint),
|
|
35802
35811
|
spotPosition: {
|
|
35803
|
-
scaledBalance: new
|
|
35804
|
-
openBids: new
|
|
35805
|
-
openAsks: new
|
|
35806
|
-
cumulativeDeposits: new
|
|
35812
|
+
scaledBalance: new BN8__default.default(rewardsDto.spotPosition.scaledBalance),
|
|
35813
|
+
openBids: new BN8__default.default(rewardsDto.spotPosition.openBids),
|
|
35814
|
+
openAsks: new BN8__default.default(rewardsDto.spotPosition.openAsks),
|
|
35815
|
+
cumulativeDeposits: new BN8__default.default(rewardsDto.spotPosition.cumulativeDeposits),
|
|
35807
35816
|
marketIndex: rewardsDto.spotPosition.marketIndex,
|
|
35808
35817
|
balanceType: rewardsDto.spotPosition.balanceType,
|
|
35809
35818
|
openOrders: rewardsDto.spotPosition.openOrders,
|
|
@@ -35817,11 +35826,11 @@ function dtoToDriftSpotMarketRaw(spotMarketDto) {
|
|
|
35817
35826
|
oracle: new web3_js.PublicKey(spotMarketDto.oracle),
|
|
35818
35827
|
mint: new web3_js.PublicKey(spotMarketDto.mint),
|
|
35819
35828
|
decimals: spotMarketDto.decimals,
|
|
35820
|
-
cumulativeDepositInterest: new
|
|
35829
|
+
cumulativeDepositInterest: new BN8__default.default(spotMarketDto.cumulativeDepositInterest),
|
|
35821
35830
|
marketIndex: spotMarketDto.marketIndex,
|
|
35822
|
-
depositBalance: new
|
|
35823
|
-
borrowBalance: new
|
|
35824
|
-
cumulativeBorrowInterest: new
|
|
35831
|
+
depositBalance: new BN8__default.default(spotMarketDto.depositBalance),
|
|
35832
|
+
borrowBalance: new BN8__default.default(spotMarketDto.borrowBalance),
|
|
35833
|
+
cumulativeBorrowInterest: new BN8__default.default(spotMarketDto.cumulativeBorrowInterest),
|
|
35825
35834
|
optimalUtilization: spotMarketDto.optimalUtilization,
|
|
35826
35835
|
optimalBorrowRate: spotMarketDto.optimalBorrowRate,
|
|
35827
35836
|
maxBorrowRate: spotMarketDto.maxBorrowRate,
|
|
@@ -35910,10 +35919,10 @@ function decodeDriftUserData(data) {
|
|
|
35910
35919
|
return {
|
|
35911
35920
|
authority: decoded.authority,
|
|
35912
35921
|
spotPositions: decoded.spot_positions.map((p) => ({
|
|
35913
|
-
scaledBalance: new
|
|
35914
|
-
openBids: new
|
|
35915
|
-
openAsks: new
|
|
35916
|
-
cumulativeDeposits: new
|
|
35922
|
+
scaledBalance: new BN8__default.default(p.scaled_balance),
|
|
35923
|
+
openBids: new BN8__default.default(p.open_bids),
|
|
35924
|
+
openAsks: new BN8__default.default(p.open_asks),
|
|
35925
|
+
cumulativeDeposits: new BN8__default.default(p.cumulative_deposits),
|
|
35917
35926
|
marketIndex: p.market_index,
|
|
35918
35927
|
balanceType: p.balance_type,
|
|
35919
35928
|
openOrders: p.open_orders,
|
|
@@ -35983,7 +35992,7 @@ function deriveDriftSpotMarket(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
35983
35992
|
return web3_js.PublicKey.findProgramAddressSync(
|
|
35984
35993
|
[
|
|
35985
35994
|
Buffer.from(SEED_SPOT_MARKET),
|
|
35986
|
-
new
|
|
35995
|
+
new BN8__default.default(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
35987
35996
|
],
|
|
35988
35997
|
programId
|
|
35989
35998
|
);
|
|
@@ -35992,7 +36001,7 @@ function deriveDriftSpotMarketVault(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
35992
36001
|
return web3_js.PublicKey.findProgramAddressSync(
|
|
35993
36002
|
[
|
|
35994
36003
|
Buffer.from(SEED_SPOT_MARKET_VAULT),
|
|
35995
|
-
new
|
|
36004
|
+
new BN8__default.default(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
35996
36005
|
],
|
|
35997
36006
|
programId
|
|
35998
36007
|
);
|
|
@@ -36386,7 +36395,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36386
36395
|
assetShares: dummyWrappedI80F48,
|
|
36387
36396
|
liabilityShares: dummyWrappedI80F48,
|
|
36388
36397
|
emissionsOutstanding: dummyWrappedI80F48,
|
|
36389
|
-
lastUpdate: new
|
|
36398
|
+
lastUpdate: new BN8__default.default(0)
|
|
36390
36399
|
});
|
|
36391
36400
|
const rawAccount = {
|
|
36392
36401
|
group,
|
|
@@ -36399,7 +36408,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36399
36408
|
liabilityValue: {
|
|
36400
36409
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
36401
36410
|
},
|
|
36402
|
-
timestamp: new
|
|
36411
|
+
timestamp: new BN8__default.default(0),
|
|
36403
36412
|
flags: 0,
|
|
36404
36413
|
prices: [],
|
|
36405
36414
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
@@ -36413,7 +36422,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36413
36422
|
mrgnErr: 0
|
|
36414
36423
|
},
|
|
36415
36424
|
emissionsDestinationAccount: new web3_js.PublicKey("11111111111111111111111111111111"),
|
|
36416
|
-
accountFlags: new
|
|
36425
|
+
accountFlags: new BN8__default.default([0, 0, 0])
|
|
36417
36426
|
};
|
|
36418
36427
|
return parseMarginfiAccountRaw(accountKey, rawAccount);
|
|
36419
36428
|
}
|
|
@@ -36446,233 +36455,63 @@ async function makeRefreshingIxs({
|
|
|
36446
36455
|
}
|
|
36447
36456
|
|
|
36448
36457
|
// src/vendor/klend/utils/klend/serialize.utils.ts
|
|
36449
|
-
function
|
|
36450
|
-
return {
|
|
36451
|
-
tag: obligationRaw.tag.toString(),
|
|
36452
|
-
lastUpdate: {
|
|
36453
|
-
slot: obligationRaw.lastUpdate.slot.toString(),
|
|
36454
|
-
stale: obligationRaw.lastUpdate.stale,
|
|
36455
|
-
priceStatus: obligationRaw.lastUpdate.priceStatus,
|
|
36456
|
-
placeholder: obligationRaw.lastUpdate.placeholder
|
|
36457
|
-
},
|
|
36458
|
-
lendingMarket: obligationRaw.lendingMarket.toBase58(),
|
|
36459
|
-
owner: obligationRaw.owner.toBase58(),
|
|
36460
|
-
deposits: obligationRaw.deposits.map(
|
|
36461
|
-
(item) => obligationCollateralToDto(item)
|
|
36462
|
-
),
|
|
36463
|
-
lowestReserveDepositLiquidationLtv: obligationRaw.lowestReserveDepositLiquidationLtv.toString(),
|
|
36464
|
-
depositedValueSf: obligationRaw.depositedValueSf.toString(),
|
|
36465
|
-
borrows: obligationRaw.borrows.map(
|
|
36466
|
-
(item) => obligationLiquidityToDto(item)
|
|
36467
|
-
),
|
|
36468
|
-
borrowFactorAdjustedDebtValueSf: obligationRaw.borrowFactorAdjustedDebtValueSf.toString(),
|
|
36469
|
-
borrowedAssetsMarketValueSf: obligationRaw.borrowedAssetsMarketValueSf.toString(),
|
|
36470
|
-
allowedBorrowValueSf: obligationRaw.allowedBorrowValueSf.toString(),
|
|
36471
|
-
unhealthyBorrowValueSf: obligationRaw.unhealthyBorrowValueSf.toString(),
|
|
36472
|
-
depositsAssetTiers: obligationRaw.depositsAssetTiers,
|
|
36473
|
-
borrowsAssetTiers: obligationRaw.borrowsAssetTiers,
|
|
36474
|
-
elevationGroup: obligationRaw.elevationGroup,
|
|
36475
|
-
numOfObsoleteDepositReserves: obligationRaw.numOfObsoleteDepositReserves,
|
|
36476
|
-
hasDebt: obligationRaw.hasDebt,
|
|
36477
|
-
referrer: obligationRaw.referrer.toBase58(),
|
|
36478
|
-
borrowingDisabled: obligationRaw.borrowingDisabled,
|
|
36479
|
-
autodeleverageTargetLtvPct: obligationRaw.autodeleverageTargetLtvPct,
|
|
36480
|
-
lowestReserveDepositMaxLtvPct: obligationRaw.lowestReserveDepositMaxLtvPct,
|
|
36481
|
-
numOfObsoleteBorrowReserves: obligationRaw.numOfObsoleteBorrowReserves,
|
|
36482
|
-
reserved: obligationRaw.reserved,
|
|
36483
|
-
highestBorrowFactorPct: obligationRaw.highestBorrowFactorPct.toString(),
|
|
36484
|
-
autodeleverageMarginCallStartedTimestamp: obligationRaw.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
36485
|
-
orders: obligationRaw.orders.map((item) => obligationOrderToDto(item)),
|
|
36486
|
-
padding3: obligationRaw.padding3.map((item) => item.toString())
|
|
36487
|
-
};
|
|
36488
|
-
}
|
|
36489
|
-
function reserveRawToDto(reserveRaw) {
|
|
36490
|
-
return {
|
|
36491
|
-
version: reserveRaw.version.toString(),
|
|
36492
|
-
lastUpdate: {
|
|
36493
|
-
slot: reserveRaw.lastUpdate.slot.toString(),
|
|
36494
|
-
stale: reserveRaw.lastUpdate.stale,
|
|
36495
|
-
priceStatus: reserveRaw.lastUpdate.priceStatus,
|
|
36496
|
-
placeholder: reserveRaw.lastUpdate.placeholder
|
|
36497
|
-
},
|
|
36498
|
-
lendingMarket: reserveRaw.lendingMarket.toBase58(),
|
|
36499
|
-
farmCollateral: reserveRaw.farmCollateral.toBase58(),
|
|
36500
|
-
farmDebt: reserveRaw.farmDebt.toBase58(),
|
|
36501
|
-
liquidity: reserveLiquidityFieldsToDto(reserveRaw.liquidity),
|
|
36502
|
-
reserveLiquidityPadding: reserveRaw.reserveLiquidityPadding.map(
|
|
36503
|
-
(item) => item.toString()
|
|
36504
|
-
),
|
|
36505
|
-
collateral: {
|
|
36506
|
-
mintPubkey: reserveRaw.collateral.mintPubkey.toBase58(),
|
|
36507
|
-
mintTotalSupply: reserveRaw.collateral.mintTotalSupply.toString(),
|
|
36508
|
-
supplyVault: reserveRaw.collateral.supplyVault.toBase58(),
|
|
36509
|
-
padding1: reserveRaw.collateral.padding1.map((item) => item.toString()),
|
|
36510
|
-
padding2: reserveRaw.collateral.padding2.map((item) => item.toString())
|
|
36511
|
-
},
|
|
36512
|
-
reserveCollateralPadding: reserveRaw.reserveCollateralPadding.map(
|
|
36513
|
-
(item) => item.toString()
|
|
36514
|
-
),
|
|
36515
|
-
config: reserveConfigFieldsToDto(reserveRaw.config),
|
|
36516
|
-
configPadding: reserveRaw.configPadding.map((item) => item.toString()),
|
|
36517
|
-
borrowedAmountOutsideElevationGroup: reserveRaw.borrowedAmountOutsideElevationGroup.toString(),
|
|
36518
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveRaw.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
36519
|
-
(item) => item.toString()
|
|
36520
|
-
),
|
|
36521
|
-
padding: reserveRaw.padding.map((item) => item.toString())
|
|
36522
|
-
};
|
|
36523
|
-
}
|
|
36524
|
-
function reserveLiquidityFieldsToDto(reserveLiquidityFields) {
|
|
36525
|
-
return {
|
|
36526
|
-
mintPubkey: reserveLiquidityFields.mintPubkey.toBase58(),
|
|
36527
|
-
supplyVault: reserveLiquidityFields.supplyVault.toBase58(),
|
|
36528
|
-
feeVault: reserveLiquidityFields.feeVault.toBase58(),
|
|
36529
|
-
availableAmount: reserveLiquidityFields.availableAmount.toString(),
|
|
36530
|
-
borrowedAmountSf: reserveLiquidityFields.borrowedAmountSf.toString(),
|
|
36531
|
-
marketPriceSf: reserveLiquidityFields.marketPriceSf.toString(),
|
|
36532
|
-
marketPriceLastUpdatedTs: reserveLiquidityFields.marketPriceLastUpdatedTs.toString(),
|
|
36533
|
-
mintDecimals: reserveLiquidityFields.mintDecimals.toString(),
|
|
36534
|
-
depositLimitCrossedTimestamp: reserveLiquidityFields.depositLimitCrossedTimestamp.toString(),
|
|
36535
|
-
borrowLimitCrossedTimestamp: reserveLiquidityFields.borrowLimitCrossedTimestamp.toString(),
|
|
36536
|
-
cumulativeBorrowRateBsf: {
|
|
36537
|
-
value: reserveLiquidityFields.cumulativeBorrowRateBsf.value.map(
|
|
36538
|
-
(item) => item.toString()
|
|
36539
|
-
),
|
|
36540
|
-
padding: reserveLiquidityFields.cumulativeBorrowRateBsf.padding.map(
|
|
36541
|
-
(item) => item.toString()
|
|
36542
|
-
)
|
|
36543
|
-
},
|
|
36544
|
-
accumulatedProtocolFeesSf: reserveLiquidityFields.accumulatedProtocolFeesSf.toString(),
|
|
36545
|
-
accumulatedReferrerFeesSf: reserveLiquidityFields.accumulatedReferrerFeesSf.toString(),
|
|
36546
|
-
pendingReferrerFeesSf: reserveLiquidityFields.pendingReferrerFeesSf.toString(),
|
|
36547
|
-
absoluteReferralRateSf: reserveLiquidityFields.absoluteReferralRateSf.toString(),
|
|
36548
|
-
tokenProgram: reserveLiquidityFields.tokenProgram.toBase58(),
|
|
36549
|
-
padding2: reserveLiquidityFields.padding2.map((item) => item.toString()),
|
|
36550
|
-
padding3: reserveLiquidityFields.padding3.map((item) => item.toString())
|
|
36551
|
-
};
|
|
36552
|
-
}
|
|
36553
|
-
function reserveConfigFieldsToDto(reserveConfigFields) {
|
|
36554
|
-
return {
|
|
36555
|
-
status: reserveConfigFields.status,
|
|
36556
|
-
assetTier: reserveConfigFields.assetTier,
|
|
36557
|
-
hostFixedInterestRateBps: reserveConfigFields.hostFixedInterestRateBps,
|
|
36558
|
-
reserved2: reserveConfigFields.reserved2,
|
|
36559
|
-
protocolOrderExecutionFeePct: reserveConfigFields.protocolOrderExecutionFeePct,
|
|
36560
|
-
protocolTakeRatePct: reserveConfigFields.protocolTakeRatePct,
|
|
36561
|
-
protocolLiquidationFeePct: reserveConfigFields.protocolLiquidationFeePct,
|
|
36562
|
-
loanToValuePct: reserveConfigFields.loanToValuePct,
|
|
36563
|
-
liquidationThresholdPct: reserveConfigFields.liquidationThresholdPct,
|
|
36564
|
-
minLiquidationBonusBps: reserveConfigFields.minLiquidationBonusBps,
|
|
36565
|
-
maxLiquidationBonusBps: reserveConfigFields.maxLiquidationBonusBps,
|
|
36566
|
-
badDebtLiquidationBonusBps: reserveConfigFields.badDebtLiquidationBonusBps,
|
|
36567
|
-
deleveragingMarginCallPeriodSecs: reserveConfigFields.deleveragingMarginCallPeriodSecs.toString(),
|
|
36568
|
-
deleveragingThresholdDecreaseBpsPerDay: reserveConfigFields.deleveragingThresholdDecreaseBpsPerDay.toString(),
|
|
36569
|
-
fees: {
|
|
36570
|
-
borrowFeeSf: reserveConfigFields.fees.borrowFeeSf.toString(),
|
|
36571
|
-
flashLoanFeeSf: reserveConfigFields.fees.flashLoanFeeSf.toString(),
|
|
36572
|
-
padding: reserveConfigFields.fees.padding
|
|
36573
|
-
},
|
|
36574
|
-
borrowRateCurve: {
|
|
36575
|
-
points: reserveConfigFields.borrowRateCurve.points.map((item) => ({
|
|
36576
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
36577
|
-
borrowRateBps: item.borrowRateBps
|
|
36578
|
-
}))
|
|
36579
|
-
},
|
|
36580
|
-
borrowFactorPct: reserveConfigFields.borrowFactorPct.toString(),
|
|
36581
|
-
depositLimit: reserveConfigFields.depositLimit.toString(),
|
|
36582
|
-
borrowLimit: reserveConfigFields.borrowLimit.toString(),
|
|
36583
|
-
tokenInfo: tokenInfoFieldsToDto(reserveConfigFields.tokenInfo),
|
|
36584
|
-
depositWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36585
|
-
reserveConfigFields.depositWithdrawalCap
|
|
36586
|
-
),
|
|
36587
|
-
debtWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36588
|
-
reserveConfigFields.debtWithdrawalCap
|
|
36589
|
-
),
|
|
36590
|
-
elevationGroups: reserveConfigFields.elevationGroups,
|
|
36591
|
-
disableUsageAsCollOutsideEmode: reserveConfigFields.disableUsageAsCollOutsideEmode,
|
|
36592
|
-
utilizationLimitBlockBorrowingAbovePct: reserveConfigFields.utilizationLimitBlockBorrowingAbovePct,
|
|
36593
|
-
autodeleverageEnabled: reserveConfigFields.autodeleverageEnabled,
|
|
36594
|
-
reserved1: reserveConfigFields.reserved1,
|
|
36595
|
-
borrowLimitOutsideElevationGroup: reserveConfigFields.borrowLimitOutsideElevationGroup.toString(),
|
|
36596
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveConfigFields.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
36597
|
-
(item) => item.toString()
|
|
36598
|
-
),
|
|
36599
|
-
deleveragingBonusIncreaseBpsPerDay: reserveConfigFields.deleveragingBonusIncreaseBpsPerDay.toString()
|
|
36600
|
-
};
|
|
36601
|
-
}
|
|
36602
|
-
function tokenInfoFieldsToDto(tokenInfoFields) {
|
|
36603
|
-
return {
|
|
36604
|
-
name: tokenInfoFields.name,
|
|
36605
|
-
heuristic: {
|
|
36606
|
-
lower: tokenInfoFields.heuristic.lower.toString(),
|
|
36607
|
-
upper: tokenInfoFields.heuristic.upper.toString(),
|
|
36608
|
-
exp: tokenInfoFields.heuristic.exp.toString()
|
|
36609
|
-
},
|
|
36610
|
-
maxTwapDivergenceBps: tokenInfoFields.maxTwapDivergenceBps.toString(),
|
|
36611
|
-
maxAgePriceSeconds: tokenInfoFields.maxAgePriceSeconds.toString(),
|
|
36612
|
-
maxAgeTwapSeconds: tokenInfoFields.maxAgeTwapSeconds.toString(),
|
|
36613
|
-
scopeConfiguration: {
|
|
36614
|
-
priceFeed: tokenInfoFields.scopeConfiguration.priceFeed.toBase58(),
|
|
36615
|
-
priceChain: tokenInfoFields.scopeConfiguration.priceChain,
|
|
36616
|
-
twapChain: tokenInfoFields.scopeConfiguration.twapChain
|
|
36617
|
-
},
|
|
36618
|
-
switchboardConfiguration: {
|
|
36619
|
-
priceAggregator: tokenInfoFields.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36620
|
-
twapAggregator: tokenInfoFields.switchboardConfiguration.twapAggregator.toBase58()
|
|
36621
|
-
},
|
|
36622
|
-
pythConfiguration: {
|
|
36623
|
-
price: tokenInfoFields.pythConfiguration.price.toBase58()
|
|
36624
|
-
},
|
|
36625
|
-
blockPriceUsage: tokenInfoFields.blockPriceUsage,
|
|
36626
|
-
reserved: tokenInfoFields.reserved,
|
|
36627
|
-
padding: tokenInfoFields.padding.map((item) => item.toString())
|
|
36628
|
-
};
|
|
36629
|
-
}
|
|
36630
|
-
function withdrawalCapsFieldsToDto(withdrawalCapsFields) {
|
|
36458
|
+
function kaminoObligationToDto(obligation) {
|
|
36631
36459
|
return {
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
|
|
36635
|
-
|
|
36636
|
-
|
|
36637
|
-
|
|
36638
|
-
|
|
36639
|
-
|
|
36640
|
-
|
|
36641
|
-
|
|
36642
|
-
|
|
36643
|
-
|
|
36644
|
-
padding: obligationCollateralFields.padding.map((item) => item.toString())
|
|
36460
|
+
lendingMarket: obligation.lendingMarket.toBase58(),
|
|
36461
|
+
owner: obligation.owner.toBase58(),
|
|
36462
|
+
deposits: obligation.deposits.map((item) => ({
|
|
36463
|
+
depositReserve: item.depositReserve.toBase58(),
|
|
36464
|
+
depositedAmount: item.depositedAmount.toString(),
|
|
36465
|
+
marketValueSf: item.marketValueSf.toString()
|
|
36466
|
+
})),
|
|
36467
|
+
borrows: obligation.borrows.map((item) => ({
|
|
36468
|
+
borrowReserve: item.borrowReserve.toBase58(),
|
|
36469
|
+
borrowedAmountSf: item.borrowedAmountSf.toString(),
|
|
36470
|
+
marketValueSf: item.marketValueSf.toString()
|
|
36471
|
+
}))
|
|
36645
36472
|
};
|
|
36646
36473
|
}
|
|
36647
|
-
function
|
|
36474
|
+
function kaminoReserveToDto(reserve) {
|
|
36648
36475
|
return {
|
|
36649
|
-
|
|
36650
|
-
|
|
36651
|
-
|
|
36652
|
-
|
|
36653
|
-
),
|
|
36654
|
-
|
|
36655
|
-
|
|
36656
|
-
)
|
|
36476
|
+
lendingMarket: reserve.lendingMarket.toBase58(),
|
|
36477
|
+
farmCollateral: reserve.farmCollateral.toBase58(),
|
|
36478
|
+
liquidity: {
|
|
36479
|
+
mintPubkey: reserve.liquidity.mintPubkey.toBase58(),
|
|
36480
|
+
supplyVault: reserve.liquidity.supplyVault.toBase58(),
|
|
36481
|
+
mintDecimals: reserve.liquidity.mintDecimals.toString(),
|
|
36482
|
+
availableAmount: reserve.liquidity.availableAmount.toString(),
|
|
36483
|
+
borrowedAmountSf: reserve.liquidity.borrowedAmountSf.toString(),
|
|
36484
|
+
accumulatedProtocolFeesSf: reserve.liquidity.accumulatedProtocolFeesSf.toString(),
|
|
36485
|
+
accumulatedReferrerFeesSf: reserve.liquidity.accumulatedReferrerFeesSf.toString(),
|
|
36486
|
+
pendingReferrerFeesSf: reserve.liquidity.pendingReferrerFeesSf.toString()
|
|
36657
36487
|
},
|
|
36658
|
-
|
|
36659
|
-
|
|
36660
|
-
|
|
36661
|
-
|
|
36662
|
-
|
|
36663
|
-
|
|
36664
|
-
|
|
36665
|
-
|
|
36666
|
-
|
|
36667
|
-
|
|
36668
|
-
|
|
36669
|
-
|
|
36670
|
-
|
|
36671
|
-
|
|
36672
|
-
|
|
36673
|
-
|
|
36674
|
-
|
|
36675
|
-
|
|
36488
|
+
collateral: {
|
|
36489
|
+
mintPubkey: reserve.collateral.mintPubkey.toBase58(),
|
|
36490
|
+
mintTotalSupply: reserve.collateral.mintTotalSupply.toString(),
|
|
36491
|
+
supplyVault: reserve.collateral.supplyVault.toBase58()
|
|
36492
|
+
},
|
|
36493
|
+
config: {
|
|
36494
|
+
protocolTakeRatePct: reserve.config.protocolTakeRatePct,
|
|
36495
|
+
hostFixedInterestRateBps: reserve.config.hostFixedInterestRateBps,
|
|
36496
|
+
borrowRateCurve: {
|
|
36497
|
+
points: reserve.config.borrowRateCurve.points.map((item) => ({
|
|
36498
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
36499
|
+
borrowRateBps: item.borrowRateBps
|
|
36500
|
+
}))
|
|
36501
|
+
},
|
|
36502
|
+
tokenInfo: {
|
|
36503
|
+
scopeConfiguration: {
|
|
36504
|
+
priceFeed: reserve.config.tokenInfo.scopeConfiguration.priceFeed.toBase58()
|
|
36505
|
+
},
|
|
36506
|
+
switchboardConfiguration: {
|
|
36507
|
+
priceAggregator: reserve.config.tokenInfo.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36508
|
+
twapAggregator: reserve.config.tokenInfo.switchboardConfiguration.twapAggregator.toBase58()
|
|
36509
|
+
},
|
|
36510
|
+
pythConfiguration: {
|
|
36511
|
+
price: reserve.config.tokenInfo.pythConfiguration.price.toBase58()
|
|
36512
|
+
}
|
|
36513
|
+
}
|
|
36514
|
+
}
|
|
36676
36515
|
};
|
|
36677
36516
|
}
|
|
36678
36517
|
|
|
@@ -43170,267 +43009,75 @@ function decodeKlendObligationData(data) {
|
|
|
43170
43009
|
const dec = obligationLayout.decode(data.slice(8));
|
|
43171
43010
|
return dec;
|
|
43172
43011
|
}
|
|
43173
|
-
function
|
|
43012
|
+
function dtoToKaminoObligation(obligationDto) {
|
|
43174
43013
|
return {
|
|
43175
|
-
tag: new BN11__default.default(obligationDto.tag),
|
|
43176
|
-
lastUpdate: {
|
|
43177
|
-
slot: new BN11__default.default(obligationDto.lastUpdate.slot),
|
|
43178
|
-
stale: obligationDto.lastUpdate.stale,
|
|
43179
|
-
priceStatus: obligationDto.lastUpdate.priceStatus,
|
|
43180
|
-
placeholder: obligationDto.lastUpdate.placeholder
|
|
43181
|
-
},
|
|
43182
43014
|
lendingMarket: new web3_js.PublicKey(obligationDto.lendingMarket),
|
|
43183
43015
|
owner: new web3_js.PublicKey(obligationDto.owner),
|
|
43184
|
-
deposits: obligationDto.deposits.map(
|
|
43185
|
-
|
|
43186
|
-
|
|
43187
|
-
|
|
43188
|
-
|
|
43189
|
-
)
|
|
43190
|
-
|
|
43191
|
-
|
|
43192
|
-
|
|
43193
|
-
)
|
|
43194
|
-
borrowFactorAdjustedDebtValueSf: new BN11__default.default(
|
|
43195
|
-
obligationDto.borrowFactorAdjustedDebtValueSf
|
|
43196
|
-
),
|
|
43197
|
-
borrowedAssetsMarketValueSf: new BN11__default.default(
|
|
43198
|
-
obligationDto.borrowedAssetsMarketValueSf
|
|
43199
|
-
),
|
|
43200
|
-
allowedBorrowValueSf: new BN11__default.default(obligationDto.allowedBorrowValueSf),
|
|
43201
|
-
unhealthyBorrowValueSf: new BN11__default.default(obligationDto.unhealthyBorrowValueSf),
|
|
43202
|
-
depositsAssetTiers: obligationDto.depositsAssetTiers,
|
|
43203
|
-
borrowsAssetTiers: obligationDto.borrowsAssetTiers,
|
|
43204
|
-
elevationGroup: obligationDto.elevationGroup,
|
|
43205
|
-
numOfObsoleteDepositReserves: obligationDto.numOfObsoleteDepositReserves,
|
|
43206
|
-
hasDebt: obligationDto.hasDebt,
|
|
43207
|
-
referrer: new web3_js.PublicKey(obligationDto.referrer),
|
|
43208
|
-
borrowingDisabled: obligationDto.borrowingDisabled,
|
|
43209
|
-
autodeleverageTargetLtvPct: obligationDto.autodeleverageTargetLtvPct,
|
|
43210
|
-
lowestReserveDepositMaxLtvPct: obligationDto.lowestReserveDepositMaxLtvPct,
|
|
43211
|
-
numOfObsoleteBorrowReserves: obligationDto.numOfObsoleteBorrowReserves,
|
|
43212
|
-
reserved: obligationDto.reserved,
|
|
43213
|
-
highestBorrowFactorPct: new BN11__default.default(obligationDto.highestBorrowFactorPct),
|
|
43214
|
-
autodeleverageMarginCallStartedTimestamp: new BN11__default.default(
|
|
43215
|
-
obligationDto.autodeleverageMarginCallStartedTimestamp
|
|
43216
|
-
),
|
|
43217
|
-
orders: obligationDto.orders.map(
|
|
43218
|
-
(item) => dtoToObligationOrderFields(item)
|
|
43219
|
-
),
|
|
43220
|
-
padding3: obligationDto.padding3.map((item) => new BN11__default.default(item))
|
|
43016
|
+
deposits: obligationDto.deposits.map((item) => ({
|
|
43017
|
+
depositReserve: new web3_js.PublicKey(item.depositReserve),
|
|
43018
|
+
depositedAmount: new BN8__default.default(item.depositedAmount),
|
|
43019
|
+
marketValueSf: new BN8__default.default(item.marketValueSf)
|
|
43020
|
+
})),
|
|
43021
|
+
borrows: obligationDto.borrows.map((item) => ({
|
|
43022
|
+
borrowReserve: new web3_js.PublicKey(item.borrowReserve),
|
|
43023
|
+
borrowedAmountSf: new BN8__default.default(item.borrowedAmountSf),
|
|
43024
|
+
marketValueSf: new BN8__default.default(item.marketValueSf)
|
|
43025
|
+
}))
|
|
43221
43026
|
};
|
|
43222
43027
|
}
|
|
43223
|
-
function
|
|
43028
|
+
function dtoToKaminoReserve(reserveDto) {
|
|
43224
43029
|
return {
|
|
43225
|
-
version: new BN11__default.default(reserveDto.version),
|
|
43226
|
-
lastUpdate: {
|
|
43227
|
-
slot: new BN11__default.default(reserveDto.lastUpdate.slot),
|
|
43228
|
-
stale: reserveDto.lastUpdate.stale,
|
|
43229
|
-
priceStatus: reserveDto.lastUpdate.priceStatus,
|
|
43230
|
-
placeholder: reserveDto.lastUpdate.placeholder
|
|
43231
|
-
},
|
|
43232
43030
|
lendingMarket: new web3_js.PublicKey(reserveDto.lendingMarket),
|
|
43233
43031
|
farmCollateral: new web3_js.PublicKey(reserveDto.farmCollateral),
|
|
43234
|
-
|
|
43235
|
-
|
|
43236
|
-
|
|
43237
|
-
|
|
43238
|
-
|
|
43239
|
-
|
|
43240
|
-
|
|
43241
|
-
|
|
43242
|
-
supplyVault: new web3_js.PublicKey(reserveDto.collateral.supplyVault),
|
|
43243
|
-
padding1: reserveDto.collateral.padding1.map((item) => new BN11__default.default(item)),
|
|
43244
|
-
padding2: reserveDto.collateral.padding2.map((item) => new BN11__default.default(item))
|
|
43245
|
-
},
|
|
43246
|
-
reserveCollateralPadding: reserveDto.reserveCollateralPadding.map(
|
|
43247
|
-
(item) => new BN11__default.default(item)
|
|
43248
|
-
),
|
|
43249
|
-
config: dtoToReserveConfigFields(reserveDto.config),
|
|
43250
|
-
configPadding: reserveDto.configPadding.map((item) => new BN11__default.default(item)),
|
|
43251
|
-
borrowedAmountOutsideElevationGroup: new BN11__default.default(
|
|
43252
|
-
reserveDto.borrowedAmountOutsideElevationGroup
|
|
43253
|
-
),
|
|
43254
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveDto.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
43255
|
-
(item) => new BN11__default.default(item)
|
|
43256
|
-
),
|
|
43257
|
-
padding: reserveDto.padding.map((item) => new BN11__default.default(item))
|
|
43258
|
-
};
|
|
43259
|
-
}
|
|
43260
|
-
function dtoToReserveLiquidityFields(reserveDto) {
|
|
43261
|
-
return {
|
|
43262
|
-
mintPubkey: new web3_js.PublicKey(reserveDto.mintPubkey),
|
|
43263
|
-
supplyVault: new web3_js.PublicKey(reserveDto.supplyVault),
|
|
43264
|
-
feeVault: new web3_js.PublicKey(reserveDto.feeVault),
|
|
43265
|
-
availableAmount: new BN11__default.default(reserveDto.availableAmount),
|
|
43266
|
-
borrowedAmountSf: new BN11__default.default(reserveDto.borrowedAmountSf),
|
|
43267
|
-
marketPriceSf: new BN11__default.default(reserveDto.marketPriceSf),
|
|
43268
|
-
marketPriceLastUpdatedTs: new BN11__default.default(reserveDto.marketPriceLastUpdatedTs),
|
|
43269
|
-
mintDecimals: new BN11__default.default(reserveDto.mintDecimals),
|
|
43270
|
-
depositLimitCrossedTimestamp: new BN11__default.default(
|
|
43271
|
-
reserveDto.depositLimitCrossedTimestamp
|
|
43272
|
-
),
|
|
43273
|
-
borrowLimitCrossedTimestamp: new BN11__default.default(reserveDto.borrowLimitCrossedTimestamp),
|
|
43274
|
-
cumulativeBorrowRateBsf: {
|
|
43275
|
-
value: reserveDto.cumulativeBorrowRateBsf.value.map(
|
|
43276
|
-
(item) => new BN11__default.default(item)
|
|
43277
|
-
),
|
|
43278
|
-
padding: reserveDto.cumulativeBorrowRateBsf.padding.map(
|
|
43279
|
-
(item) => new BN11__default.default(item)
|
|
43280
|
-
)
|
|
43281
|
-
},
|
|
43282
|
-
accumulatedProtocolFeesSf: new BN11__default.default(reserveDto.accumulatedProtocolFeesSf),
|
|
43283
|
-
accumulatedReferrerFeesSf: new BN11__default.default(reserveDto.accumulatedReferrerFeesSf),
|
|
43284
|
-
pendingReferrerFeesSf: new BN11__default.default(reserveDto.pendingReferrerFeesSf),
|
|
43285
|
-
absoluteReferralRateSf: new BN11__default.default(reserveDto.absoluteReferralRateSf),
|
|
43286
|
-
tokenProgram: new web3_js.PublicKey(reserveDto.tokenProgram),
|
|
43287
|
-
padding2: reserveDto.padding2.map((item) => new BN11__default.default(item)),
|
|
43288
|
-
padding3: reserveDto.padding3.map((item) => new BN11__default.default(item))
|
|
43289
|
-
};
|
|
43290
|
-
}
|
|
43291
|
-
function dtoToReserveConfigFields(reserveDto) {
|
|
43292
|
-
return {
|
|
43293
|
-
status: reserveDto.status,
|
|
43294
|
-
assetTier: reserveDto.assetTier,
|
|
43295
|
-
hostFixedInterestRateBps: reserveDto.hostFixedInterestRateBps,
|
|
43296
|
-
reserved2: reserveDto.reserved2,
|
|
43297
|
-
protocolOrderExecutionFeePct: reserveDto.protocolOrderExecutionFeePct,
|
|
43298
|
-
protocolTakeRatePct: reserveDto.protocolTakeRatePct,
|
|
43299
|
-
protocolLiquidationFeePct: reserveDto.protocolLiquidationFeePct,
|
|
43300
|
-
loanToValuePct: reserveDto.loanToValuePct,
|
|
43301
|
-
liquidationThresholdPct: reserveDto.liquidationThresholdPct,
|
|
43302
|
-
minLiquidationBonusBps: reserveDto.minLiquidationBonusBps,
|
|
43303
|
-
maxLiquidationBonusBps: reserveDto.maxLiquidationBonusBps,
|
|
43304
|
-
badDebtLiquidationBonusBps: reserveDto.badDebtLiquidationBonusBps,
|
|
43305
|
-
deleveragingMarginCallPeriodSecs: new BN11__default.default(
|
|
43306
|
-
reserveDto.deleveragingMarginCallPeriodSecs
|
|
43307
|
-
),
|
|
43308
|
-
deleveragingThresholdDecreaseBpsPerDay: new BN11__default.default(
|
|
43309
|
-
reserveDto.deleveragingThresholdDecreaseBpsPerDay
|
|
43310
|
-
),
|
|
43311
|
-
fees: {
|
|
43312
|
-
borrowFeeSf: new BN11__default.default(reserveDto.fees.borrowFeeSf),
|
|
43313
|
-
flashLoanFeeSf: new BN11__default.default(reserveDto.fees.flashLoanFeeSf),
|
|
43314
|
-
padding: reserveDto.fees.padding
|
|
43315
|
-
},
|
|
43316
|
-
borrowRateCurve: {
|
|
43317
|
-
points: reserveDto.borrowRateCurve.points.map((item) => ({
|
|
43318
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
43319
|
-
borrowRateBps: item.borrowRateBps
|
|
43320
|
-
}))
|
|
43321
|
-
},
|
|
43322
|
-
borrowFactorPct: new BN11__default.default(reserveDto.borrowFactorPct),
|
|
43323
|
-
depositLimit: new BN11__default.default(reserveDto.depositLimit),
|
|
43324
|
-
borrowLimit: new BN11__default.default(reserveDto.borrowLimit),
|
|
43325
|
-
tokenInfo: dtoToTokenInfoFields(reserveDto.tokenInfo),
|
|
43326
|
-
depositWithdrawalCap: dtoToWithdrawalCapsFields(
|
|
43327
|
-
reserveDto.depositWithdrawalCap
|
|
43328
|
-
),
|
|
43329
|
-
debtWithdrawalCap: dtoToWithdrawalCapsFields(reserveDto.debtWithdrawalCap),
|
|
43330
|
-
elevationGroups: reserveDto.elevationGroups,
|
|
43331
|
-
disableUsageAsCollOutsideEmode: reserveDto.disableUsageAsCollOutsideEmode,
|
|
43332
|
-
utilizationLimitBlockBorrowingAbovePct: reserveDto.utilizationLimitBlockBorrowingAbovePct,
|
|
43333
|
-
autodeleverageEnabled: reserveDto.autodeleverageEnabled,
|
|
43334
|
-
reserved1: reserveDto.reserved1,
|
|
43335
|
-
borrowLimitOutsideElevationGroup: new BN11__default.default(
|
|
43336
|
-
reserveDto.borrowLimitOutsideElevationGroup
|
|
43337
|
-
),
|
|
43338
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveDto.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
43339
|
-
(item) => new BN11__default.default(item)
|
|
43340
|
-
),
|
|
43341
|
-
deleveragingBonusIncreaseBpsPerDay: new BN11__default.default(
|
|
43342
|
-
reserveDto.deleveragingBonusIncreaseBpsPerDay
|
|
43343
|
-
)
|
|
43344
|
-
};
|
|
43345
|
-
}
|
|
43346
|
-
function dtoToTokenInfoFields(tokenInfoDto) {
|
|
43347
|
-
return {
|
|
43348
|
-
name: tokenInfoDto.name,
|
|
43349
|
-
heuristic: {
|
|
43350
|
-
lower: new BN11__default.default(tokenInfoDto.heuristic.lower),
|
|
43351
|
-
upper: new BN11__default.default(tokenInfoDto.heuristic.upper),
|
|
43352
|
-
exp: new BN11__default.default(tokenInfoDto.heuristic.exp)
|
|
43353
|
-
},
|
|
43354
|
-
maxTwapDivergenceBps: new BN11__default.default(tokenInfoDto.maxTwapDivergenceBps),
|
|
43355
|
-
maxAgePriceSeconds: new BN11__default.default(tokenInfoDto.maxAgePriceSeconds),
|
|
43356
|
-
maxAgeTwapSeconds: new BN11__default.default(tokenInfoDto.maxAgeTwapSeconds),
|
|
43357
|
-
scopeConfiguration: {
|
|
43358
|
-
priceFeed: new web3_js.PublicKey(tokenInfoDto.scopeConfiguration.priceFeed),
|
|
43359
|
-
priceChain: tokenInfoDto.scopeConfiguration.priceChain,
|
|
43360
|
-
twapChain: tokenInfoDto.scopeConfiguration.twapChain
|
|
43361
|
-
},
|
|
43362
|
-
switchboardConfiguration: {
|
|
43363
|
-
priceAggregator: new web3_js.PublicKey(
|
|
43364
|
-
tokenInfoDto.switchboardConfiguration.priceAggregator
|
|
43032
|
+
liquidity: {
|
|
43033
|
+
mintPubkey: new web3_js.PublicKey(reserveDto.liquidity.mintPubkey),
|
|
43034
|
+
supplyVault: new web3_js.PublicKey(reserveDto.liquidity.supplyVault),
|
|
43035
|
+
mintDecimals: new BN8__default.default(reserveDto.liquidity.mintDecimals),
|
|
43036
|
+
availableAmount: new BN8__default.default(reserveDto.liquidity.availableAmount),
|
|
43037
|
+
borrowedAmountSf: new BN8__default.default(reserveDto.liquidity.borrowedAmountSf),
|
|
43038
|
+
accumulatedProtocolFeesSf: new BN8__default.default(
|
|
43039
|
+
reserveDto.liquidity.accumulatedProtocolFeesSf
|
|
43365
43040
|
),
|
|
43366
|
-
|
|
43367
|
-
|
|
43368
|
-
)
|
|
43369
|
-
},
|
|
43370
|
-
pythConfiguration: {
|
|
43371
|
-
price: new web3_js.PublicKey(tokenInfoDto.pythConfiguration.price)
|
|
43372
|
-
},
|
|
43373
|
-
blockPriceUsage: tokenInfoDto.blockPriceUsage,
|
|
43374
|
-
reserved: tokenInfoDto.reserved,
|
|
43375
|
-
padding: tokenInfoDto.padding.map((item) => new BN11__default.default(item))
|
|
43376
|
-
};
|
|
43377
|
-
}
|
|
43378
|
-
function dtoToWithdrawalCapsFields(withdrawalCapsDto) {
|
|
43379
|
-
return {
|
|
43380
|
-
configCapacity: new BN11__default.default(withdrawalCapsDto.configCapacity),
|
|
43381
|
-
currentTotal: new BN11__default.default(withdrawalCapsDto.currentTotal),
|
|
43382
|
-
lastIntervalStartTimestamp: new BN11__default.default(
|
|
43383
|
-
withdrawalCapsDto.lastIntervalStartTimestamp
|
|
43384
|
-
),
|
|
43385
|
-
configIntervalLengthSeconds: new BN11__default.default(
|
|
43386
|
-
withdrawalCapsDto.configIntervalLengthSeconds
|
|
43387
|
-
)
|
|
43388
|
-
};
|
|
43389
|
-
}
|
|
43390
|
-
function dtoToObligationCollateralFields(obligationCollateralDto) {
|
|
43391
|
-
return {
|
|
43392
|
-
depositReserve: new web3_js.PublicKey(obligationCollateralDto.depositReserve),
|
|
43393
|
-
depositedAmount: new BN11__default.default(obligationCollateralDto.depositedAmount),
|
|
43394
|
-
marketValueSf: new BN11__default.default(obligationCollateralDto.marketValueSf),
|
|
43395
|
-
borrowedAmountAgainstThisCollateralInElevationGroup: new BN11__default.default(
|
|
43396
|
-
obligationCollateralDto.borrowedAmountAgainstThisCollateralInElevationGroup
|
|
43397
|
-
),
|
|
43398
|
-
padding: obligationCollateralDto.padding.map((item) => new BN11__default.default(item))
|
|
43399
|
-
};
|
|
43400
|
-
}
|
|
43401
|
-
function dtoToObligationLiquidityFields(obligationLiquidityDto) {
|
|
43402
|
-
return {
|
|
43403
|
-
borrowReserve: new web3_js.PublicKey(obligationLiquidityDto.borrowReserve),
|
|
43404
|
-
cumulativeBorrowRateBsf: {
|
|
43405
|
-
value: obligationLiquidityDto.cumulativeBorrowRateBsf.value.map(
|
|
43406
|
-
(item) => new BN11__default.default(item)
|
|
43041
|
+
accumulatedReferrerFeesSf: new BN8__default.default(
|
|
43042
|
+
reserveDto.liquidity.accumulatedReferrerFeesSf
|
|
43407
43043
|
),
|
|
43408
|
-
|
|
43409
|
-
(item) => new BN11__default.default(item)
|
|
43410
|
-
)
|
|
43044
|
+
pendingReferrerFeesSf: new BN8__default.default(reserveDto.liquidity.pendingReferrerFeesSf)
|
|
43411
43045
|
},
|
|
43412
|
-
|
|
43413
|
-
|
|
43414
|
-
|
|
43415
|
-
|
|
43416
|
-
|
|
43417
|
-
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
|
|
43421
|
-
|
|
43422
|
-
|
|
43423
|
-
|
|
43424
|
-
|
|
43425
|
-
|
|
43426
|
-
|
|
43427
|
-
|
|
43428
|
-
|
|
43429
|
-
|
|
43430
|
-
|
|
43431
|
-
|
|
43432
|
-
|
|
43433
|
-
|
|
43046
|
+
collateral: {
|
|
43047
|
+
mintPubkey: new web3_js.PublicKey(reserveDto.collateral.mintPubkey),
|
|
43048
|
+
mintTotalSupply: new BN8__default.default(reserveDto.collateral.mintTotalSupply),
|
|
43049
|
+
supplyVault: new web3_js.PublicKey(reserveDto.collateral.supplyVault)
|
|
43050
|
+
},
|
|
43051
|
+
config: {
|
|
43052
|
+
protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
|
|
43053
|
+
hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
|
|
43054
|
+
borrowRateCurve: {
|
|
43055
|
+
points: reserveDto.config.borrowRateCurve.points.map((item) => ({
|
|
43056
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
43057
|
+
borrowRateBps: item.borrowRateBps
|
|
43058
|
+
}))
|
|
43059
|
+
},
|
|
43060
|
+
tokenInfo: {
|
|
43061
|
+
scopeConfiguration: {
|
|
43062
|
+
priceFeed: new web3_js.PublicKey(
|
|
43063
|
+
reserveDto.config.tokenInfo.scopeConfiguration.priceFeed
|
|
43064
|
+
)
|
|
43065
|
+
},
|
|
43066
|
+
switchboardConfiguration: {
|
|
43067
|
+
priceAggregator: new web3_js.PublicKey(
|
|
43068
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.priceAggregator
|
|
43069
|
+
),
|
|
43070
|
+
twapAggregator: new web3_js.PublicKey(
|
|
43071
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.twapAggregator
|
|
43072
|
+
)
|
|
43073
|
+
},
|
|
43074
|
+
pythConfiguration: {
|
|
43075
|
+
price: new web3_js.PublicKey(
|
|
43076
|
+
reserveDto.config.tokenInfo.pythConfiguration.price
|
|
43077
|
+
)
|
|
43078
|
+
}
|
|
43079
|
+
}
|
|
43080
|
+
}
|
|
43434
43081
|
};
|
|
43435
43082
|
}
|
|
43436
43083
|
var SEED_LENDING_MARKET_AUTH = "lma";
|
|
@@ -43497,9 +43144,9 @@ var Fraction = class _Fraction {
|
|
|
43497
43144
|
static MAX_SIZE_BF = 256;
|
|
43498
43145
|
static FRACTIONS = 60;
|
|
43499
43146
|
static MULTIPLIER = new FractionDecimal(2).pow(_Fraction.FRACTIONS);
|
|
43500
|
-
static MAX_F_BN = new
|
|
43501
|
-
static MAX_BF_BN = new
|
|
43502
|
-
static MIN_BN = new
|
|
43147
|
+
static MAX_F_BN = new BN8__default.default(2).pow(new BN8__default.default(_Fraction.MAX_SIZE_F)).sub(new BN8__default.default(1));
|
|
43148
|
+
static MAX_BF_BN = new BN8__default.default(2).pow(new BN8__default.default(_Fraction.MAX_SIZE_BF)).sub(new BN8__default.default(1));
|
|
43149
|
+
static MIN_BN = new BN8__default.default(0);
|
|
43503
43150
|
valueSf;
|
|
43504
43151
|
constructor(valueSf) {
|
|
43505
43152
|
if (valueSf.lt(_Fraction.MIN_BN) || valueSf.gt(_Fraction.MAX_BF_BN)) {
|
|
@@ -43515,7 +43162,7 @@ var Fraction = class _Fraction {
|
|
|
43515
43162
|
static fromDecimal(n) {
|
|
43516
43163
|
const scaledDecimal = new FractionDecimal(n).mul(_Fraction.MULTIPLIER);
|
|
43517
43164
|
const roundedScaledDecimal = roundNearest(scaledDecimal);
|
|
43518
|
-
const scaledValue = new
|
|
43165
|
+
const scaledValue = new BN8__default.default(roundedScaledDecimal.toFixed());
|
|
43519
43166
|
return new _Fraction(scaledValue);
|
|
43520
43167
|
}
|
|
43521
43168
|
static fromBps(n) {
|
|
@@ -43545,7 +43192,7 @@ var Fraction = class _Fraction {
|
|
|
43545
43192
|
return this.valueSf.eq(x.getValue());
|
|
43546
43193
|
}
|
|
43547
43194
|
};
|
|
43548
|
-
new Fraction(new
|
|
43195
|
+
new Fraction(new BN8__default.default(0));
|
|
43549
43196
|
function roundNearest(decimal) {
|
|
43550
43197
|
return decimal.toDecimalPlaces(0, Decimal3__default.default.ROUND_HALF_CEIL);
|
|
43551
43198
|
}
|
|
@@ -43628,7 +43275,7 @@ var SinglePoolInstruction = {
|
|
|
43628
43275
|
const data = Buffer.concat([
|
|
43629
43276
|
Buffer.from([3 /* WithdrawStake */]),
|
|
43630
43277
|
userStakeAuthority.toBuffer(),
|
|
43631
|
-
Buffer.from(new
|
|
43278
|
+
Buffer.from(new BN8.BN(rawAmount.toString()).toArray("le", 8))
|
|
43632
43279
|
]);
|
|
43633
43280
|
return createTransactionInstruction(
|
|
43634
43281
|
SINGLE_POOL_PROGRAM_ID,
|
|
@@ -44145,29 +43792,29 @@ function decodeJupTokenReserveData(data, pubkey) {
|
|
|
44145
43792
|
offset += 2;
|
|
44146
43793
|
const lastUtilization = data.readUInt16LE(offset);
|
|
44147
43794
|
offset += 2;
|
|
44148
|
-
const lastUpdateTimestamp = new
|
|
43795
|
+
const lastUpdateTimestamp = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44149
43796
|
offset += 8;
|
|
44150
|
-
const supplyExchangePrice = new
|
|
43797
|
+
const supplyExchangePrice = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44151
43798
|
offset += 8;
|
|
44152
|
-
const borrowExchangePrice = new
|
|
43799
|
+
const borrowExchangePrice = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44153
43800
|
offset += 8;
|
|
44154
43801
|
const maxUtilization = data.readUInt16LE(offset);
|
|
44155
43802
|
offset += 2;
|
|
44156
|
-
const totalSupplyWithInterest = new
|
|
43803
|
+
const totalSupplyWithInterest = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44157
43804
|
offset += 8;
|
|
44158
|
-
const totalSupplyInterestFree = new
|
|
43805
|
+
const totalSupplyInterestFree = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44159
43806
|
offset += 8;
|
|
44160
|
-
const totalBorrowWithInterest = new
|
|
43807
|
+
const totalBorrowWithInterest = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44161
43808
|
offset += 8;
|
|
44162
|
-
const totalBorrowInterestFree = new
|
|
43809
|
+
const totalBorrowInterestFree = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44163
43810
|
offset += 8;
|
|
44164
|
-
const totalClaimAmount = new
|
|
43811
|
+
const totalClaimAmount = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44165
43812
|
offset += 8;
|
|
44166
43813
|
const interactingProtocol = new web3_js.PublicKey(data.slice(offset, offset + 32));
|
|
44167
43814
|
offset += 32;
|
|
44168
|
-
const interactingTimestamp = new
|
|
43815
|
+
const interactingTimestamp = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44169
43816
|
offset += 8;
|
|
44170
|
-
const interactingBalance = new
|
|
43817
|
+
const interactingBalance = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44171
43818
|
return {
|
|
44172
43819
|
pubkey,
|
|
44173
43820
|
mint,
|
|
@@ -44229,9 +43876,9 @@ function dtoToJupLendingStateRaw(dto) {
|
|
|
44229
43876
|
lendingId: dto.lendingId,
|
|
44230
43877
|
decimals: dto.decimals,
|
|
44231
43878
|
rewardsRateModel: new web3_js.PublicKey(dto.rewardsRateModel),
|
|
44232
|
-
liquidityExchangePrice: new
|
|
44233
|
-
tokenExchangePrice: new
|
|
44234
|
-
lastUpdateTimestamp: new
|
|
43879
|
+
liquidityExchangePrice: new BN8__default.default(dto.liquidityExchangePrice),
|
|
43880
|
+
tokenExchangePrice: new BN8__default.default(dto.tokenExchangePrice),
|
|
43881
|
+
lastUpdateTimestamp: new BN8__default.default(dto.lastUpdateTimestamp),
|
|
44235
43882
|
tokenReservesLiquidity: new web3_js.PublicKey(dto.tokenReservesLiquidity),
|
|
44236
43883
|
supplyPositionOnLiquidity: new web3_js.PublicKey(dto.supplyPositionOnLiquidity)
|
|
44237
43884
|
};
|
|
@@ -44244,30 +43891,30 @@ function dtoToJupTokenReserveRaw(dto) {
|
|
|
44244
43891
|
borrowRate: dto.borrowRate,
|
|
44245
43892
|
feeOnInterest: dto.feeOnInterest,
|
|
44246
43893
|
lastUtilization: dto.lastUtilization,
|
|
44247
|
-
lastUpdateTimestamp: new
|
|
44248
|
-
supplyExchangePrice: new
|
|
44249
|
-
borrowExchangePrice: new
|
|
43894
|
+
lastUpdateTimestamp: new BN8__default.default(dto.lastUpdateTimestamp),
|
|
43895
|
+
supplyExchangePrice: new BN8__default.default(dto.supplyExchangePrice),
|
|
43896
|
+
borrowExchangePrice: new BN8__default.default(dto.borrowExchangePrice),
|
|
44250
43897
|
maxUtilization: dto.maxUtilization,
|
|
44251
|
-
totalSupplyWithInterest: new
|
|
44252
|
-
totalSupplyInterestFree: new
|
|
44253
|
-
totalBorrowWithInterest: new
|
|
44254
|
-
totalBorrowInterestFree: new
|
|
44255
|
-
totalClaimAmount: new
|
|
43898
|
+
totalSupplyWithInterest: new BN8__default.default(dto.totalSupplyWithInterest),
|
|
43899
|
+
totalSupplyInterestFree: new BN8__default.default(dto.totalSupplyInterestFree),
|
|
43900
|
+
totalBorrowWithInterest: new BN8__default.default(dto.totalBorrowWithInterest),
|
|
43901
|
+
totalBorrowInterestFree: new BN8__default.default(dto.totalBorrowInterestFree),
|
|
43902
|
+
totalClaimAmount: new BN8__default.default(dto.totalClaimAmount),
|
|
44256
43903
|
interactingProtocol: new web3_js.PublicKey(dto.interactingProtocol),
|
|
44257
|
-
interactingTimestamp: new
|
|
44258
|
-
interactingBalance: new
|
|
43904
|
+
interactingTimestamp: new BN8__default.default(dto.interactingTimestamp),
|
|
43905
|
+
interactingBalance: new BN8__default.default(dto.interactingBalance)
|
|
44259
43906
|
};
|
|
44260
43907
|
}
|
|
44261
43908
|
function dtoToJupLendingRewardsRateModelRaw(dto) {
|
|
44262
43909
|
return {
|
|
44263
43910
|
pubkey: new web3_js.PublicKey(dto.pubkey),
|
|
44264
43911
|
mint: new web3_js.PublicKey(dto.mint),
|
|
44265
|
-
startTvl: new
|
|
44266
|
-
duration: new
|
|
44267
|
-
startTime: new
|
|
44268
|
-
yearlyReward: new
|
|
44269
|
-
nextDuration: new
|
|
44270
|
-
nextRewardAmount: new
|
|
43912
|
+
startTvl: new BN8__default.default(dto.startTvl),
|
|
43913
|
+
duration: new BN8__default.default(dto.duration),
|
|
43914
|
+
startTime: new BN8__default.default(dto.startTime),
|
|
43915
|
+
yearlyReward: new BN8__default.default(dto.yearlyReward),
|
|
43916
|
+
nextDuration: new BN8__default.default(dto.nextDuration),
|
|
43917
|
+
nextRewardAmount: new BN8__default.default(dto.nextRewardAmount)
|
|
44271
43918
|
};
|
|
44272
43919
|
}
|
|
44273
43920
|
function dtoToJupRateModelRaw(dto) {
|
|
@@ -44358,14 +44005,14 @@ function deriveJupLendLiquiditySupplyPositionPda(underlyingMint, lendingPda, liq
|
|
|
44358
44005
|
liquidityProgramId
|
|
44359
44006
|
);
|
|
44360
44007
|
}
|
|
44361
|
-
var JUP_EXCHANGE_PRICES_PRECISION = new
|
|
44362
|
-
var JUP_SECONDS_PER_YEAR = new
|
|
44363
|
-
var JUP_MAX_REWARDS_RATE = new
|
|
44008
|
+
var JUP_EXCHANGE_PRICES_PRECISION = new BN8__default.default("1000000000000");
|
|
44009
|
+
var JUP_SECONDS_PER_YEAR = new BN8__default.default(31536e3);
|
|
44010
|
+
var JUP_MAX_REWARDS_RATE = new BN8__default.default("50000000000000");
|
|
44364
44011
|
function calculateJupLendTotalAssets(lendingState, fTokenTotalSupply) {
|
|
44365
44012
|
return lendingState.tokenExchangePrice.mul(fTokenTotalSupply).div(JUP_EXCHANGE_PRICES_PRECISION);
|
|
44366
44013
|
}
|
|
44367
44014
|
function calculateJupLendRewardsRateForExchangePrice(rewardsModel, totalAssets, currentTimestamp) {
|
|
44368
|
-
const defaultResult = { rate: new
|
|
44015
|
+
const defaultResult = { rate: new BN8__default.default(0), rewardsStartTime: rewardsModel.startTime };
|
|
44369
44016
|
if (rewardsModel.startTime.isZero() || rewardsModel.duration.isZero()) {
|
|
44370
44017
|
return defaultResult;
|
|
44371
44018
|
}
|
|
@@ -44385,7 +44032,7 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44385
44032
|
const oldTokenExchangePrice = lendingState.tokenExchangePrice;
|
|
44386
44033
|
const oldLiquidityExchangePrice = lendingState.liquidityExchangePrice;
|
|
44387
44034
|
const currentLiquidityExchangePrice = tokenReserve.supplyExchangePrice;
|
|
44388
|
-
let rewardsRate = new
|
|
44035
|
+
let rewardsRate = new BN8__default.default(0);
|
|
44389
44036
|
let rewardsStartTime = lendingState.lastUpdateTimestamp;
|
|
44390
44037
|
if (rewardsModel) {
|
|
44391
44038
|
const totalAssets = calculateJupLendTotalAssets(lendingState, fTokenTotalSupply);
|
|
@@ -44402,12 +44049,12 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44402
44049
|
lastUpdateTime = rewardsStartTime;
|
|
44403
44050
|
}
|
|
44404
44051
|
const secondsElapsed = currentTimestamp.sub(lastUpdateTime);
|
|
44405
|
-
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new
|
|
44052
|
+
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new BN8__default.default(100));
|
|
44406
44053
|
const delta = currentLiquidityExchangePrice.sub(oldLiquidityExchangePrice);
|
|
44407
44054
|
totalReturnPercent = totalReturnPercent.add(
|
|
44408
|
-
delta.mul(new
|
|
44055
|
+
delta.mul(new BN8__default.default(1e14)).div(oldLiquidityExchangePrice)
|
|
44409
44056
|
);
|
|
44410
|
-
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new
|
|
44057
|
+
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new BN8__default.default(1e14)));
|
|
44411
44058
|
}
|
|
44412
44059
|
var UPDATE_RATE_DISCRIMINATOR = Buffer.from([
|
|
44413
44060
|
24,
|
|
@@ -57888,7 +57535,7 @@ function exponentNumberToBigNumber(raw) {
|
|
|
57888
57535
|
let value = new BigNumber3.BigNumber(0);
|
|
57889
57536
|
const TWO_64 = new BigNumber3.BigNumber(2).pow(64);
|
|
57890
57537
|
words.forEach((w, i) => {
|
|
57891
|
-
const word = new BigNumber3.BigNumber(
|
|
57538
|
+
const word = new BigNumber3.BigNumber(BN8__default.default.isBN(w) ? w.toString() : String(w));
|
|
57892
57539
|
value = value.plus(word.times(TWO_64.pow(i)));
|
|
57893
57540
|
});
|
|
57894
57541
|
return value.div(EXPONENT_NUMBER_DENOM);
|
|
@@ -57899,7 +57546,7 @@ function pk(v) {
|
|
|
57899
57546
|
function decodeExponentVault(data) {
|
|
57900
57547
|
const d = EXPONENT_ACCOUNTS_CODER.decode("Vault", data);
|
|
57901
57548
|
const get = (snake, camel) => d[snake] ?? d[camel];
|
|
57902
|
-
const u646 = (v) => BigInt(
|
|
57549
|
+
const u646 = (v) => BigInt(BN8__default.default.isBN(v) ? v.toString() : String(v ?? 0));
|
|
57903
57550
|
const cpi = get("cpi_accounts", "cpiAccounts") ?? {};
|
|
57904
57551
|
return {
|
|
57905
57552
|
authority: pk(get("authority", "authority")),
|
|
@@ -58246,76 +57893,25 @@ function scaledSupplies(state) {
|
|
|
58246
57893
|
}
|
|
58247
57894
|
|
|
58248
57895
|
// src/vendor/klend/utils/farms/serialize.utils.ts
|
|
58249
|
-
function
|
|
57896
|
+
function kaminoFarmStateToDto(farmState) {
|
|
58250
57897
|
return {
|
|
58251
|
-
farmAdmin: farmRaw.farmAdmin.toBase58(),
|
|
58252
|
-
globalConfig: farmRaw.globalConfig.toBase58(),
|
|
58253
57898
|
token: {
|
|
58254
|
-
mint:
|
|
58255
|
-
decimals:
|
|
58256
|
-
tokenProgram: farmRaw.token.tokenProgram.toBase58(),
|
|
58257
|
-
padding: farmRaw.token.padding.map((p) => p.toString())
|
|
57899
|
+
mint: farmState.token.mint.toBase58(),
|
|
57900
|
+
decimals: farmState.token.decimals.toString()
|
|
58258
57901
|
},
|
|
58259
|
-
rewardInfos:
|
|
57902
|
+
rewardInfos: farmState.rewardInfos.map((item) => ({
|
|
58260
57903
|
token: {
|
|
58261
57904
|
mint: item.token.mint.toBase58(),
|
|
58262
|
-
decimals: item.token.decimals.toString()
|
|
58263
|
-
tokenProgram: item.token.tokenProgram.toBase58(),
|
|
58264
|
-
padding: item.token.padding.map((p) => p.toString())
|
|
57905
|
+
decimals: item.token.decimals.toString()
|
|
58265
57906
|
},
|
|
58266
|
-
|
|
58267
|
-
rewardsAvailable: item.rewardsAvailable.toString(),
|
|
57907
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58268
57908
|
rewardScheduleCurve: {
|
|
58269
57909
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58270
57910
|
tsStart: p.tsStart.toString(),
|
|
58271
57911
|
rewardPerTimeUnit: p.rewardPerTimeUnit.toString()
|
|
58272
57912
|
}))
|
|
58273
|
-
}
|
|
58274
|
-
|
|
58275
|
-
lastIssuanceTs: item.lastIssuanceTs.toString(),
|
|
58276
|
-
rewardsIssuedUnclaimed: item.rewardsIssuedUnclaimed.toString(),
|
|
58277
|
-
rewardsIssuedCumulative: item.rewardsIssuedCumulative.toString(),
|
|
58278
|
-
rewardPerShareScaled: item.rewardPerShareScaled.toString(),
|
|
58279
|
-
placeholder0: item.placeholder0.toString(),
|
|
58280
|
-
rewardType: item.rewardType,
|
|
58281
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58282
|
-
padding0: item.padding0,
|
|
58283
|
-
padding1: item.padding1.map((p) => p.toString())
|
|
58284
|
-
})),
|
|
58285
|
-
numRewardTokens: farmRaw.numRewardTokens.toString(),
|
|
58286
|
-
numUsers: farmRaw.numUsers.toString(),
|
|
58287
|
-
totalStakedAmount: farmRaw.totalStakedAmount.toString(),
|
|
58288
|
-
farmVault: farmRaw.farmVault.toBase58(),
|
|
58289
|
-
farmVaultsAuthority: farmRaw.farmVaultsAuthority.toBase58(),
|
|
58290
|
-
farmVaultsAuthorityBump: farmRaw.farmVaultsAuthorityBump.toString(),
|
|
58291
|
-
delegateAuthority: farmRaw.delegateAuthority.toBase58(),
|
|
58292
|
-
timeUnit: farmRaw.timeUnit,
|
|
58293
|
-
isFarmFrozen: farmRaw.isFarmFrozen,
|
|
58294
|
-
isFarmDelegated: farmRaw.isFarmDelegated,
|
|
58295
|
-
padding0: farmRaw.padding0,
|
|
58296
|
-
withdrawAuthority: farmRaw.withdrawAuthority.toBase58(),
|
|
58297
|
-
depositWarmupPeriod: farmRaw.depositWarmupPeriod,
|
|
58298
|
-
withdrawalCooldownPeriod: farmRaw.withdrawalCooldownPeriod,
|
|
58299
|
-
totalActiveStakeScaled: farmRaw.totalActiveStakeScaled.toString(),
|
|
58300
|
-
totalPendingStakeScaled: farmRaw.totalPendingStakeScaled.toString(),
|
|
58301
|
-
totalPendingAmount: farmRaw.totalPendingAmount.toString(),
|
|
58302
|
-
slashedAmountCurrent: farmRaw.slashedAmountCurrent.toString(),
|
|
58303
|
-
slashedAmountCumulative: farmRaw.slashedAmountCumulative.toString(),
|
|
58304
|
-
slashedAmountSpillAddress: farmRaw.slashedAmountSpillAddress.toBase58(),
|
|
58305
|
-
lockingMode: farmRaw.lockingMode.toString(),
|
|
58306
|
-
lockingStartTimestamp: farmRaw.lockingStartTimestamp.toString(),
|
|
58307
|
-
lockingDuration: farmRaw.lockingDuration.toString(),
|
|
58308
|
-
lockingEarlyWithdrawalPenaltyBps: farmRaw.lockingEarlyWithdrawalPenaltyBps.toString(),
|
|
58309
|
-
depositCapAmount: farmRaw.depositCapAmount.toString(),
|
|
58310
|
-
scopePrices: farmRaw.scopePrices.toBase58(),
|
|
58311
|
-
scopeOraclePriceId: farmRaw.scopeOraclePriceId.toString(),
|
|
58312
|
-
scopeOracleMaxAge: farmRaw.scopeOracleMaxAge.toString(),
|
|
58313
|
-
pendingFarmAdmin: farmRaw.pendingFarmAdmin.toBase58(),
|
|
58314
|
-
strategyId: farmRaw.strategyId.toBase58(),
|
|
58315
|
-
delegatedRpsAdmin: farmRaw.delegatedRpsAdmin.toBase58(),
|
|
58316
|
-
vaultId: farmRaw.vaultId.toBase58(),
|
|
58317
|
-
secondDelegatedAuthority: farmRaw.secondDelegatedAuthority.toBase58(),
|
|
58318
|
-
padding: farmRaw.padding.map((item) => item.toString())
|
|
57913
|
+
}
|
|
57914
|
+
}))
|
|
58319
57915
|
};
|
|
58320
57916
|
}
|
|
58321
57917
|
var farmDiscriminator = Buffer.from([198, 102, 216, 74, 63, 66, 163, 190]);
|
|
@@ -58410,78 +58006,25 @@ function decodeFarmDataRaw(data) {
|
|
|
58410
58006
|
const dec = farmLayout.decode(data.slice(8));
|
|
58411
58007
|
return dec;
|
|
58412
58008
|
}
|
|
58413
|
-
function
|
|
58009
|
+
function dtoToKaminoFarmState(dto) {
|
|
58414
58010
|
return {
|
|
58415
|
-
farmAdmin: new web3_js.PublicKey(dto.farmAdmin),
|
|
58416
|
-
globalConfig: new web3_js.PublicKey(dto.globalConfig),
|
|
58417
58011
|
token: {
|
|
58418
58012
|
mint: new web3_js.PublicKey(dto.token.mint),
|
|
58419
|
-
decimals: new
|
|
58420
|
-
tokenProgram: new web3_js.PublicKey(dto.token.tokenProgram),
|
|
58421
|
-
padding: dto.token.padding.map((item) => new BN11__default.default(item))
|
|
58013
|
+
decimals: new BN8__default.default(dto.token.decimals)
|
|
58422
58014
|
},
|
|
58423
58015
|
rewardInfos: dto.rewardInfos.map((item) => ({
|
|
58424
58016
|
token: {
|
|
58425
58017
|
mint: new web3_js.PublicKey(item.token.mint),
|
|
58426
|
-
decimals: new
|
|
58427
|
-
tokenProgram: new web3_js.PublicKey(item.token.tokenProgram),
|
|
58428
|
-
padding: item.token.padding.map((p) => new BN11__default.default(p))
|
|
58018
|
+
decimals: new BN8__default.default(item.token.decimals)
|
|
58429
58019
|
},
|
|
58430
|
-
|
|
58431
|
-
rewardsAvailable: new BN11__default.default(item.rewardsAvailable),
|
|
58020
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58432
58021
|
rewardScheduleCurve: {
|
|
58433
58022
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58434
|
-
tsStart: new
|
|
58435
|
-
rewardPerTimeUnit: new
|
|
58023
|
+
tsStart: new BN8__default.default(p.tsStart),
|
|
58024
|
+
rewardPerTimeUnit: new BN8__default.default(p.rewardPerTimeUnit)
|
|
58436
58025
|
}))
|
|
58437
|
-
}
|
|
58438
|
-
|
|
58439
|
-
lastIssuanceTs: new BN11__default.default(item.lastIssuanceTs),
|
|
58440
|
-
rewardsIssuedUnclaimed: new BN11__default.default(item.rewardsIssuedUnclaimed),
|
|
58441
|
-
rewardsIssuedCumulative: new BN11__default.default(item.rewardsIssuedCumulative),
|
|
58442
|
-
rewardPerShareScaled: new BN11__default.default(item.rewardPerShareScaled),
|
|
58443
|
-
placeholder0: new BN11__default.default(item.placeholder0),
|
|
58444
|
-
rewardType: item.rewardType,
|
|
58445
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58446
|
-
padding0: item.padding0,
|
|
58447
|
-
padding1: item.padding1.map((p) => new BN11__default.default(p))
|
|
58448
|
-
})),
|
|
58449
|
-
numRewardTokens: new BN11__default.default(dto.numRewardTokens),
|
|
58450
|
-
numUsers: new BN11__default.default(dto.numUsers),
|
|
58451
|
-
totalStakedAmount: new BN11__default.default(dto.totalStakedAmount),
|
|
58452
|
-
farmVault: new web3_js.PublicKey(dto.farmVault),
|
|
58453
|
-
farmVaultsAuthority: new web3_js.PublicKey(dto.farmVaultsAuthority),
|
|
58454
|
-
farmVaultsAuthorityBump: new BN11__default.default(dto.farmVaultsAuthorityBump),
|
|
58455
|
-
delegateAuthority: new web3_js.PublicKey(dto.delegateAuthority),
|
|
58456
|
-
timeUnit: dto.timeUnit,
|
|
58457
|
-
isFarmFrozen: dto.isFarmFrozen,
|
|
58458
|
-
isFarmDelegated: dto.isFarmDelegated,
|
|
58459
|
-
padding0: dto.padding0,
|
|
58460
|
-
withdrawAuthority: new web3_js.PublicKey(dto.withdrawAuthority),
|
|
58461
|
-
depositWarmupPeriod: dto.depositWarmupPeriod,
|
|
58462
|
-
withdrawalCooldownPeriod: dto.withdrawalCooldownPeriod,
|
|
58463
|
-
totalActiveStakeScaled: new BN11__default.default(dto.totalActiveStakeScaled),
|
|
58464
|
-
totalPendingStakeScaled: new BN11__default.default(dto.totalPendingStakeScaled),
|
|
58465
|
-
totalPendingAmount: new BN11__default.default(dto.totalPendingAmount),
|
|
58466
|
-
slashedAmountCurrent: new BN11__default.default(dto.slashedAmountCurrent),
|
|
58467
|
-
slashedAmountCumulative: new BN11__default.default(dto.slashedAmountCumulative),
|
|
58468
|
-
slashedAmountSpillAddress: new web3_js.PublicKey(dto.slashedAmountSpillAddress),
|
|
58469
|
-
lockingMode: new BN11__default.default(dto.lockingMode),
|
|
58470
|
-
lockingStartTimestamp: new BN11__default.default(dto.lockingStartTimestamp),
|
|
58471
|
-
lockingDuration: new BN11__default.default(dto.lockingDuration),
|
|
58472
|
-
lockingEarlyWithdrawalPenaltyBps: new BN11__default.default(
|
|
58473
|
-
dto.lockingEarlyWithdrawalPenaltyBps
|
|
58474
|
-
),
|
|
58475
|
-
depositCapAmount: new BN11__default.default(dto.depositCapAmount),
|
|
58476
|
-
scopePrices: new web3_js.PublicKey(dto.scopePrices),
|
|
58477
|
-
scopeOraclePriceId: new BN11__default.default(dto.scopeOraclePriceId),
|
|
58478
|
-
scopeOracleMaxAge: new BN11__default.default(dto.scopeOracleMaxAge),
|
|
58479
|
-
pendingFarmAdmin: new web3_js.PublicKey(dto.pendingFarmAdmin),
|
|
58480
|
-
strategyId: new web3_js.PublicKey(dto.strategyId),
|
|
58481
|
-
delegatedRpsAdmin: new web3_js.PublicKey(dto.delegatedRpsAdmin),
|
|
58482
|
-
vaultId: new web3_js.PublicKey(dto.vaultId),
|
|
58483
|
-
secondDelegatedAuthority: new web3_js.PublicKey(dto.secondDelegatedAuthority),
|
|
58484
|
-
padding: dto.padding.map((item) => new BN11__default.default(item))
|
|
58026
|
+
}
|
|
58027
|
+
}))
|
|
58485
58028
|
};
|
|
58486
58029
|
}
|
|
58487
58030
|
var KAMINO_PROGRAM_ID = new web3_js.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
@@ -59156,7 +58699,7 @@ function makePoolAddPermissionlessStakedBankIx2(programId, accounts, remainingAc
|
|
|
59156
58699
|
keys.push(...remainingAccounts);
|
|
59157
58700
|
const data = Buffer.concat([
|
|
59158
58701
|
DISCRIMINATORS.LENDING_POOL_ADD_BANK_PERMISSIONLESS,
|
|
59159
|
-
encodeU64(args.seed || new
|
|
58702
|
+
encodeU64(args.seed || new BN8__default.default(0))
|
|
59160
58703
|
]);
|
|
59161
58704
|
return new web3_js.TransactionInstruction({
|
|
59162
58705
|
keys,
|
|
@@ -60660,7 +60203,7 @@ function deserializeSwapEngineResult(s) {
|
|
|
60660
60203
|
setupInstructions: s.setupInstructions.map(deserializeInstruction),
|
|
60661
60204
|
swapLuts: s.swapLuts.map(deserializeLut),
|
|
60662
60205
|
quoteResponse: s.quoteResponse,
|
|
60663
|
-
outputAmountNative: new
|
|
60206
|
+
outputAmountNative: new BN8__default.default(s.outputAmountNative),
|
|
60664
60207
|
provider: s.provider
|
|
60665
60208
|
};
|
|
60666
60209
|
}
|
|
@@ -61459,8 +61002,8 @@ async function buildCandidates(req, apiConfig) {
|
|
|
61459
61002
|
swapInstructions: [deserializeJupiterInstruction2(build.swapInstruction)],
|
|
61460
61003
|
setupInstructions: (build.setupInstructions ?? []).map(deserializeJupiterInstruction2),
|
|
61461
61004
|
luts,
|
|
61462
|
-
outAmountNative: new
|
|
61463
|
-
otherAmountThresholdNative: new
|
|
61005
|
+
outAmountNative: new BN8__default.default(build.outAmount),
|
|
61006
|
+
otherAmountThresholdNative: new BN8__default.default(build.otherAmountThreshold),
|
|
61464
61007
|
quoteResult: mapBuildToQuoteResult(build),
|
|
61465
61008
|
label: `jupiter:maxAccounts=${maxAccounts}`
|
|
61466
61009
|
};
|
|
@@ -61557,8 +61100,8 @@ async function buildCandidates2(req, apiConfig) {
|
|
|
61557
61100
|
swapInstructions,
|
|
61558
61101
|
setupInstructions: [],
|
|
61559
61102
|
luts,
|
|
61560
|
-
outAmountNative: new
|
|
61561
|
-
otherAmountThresholdNative: new
|
|
61103
|
+
outAmountNative: new BN8__default.default(quote.outAmount),
|
|
61104
|
+
otherAmountThresholdNative: new BN8__default.default(quote.otherAmountThreshold),
|
|
61562
61105
|
quoteResult: { ...quote, provider: "TITAN" /* TITAN */ },
|
|
61563
61106
|
label: "titan:v3"
|
|
61564
61107
|
}
|
|
@@ -61614,14 +61157,14 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
|
|
|
61614
61157
|
marginfiAccount: marginfiAccountPk,
|
|
61615
61158
|
authority
|
|
61616
61159
|
},
|
|
61617
|
-
{ endIndex: new
|
|
61160
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
61618
61161
|
) : await instructions_default.makeBeginFlashLoanIx(
|
|
61619
61162
|
program,
|
|
61620
61163
|
{
|
|
61621
61164
|
marginfiAccount: marginfiAccountPk,
|
|
61622
61165
|
authority
|
|
61623
61166
|
},
|
|
61624
|
-
{ endIndex: new
|
|
61167
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
61625
61168
|
);
|
|
61626
61169
|
return { instructions: [ix], keys: [] };
|
|
61627
61170
|
}
|
|
@@ -62187,6 +61730,7 @@ async function buildRepayWithCollatFlashloanTx({
|
|
|
62187
61730
|
// src/services/account/utils/flashloan-size.utils.ts
|
|
62188
61731
|
var SWAP_MERGE_OVERHEAD = 150;
|
|
62189
61732
|
var FL_IX_OVERHEAD = 52;
|
|
61733
|
+
var OVERSIZED_TX_SENTINEL = MAX_TX_SIZE * 4;
|
|
62190
61734
|
function compactU16Size(n) {
|
|
62191
61735
|
return n < 128 ? 1 : n < 16384 ? 2 : 3;
|
|
62192
61736
|
}
|
|
@@ -62299,7 +61843,7 @@ function computeFlashLoanNonSwapBudget({
|
|
|
62299
61843
|
const beginFlIx = sync_instructions_default.makeBeginFlashLoanIx(
|
|
62300
61844
|
program.programId,
|
|
62301
61845
|
{ marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
|
|
62302
|
-
{ endIndex: new
|
|
61846
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
62303
61847
|
);
|
|
62304
61848
|
const endFlRemainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
|
|
62305
61849
|
const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
|
|
@@ -62343,7 +61887,13 @@ function compileFlashloanPrecheck({
|
|
|
62343
61887
|
recentBlockhash: web3_js.PublicKey.default.toBase58(),
|
|
62344
61888
|
instructions: allIxs
|
|
62345
61889
|
}).compileToV0Message(luts);
|
|
62346
|
-
|
|
61890
|
+
let rawSize;
|
|
61891
|
+
try {
|
|
61892
|
+
rawSize = new web3_js.VersionedTransaction(msg).serialize().length;
|
|
61893
|
+
} catch (e) {
|
|
61894
|
+
if (!(e instanceof RangeError)) throw e;
|
|
61895
|
+
rawSize = OVERSIZED_TX_SENTINEL;
|
|
61896
|
+
}
|
|
62347
61897
|
const fullTxSize = rawSize + FL_IX_OVERHEAD;
|
|
62348
61898
|
const overshoot = fullTxSize - MAX_TX_SIZE;
|
|
62349
61899
|
const { header, staticAccountKeys, addressTableLookups } = msg;
|
|
@@ -62872,7 +62422,7 @@ async function buildLoopFlashloanTx(params) {
|
|
|
62872
62422
|
const engineResult = await runLoopSwapEngine(descriptor, params);
|
|
62873
62423
|
const finalIxs = [...descriptor.innerIxs];
|
|
62874
62424
|
finalIxs.splice(descriptor.swapSlotIndex, 0, ...engineResult.swapInstructions);
|
|
62875
|
-
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new
|
|
62425
|
+
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new BN8__default.default(0);
|
|
62876
62426
|
const finalDepositNative = engineResult.outputAmountNative.add(principalNative);
|
|
62877
62427
|
const depositIxPosition = descriptor.depositIxIndex + engineResult.swapInstructions.length;
|
|
62878
62428
|
patchDepositAmount(finalIxs[depositIxPosition], finalDepositNative);
|
|
@@ -63084,7 +62634,7 @@ async function runLoopSwapEngine(descriptor, params) {
|
|
|
63084
62634
|
otherAmountThreshold: "0",
|
|
63085
62635
|
slippageBps: 0
|
|
63086
62636
|
},
|
|
63087
|
-
outputAmountNative: new
|
|
62637
|
+
outputAmountNative: new BN8__default.default(0)
|
|
63088
62638
|
};
|
|
63089
62639
|
}
|
|
63090
62640
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
@@ -64105,7 +63655,7 @@ async function buildRollPtFlashloanTx({
|
|
|
64105
63655
|
if (!depositIxToPatch) {
|
|
64106
63656
|
throw new Error("roll-pt: could not locate deposit instruction for amount patching");
|
|
64107
63657
|
}
|
|
64108
|
-
patchDepositAmount(depositIxToPatch, new
|
|
63658
|
+
patchDepositAmount(depositIxToPatch, new BN8__default.default(minPtOut.toString()));
|
|
64109
63659
|
const allNonFlIxs = [
|
|
64110
63660
|
...cuRequestIxs,
|
|
64111
63661
|
...withdrawIxs.instructions,
|
|
@@ -65343,7 +64893,7 @@ function composeBundle(firstLegTxs, secondLegTxs, payer, blockhash, maxBundleTxs
|
|
|
65343
64893
|
if (result.length > maxBundleTxs) return null;
|
|
65344
64894
|
return result;
|
|
65345
64895
|
}
|
|
65346
|
-
function
|
|
64896
|
+
function compoundQuoteRisk(firstLeg, secondLeg) {
|
|
65347
64897
|
const compound = (a, b) => {
|
|
65348
64898
|
if (a == null && b == null) return void 0;
|
|
65349
64899
|
const x = Number(a ?? 0);
|
|
@@ -65351,13 +64901,36 @@ function mergeBridgeQuotes(firstLeg, secondLeg) {
|
|
|
65351
64901
|
return String(1 - (1 - x) * (1 - y));
|
|
65352
64902
|
};
|
|
65353
64903
|
return {
|
|
65354
|
-
inAmount: firstLeg.inAmount,
|
|
65355
|
-
outAmount: secondLeg.outAmount,
|
|
65356
|
-
otherAmountThreshold: secondLeg.otherAmountThreshold,
|
|
65357
64904
|
slippageBps: Math.round(
|
|
65358
64905
|
(1 - (1 - firstLeg.slippageBps / 1e4) * (1 - secondLeg.slippageBps / 1e4)) * 1e4
|
|
65359
64906
|
),
|
|
65360
|
-
priceImpactPct: compound(firstLeg.priceImpactPct, secondLeg.priceImpactPct)
|
|
64907
|
+
priceImpactPct: compound(firstLeg.priceImpactPct, secondLeg.priceImpactPct)
|
|
64908
|
+
};
|
|
64909
|
+
}
|
|
64910
|
+
function mergeBridgeQuotes(firstLeg, secondLeg) {
|
|
64911
|
+
return {
|
|
64912
|
+
inAmount: firstLeg.inAmount,
|
|
64913
|
+
outAmount: secondLeg.outAmount,
|
|
64914
|
+
otherAmountThreshold: secondLeg.otherAmountThreshold,
|
|
64915
|
+
...compoundQuoteRisk(firstLeg, secondLeg),
|
|
64916
|
+
provider: firstLeg.provider
|
|
64917
|
+
};
|
|
64918
|
+
}
|
|
64919
|
+
function mergeBridgeQuotesDebt(firstLeg, secondLeg) {
|
|
64920
|
+
return {
|
|
64921
|
+
inAmount: firstLeg.outAmount,
|
|
64922
|
+
outAmount: secondLeg.inAmount,
|
|
64923
|
+
otherAmountThreshold: secondLeg.inAmount,
|
|
64924
|
+
...compoundQuoteRisk(firstLeg, secondLeg),
|
|
64925
|
+
provider: firstLeg.provider
|
|
64926
|
+
};
|
|
64927
|
+
}
|
|
64928
|
+
function mergeBridgeQuotesLoop(firstLeg, secondLeg) {
|
|
64929
|
+
return {
|
|
64930
|
+
inAmount: secondLeg.inAmount,
|
|
64931
|
+
outAmount: firstLeg.outAmount,
|
|
64932
|
+
otherAmountThreshold: firstLeg.otherAmountThreshold,
|
|
64933
|
+
...compoundQuoteRisk(firstLeg, secondLeg),
|
|
65361
64934
|
provider: firstLeg.provider
|
|
65362
64935
|
};
|
|
65363
64936
|
}
|
|
@@ -66146,6 +65719,33 @@ function patchDepositAmount(ix, amountNative) {
|
|
|
66146
65719
|
amountNative.toArrayLike(Buffer, "le", 8).copy(ix.data, DEPOSIT_AMOUNT_OFFSET);
|
|
66147
65720
|
}
|
|
66148
65721
|
|
|
65722
|
+
// src/services/account/utils/bridge.utils.ts
|
|
65723
|
+
function accountConflictsWithBridge(account, bankPk, side) {
|
|
65724
|
+
const balance = account.balances.find((b) => b.active && b.bankPk.equals(bankPk));
|
|
65725
|
+
if (!balance) return false;
|
|
65726
|
+
return side === "deposit" ? balance.liabilityShares.gt(0) : balance.assetShares.gt(0);
|
|
65727
|
+
}
|
|
65728
|
+
function resolveBridgeBanks(params) {
|
|
65729
|
+
const { orderedBridgeMints, banks, marginfiAccount, side } = params;
|
|
65730
|
+
const passesSideFilter = side === "borrow" ? isStandardBorrowable : isStandardDepositable;
|
|
65731
|
+
const bridges = [];
|
|
65732
|
+
const conflicts = [];
|
|
65733
|
+
const seenMints = /* @__PURE__ */ new Set();
|
|
65734
|
+
for (const mint of orderedBridgeMints) {
|
|
65735
|
+
const mintKey = mint.toBase58();
|
|
65736
|
+
if (seenMints.has(mintKey)) continue;
|
|
65737
|
+
seenMints.add(mintKey);
|
|
65738
|
+
const bank = banks.find((b) => b.mint.equals(mint) && passesSideFilter(b));
|
|
65739
|
+
if (!bank) continue;
|
|
65740
|
+
if (accountConflictsWithBridge(marginfiAccount, bank.address, side)) {
|
|
65741
|
+
conflicts.push(bank);
|
|
65742
|
+
} else {
|
|
65743
|
+
bridges.push(bank);
|
|
65744
|
+
}
|
|
65745
|
+
}
|
|
65746
|
+
return { bridges, conflicts };
|
|
65747
|
+
}
|
|
65748
|
+
|
|
66149
65749
|
// src/services/price/utils/smart-crank.utils.ts
|
|
66150
65750
|
async function computeSmartCrank({
|
|
66151
65751
|
marginfiAccount,
|
|
@@ -66605,9 +66205,9 @@ function dtoToBankMetadataMap(bankMetadataDto) {
|
|
|
66605
66205
|
function dtoToBankMetadata(bankMetadataDto) {
|
|
66606
66206
|
return {
|
|
66607
66207
|
kaminoStates: bankMetadataDto.kaminoStates ? {
|
|
66608
|
-
reserveState:
|
|
66609
|
-
obligationState:
|
|
66610
|
-
farmState: bankMetadataDto.kaminoStates.farmState ?
|
|
66208
|
+
reserveState: dtoToKaminoReserve(bankMetadataDto.kaminoStates.reserveState),
|
|
66209
|
+
obligationState: dtoToKaminoObligation(bankMetadataDto.kaminoStates.obligationState),
|
|
66210
|
+
farmState: bankMetadataDto.kaminoStates.farmState ? dtoToKaminoFarmState(bankMetadataDto.kaminoStates.farmState) : void 0
|
|
66611
66211
|
} : void 0,
|
|
66612
66212
|
driftStates: bankMetadataDto.driftStates ? {
|
|
66613
66213
|
spotMarketState: dtoToDriftSpotMarketRaw(bankMetadataDto.driftStates.spotMarketState),
|
|
@@ -66622,16 +66222,16 @@ function dtoToBankMetadata(bankMetadataDto) {
|
|
|
66622
66222
|
),
|
|
66623
66223
|
jupRewardsRateModel: bankMetadataDto.jupLendStates.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(bankMetadataDto.jupLendStates.jupRewardsRateModel) : null,
|
|
66624
66224
|
jupRateModel: bankMetadataDto.jupLendStates.jupRateModel ? dtoToJupRateModelRaw(bankMetadataDto.jupLendStates.jupRateModel) : null,
|
|
66625
|
-
fTokenTotalSupply: new
|
|
66225
|
+
fTokenTotalSupply: new BN8__default.default(bankMetadataDto.jupLendStates.fTokenTotalSupply)
|
|
66626
66226
|
} : void 0
|
|
66627
66227
|
};
|
|
66628
66228
|
}
|
|
66629
66229
|
function bankMetadataToDto(bankMetadata) {
|
|
66630
66230
|
return {
|
|
66631
66231
|
kaminoStates: bankMetadata.kaminoStates ? {
|
|
66632
|
-
reserveState:
|
|
66633
|
-
obligationState:
|
|
66634
|
-
farmState: bankMetadata.kaminoStates.farmState ?
|
|
66232
|
+
reserveState: kaminoReserveToDto(bankMetadata.kaminoStates.reserveState),
|
|
66233
|
+
obligationState: kaminoObligationToDto(bankMetadata.kaminoStates.obligationState),
|
|
66234
|
+
farmState: bankMetadata.kaminoStates.farmState ? kaminoFarmStateToDto(bankMetadata.kaminoStates.farmState) : void 0
|
|
66635
66235
|
} : void 0,
|
|
66636
66236
|
driftStates: bankMetadata.driftStates ? {
|
|
66637
66237
|
spotMarketState: driftSpotMarketRawToDto(bankMetadata.driftStates.spotMarketState),
|
|
@@ -66940,8 +66540,8 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
66940
66540
|
const brokenSwbFeeds = [];
|
|
66941
66541
|
Object.keys(swbOracleAiDataByKey).forEach((oracleKey) => {
|
|
66942
66542
|
const oracleAiData = swbOracleAiDataByKey[oracleKey];
|
|
66943
|
-
const rawPriceBN = new
|
|
66944
|
-
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new
|
|
66543
|
+
const rawPriceBN = new BN8__default.default(oracleAiData.rawPrice);
|
|
66544
|
+
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new BN8__default.default(1e-6)) || rawPriceBN.eq(new BN8__default.default(1e-8));
|
|
66945
66545
|
if (isFeedBroken) {
|
|
66946
66546
|
const bank = switchboardBanks.find(
|
|
66947
66547
|
(bank2) => bank2.config.oracleKeys[0].toBase58() === oracleKey
|
|
@@ -67646,6 +67246,14 @@ function computeRemainingCapacity(bank) {
|
|
|
67646
67246
|
}
|
|
67647
67247
|
|
|
67648
67248
|
// src/services/bank/utils/bank-metrics.utils.ts
|
|
67249
|
+
function isStandardBorrowable(bank) {
|
|
67250
|
+
const { assetTag, operationalState, borrowLimit } = bank.config;
|
|
67251
|
+
return (assetTag === 0 /* DEFAULT */ || assetTag === 1 /* SOL */) && operationalState === "Operational" /* Operational */ && borrowLimit.gt(0);
|
|
67252
|
+
}
|
|
67253
|
+
function isStandardDepositable(bank) {
|
|
67254
|
+
const { assetTag, operationalState } = bank.config;
|
|
67255
|
+
return (assetTag === 0 /* DEFAULT */ || assetTag === 1 /* SOL */) && operationalState === "Operational" /* Operational */;
|
|
67256
|
+
}
|
|
67649
67257
|
function computeBankTotalDeposits(bank, assetShareValueMultiplier) {
|
|
67650
67258
|
const totalAssets = getTotalAssetQuantity(bank).times(
|
|
67651
67259
|
assetShareValueMultiplier ?? 1
|
|
@@ -67832,7 +67440,7 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
67832
67440
|
isWritable: false
|
|
67833
67441
|
})),
|
|
67834
67442
|
{
|
|
67835
|
-
seed: new
|
|
67443
|
+
seed: new BN8__default.default(0)
|
|
67836
67444
|
}
|
|
67837
67445
|
);
|
|
67838
67446
|
return {
|
|
@@ -68764,9 +68372,9 @@ async function getKaminoMetadata(options) {
|
|
|
68764
68372
|
for (const [bankAddress, state] of Object.entries(kaminoStates)) {
|
|
68765
68373
|
kaminoMetadataMap.set(bankAddress, {
|
|
68766
68374
|
kaminoStates: {
|
|
68767
|
-
reserveState:
|
|
68768
|
-
obligationState:
|
|
68769
|
-
farmState: state.farmState ?
|
|
68375
|
+
reserveState: dtoToKaminoReserve(state.reserveState),
|
|
68376
|
+
obligationState: dtoToKaminoObligation(state.obligationState),
|
|
68377
|
+
farmState: state.farmState ? dtoToKaminoFarmState(state.farmState) : void 0
|
|
68770
68378
|
}
|
|
68771
68379
|
});
|
|
68772
68380
|
}
|
|
@@ -68798,8 +68406,8 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68798
68406
|
bankByFarmKey[reserveState.farmCollateral.toBase58()] = bank.bankAddress;
|
|
68799
68407
|
}
|
|
68800
68408
|
kaminoStatesMap[bank.bankAddress] = {
|
|
68801
|
-
reserveState:
|
|
68802
|
-
obligationState:
|
|
68409
|
+
reserveState: kaminoReserveToDto(reserveState),
|
|
68410
|
+
obligationState: kaminoObligationToDto(obligationState)
|
|
68803
68411
|
};
|
|
68804
68412
|
}
|
|
68805
68413
|
const allFarmKeys = Object.keys(bankByFarmKey);
|
|
@@ -68822,7 +68430,7 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68822
68430
|
const decodedFarmState = decodeFarmDataRaw(farmState.data);
|
|
68823
68431
|
kaminoStatesMap[bankKey] = {
|
|
68824
68432
|
...kaminoState,
|
|
68825
|
-
farmState:
|
|
68433
|
+
farmState: kaminoFarmStateToDto(decodedFarmState)
|
|
68826
68434
|
};
|
|
68827
68435
|
}
|
|
68828
68436
|
}
|
|
@@ -68953,7 +68561,7 @@ async function getJupLendMetadata(options) {
|
|
|
68953
68561
|
jupTokenReserveState: dtoToJupTokenReserveRaw(state.jupTokenReserveState),
|
|
68954
68562
|
jupRewardsRateModel: state.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(state.jupRewardsRateModel) : null,
|
|
68955
68563
|
jupRateModel: state.jupRateModel ? dtoToJupRateModelRaw(state.jupRateModel) : null,
|
|
68956
|
-
fTokenTotalSupply: new
|
|
68564
|
+
fTokenTotalSupply: new BN8__default.default(state.fTokenTotalSupply)
|
|
68957
68565
|
}
|
|
68958
68566
|
});
|
|
68959
68567
|
}
|
|
@@ -69068,7 +68676,7 @@ async function getJupLendStatesDto(connection, jupLendBanks) {
|
|
|
69068
68676
|
return jupLendStatesMap;
|
|
69069
68677
|
}
|
|
69070
68678
|
function getJupLendFTokenMultiplier(lendingState, tokenReserve, rewardsModel, fTokenTotalSupply, nowSeconds) {
|
|
69071
|
-
const currentTimestamp = new
|
|
68679
|
+
const currentTimestamp = new BN8__default.default(nowSeconds);
|
|
69072
68680
|
const newExchangePrice = calculateJupLendNewExchangePrice(
|
|
69073
68681
|
lendingState,
|
|
69074
68682
|
tokenReserve,
|
|
@@ -70676,6 +70284,7 @@ exports.USDC_DECIMALS = USDC_DECIMALS;
|
|
|
70676
70284
|
exports.USDC_MINT = USDC_MINT;
|
|
70677
70285
|
exports.WSOL_MINT = WSOL_MINT;
|
|
70678
70286
|
exports.ZERO_ORACLE_KEY = ZERO_ORACLE_KEY;
|
|
70287
|
+
exports.accountConflictsWithBridge = accountConflictsWithBridge;
|
|
70679
70288
|
exports.accountFlagToBN = accountFlagToBN;
|
|
70680
70289
|
exports.addOracleToBanksIx = addOracleToBanksIx;
|
|
70681
70290
|
exports.addTransactionMetadata = addTransactionMetadata;
|
|
@@ -70876,8 +70485,11 @@ exports.hasEmodeEntryFlag = hasEmodeEntryFlag;
|
|
|
70876
70485
|
exports.hasEmodeFlag = hasEmodeFlag;
|
|
70877
70486
|
exports.hasHealthCacheFlag = hasHealthCacheFlag;
|
|
70878
70487
|
exports.healthCacheToDto = healthCacheToDto;
|
|
70488
|
+
exports.isDecomposableSwapError = isDecomposableSwapError;
|
|
70879
70489
|
exports.isDepositIx = isDepositIx;
|
|
70880
70490
|
exports.isFlashloan = isFlashloan;
|
|
70491
|
+
exports.isStandardBorrowable = isStandardBorrowable;
|
|
70492
|
+
exports.isStandardDepositable = isStandardDepositable;
|
|
70881
70493
|
exports.isV0Tx = isV0Tx;
|
|
70882
70494
|
exports.isWeightedPrice = isWeightedPrice;
|
|
70883
70495
|
exports.isWholePosition = isWholePosition;
|
|
@@ -70946,6 +70558,8 @@ exports.mapPythBanksToOraclePrices = mapPythBanksToOraclePrices;
|
|
|
70946
70558
|
exports.mapSwbBanksToOraclePrices = mapSwbBanksToOraclePrices;
|
|
70947
70559
|
exports.marginfiAccountToDto = marginfiAccountToDto;
|
|
70948
70560
|
exports.mergeBridgeQuotes = mergeBridgeQuotes;
|
|
70561
|
+
exports.mergeBridgeQuotesDebt = mergeBridgeQuotesDebt;
|
|
70562
|
+
exports.mergeBridgeQuotesLoop = mergeBridgeQuotesLoop;
|
|
70949
70563
|
exports.nativeToUi = nativeToUi;
|
|
70950
70564
|
exports.oraclePriceToDto = oraclePriceToDto;
|
|
70951
70565
|
exports.parseBalanceRaw = parseBalanceRaw;
|
|
@@ -70965,6 +70579,7 @@ exports.parseSwbOraclePriceData = parseSwbOraclePriceData;
|
|
|
70965
70579
|
exports.partitionBanksByCrankability = partitionBanksByCrankability;
|
|
70966
70580
|
exports.patchDepositAmount = patchDepositAmount;
|
|
70967
70581
|
exports.resolveAmount = resolveAmount;
|
|
70582
|
+
exports.resolveBridgeBanks = resolveBridgeBanks;
|
|
70968
70583
|
exports.runSwapEngine = runSwapEngine;
|
|
70969
70584
|
exports.selectLutsForAccountAction = selectLutsForAccountAction;
|
|
70970
70585
|
exports.selectLutsForBanks = selectLutsForBanks;
|