@0dotxyz/p0-ts-sdk 2.3.3 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dto-rate-model.types-CfqbDcgG.d.cts +869 -0
- package/dist/dto-rate-model.types-CfqbDcgG.d.ts +869 -0
- package/dist/index.cjs +272 -731
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +270 -729
- 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-BnW15JjT.d.cts} +10 -10
- package/dist/{types-DtUR-yHt.d.cts → types-CviIoob4.d.ts} +10 -10
- package/dist/vendor.cjs +262 -721
- 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 +253 -712
- 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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey, SolanaJSONRPCError, ComputeBudgetProgram, SystemProgram, TransactionMessage, VersionedTransaction, Keypair, Transaction, TransactionInstruction, AddressLookupTableAccount, SYSVAR_RENT_PUBKEY, StakeProgram, LAMPORTS_PER_SOL, StakeAuthorizationLayout, SYSVAR_INSTRUCTIONS_PUBKEY, STAKE_CONFIG_ID as STAKE_CONFIG_ID$1 } from '@solana/web3.js';
|
|
2
2
|
import { object, string, enums, array, assert } from 'superstruct';
|
|
3
3
|
import BigNumber3, { BigNumber } from 'bignumber.js';
|
|
4
|
-
import
|
|
4
|
+
import BN8, { BN } from 'bn.js';
|
|
5
5
|
import Decimal3, { Decimal } from 'decimal.js';
|
|
6
6
|
import { BorshCoder, BorshAccountsCoder, BorshInstructionCoder, AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
7
7
|
import { struct, u32, u8 } from '@solana/buffer-layout';
|
|
@@ -404,7 +404,7 @@ function bigNumberToWrappedI80F48(value) {
|
|
|
404
404
|
let decimalValue = new Decimal(value.toString());
|
|
405
405
|
const isNegative = decimalValue.isNegative();
|
|
406
406
|
decimalValue = decimalValue.times(I80F48_DIVISOR);
|
|
407
|
-
let wrappedValue = new
|
|
407
|
+
let wrappedValue = new BN8(decimalValue.round().toFixed()).toArray();
|
|
408
408
|
if (wrappedValue.length < I80F48_TOTAL_BYTES) {
|
|
409
409
|
const padding = Array(I80F48_TOTAL_BYTES - wrappedValue.length).fill(0);
|
|
410
410
|
wrappedValue.unshift(...padding);
|
|
@@ -438,7 +438,7 @@ function toBigNumber(amount) {
|
|
|
438
438
|
}
|
|
439
439
|
function uiToNative(amount, decimals) {
|
|
440
440
|
let amt = toBigNumber(amount);
|
|
441
|
-
return new
|
|
441
|
+
return new BN8(amt.times(10 ** decimals).toFixed(0, BigNumber3.ROUND_FLOOR));
|
|
442
442
|
}
|
|
443
443
|
function uiToNativeBigNumber(amount, decimals) {
|
|
444
444
|
let amt = toBigNumber(amount);
|
|
@@ -15779,7 +15779,7 @@ async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remain
|
|
|
15779
15779
|
tokenProgram = TOKEN_PROGRAM_ID,
|
|
15780
15780
|
...optionalAccounts
|
|
15781
15781
|
} = accounts;
|
|
15782
|
-
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new
|
|
15782
|
+
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN8(0)).accounts({
|
|
15783
15783
|
stakedSettings,
|
|
15784
15784
|
feePayer,
|
|
15785
15785
|
bankMint,
|
|
@@ -15843,7 +15843,7 @@ var instructions = {
|
|
|
15843
15843
|
var instructions_default = instructions;
|
|
15844
15844
|
function serializeBankConfigOpt(bankConfigOpt) {
|
|
15845
15845
|
const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
|
|
15846
|
-
const toBN = (value) => value && new
|
|
15846
|
+
const toBN = (value) => value && new BN8(value.toString());
|
|
15847
15847
|
return {
|
|
15848
15848
|
assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
|
|
15849
15849
|
assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
|
|
@@ -16196,16 +16196,16 @@ function bankConfigToBankConfigRaw(config) {
|
|
|
16196
16196
|
assetWeightMaint: bigNumberToWrappedI80F48(config.assetWeightMaint),
|
|
16197
16197
|
liabilityWeightInit: bigNumberToWrappedI80F48(config.liabilityWeightInit),
|
|
16198
16198
|
liabilityWeightMaint: bigNumberToWrappedI80F48(config.liabilityWeightMaint),
|
|
16199
|
-
depositLimit: new
|
|
16199
|
+
depositLimit: new BN8(config.depositLimit.toString()),
|
|
16200
16200
|
interestRateConfig: serializeInterestRateConfig(config.interestRateConfig),
|
|
16201
16201
|
operationalState: serializeOperationalState(config.operationalState),
|
|
16202
16202
|
oracleSetup: serializeOracleSetup(config.oracleSetup),
|
|
16203
16203
|
oracleKeys: config.oracleKeys,
|
|
16204
16204
|
configFlags: config.configFlags,
|
|
16205
|
-
borrowLimit: new
|
|
16205
|
+
borrowLimit: new BN8(config.borrowLimit.toString()),
|
|
16206
16206
|
riskTier: serializeRiskTier(config.riskTier),
|
|
16207
16207
|
assetTag: config.assetTag,
|
|
16208
|
-
totalAssetValueInitLimit: new
|
|
16208
|
+
totalAssetValueInitLimit: new BN8(config.totalAssetValueInitLimit.toString()),
|
|
16209
16209
|
oracleMaxAge: config.oracleMaxAge,
|
|
16210
16210
|
oracleMaxConfidence: config.oracleMaxConfidence,
|
|
16211
16211
|
fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice)
|
|
@@ -16537,12 +16537,12 @@ function dtoToBankRaw(bankDto) {
|
|
|
16537
16537
|
feeVaultBump: bankDto.feeVaultBump,
|
|
16538
16538
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
16539
16539
|
collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
|
|
16540
|
-
lastUpdate: new
|
|
16540
|
+
lastUpdate: new BN8(bankDto.lastUpdate),
|
|
16541
16541
|
config: dtoToBankConfigRaw(bankDto.config),
|
|
16542
16542
|
totalAssetShares: bankDto.totalAssetShares,
|
|
16543
16543
|
totalLiabilityShares: bankDto.totalLiabilityShares,
|
|
16544
|
-
flags: new
|
|
16545
|
-
emissionsRate: new
|
|
16544
|
+
flags: new BN8(bankDto.flags),
|
|
16545
|
+
emissionsRate: new BN8(bankDto.emissionsRate),
|
|
16546
16546
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
16547
16547
|
emissionsMint: new PublicKey(bankDto.emissionsMint),
|
|
16548
16548
|
collectedProgramFeesOutstanding: bankDto.collectedProgramFeesOutstanding,
|
|
@@ -16558,11 +16558,11 @@ function dtoToBankRaw(bankDto) {
|
|
|
16558
16558
|
}
|
|
16559
16559
|
function dtoToRateLimitWindowRaw(window) {
|
|
16560
16560
|
return {
|
|
16561
|
-
maxOutflow: new
|
|
16562
|
-
windowDuration: new
|
|
16563
|
-
windowStart: new
|
|
16564
|
-
prevWindowOutflow: new
|
|
16565
|
-
curWindowOutflow: new
|
|
16561
|
+
maxOutflow: new BN8(window.maxOutflow),
|
|
16562
|
+
windowDuration: new BN8(window.windowDuration),
|
|
16563
|
+
windowStart: new BN8(window.windowStart),
|
|
16564
|
+
prevWindowOutflow: new BN8(window.prevWindowOutflow),
|
|
16565
|
+
curWindowOutflow: new BN8(window.curWindowOutflow)
|
|
16566
16566
|
};
|
|
16567
16567
|
}
|
|
16568
16568
|
function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
@@ -16574,8 +16574,8 @@ function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
|
16574
16574
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
16575
16575
|
return {
|
|
16576
16576
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
16577
|
-
timestamp: new
|
|
16578
|
-
flags: new
|
|
16577
|
+
timestamp: new BN8(emodeSettingsDto.timestamp),
|
|
16578
|
+
flags: new BN8(emodeSettingsDto.flags),
|
|
16579
16579
|
emodeConfig: {
|
|
16580
16580
|
entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
|
|
16581
16581
|
return {
|
|
@@ -16594,11 +16594,11 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
16594
16594
|
assetWeightMaint: bankConfigDto.assetWeightMaint,
|
|
16595
16595
|
liabilityWeightInit: bankConfigDto.liabilityWeightInit,
|
|
16596
16596
|
liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
|
|
16597
|
-
depositLimit: new
|
|
16598
|
-
borrowLimit: new
|
|
16597
|
+
depositLimit: new BN8(bankConfigDto.depositLimit),
|
|
16598
|
+
borrowLimit: new BN8(bankConfigDto.borrowLimit),
|
|
16599
16599
|
riskTier: bankConfigDto.riskTier,
|
|
16600
16600
|
operationalState: bankConfigDto.operationalState,
|
|
16601
|
-
totalAssetValueInitLimit: new
|
|
16601
|
+
totalAssetValueInitLimit: new BN8(bankConfigDto.totalAssetValueInitLimit),
|
|
16602
16602
|
assetTag: bankConfigDto.assetTag,
|
|
16603
16603
|
configFlags: bankConfigDto.configFlags,
|
|
16604
16604
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
@@ -16746,7 +16746,7 @@ function getActiveEmodeFlags(flags) {
|
|
|
16746
16746
|
return activeFlags;
|
|
16747
16747
|
}
|
|
16748
16748
|
function hasEmodeFlag(flags, flag) {
|
|
16749
|
-
return !flags.and(new
|
|
16749
|
+
return !flags.and(new BN8(flag)).isZero();
|
|
16750
16750
|
}
|
|
16751
16751
|
function getActiveEmodeEntryFlags(flags) {
|
|
16752
16752
|
const activeFlags = [];
|
|
@@ -19735,8 +19735,8 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
|
|
|
19735
19735
|
const crossbarData = crossbarResponse[oracleFeed]?.results;
|
|
19736
19736
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19737
19737
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19738
|
-
crossbarData ?? new
|
|
19739
|
-
new
|
|
19738
|
+
crossbarData ?? new BN8(oracleData.rawPrice),
|
|
19739
|
+
new BN8(oracleData.stdev),
|
|
19740
19740
|
timestamp,
|
|
19741
19741
|
oracleData
|
|
19742
19742
|
);
|
|
@@ -19762,7 +19762,7 @@ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse
|
|
|
19762
19762
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19763
19763
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19764
19764
|
[birdeyeData],
|
|
19765
|
-
new
|
|
19765
|
+
new BN8(oracleData.stdev),
|
|
19766
19766
|
timestamp,
|
|
19767
19767
|
oracleData
|
|
19768
19768
|
);
|
|
@@ -20378,7 +20378,7 @@ var EMPTY_HEALTH_CACHE = {
|
|
|
20378
20378
|
liabilityValue: {
|
|
20379
20379
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
20380
20380
|
},
|
|
20381
|
-
timestamp: new
|
|
20381
|
+
timestamp: new BN8(0),
|
|
20382
20382
|
flags: 0,
|
|
20383
20383
|
prices: [],
|
|
20384
20384
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3(0)),
|
|
@@ -20465,7 +20465,7 @@ function getActiveAccountFlags(flags) {
|
|
|
20465
20465
|
return activeFlags;
|
|
20466
20466
|
}
|
|
20467
20467
|
function hasAccountFlag(flags, flag) {
|
|
20468
|
-
return !flags.and(new
|
|
20468
|
+
return !flags.and(new BN8(flag)).isZero();
|
|
20469
20469
|
}
|
|
20470
20470
|
function getActiveHealthCacheFlags(flags) {
|
|
20471
20471
|
const activeFlags = [];
|
|
@@ -20535,7 +20535,7 @@ function dtoToHealthCache(healthCacheDto) {
|
|
|
20535
20535
|
};
|
|
20536
20536
|
}
|
|
20537
20537
|
function accountFlagToBN(flag) {
|
|
20538
|
-
return new
|
|
20538
|
+
return new BN8(flag);
|
|
20539
20539
|
}
|
|
20540
20540
|
function marginfiAccountToDto(marginfiAccount) {
|
|
20541
20541
|
return {
|
|
@@ -35725,23 +35725,23 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35725
35725
|
authority: new PublicKey(userStatsDto.authority),
|
|
35726
35726
|
referrer: new PublicKey(userStatsDto.referrer),
|
|
35727
35727
|
fees: {
|
|
35728
|
-
totalFeePaid: new
|
|
35729
|
-
totalFeeRebate: new
|
|
35730
|
-
totalTokenDiscount: new
|
|
35731
|
-
totalRefereeDiscount: new
|
|
35732
|
-
totalReferrerReward: new
|
|
35733
|
-
currentEpochReferrerReward: new
|
|
35728
|
+
totalFeePaid: new BN8(userStatsDto.fees.totalFeePaid),
|
|
35729
|
+
totalFeeRebate: new BN8(userStatsDto.fees.totalFeeRebate),
|
|
35730
|
+
totalTokenDiscount: new BN8(userStatsDto.fees.totalTokenDiscount),
|
|
35731
|
+
totalRefereeDiscount: new BN8(userStatsDto.fees.totalRefereeDiscount),
|
|
35732
|
+
totalReferrerReward: new BN8(userStatsDto.fees.totalReferrerReward),
|
|
35733
|
+
currentEpochReferrerReward: new BN8(
|
|
35734
35734
|
userStatsDto.fees.currentEpochReferrerReward
|
|
35735
35735
|
)
|
|
35736
35736
|
},
|
|
35737
|
-
nextEpochTs: new
|
|
35738
|
-
makerVolume30d: new
|
|
35739
|
-
takerVolume30d: new
|
|
35740
|
-
fillerVolume30d: new
|
|
35741
|
-
lastMakerVolume30dTs: new
|
|
35742
|
-
lastTakerVolume30dTs: new
|
|
35743
|
-
lastFillerVolume30dTs: new
|
|
35744
|
-
ifStakedQuoteAssetAmount: new
|
|
35737
|
+
nextEpochTs: new BN8(userStatsDto.nextEpochTs),
|
|
35738
|
+
makerVolume30d: new BN8(userStatsDto.makerVolume30d),
|
|
35739
|
+
takerVolume30d: new BN8(userStatsDto.takerVolume30d),
|
|
35740
|
+
fillerVolume30d: new BN8(userStatsDto.fillerVolume30d),
|
|
35741
|
+
lastMakerVolume30dTs: new BN8(userStatsDto.lastMakerVolume30dTs),
|
|
35742
|
+
lastTakerVolume30dTs: new BN8(userStatsDto.lastTakerVolume30dTs),
|
|
35743
|
+
lastFillerVolume30dTs: new BN8(userStatsDto.lastFillerVolume30dTs),
|
|
35744
|
+
ifStakedQuoteAssetAmount: new BN8(userStatsDto.ifStakedQuoteAssetAmount),
|
|
35745
35745
|
numberOfSubAccounts: userStatsDto.numberOfSubAccounts,
|
|
35746
35746
|
numberOfSubAccountsCreated: userStatsDto.numberOfSubAccountsCreated,
|
|
35747
35747
|
referrerStatus: userStatsDto.referrerStatus,
|
|
@@ -35754,7 +35754,7 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35754
35754
|
fuelPositions: userStatsDto.fuelPositions,
|
|
35755
35755
|
fuelTaker: userStatsDto.fuelTaker,
|
|
35756
35756
|
fuelMaker: userStatsDto.fuelMaker,
|
|
35757
|
-
ifStakedGovTokenAmount: new
|
|
35757
|
+
ifStakedGovTokenAmount: new BN8(userStatsDto.ifStakedGovTokenAmount),
|
|
35758
35758
|
lastFuelIfBonusUpdateTs: userStatsDto.lastFuelIfBonusUpdateTs,
|
|
35759
35759
|
padding: userStatsDto.padding
|
|
35760
35760
|
};
|
|
@@ -35763,10 +35763,10 @@ function dtoToDriftUserRaw(userDto) {
|
|
|
35763
35763
|
return {
|
|
35764
35764
|
authority: new PublicKey(userDto.authority),
|
|
35765
35765
|
spotPositions: userDto.spotPositions.map((p) => ({
|
|
35766
|
-
scaledBalance: new
|
|
35767
|
-
openBids: new
|
|
35768
|
-
openAsks: new
|
|
35769
|
-
cumulativeDeposits: new
|
|
35766
|
+
scaledBalance: new BN8(p.scaledBalance),
|
|
35767
|
+
openBids: new BN8(p.openBids),
|
|
35768
|
+
openAsks: new BN8(p.openAsks),
|
|
35769
|
+
cumulativeDeposits: new BN8(p.cumulativeDeposits),
|
|
35770
35770
|
marketIndex: p.marketIndex,
|
|
35771
35771
|
balanceType: p.balanceType,
|
|
35772
35772
|
openOrders: p.openOrders,
|
|
@@ -35781,10 +35781,10 @@ function dtoToDriftRewardsRaw(rewardsDto) {
|
|
|
35781
35781
|
spotMarket: new PublicKey(rewardsDto.spotMarket),
|
|
35782
35782
|
mint: new PublicKey(rewardsDto.mint),
|
|
35783
35783
|
spotPosition: {
|
|
35784
|
-
scaledBalance: new
|
|
35785
|
-
openBids: new
|
|
35786
|
-
openAsks: new
|
|
35787
|
-
cumulativeDeposits: new
|
|
35784
|
+
scaledBalance: new BN8(rewardsDto.spotPosition.scaledBalance),
|
|
35785
|
+
openBids: new BN8(rewardsDto.spotPosition.openBids),
|
|
35786
|
+
openAsks: new BN8(rewardsDto.spotPosition.openAsks),
|
|
35787
|
+
cumulativeDeposits: new BN8(rewardsDto.spotPosition.cumulativeDeposits),
|
|
35788
35788
|
marketIndex: rewardsDto.spotPosition.marketIndex,
|
|
35789
35789
|
balanceType: rewardsDto.spotPosition.balanceType,
|
|
35790
35790
|
openOrders: rewardsDto.spotPosition.openOrders,
|
|
@@ -35798,11 +35798,11 @@ function dtoToDriftSpotMarketRaw(spotMarketDto) {
|
|
|
35798
35798
|
oracle: new PublicKey(spotMarketDto.oracle),
|
|
35799
35799
|
mint: new PublicKey(spotMarketDto.mint),
|
|
35800
35800
|
decimals: spotMarketDto.decimals,
|
|
35801
|
-
cumulativeDepositInterest: new
|
|
35801
|
+
cumulativeDepositInterest: new BN8(spotMarketDto.cumulativeDepositInterest),
|
|
35802
35802
|
marketIndex: spotMarketDto.marketIndex,
|
|
35803
|
-
depositBalance: new
|
|
35804
|
-
borrowBalance: new
|
|
35805
|
-
cumulativeBorrowInterest: new
|
|
35803
|
+
depositBalance: new BN8(spotMarketDto.depositBalance),
|
|
35804
|
+
borrowBalance: new BN8(spotMarketDto.borrowBalance),
|
|
35805
|
+
cumulativeBorrowInterest: new BN8(spotMarketDto.cumulativeBorrowInterest),
|
|
35806
35806
|
optimalUtilization: spotMarketDto.optimalUtilization,
|
|
35807
35807
|
optimalBorrowRate: spotMarketDto.optimalBorrowRate,
|
|
35808
35808
|
maxBorrowRate: spotMarketDto.maxBorrowRate,
|
|
@@ -35891,10 +35891,10 @@ function decodeDriftUserData(data) {
|
|
|
35891
35891
|
return {
|
|
35892
35892
|
authority: decoded.authority,
|
|
35893
35893
|
spotPositions: decoded.spot_positions.map((p) => ({
|
|
35894
|
-
scaledBalance: new
|
|
35895
|
-
openBids: new
|
|
35896
|
-
openAsks: new
|
|
35897
|
-
cumulativeDeposits: new
|
|
35894
|
+
scaledBalance: new BN8(p.scaled_balance),
|
|
35895
|
+
openBids: new BN8(p.open_bids),
|
|
35896
|
+
openAsks: new BN8(p.open_asks),
|
|
35897
|
+
cumulativeDeposits: new BN8(p.cumulative_deposits),
|
|
35898
35898
|
marketIndex: p.market_index,
|
|
35899
35899
|
balanceType: p.balance_type,
|
|
35900
35900
|
openOrders: p.open_orders,
|
|
@@ -35964,7 +35964,7 @@ function deriveDriftSpotMarket(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
35964
35964
|
return PublicKey.findProgramAddressSync(
|
|
35965
35965
|
[
|
|
35966
35966
|
Buffer.from(SEED_SPOT_MARKET),
|
|
35967
|
-
new
|
|
35967
|
+
new BN8(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
35968
35968
|
],
|
|
35969
35969
|
programId
|
|
35970
35970
|
);
|
|
@@ -35973,7 +35973,7 @@ function deriveDriftSpotMarketVault(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
35973
35973
|
return PublicKey.findProgramAddressSync(
|
|
35974
35974
|
[
|
|
35975
35975
|
Buffer.from(SEED_SPOT_MARKET_VAULT),
|
|
35976
|
-
new
|
|
35976
|
+
new BN8(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
35977
35977
|
],
|
|
35978
35978
|
programId
|
|
35979
35979
|
);
|
|
@@ -36367,7 +36367,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36367
36367
|
assetShares: dummyWrappedI80F48,
|
|
36368
36368
|
liabilityShares: dummyWrappedI80F48,
|
|
36369
36369
|
emissionsOutstanding: dummyWrappedI80F48,
|
|
36370
|
-
lastUpdate: new
|
|
36370
|
+
lastUpdate: new BN8(0)
|
|
36371
36371
|
});
|
|
36372
36372
|
const rawAccount = {
|
|
36373
36373
|
group,
|
|
@@ -36380,7 +36380,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36380
36380
|
liabilityValue: {
|
|
36381
36381
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
36382
36382
|
},
|
|
36383
|
-
timestamp: new
|
|
36383
|
+
timestamp: new BN8(0),
|
|
36384
36384
|
flags: 0,
|
|
36385
36385
|
prices: [],
|
|
36386
36386
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3(0)),
|
|
@@ -36394,7 +36394,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36394
36394
|
mrgnErr: 0
|
|
36395
36395
|
},
|
|
36396
36396
|
emissionsDestinationAccount: new PublicKey("11111111111111111111111111111111"),
|
|
36397
|
-
accountFlags: new
|
|
36397
|
+
accountFlags: new BN8([0, 0, 0])
|
|
36398
36398
|
};
|
|
36399
36399
|
return parseMarginfiAccountRaw(accountKey, rawAccount);
|
|
36400
36400
|
}
|
|
@@ -36427,233 +36427,65 @@ async function makeRefreshingIxs({
|
|
|
36427
36427
|
}
|
|
36428
36428
|
|
|
36429
36429
|
// src/vendor/klend/utils/klend/serialize.utils.ts
|
|
36430
|
-
function
|
|
36430
|
+
function kaminoObligationToDto(obligation) {
|
|
36431
36431
|
return {
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36435
|
-
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
},
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
)
|
|
36444
|
-
lowestReserveDepositLiquidationLtv: obligationRaw.lowestReserveDepositLiquidationLtv.toString(),
|
|
36445
|
-
depositedValueSf: obligationRaw.depositedValueSf.toString(),
|
|
36446
|
-
borrows: obligationRaw.borrows.map(
|
|
36447
|
-
(item) => obligationLiquidityToDto(item)
|
|
36448
|
-
),
|
|
36449
|
-
borrowFactorAdjustedDebtValueSf: obligationRaw.borrowFactorAdjustedDebtValueSf.toString(),
|
|
36450
|
-
borrowedAssetsMarketValueSf: obligationRaw.borrowedAssetsMarketValueSf.toString(),
|
|
36451
|
-
allowedBorrowValueSf: obligationRaw.allowedBorrowValueSf.toString(),
|
|
36452
|
-
unhealthyBorrowValueSf: obligationRaw.unhealthyBorrowValueSf.toString(),
|
|
36453
|
-
depositsAssetTiers: obligationRaw.depositsAssetTiers,
|
|
36454
|
-
borrowsAssetTiers: obligationRaw.borrowsAssetTiers,
|
|
36455
|
-
elevationGroup: obligationRaw.elevationGroup,
|
|
36456
|
-
numOfObsoleteDepositReserves: obligationRaw.numOfObsoleteDepositReserves,
|
|
36457
|
-
hasDebt: obligationRaw.hasDebt,
|
|
36458
|
-
referrer: obligationRaw.referrer.toBase58(),
|
|
36459
|
-
borrowingDisabled: obligationRaw.borrowingDisabled,
|
|
36460
|
-
autodeleverageTargetLtvPct: obligationRaw.autodeleverageTargetLtvPct,
|
|
36461
|
-
lowestReserveDepositMaxLtvPct: obligationRaw.lowestReserveDepositMaxLtvPct,
|
|
36462
|
-
numOfObsoleteBorrowReserves: obligationRaw.numOfObsoleteBorrowReserves,
|
|
36463
|
-
reserved: obligationRaw.reserved,
|
|
36464
|
-
highestBorrowFactorPct: obligationRaw.highestBorrowFactorPct.toString(),
|
|
36465
|
-
autodeleverageMarginCallStartedTimestamp: obligationRaw.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
36466
|
-
orders: obligationRaw.orders.map((item) => obligationOrderToDto(item)),
|
|
36467
|
-
padding3: obligationRaw.padding3.map((item) => item.toString())
|
|
36468
|
-
};
|
|
36469
|
-
}
|
|
36470
|
-
function reserveRawToDto(reserveRaw) {
|
|
36471
|
-
return {
|
|
36472
|
-
version: reserveRaw.version.toString(),
|
|
36473
|
-
lastUpdate: {
|
|
36474
|
-
slot: reserveRaw.lastUpdate.slot.toString(),
|
|
36475
|
-
stale: reserveRaw.lastUpdate.stale,
|
|
36476
|
-
priceStatus: reserveRaw.lastUpdate.priceStatus,
|
|
36477
|
-
placeholder: reserveRaw.lastUpdate.placeholder
|
|
36478
|
-
},
|
|
36479
|
-
lendingMarket: reserveRaw.lendingMarket.toBase58(),
|
|
36480
|
-
farmCollateral: reserveRaw.farmCollateral.toBase58(),
|
|
36481
|
-
farmDebt: reserveRaw.farmDebt.toBase58(),
|
|
36482
|
-
liquidity: reserveLiquidityFieldsToDto(reserveRaw.liquidity),
|
|
36483
|
-
reserveLiquidityPadding: reserveRaw.reserveLiquidityPadding.map(
|
|
36484
|
-
(item) => item.toString()
|
|
36485
|
-
),
|
|
36486
|
-
collateral: {
|
|
36487
|
-
mintPubkey: reserveRaw.collateral.mintPubkey.toBase58(),
|
|
36488
|
-
mintTotalSupply: reserveRaw.collateral.mintTotalSupply.toString(),
|
|
36489
|
-
supplyVault: reserveRaw.collateral.supplyVault.toBase58(),
|
|
36490
|
-
padding1: reserveRaw.collateral.padding1.map((item) => item.toString()),
|
|
36491
|
-
padding2: reserveRaw.collateral.padding2.map((item) => item.toString())
|
|
36492
|
-
},
|
|
36493
|
-
reserveCollateralPadding: reserveRaw.reserveCollateralPadding.map(
|
|
36494
|
-
(item) => item.toString()
|
|
36495
|
-
),
|
|
36496
|
-
config: reserveConfigFieldsToDto(reserveRaw.config),
|
|
36497
|
-
configPadding: reserveRaw.configPadding.map((item) => item.toString()),
|
|
36498
|
-
borrowedAmountOutsideElevationGroup: reserveRaw.borrowedAmountOutsideElevationGroup.toString(),
|
|
36499
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveRaw.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
36500
|
-
(item) => item.toString()
|
|
36501
|
-
),
|
|
36502
|
-
padding: reserveRaw.padding.map((item) => item.toString())
|
|
36503
|
-
};
|
|
36504
|
-
}
|
|
36505
|
-
function reserveLiquidityFieldsToDto(reserveLiquidityFields) {
|
|
36506
|
-
return {
|
|
36507
|
-
mintPubkey: reserveLiquidityFields.mintPubkey.toBase58(),
|
|
36508
|
-
supplyVault: reserveLiquidityFields.supplyVault.toBase58(),
|
|
36509
|
-
feeVault: reserveLiquidityFields.feeVault.toBase58(),
|
|
36510
|
-
availableAmount: reserveLiquidityFields.availableAmount.toString(),
|
|
36511
|
-
borrowedAmountSf: reserveLiquidityFields.borrowedAmountSf.toString(),
|
|
36512
|
-
marketPriceSf: reserveLiquidityFields.marketPriceSf.toString(),
|
|
36513
|
-
marketPriceLastUpdatedTs: reserveLiquidityFields.marketPriceLastUpdatedTs.toString(),
|
|
36514
|
-
mintDecimals: reserveLiquidityFields.mintDecimals.toString(),
|
|
36515
|
-
depositLimitCrossedTimestamp: reserveLiquidityFields.depositLimitCrossedTimestamp.toString(),
|
|
36516
|
-
borrowLimitCrossedTimestamp: reserveLiquidityFields.borrowLimitCrossedTimestamp.toString(),
|
|
36517
|
-
cumulativeBorrowRateBsf: {
|
|
36518
|
-
value: reserveLiquidityFields.cumulativeBorrowRateBsf.value.map(
|
|
36519
|
-
(item) => item.toString()
|
|
36520
|
-
),
|
|
36521
|
-
padding: reserveLiquidityFields.cumulativeBorrowRateBsf.padding.map(
|
|
36522
|
-
(item) => item.toString()
|
|
36523
|
-
)
|
|
36524
|
-
},
|
|
36525
|
-
accumulatedProtocolFeesSf: reserveLiquidityFields.accumulatedProtocolFeesSf.toString(),
|
|
36526
|
-
accumulatedReferrerFeesSf: reserveLiquidityFields.accumulatedReferrerFeesSf.toString(),
|
|
36527
|
-
pendingReferrerFeesSf: reserveLiquidityFields.pendingReferrerFeesSf.toString(),
|
|
36528
|
-
absoluteReferralRateSf: reserveLiquidityFields.absoluteReferralRateSf.toString(),
|
|
36529
|
-
tokenProgram: reserveLiquidityFields.tokenProgram.toBase58(),
|
|
36530
|
-
padding2: reserveLiquidityFields.padding2.map((item) => item.toString()),
|
|
36531
|
-
padding3: reserveLiquidityFields.padding3.map((item) => item.toString())
|
|
36532
|
-
};
|
|
36533
|
-
}
|
|
36534
|
-
function reserveConfigFieldsToDto(reserveConfigFields) {
|
|
36535
|
-
return {
|
|
36536
|
-
status: reserveConfigFields.status,
|
|
36537
|
-
assetTier: reserveConfigFields.assetTier,
|
|
36538
|
-
hostFixedInterestRateBps: reserveConfigFields.hostFixedInterestRateBps,
|
|
36539
|
-
reserved2: reserveConfigFields.reserved2,
|
|
36540
|
-
protocolOrderExecutionFeePct: reserveConfigFields.protocolOrderExecutionFeePct,
|
|
36541
|
-
protocolTakeRatePct: reserveConfigFields.protocolTakeRatePct,
|
|
36542
|
-
protocolLiquidationFeePct: reserveConfigFields.protocolLiquidationFeePct,
|
|
36543
|
-
loanToValuePct: reserveConfigFields.loanToValuePct,
|
|
36544
|
-
liquidationThresholdPct: reserveConfigFields.liquidationThresholdPct,
|
|
36545
|
-
minLiquidationBonusBps: reserveConfigFields.minLiquidationBonusBps,
|
|
36546
|
-
maxLiquidationBonusBps: reserveConfigFields.maxLiquidationBonusBps,
|
|
36547
|
-
badDebtLiquidationBonusBps: reserveConfigFields.badDebtLiquidationBonusBps,
|
|
36548
|
-
deleveragingMarginCallPeriodSecs: reserveConfigFields.deleveragingMarginCallPeriodSecs.toString(),
|
|
36549
|
-
deleveragingThresholdDecreaseBpsPerDay: reserveConfigFields.deleveragingThresholdDecreaseBpsPerDay.toString(),
|
|
36550
|
-
fees: {
|
|
36551
|
-
borrowFeeSf: reserveConfigFields.fees.borrowFeeSf.toString(),
|
|
36552
|
-
flashLoanFeeSf: reserveConfigFields.fees.flashLoanFeeSf.toString(),
|
|
36553
|
-
padding: reserveConfigFields.fees.padding
|
|
36554
|
-
},
|
|
36555
|
-
borrowRateCurve: {
|
|
36556
|
-
points: reserveConfigFields.borrowRateCurve.points.map((item) => ({
|
|
36557
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
36558
|
-
borrowRateBps: item.borrowRateBps
|
|
36559
|
-
}))
|
|
36560
|
-
},
|
|
36561
|
-
borrowFactorPct: reserveConfigFields.borrowFactorPct.toString(),
|
|
36562
|
-
depositLimit: reserveConfigFields.depositLimit.toString(),
|
|
36563
|
-
borrowLimit: reserveConfigFields.borrowLimit.toString(),
|
|
36564
|
-
tokenInfo: tokenInfoFieldsToDto(reserveConfigFields.tokenInfo),
|
|
36565
|
-
depositWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36566
|
-
reserveConfigFields.depositWithdrawalCap
|
|
36567
|
-
),
|
|
36568
|
-
debtWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36569
|
-
reserveConfigFields.debtWithdrawalCap
|
|
36570
|
-
),
|
|
36571
|
-
elevationGroups: reserveConfigFields.elevationGroups,
|
|
36572
|
-
disableUsageAsCollOutsideEmode: reserveConfigFields.disableUsageAsCollOutsideEmode,
|
|
36573
|
-
utilizationLimitBlockBorrowingAbovePct: reserveConfigFields.utilizationLimitBlockBorrowingAbovePct,
|
|
36574
|
-
autodeleverageEnabled: reserveConfigFields.autodeleverageEnabled,
|
|
36575
|
-
reserved1: reserveConfigFields.reserved1,
|
|
36576
|
-
borrowLimitOutsideElevationGroup: reserveConfigFields.borrowLimitOutsideElevationGroup.toString(),
|
|
36577
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveConfigFields.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
36578
|
-
(item) => item.toString()
|
|
36579
|
-
),
|
|
36580
|
-
deleveragingBonusIncreaseBpsPerDay: reserveConfigFields.deleveragingBonusIncreaseBpsPerDay.toString()
|
|
36581
|
-
};
|
|
36582
|
-
}
|
|
36583
|
-
function tokenInfoFieldsToDto(tokenInfoFields) {
|
|
36584
|
-
return {
|
|
36585
|
-
name: tokenInfoFields.name,
|
|
36586
|
-
heuristic: {
|
|
36587
|
-
lower: tokenInfoFields.heuristic.lower.toString(),
|
|
36588
|
-
upper: tokenInfoFields.heuristic.upper.toString(),
|
|
36589
|
-
exp: tokenInfoFields.heuristic.exp.toString()
|
|
36590
|
-
},
|
|
36591
|
-
maxTwapDivergenceBps: tokenInfoFields.maxTwapDivergenceBps.toString(),
|
|
36592
|
-
maxAgePriceSeconds: tokenInfoFields.maxAgePriceSeconds.toString(),
|
|
36593
|
-
maxAgeTwapSeconds: tokenInfoFields.maxAgeTwapSeconds.toString(),
|
|
36594
|
-
scopeConfiguration: {
|
|
36595
|
-
priceFeed: tokenInfoFields.scopeConfiguration.priceFeed.toBase58(),
|
|
36596
|
-
priceChain: tokenInfoFields.scopeConfiguration.priceChain,
|
|
36597
|
-
twapChain: tokenInfoFields.scopeConfiguration.twapChain
|
|
36598
|
-
},
|
|
36599
|
-
switchboardConfiguration: {
|
|
36600
|
-
priceAggregator: tokenInfoFields.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36601
|
-
twapAggregator: tokenInfoFields.switchboardConfiguration.twapAggregator.toBase58()
|
|
36602
|
-
},
|
|
36603
|
-
pythConfiguration: {
|
|
36604
|
-
price: tokenInfoFields.pythConfiguration.price.toBase58()
|
|
36605
|
-
},
|
|
36606
|
-
blockPriceUsage: tokenInfoFields.blockPriceUsage,
|
|
36607
|
-
reserved: tokenInfoFields.reserved,
|
|
36608
|
-
padding: tokenInfoFields.padding.map((item) => item.toString())
|
|
36609
|
-
};
|
|
36610
|
-
}
|
|
36611
|
-
function withdrawalCapsFieldsToDto(withdrawalCapsFields) {
|
|
36612
|
-
return {
|
|
36613
|
-
configCapacity: withdrawalCapsFields.configCapacity.toString(),
|
|
36614
|
-
currentTotal: withdrawalCapsFields.currentTotal.toString(),
|
|
36615
|
-
lastIntervalStartTimestamp: withdrawalCapsFields.lastIntervalStartTimestamp.toString(),
|
|
36616
|
-
configIntervalLengthSeconds: withdrawalCapsFields.configIntervalLengthSeconds.toString()
|
|
36617
|
-
};
|
|
36618
|
-
}
|
|
36619
|
-
function obligationCollateralToDto(obligationCollateralFields) {
|
|
36620
|
-
return {
|
|
36621
|
-
depositReserve: obligationCollateralFields.depositReserve.toBase58(),
|
|
36622
|
-
depositedAmount: obligationCollateralFields.depositedAmount.toString(),
|
|
36623
|
-
marketValueSf: obligationCollateralFields.marketValueSf.toString(),
|
|
36624
|
-
borrowedAmountAgainstThisCollateralInElevationGroup: obligationCollateralFields.borrowedAmountAgainstThisCollateralInElevationGroup.toString(),
|
|
36625
|
-
padding: obligationCollateralFields.padding.map((item) => item.toString())
|
|
36432
|
+
lendingMarket: obligation.lendingMarket.toBase58(),
|
|
36433
|
+
owner: obligation.owner.toBase58(),
|
|
36434
|
+
deposits: obligation.deposits.map((item) => ({
|
|
36435
|
+
depositReserve: item.depositReserve.toBase58(),
|
|
36436
|
+
depositedAmount: item.depositedAmount.toString(),
|
|
36437
|
+
marketValueSf: item.marketValueSf.toString()
|
|
36438
|
+
})),
|
|
36439
|
+
borrows: obligation.borrows.map((item) => ({
|
|
36440
|
+
borrowReserve: item.borrowReserve.toBase58(),
|
|
36441
|
+
borrowedAmountSf: item.borrowedAmountSf.toString(),
|
|
36442
|
+
marketValueSf: item.marketValueSf.toString()
|
|
36443
|
+
}))
|
|
36626
36444
|
};
|
|
36627
36445
|
}
|
|
36628
|
-
function
|
|
36446
|
+
function kaminoReserveToDto(reserve) {
|
|
36629
36447
|
return {
|
|
36630
|
-
|
|
36631
|
-
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
),
|
|
36635
|
-
|
|
36636
|
-
|
|
36637
|
-
)
|
|
36448
|
+
lendingMarket: reserve.lendingMarket.toBase58(),
|
|
36449
|
+
farmCollateral: reserve.farmCollateral.toBase58(),
|
|
36450
|
+
liquidity: {
|
|
36451
|
+
mintPubkey: reserve.liquidity.mintPubkey.toBase58(),
|
|
36452
|
+
supplyVault: reserve.liquidity.supplyVault.toBase58(),
|
|
36453
|
+
mintDecimals: reserve.liquidity.mintDecimals.toString(),
|
|
36454
|
+
availableAmount: reserve.liquidity.availableAmount.toString(),
|
|
36455
|
+
borrowedAmountSf: reserve.liquidity.borrowedAmountSf.toString(),
|
|
36456
|
+
accumulatedProtocolFeesSf: reserve.liquidity.accumulatedProtocolFeesSf.toString(),
|
|
36457
|
+
accumulatedReferrerFeesSf: reserve.liquidity.accumulatedReferrerFeesSf.toString(),
|
|
36458
|
+
pendingReferrerFeesSf: reserve.liquidity.pendingReferrerFeesSf.toString()
|
|
36638
36459
|
},
|
|
36639
|
-
|
|
36640
|
-
|
|
36641
|
-
|
|
36642
|
-
|
|
36643
|
-
|
|
36644
|
-
|
|
36645
|
-
|
|
36646
|
-
|
|
36647
|
-
|
|
36648
|
-
|
|
36649
|
-
|
|
36650
|
-
|
|
36651
|
-
|
|
36652
|
-
|
|
36653
|
-
|
|
36654
|
-
|
|
36655
|
-
|
|
36656
|
-
|
|
36460
|
+
collateral: {
|
|
36461
|
+
mintPubkey: reserve.collateral.mintPubkey.toBase58(),
|
|
36462
|
+
mintTotalSupply: reserve.collateral.mintTotalSupply.toString(),
|
|
36463
|
+
supplyVault: reserve.collateral.supplyVault.toBase58()
|
|
36464
|
+
},
|
|
36465
|
+
config: {
|
|
36466
|
+
protocolTakeRatePct: reserve.config.protocolTakeRatePct,
|
|
36467
|
+
hostFixedInterestRateBps: reserve.config.hostFixedInterestRateBps,
|
|
36468
|
+
depositLimit: reserve.config.depositLimit.toString(),
|
|
36469
|
+
borrowLimit: reserve.config.borrowLimit.toString(),
|
|
36470
|
+
borrowRateCurve: {
|
|
36471
|
+
points: reserve.config.borrowRateCurve.points.map((item) => ({
|
|
36472
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
36473
|
+
borrowRateBps: item.borrowRateBps
|
|
36474
|
+
}))
|
|
36475
|
+
},
|
|
36476
|
+
tokenInfo: {
|
|
36477
|
+
scopeConfiguration: {
|
|
36478
|
+
priceFeed: reserve.config.tokenInfo.scopeConfiguration.priceFeed.toBase58()
|
|
36479
|
+
},
|
|
36480
|
+
switchboardConfiguration: {
|
|
36481
|
+
priceAggregator: reserve.config.tokenInfo.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36482
|
+
twapAggregator: reserve.config.tokenInfo.switchboardConfiguration.twapAggregator.toBase58()
|
|
36483
|
+
},
|
|
36484
|
+
pythConfiguration: {
|
|
36485
|
+
price: reserve.config.tokenInfo.pythConfiguration.price.toBase58()
|
|
36486
|
+
}
|
|
36487
|
+
}
|
|
36488
|
+
}
|
|
36657
36489
|
};
|
|
36658
36490
|
}
|
|
36659
36491
|
|
|
@@ -43151,267 +42983,78 @@ function decodeKlendObligationData(data) {
|
|
|
43151
42983
|
const dec = obligationLayout.decode(data.slice(8));
|
|
43152
42984
|
return dec;
|
|
43153
42985
|
}
|
|
43154
|
-
function
|
|
42986
|
+
function dtoToKaminoObligation(obligationDto) {
|
|
43155
42987
|
return {
|
|
43156
|
-
tag: new BN11(obligationDto.tag),
|
|
43157
|
-
lastUpdate: {
|
|
43158
|
-
slot: new BN11(obligationDto.lastUpdate.slot),
|
|
43159
|
-
stale: obligationDto.lastUpdate.stale,
|
|
43160
|
-
priceStatus: obligationDto.lastUpdate.priceStatus,
|
|
43161
|
-
placeholder: obligationDto.lastUpdate.placeholder
|
|
43162
|
-
},
|
|
43163
42988
|
lendingMarket: new PublicKey(obligationDto.lendingMarket),
|
|
43164
42989
|
owner: new PublicKey(obligationDto.owner),
|
|
43165
|
-
|
|
43166
|
-
|
|
43167
|
-
|
|
43168
|
-
|
|
43169
|
-
|
|
43170
|
-
),
|
|
43171
|
-
|
|
43172
|
-
|
|
43173
|
-
|
|
43174
|
-
|
|
43175
|
-
|
|
43176
|
-
obligationDto.borrowFactorAdjustedDebtValueSf
|
|
43177
|
-
),
|
|
43178
|
-
borrowedAssetsMarketValueSf: new BN11(
|
|
43179
|
-
obligationDto.borrowedAssetsMarketValueSf
|
|
43180
|
-
),
|
|
43181
|
-
allowedBorrowValueSf: new BN11(obligationDto.allowedBorrowValueSf),
|
|
43182
|
-
unhealthyBorrowValueSf: new BN11(obligationDto.unhealthyBorrowValueSf),
|
|
43183
|
-
depositsAssetTiers: obligationDto.depositsAssetTiers,
|
|
43184
|
-
borrowsAssetTiers: obligationDto.borrowsAssetTiers,
|
|
43185
|
-
elevationGroup: obligationDto.elevationGroup,
|
|
43186
|
-
numOfObsoleteDepositReserves: obligationDto.numOfObsoleteDepositReserves,
|
|
43187
|
-
hasDebt: obligationDto.hasDebt,
|
|
43188
|
-
referrer: new PublicKey(obligationDto.referrer),
|
|
43189
|
-
borrowingDisabled: obligationDto.borrowingDisabled,
|
|
43190
|
-
autodeleverageTargetLtvPct: obligationDto.autodeleverageTargetLtvPct,
|
|
43191
|
-
lowestReserveDepositMaxLtvPct: obligationDto.lowestReserveDepositMaxLtvPct,
|
|
43192
|
-
numOfObsoleteBorrowReserves: obligationDto.numOfObsoleteBorrowReserves,
|
|
43193
|
-
reserved: obligationDto.reserved,
|
|
43194
|
-
highestBorrowFactorPct: new BN11(obligationDto.highestBorrowFactorPct),
|
|
43195
|
-
autodeleverageMarginCallStartedTimestamp: new BN11(
|
|
43196
|
-
obligationDto.autodeleverageMarginCallStartedTimestamp
|
|
43197
|
-
),
|
|
43198
|
-
orders: obligationDto.orders.map(
|
|
43199
|
-
(item) => dtoToObligationOrderFields(item)
|
|
43200
|
-
),
|
|
43201
|
-
padding3: obligationDto.padding3.map((item) => new BN11(item))
|
|
42990
|
+
// Hosted endpoints may prune empty position arrays from the payload
|
|
42991
|
+
deposits: (obligationDto.deposits ?? []).map((item) => ({
|
|
42992
|
+
depositReserve: new PublicKey(item.depositReserve),
|
|
42993
|
+
depositedAmount: new BN8(item.depositedAmount),
|
|
42994
|
+
marketValueSf: new BN8(item.marketValueSf)
|
|
42995
|
+
})),
|
|
42996
|
+
borrows: (obligationDto.borrows ?? []).map((item) => ({
|
|
42997
|
+
borrowReserve: new PublicKey(item.borrowReserve),
|
|
42998
|
+
borrowedAmountSf: new BN8(item.borrowedAmountSf),
|
|
42999
|
+
marketValueSf: new BN8(item.marketValueSf)
|
|
43000
|
+
}))
|
|
43202
43001
|
};
|
|
43203
43002
|
}
|
|
43204
|
-
function
|
|
43003
|
+
function dtoToKaminoReserve(reserveDto) {
|
|
43205
43004
|
return {
|
|
43206
|
-
version: new BN11(reserveDto.version),
|
|
43207
|
-
lastUpdate: {
|
|
43208
|
-
slot: new BN11(reserveDto.lastUpdate.slot),
|
|
43209
|
-
stale: reserveDto.lastUpdate.stale,
|
|
43210
|
-
priceStatus: reserveDto.lastUpdate.priceStatus,
|
|
43211
|
-
placeholder: reserveDto.lastUpdate.placeholder
|
|
43212
|
-
},
|
|
43213
43005
|
lendingMarket: new PublicKey(reserveDto.lendingMarket),
|
|
43214
43006
|
farmCollateral: new PublicKey(reserveDto.farmCollateral),
|
|
43215
|
-
|
|
43216
|
-
|
|
43217
|
-
|
|
43218
|
-
|
|
43219
|
-
|
|
43220
|
-
|
|
43221
|
-
|
|
43222
|
-
|
|
43223
|
-
supplyVault: new PublicKey(reserveDto.collateral.supplyVault),
|
|
43224
|
-
padding1: reserveDto.collateral.padding1.map((item) => new BN11(item)),
|
|
43225
|
-
padding2: reserveDto.collateral.padding2.map((item) => new BN11(item))
|
|
43226
|
-
},
|
|
43227
|
-
reserveCollateralPadding: reserveDto.reserveCollateralPadding.map(
|
|
43228
|
-
(item) => new BN11(item)
|
|
43229
|
-
),
|
|
43230
|
-
config: dtoToReserveConfigFields(reserveDto.config),
|
|
43231
|
-
configPadding: reserveDto.configPadding.map((item) => new BN11(item)),
|
|
43232
|
-
borrowedAmountOutsideElevationGroup: new BN11(
|
|
43233
|
-
reserveDto.borrowedAmountOutsideElevationGroup
|
|
43234
|
-
),
|
|
43235
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveDto.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
43236
|
-
(item) => new BN11(item)
|
|
43237
|
-
),
|
|
43238
|
-
padding: reserveDto.padding.map((item) => new BN11(item))
|
|
43239
|
-
};
|
|
43240
|
-
}
|
|
43241
|
-
function dtoToReserveLiquidityFields(reserveDto) {
|
|
43242
|
-
return {
|
|
43243
|
-
mintPubkey: new PublicKey(reserveDto.mintPubkey),
|
|
43244
|
-
supplyVault: new PublicKey(reserveDto.supplyVault),
|
|
43245
|
-
feeVault: new PublicKey(reserveDto.feeVault),
|
|
43246
|
-
availableAmount: new BN11(reserveDto.availableAmount),
|
|
43247
|
-
borrowedAmountSf: new BN11(reserveDto.borrowedAmountSf),
|
|
43248
|
-
marketPriceSf: new BN11(reserveDto.marketPriceSf),
|
|
43249
|
-
marketPriceLastUpdatedTs: new BN11(reserveDto.marketPriceLastUpdatedTs),
|
|
43250
|
-
mintDecimals: new BN11(reserveDto.mintDecimals),
|
|
43251
|
-
depositLimitCrossedTimestamp: new BN11(
|
|
43252
|
-
reserveDto.depositLimitCrossedTimestamp
|
|
43253
|
-
),
|
|
43254
|
-
borrowLimitCrossedTimestamp: new BN11(reserveDto.borrowLimitCrossedTimestamp),
|
|
43255
|
-
cumulativeBorrowRateBsf: {
|
|
43256
|
-
value: reserveDto.cumulativeBorrowRateBsf.value.map(
|
|
43257
|
-
(item) => new BN11(item)
|
|
43007
|
+
liquidity: {
|
|
43008
|
+
mintPubkey: new PublicKey(reserveDto.liquidity.mintPubkey),
|
|
43009
|
+
supplyVault: new PublicKey(reserveDto.liquidity.supplyVault),
|
|
43010
|
+
mintDecimals: new BN8(reserveDto.liquidity.mintDecimals),
|
|
43011
|
+
availableAmount: new BN8(reserveDto.liquidity.availableAmount),
|
|
43012
|
+
borrowedAmountSf: new BN8(reserveDto.liquidity.borrowedAmountSf),
|
|
43013
|
+
accumulatedProtocolFeesSf: new BN8(
|
|
43014
|
+
reserveDto.liquidity.accumulatedProtocolFeesSf
|
|
43258
43015
|
),
|
|
43259
|
-
|
|
43260
|
-
|
|
43261
|
-
)
|
|
43262
|
-
},
|
|
43263
|
-
accumulatedProtocolFeesSf: new BN11(reserveDto.accumulatedProtocolFeesSf),
|
|
43264
|
-
accumulatedReferrerFeesSf: new BN11(reserveDto.accumulatedReferrerFeesSf),
|
|
43265
|
-
pendingReferrerFeesSf: new BN11(reserveDto.pendingReferrerFeesSf),
|
|
43266
|
-
absoluteReferralRateSf: new BN11(reserveDto.absoluteReferralRateSf),
|
|
43267
|
-
tokenProgram: new PublicKey(reserveDto.tokenProgram),
|
|
43268
|
-
padding2: reserveDto.padding2.map((item) => new BN11(item)),
|
|
43269
|
-
padding3: reserveDto.padding3.map((item) => new BN11(item))
|
|
43270
|
-
};
|
|
43271
|
-
}
|
|
43272
|
-
function dtoToReserveConfigFields(reserveDto) {
|
|
43273
|
-
return {
|
|
43274
|
-
status: reserveDto.status,
|
|
43275
|
-
assetTier: reserveDto.assetTier,
|
|
43276
|
-
hostFixedInterestRateBps: reserveDto.hostFixedInterestRateBps,
|
|
43277
|
-
reserved2: reserveDto.reserved2,
|
|
43278
|
-
protocolOrderExecutionFeePct: reserveDto.protocolOrderExecutionFeePct,
|
|
43279
|
-
protocolTakeRatePct: reserveDto.protocolTakeRatePct,
|
|
43280
|
-
protocolLiquidationFeePct: reserveDto.protocolLiquidationFeePct,
|
|
43281
|
-
loanToValuePct: reserveDto.loanToValuePct,
|
|
43282
|
-
liquidationThresholdPct: reserveDto.liquidationThresholdPct,
|
|
43283
|
-
minLiquidationBonusBps: reserveDto.minLiquidationBonusBps,
|
|
43284
|
-
maxLiquidationBonusBps: reserveDto.maxLiquidationBonusBps,
|
|
43285
|
-
badDebtLiquidationBonusBps: reserveDto.badDebtLiquidationBonusBps,
|
|
43286
|
-
deleveragingMarginCallPeriodSecs: new BN11(
|
|
43287
|
-
reserveDto.deleveragingMarginCallPeriodSecs
|
|
43288
|
-
),
|
|
43289
|
-
deleveragingThresholdDecreaseBpsPerDay: new BN11(
|
|
43290
|
-
reserveDto.deleveragingThresholdDecreaseBpsPerDay
|
|
43291
|
-
),
|
|
43292
|
-
fees: {
|
|
43293
|
-
borrowFeeSf: new BN11(reserveDto.fees.borrowFeeSf),
|
|
43294
|
-
flashLoanFeeSf: new BN11(reserveDto.fees.flashLoanFeeSf),
|
|
43295
|
-
padding: reserveDto.fees.padding
|
|
43296
|
-
},
|
|
43297
|
-
borrowRateCurve: {
|
|
43298
|
-
points: reserveDto.borrowRateCurve.points.map((item) => ({
|
|
43299
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
43300
|
-
borrowRateBps: item.borrowRateBps
|
|
43301
|
-
}))
|
|
43302
|
-
},
|
|
43303
|
-
borrowFactorPct: new BN11(reserveDto.borrowFactorPct),
|
|
43304
|
-
depositLimit: new BN11(reserveDto.depositLimit),
|
|
43305
|
-
borrowLimit: new BN11(reserveDto.borrowLimit),
|
|
43306
|
-
tokenInfo: dtoToTokenInfoFields(reserveDto.tokenInfo),
|
|
43307
|
-
depositWithdrawalCap: dtoToWithdrawalCapsFields(
|
|
43308
|
-
reserveDto.depositWithdrawalCap
|
|
43309
|
-
),
|
|
43310
|
-
debtWithdrawalCap: dtoToWithdrawalCapsFields(reserveDto.debtWithdrawalCap),
|
|
43311
|
-
elevationGroups: reserveDto.elevationGroups,
|
|
43312
|
-
disableUsageAsCollOutsideEmode: reserveDto.disableUsageAsCollOutsideEmode,
|
|
43313
|
-
utilizationLimitBlockBorrowingAbovePct: reserveDto.utilizationLimitBlockBorrowingAbovePct,
|
|
43314
|
-
autodeleverageEnabled: reserveDto.autodeleverageEnabled,
|
|
43315
|
-
reserved1: reserveDto.reserved1,
|
|
43316
|
-
borrowLimitOutsideElevationGroup: new BN11(
|
|
43317
|
-
reserveDto.borrowLimitOutsideElevationGroup
|
|
43318
|
-
),
|
|
43319
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveDto.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
43320
|
-
(item) => new BN11(item)
|
|
43321
|
-
),
|
|
43322
|
-
deleveragingBonusIncreaseBpsPerDay: new BN11(
|
|
43323
|
-
reserveDto.deleveragingBonusIncreaseBpsPerDay
|
|
43324
|
-
)
|
|
43325
|
-
};
|
|
43326
|
-
}
|
|
43327
|
-
function dtoToTokenInfoFields(tokenInfoDto) {
|
|
43328
|
-
return {
|
|
43329
|
-
name: tokenInfoDto.name,
|
|
43330
|
-
heuristic: {
|
|
43331
|
-
lower: new BN11(tokenInfoDto.heuristic.lower),
|
|
43332
|
-
upper: new BN11(tokenInfoDto.heuristic.upper),
|
|
43333
|
-
exp: new BN11(tokenInfoDto.heuristic.exp)
|
|
43334
|
-
},
|
|
43335
|
-
maxTwapDivergenceBps: new BN11(tokenInfoDto.maxTwapDivergenceBps),
|
|
43336
|
-
maxAgePriceSeconds: new BN11(tokenInfoDto.maxAgePriceSeconds),
|
|
43337
|
-
maxAgeTwapSeconds: new BN11(tokenInfoDto.maxAgeTwapSeconds),
|
|
43338
|
-
scopeConfiguration: {
|
|
43339
|
-
priceFeed: new PublicKey(tokenInfoDto.scopeConfiguration.priceFeed),
|
|
43340
|
-
priceChain: tokenInfoDto.scopeConfiguration.priceChain,
|
|
43341
|
-
twapChain: tokenInfoDto.scopeConfiguration.twapChain
|
|
43342
|
-
},
|
|
43343
|
-
switchboardConfiguration: {
|
|
43344
|
-
priceAggregator: new PublicKey(
|
|
43345
|
-
tokenInfoDto.switchboardConfiguration.priceAggregator
|
|
43016
|
+
accumulatedReferrerFeesSf: new BN8(
|
|
43017
|
+
reserveDto.liquidity.accumulatedReferrerFeesSf
|
|
43346
43018
|
),
|
|
43347
|
-
|
|
43348
|
-
tokenInfoDto.switchboardConfiguration.twapAggregator
|
|
43349
|
-
)
|
|
43019
|
+
pendingReferrerFeesSf: new BN8(reserveDto.liquidity.pendingReferrerFeesSf)
|
|
43350
43020
|
},
|
|
43351
|
-
|
|
43352
|
-
|
|
43353
|
-
|
|
43354
|
-
|
|
43355
|
-
|
|
43356
|
-
|
|
43357
|
-
|
|
43358
|
-
|
|
43359
|
-
|
|
43360
|
-
|
|
43361
|
-
|
|
43362
|
-
|
|
43363
|
-
|
|
43364
|
-
|
|
43365
|
-
|
|
43366
|
-
|
|
43367
|
-
|
|
43368
|
-
|
|
43369
|
-
|
|
43370
|
-
|
|
43371
|
-
|
|
43372
|
-
|
|
43373
|
-
|
|
43374
|
-
|
|
43375
|
-
|
|
43376
|
-
|
|
43377
|
-
|
|
43378
|
-
|
|
43379
|
-
|
|
43380
|
-
|
|
43381
|
-
|
|
43382
|
-
|
|
43383
|
-
|
|
43384
|
-
|
|
43385
|
-
|
|
43386
|
-
|
|
43387
|
-
|
|
43388
|
-
),
|
|
43389
|
-
padding: obligationLiquidityDto.cumulativeBorrowRateBsf.padding.map(
|
|
43390
|
-
(item) => new BN11(item)
|
|
43391
|
-
)
|
|
43392
|
-
},
|
|
43393
|
-
padding: new BN11(obligationLiquidityDto.padding),
|
|
43394
|
-
borrowedAmountSf: new BN11(obligationLiquidityDto.borrowedAmountSf),
|
|
43395
|
-
marketValueSf: new BN11(obligationLiquidityDto.marketValueSf),
|
|
43396
|
-
borrowFactorAdjustedMarketValueSf: new BN11(
|
|
43397
|
-
obligationLiquidityDto.borrowFactorAdjustedMarketValueSf
|
|
43398
|
-
),
|
|
43399
|
-
borrowedAmountOutsideElevationGroups: new BN11(
|
|
43400
|
-
obligationLiquidityDto.borrowedAmountOutsideElevationGroups
|
|
43401
|
-
),
|
|
43402
|
-
padding2: obligationLiquidityDto.padding2.map((item) => new BN11(item))
|
|
43403
|
-
};
|
|
43404
|
-
}
|
|
43405
|
-
function dtoToObligationOrderFields(obligationOrderDto) {
|
|
43406
|
-
return {
|
|
43407
|
-
conditionThresholdSf: new BN11(obligationOrderDto.conditionThresholdSf),
|
|
43408
|
-
opportunityParameterSf: new BN11(obligationOrderDto.opportunityParameterSf),
|
|
43409
|
-
minExecutionBonusBps: obligationOrderDto.minExecutionBonusBps,
|
|
43410
|
-
maxExecutionBonusBps: obligationOrderDto.maxExecutionBonusBps,
|
|
43411
|
-
conditionType: obligationOrderDto.conditionType,
|
|
43412
|
-
opportunityType: obligationOrderDto.opportunityType,
|
|
43413
|
-
padding1: obligationOrderDto.padding1,
|
|
43414
|
-
padding2: obligationOrderDto.padding2.map((item) => new BN11(item))
|
|
43021
|
+
collateral: {
|
|
43022
|
+
mintPubkey: new PublicKey(reserveDto.collateral.mintPubkey),
|
|
43023
|
+
mintTotalSupply: new BN8(reserveDto.collateral.mintTotalSupply),
|
|
43024
|
+
supplyVault: new PublicKey(reserveDto.collateral.supplyVault)
|
|
43025
|
+
},
|
|
43026
|
+
config: {
|
|
43027
|
+
protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
|
|
43028
|
+
hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
|
|
43029
|
+
depositLimit: new BN8(reserveDto.config.depositLimit),
|
|
43030
|
+
borrowLimit: new BN8(reserveDto.config.borrowLimit),
|
|
43031
|
+
borrowRateCurve: {
|
|
43032
|
+
points: reserveDto.config.borrowRateCurve.points.map((item) => ({
|
|
43033
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
43034
|
+
borrowRateBps: item.borrowRateBps
|
|
43035
|
+
}))
|
|
43036
|
+
},
|
|
43037
|
+
tokenInfo: {
|
|
43038
|
+
scopeConfiguration: {
|
|
43039
|
+
priceFeed: new PublicKey(
|
|
43040
|
+
reserveDto.config.tokenInfo.scopeConfiguration.priceFeed
|
|
43041
|
+
)
|
|
43042
|
+
},
|
|
43043
|
+
switchboardConfiguration: {
|
|
43044
|
+
priceAggregator: new PublicKey(
|
|
43045
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.priceAggregator
|
|
43046
|
+
),
|
|
43047
|
+
twapAggregator: new PublicKey(
|
|
43048
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.twapAggregator
|
|
43049
|
+
)
|
|
43050
|
+
},
|
|
43051
|
+
pythConfiguration: {
|
|
43052
|
+
price: new PublicKey(
|
|
43053
|
+
reserveDto.config.tokenInfo.pythConfiguration.price
|
|
43054
|
+
)
|
|
43055
|
+
}
|
|
43056
|
+
}
|
|
43057
|
+
}
|
|
43415
43058
|
};
|
|
43416
43059
|
}
|
|
43417
43060
|
var SEED_LENDING_MARKET_AUTH = "lma";
|
|
@@ -43478,9 +43121,9 @@ var Fraction = class _Fraction {
|
|
|
43478
43121
|
static MAX_SIZE_BF = 256;
|
|
43479
43122
|
static FRACTIONS = 60;
|
|
43480
43123
|
static MULTIPLIER = new FractionDecimal(2).pow(_Fraction.FRACTIONS);
|
|
43481
|
-
static MAX_F_BN = new
|
|
43482
|
-
static MAX_BF_BN = new
|
|
43483
|
-
static MIN_BN = new
|
|
43124
|
+
static MAX_F_BN = new BN8(2).pow(new BN8(_Fraction.MAX_SIZE_F)).sub(new BN8(1));
|
|
43125
|
+
static MAX_BF_BN = new BN8(2).pow(new BN8(_Fraction.MAX_SIZE_BF)).sub(new BN8(1));
|
|
43126
|
+
static MIN_BN = new BN8(0);
|
|
43484
43127
|
valueSf;
|
|
43485
43128
|
constructor(valueSf) {
|
|
43486
43129
|
if (valueSf.lt(_Fraction.MIN_BN) || valueSf.gt(_Fraction.MAX_BF_BN)) {
|
|
@@ -43496,7 +43139,7 @@ var Fraction = class _Fraction {
|
|
|
43496
43139
|
static fromDecimal(n) {
|
|
43497
43140
|
const scaledDecimal = new FractionDecimal(n).mul(_Fraction.MULTIPLIER);
|
|
43498
43141
|
const roundedScaledDecimal = roundNearest(scaledDecimal);
|
|
43499
|
-
const scaledValue = new
|
|
43142
|
+
const scaledValue = new BN8(roundedScaledDecimal.toFixed());
|
|
43500
43143
|
return new _Fraction(scaledValue);
|
|
43501
43144
|
}
|
|
43502
43145
|
static fromBps(n) {
|
|
@@ -43526,7 +43169,7 @@ var Fraction = class _Fraction {
|
|
|
43526
43169
|
return this.valueSf.eq(x.getValue());
|
|
43527
43170
|
}
|
|
43528
43171
|
};
|
|
43529
|
-
new Fraction(new
|
|
43172
|
+
new Fraction(new BN8(0));
|
|
43530
43173
|
function roundNearest(decimal) {
|
|
43531
43174
|
return decimal.toDecimalPlaces(0, Decimal3.ROUND_HALF_CEIL);
|
|
43532
43175
|
}
|
|
@@ -44126,29 +43769,29 @@ function decodeJupTokenReserveData(data, pubkey) {
|
|
|
44126
43769
|
offset += 2;
|
|
44127
43770
|
const lastUtilization = data.readUInt16LE(offset);
|
|
44128
43771
|
offset += 2;
|
|
44129
|
-
const lastUpdateTimestamp = new
|
|
43772
|
+
const lastUpdateTimestamp = new BN8(data.slice(offset, offset + 8), "le");
|
|
44130
43773
|
offset += 8;
|
|
44131
|
-
const supplyExchangePrice = new
|
|
43774
|
+
const supplyExchangePrice = new BN8(data.slice(offset, offset + 8), "le");
|
|
44132
43775
|
offset += 8;
|
|
44133
|
-
const borrowExchangePrice = new
|
|
43776
|
+
const borrowExchangePrice = new BN8(data.slice(offset, offset + 8), "le");
|
|
44134
43777
|
offset += 8;
|
|
44135
43778
|
const maxUtilization = data.readUInt16LE(offset);
|
|
44136
43779
|
offset += 2;
|
|
44137
|
-
const totalSupplyWithInterest = new
|
|
43780
|
+
const totalSupplyWithInterest = new BN8(data.slice(offset, offset + 8), "le");
|
|
44138
43781
|
offset += 8;
|
|
44139
|
-
const totalSupplyInterestFree = new
|
|
43782
|
+
const totalSupplyInterestFree = new BN8(data.slice(offset, offset + 8), "le");
|
|
44140
43783
|
offset += 8;
|
|
44141
|
-
const totalBorrowWithInterest = new
|
|
43784
|
+
const totalBorrowWithInterest = new BN8(data.slice(offset, offset + 8), "le");
|
|
44142
43785
|
offset += 8;
|
|
44143
|
-
const totalBorrowInterestFree = new
|
|
43786
|
+
const totalBorrowInterestFree = new BN8(data.slice(offset, offset + 8), "le");
|
|
44144
43787
|
offset += 8;
|
|
44145
|
-
const totalClaimAmount = new
|
|
43788
|
+
const totalClaimAmount = new BN8(data.slice(offset, offset + 8), "le");
|
|
44146
43789
|
offset += 8;
|
|
44147
43790
|
const interactingProtocol = new PublicKey(data.slice(offset, offset + 32));
|
|
44148
43791
|
offset += 32;
|
|
44149
|
-
const interactingTimestamp = new
|
|
43792
|
+
const interactingTimestamp = new BN8(data.slice(offset, offset + 8), "le");
|
|
44150
43793
|
offset += 8;
|
|
44151
|
-
const interactingBalance = new
|
|
43794
|
+
const interactingBalance = new BN8(data.slice(offset, offset + 8), "le");
|
|
44152
43795
|
return {
|
|
44153
43796
|
pubkey,
|
|
44154
43797
|
mint,
|
|
@@ -44210,9 +43853,9 @@ function dtoToJupLendingStateRaw(dto) {
|
|
|
44210
43853
|
lendingId: dto.lendingId,
|
|
44211
43854
|
decimals: dto.decimals,
|
|
44212
43855
|
rewardsRateModel: new PublicKey(dto.rewardsRateModel),
|
|
44213
|
-
liquidityExchangePrice: new
|
|
44214
|
-
tokenExchangePrice: new
|
|
44215
|
-
lastUpdateTimestamp: new
|
|
43856
|
+
liquidityExchangePrice: new BN8(dto.liquidityExchangePrice),
|
|
43857
|
+
tokenExchangePrice: new BN8(dto.tokenExchangePrice),
|
|
43858
|
+
lastUpdateTimestamp: new BN8(dto.lastUpdateTimestamp),
|
|
44216
43859
|
tokenReservesLiquidity: new PublicKey(dto.tokenReservesLiquidity),
|
|
44217
43860
|
supplyPositionOnLiquidity: new PublicKey(dto.supplyPositionOnLiquidity)
|
|
44218
43861
|
};
|
|
@@ -44225,30 +43868,30 @@ function dtoToJupTokenReserveRaw(dto) {
|
|
|
44225
43868
|
borrowRate: dto.borrowRate,
|
|
44226
43869
|
feeOnInterest: dto.feeOnInterest,
|
|
44227
43870
|
lastUtilization: dto.lastUtilization,
|
|
44228
|
-
lastUpdateTimestamp: new
|
|
44229
|
-
supplyExchangePrice: new
|
|
44230
|
-
borrowExchangePrice: new
|
|
43871
|
+
lastUpdateTimestamp: new BN8(dto.lastUpdateTimestamp),
|
|
43872
|
+
supplyExchangePrice: new BN8(dto.supplyExchangePrice),
|
|
43873
|
+
borrowExchangePrice: new BN8(dto.borrowExchangePrice),
|
|
44231
43874
|
maxUtilization: dto.maxUtilization,
|
|
44232
|
-
totalSupplyWithInterest: new
|
|
44233
|
-
totalSupplyInterestFree: new
|
|
44234
|
-
totalBorrowWithInterest: new
|
|
44235
|
-
totalBorrowInterestFree: new
|
|
44236
|
-
totalClaimAmount: new
|
|
43875
|
+
totalSupplyWithInterest: new BN8(dto.totalSupplyWithInterest),
|
|
43876
|
+
totalSupplyInterestFree: new BN8(dto.totalSupplyInterestFree),
|
|
43877
|
+
totalBorrowWithInterest: new BN8(dto.totalBorrowWithInterest),
|
|
43878
|
+
totalBorrowInterestFree: new BN8(dto.totalBorrowInterestFree),
|
|
43879
|
+
totalClaimAmount: new BN8(dto.totalClaimAmount),
|
|
44237
43880
|
interactingProtocol: new PublicKey(dto.interactingProtocol),
|
|
44238
|
-
interactingTimestamp: new
|
|
44239
|
-
interactingBalance: new
|
|
43881
|
+
interactingTimestamp: new BN8(dto.interactingTimestamp),
|
|
43882
|
+
interactingBalance: new BN8(dto.interactingBalance)
|
|
44240
43883
|
};
|
|
44241
43884
|
}
|
|
44242
43885
|
function dtoToJupLendingRewardsRateModelRaw(dto) {
|
|
44243
43886
|
return {
|
|
44244
43887
|
pubkey: new PublicKey(dto.pubkey),
|
|
44245
43888
|
mint: new PublicKey(dto.mint),
|
|
44246
|
-
startTvl: new
|
|
44247
|
-
duration: new
|
|
44248
|
-
startTime: new
|
|
44249
|
-
yearlyReward: new
|
|
44250
|
-
nextDuration: new
|
|
44251
|
-
nextRewardAmount: new
|
|
43889
|
+
startTvl: new BN8(dto.startTvl),
|
|
43890
|
+
duration: new BN8(dto.duration),
|
|
43891
|
+
startTime: new BN8(dto.startTime),
|
|
43892
|
+
yearlyReward: new BN8(dto.yearlyReward),
|
|
43893
|
+
nextDuration: new BN8(dto.nextDuration),
|
|
43894
|
+
nextRewardAmount: new BN8(dto.nextRewardAmount)
|
|
44252
43895
|
};
|
|
44253
43896
|
}
|
|
44254
43897
|
function dtoToJupRateModelRaw(dto) {
|
|
@@ -44339,14 +43982,14 @@ function deriveJupLendLiquiditySupplyPositionPda(underlyingMint, lendingPda, liq
|
|
|
44339
43982
|
liquidityProgramId
|
|
44340
43983
|
);
|
|
44341
43984
|
}
|
|
44342
|
-
var JUP_EXCHANGE_PRICES_PRECISION = new
|
|
44343
|
-
var JUP_SECONDS_PER_YEAR = new
|
|
44344
|
-
var JUP_MAX_REWARDS_RATE = new
|
|
43985
|
+
var JUP_EXCHANGE_PRICES_PRECISION = new BN8("1000000000000");
|
|
43986
|
+
var JUP_SECONDS_PER_YEAR = new BN8(31536e3);
|
|
43987
|
+
var JUP_MAX_REWARDS_RATE = new BN8("50000000000000");
|
|
44345
43988
|
function calculateJupLendTotalAssets(lendingState, fTokenTotalSupply) {
|
|
44346
43989
|
return lendingState.tokenExchangePrice.mul(fTokenTotalSupply).div(JUP_EXCHANGE_PRICES_PRECISION);
|
|
44347
43990
|
}
|
|
44348
43991
|
function calculateJupLendRewardsRateForExchangePrice(rewardsModel, totalAssets, currentTimestamp) {
|
|
44349
|
-
const defaultResult = { rate: new
|
|
43992
|
+
const defaultResult = { rate: new BN8(0), rewardsStartTime: rewardsModel.startTime };
|
|
44350
43993
|
if (rewardsModel.startTime.isZero() || rewardsModel.duration.isZero()) {
|
|
44351
43994
|
return defaultResult;
|
|
44352
43995
|
}
|
|
@@ -44366,7 +44009,7 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44366
44009
|
const oldTokenExchangePrice = lendingState.tokenExchangePrice;
|
|
44367
44010
|
const oldLiquidityExchangePrice = lendingState.liquidityExchangePrice;
|
|
44368
44011
|
const currentLiquidityExchangePrice = tokenReserve.supplyExchangePrice;
|
|
44369
|
-
let rewardsRate = new
|
|
44012
|
+
let rewardsRate = new BN8(0);
|
|
44370
44013
|
let rewardsStartTime = lendingState.lastUpdateTimestamp;
|
|
44371
44014
|
if (rewardsModel) {
|
|
44372
44015
|
const totalAssets = calculateJupLendTotalAssets(lendingState, fTokenTotalSupply);
|
|
@@ -44383,12 +44026,12 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44383
44026
|
lastUpdateTime = rewardsStartTime;
|
|
44384
44027
|
}
|
|
44385
44028
|
const secondsElapsed = currentTimestamp.sub(lastUpdateTime);
|
|
44386
|
-
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new
|
|
44029
|
+
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new BN8(100));
|
|
44387
44030
|
const delta = currentLiquidityExchangePrice.sub(oldLiquidityExchangePrice);
|
|
44388
44031
|
totalReturnPercent = totalReturnPercent.add(
|
|
44389
|
-
delta.mul(new
|
|
44032
|
+
delta.mul(new BN8(1e14)).div(oldLiquidityExchangePrice)
|
|
44390
44033
|
);
|
|
44391
|
-
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new
|
|
44034
|
+
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new BN8(1e14)));
|
|
44392
44035
|
}
|
|
44393
44036
|
var UPDATE_RATE_DISCRIMINATOR = Buffer.from([
|
|
44394
44037
|
24,
|
|
@@ -57869,7 +57512,7 @@ function exponentNumberToBigNumber(raw) {
|
|
|
57869
57512
|
let value = new BigNumber(0);
|
|
57870
57513
|
const TWO_64 = new BigNumber(2).pow(64);
|
|
57871
57514
|
words.forEach((w, i) => {
|
|
57872
|
-
const word = new BigNumber(
|
|
57515
|
+
const word = new BigNumber(BN8.isBN(w) ? w.toString() : String(w));
|
|
57873
57516
|
value = value.plus(word.times(TWO_64.pow(i)));
|
|
57874
57517
|
});
|
|
57875
57518
|
return value.div(EXPONENT_NUMBER_DENOM);
|
|
@@ -57880,7 +57523,7 @@ function pk(v) {
|
|
|
57880
57523
|
function decodeExponentVault(data) {
|
|
57881
57524
|
const d = EXPONENT_ACCOUNTS_CODER.decode("Vault", data);
|
|
57882
57525
|
const get = (snake, camel) => d[snake] ?? d[camel];
|
|
57883
|
-
const u646 = (v) => BigInt(
|
|
57526
|
+
const u646 = (v) => BigInt(BN8.isBN(v) ? v.toString() : String(v ?? 0));
|
|
57884
57527
|
const cpi = get("cpi_accounts", "cpiAccounts") ?? {};
|
|
57885
57528
|
return {
|
|
57886
57529
|
authority: pk(get("authority", "authority")),
|
|
@@ -58227,76 +57870,26 @@ function scaledSupplies(state) {
|
|
|
58227
57870
|
}
|
|
58228
57871
|
|
|
58229
57872
|
// src/vendor/klend/utils/farms/serialize.utils.ts
|
|
58230
|
-
function
|
|
57873
|
+
function kaminoFarmStateToDto(farmState) {
|
|
58231
57874
|
return {
|
|
58232
|
-
farmAdmin: farmRaw.farmAdmin.toBase58(),
|
|
58233
|
-
globalConfig: farmRaw.globalConfig.toBase58(),
|
|
58234
57875
|
token: {
|
|
58235
|
-
mint:
|
|
58236
|
-
decimals:
|
|
58237
|
-
tokenProgram: farmRaw.token.tokenProgram.toBase58(),
|
|
58238
|
-
padding: farmRaw.token.padding.map((p) => p.toString())
|
|
57876
|
+
mint: farmState.token.mint.toBase58(),
|
|
57877
|
+
decimals: farmState.token.decimals.toString()
|
|
58239
57878
|
},
|
|
58240
|
-
rewardInfos:
|
|
57879
|
+
rewardInfos: farmState.rewardInfos.map((item) => ({
|
|
58241
57880
|
token: {
|
|
58242
57881
|
mint: item.token.mint.toBase58(),
|
|
58243
|
-
decimals: item.token.decimals.toString()
|
|
58244
|
-
tokenProgram: item.token.tokenProgram.toBase58(),
|
|
58245
|
-
padding: item.token.padding.map((p) => p.toString())
|
|
57882
|
+
decimals: item.token.decimals.toString()
|
|
58246
57883
|
},
|
|
58247
|
-
rewardsVault: item.rewardsVault.toBase58(),
|
|
58248
57884
|
rewardsAvailable: item.rewardsAvailable.toString(),
|
|
57885
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58249
57886
|
rewardScheduleCurve: {
|
|
58250
57887
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58251
57888
|
tsStart: p.tsStart.toString(),
|
|
58252
57889
|
rewardPerTimeUnit: p.rewardPerTimeUnit.toString()
|
|
58253
57890
|
}))
|
|
58254
|
-
}
|
|
58255
|
-
|
|
58256
|
-
lastIssuanceTs: item.lastIssuanceTs.toString(),
|
|
58257
|
-
rewardsIssuedUnclaimed: item.rewardsIssuedUnclaimed.toString(),
|
|
58258
|
-
rewardsIssuedCumulative: item.rewardsIssuedCumulative.toString(),
|
|
58259
|
-
rewardPerShareScaled: item.rewardPerShareScaled.toString(),
|
|
58260
|
-
placeholder0: item.placeholder0.toString(),
|
|
58261
|
-
rewardType: item.rewardType,
|
|
58262
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58263
|
-
padding0: item.padding0,
|
|
58264
|
-
padding1: item.padding1.map((p) => p.toString())
|
|
58265
|
-
})),
|
|
58266
|
-
numRewardTokens: farmRaw.numRewardTokens.toString(),
|
|
58267
|
-
numUsers: farmRaw.numUsers.toString(),
|
|
58268
|
-
totalStakedAmount: farmRaw.totalStakedAmount.toString(),
|
|
58269
|
-
farmVault: farmRaw.farmVault.toBase58(),
|
|
58270
|
-
farmVaultsAuthority: farmRaw.farmVaultsAuthority.toBase58(),
|
|
58271
|
-
farmVaultsAuthorityBump: farmRaw.farmVaultsAuthorityBump.toString(),
|
|
58272
|
-
delegateAuthority: farmRaw.delegateAuthority.toBase58(),
|
|
58273
|
-
timeUnit: farmRaw.timeUnit,
|
|
58274
|
-
isFarmFrozen: farmRaw.isFarmFrozen,
|
|
58275
|
-
isFarmDelegated: farmRaw.isFarmDelegated,
|
|
58276
|
-
padding0: farmRaw.padding0,
|
|
58277
|
-
withdrawAuthority: farmRaw.withdrawAuthority.toBase58(),
|
|
58278
|
-
depositWarmupPeriod: farmRaw.depositWarmupPeriod,
|
|
58279
|
-
withdrawalCooldownPeriod: farmRaw.withdrawalCooldownPeriod,
|
|
58280
|
-
totalActiveStakeScaled: farmRaw.totalActiveStakeScaled.toString(),
|
|
58281
|
-
totalPendingStakeScaled: farmRaw.totalPendingStakeScaled.toString(),
|
|
58282
|
-
totalPendingAmount: farmRaw.totalPendingAmount.toString(),
|
|
58283
|
-
slashedAmountCurrent: farmRaw.slashedAmountCurrent.toString(),
|
|
58284
|
-
slashedAmountCumulative: farmRaw.slashedAmountCumulative.toString(),
|
|
58285
|
-
slashedAmountSpillAddress: farmRaw.slashedAmountSpillAddress.toBase58(),
|
|
58286
|
-
lockingMode: farmRaw.lockingMode.toString(),
|
|
58287
|
-
lockingStartTimestamp: farmRaw.lockingStartTimestamp.toString(),
|
|
58288
|
-
lockingDuration: farmRaw.lockingDuration.toString(),
|
|
58289
|
-
lockingEarlyWithdrawalPenaltyBps: farmRaw.lockingEarlyWithdrawalPenaltyBps.toString(),
|
|
58290
|
-
depositCapAmount: farmRaw.depositCapAmount.toString(),
|
|
58291
|
-
scopePrices: farmRaw.scopePrices.toBase58(),
|
|
58292
|
-
scopeOraclePriceId: farmRaw.scopeOraclePriceId.toString(),
|
|
58293
|
-
scopeOracleMaxAge: farmRaw.scopeOracleMaxAge.toString(),
|
|
58294
|
-
pendingFarmAdmin: farmRaw.pendingFarmAdmin.toBase58(),
|
|
58295
|
-
strategyId: farmRaw.strategyId.toBase58(),
|
|
58296
|
-
delegatedRpsAdmin: farmRaw.delegatedRpsAdmin.toBase58(),
|
|
58297
|
-
vaultId: farmRaw.vaultId.toBase58(),
|
|
58298
|
-
secondDelegatedAuthority: farmRaw.secondDelegatedAuthority.toBase58(),
|
|
58299
|
-
padding: farmRaw.padding.map((item) => item.toString())
|
|
57891
|
+
}
|
|
57892
|
+
}))
|
|
58300
57893
|
};
|
|
58301
57894
|
}
|
|
58302
57895
|
var farmDiscriminator = Buffer.from([198, 102, 216, 74, 63, 66, 163, 190]);
|
|
@@ -58391,78 +57984,26 @@ function decodeFarmDataRaw(data) {
|
|
|
58391
57984
|
const dec = farmLayout.decode(data.slice(8));
|
|
58392
57985
|
return dec;
|
|
58393
57986
|
}
|
|
58394
|
-
function
|
|
57987
|
+
function dtoToKaminoFarmState(dto) {
|
|
58395
57988
|
return {
|
|
58396
|
-
farmAdmin: new PublicKey(dto.farmAdmin),
|
|
58397
|
-
globalConfig: new PublicKey(dto.globalConfig),
|
|
58398
57989
|
token: {
|
|
58399
57990
|
mint: new PublicKey(dto.token.mint),
|
|
58400
|
-
decimals: new
|
|
58401
|
-
tokenProgram: new PublicKey(dto.token.tokenProgram),
|
|
58402
|
-
padding: dto.token.padding.map((item) => new BN11(item))
|
|
57991
|
+
decimals: new BN8(dto.token.decimals)
|
|
58403
57992
|
},
|
|
58404
57993
|
rewardInfos: dto.rewardInfos.map((item) => ({
|
|
58405
57994
|
token: {
|
|
58406
57995
|
mint: new PublicKey(item.token.mint),
|
|
58407
|
-
decimals: new
|
|
58408
|
-
tokenProgram: new PublicKey(item.token.tokenProgram),
|
|
58409
|
-
padding: item.token.padding.map((p) => new BN11(p))
|
|
57996
|
+
decimals: new BN8(item.token.decimals)
|
|
58410
57997
|
},
|
|
58411
|
-
|
|
58412
|
-
|
|
57998
|
+
rewardsAvailable: new BN8(item.rewardsAvailable),
|
|
57999
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58413
58000
|
rewardScheduleCurve: {
|
|
58414
58001
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58415
|
-
tsStart: new
|
|
58416
|
-
rewardPerTimeUnit: new
|
|
58002
|
+
tsStart: new BN8(p.tsStart),
|
|
58003
|
+
rewardPerTimeUnit: new BN8(p.rewardPerTimeUnit)
|
|
58417
58004
|
}))
|
|
58418
|
-
}
|
|
58419
|
-
|
|
58420
|
-
lastIssuanceTs: new BN11(item.lastIssuanceTs),
|
|
58421
|
-
rewardsIssuedUnclaimed: new BN11(item.rewardsIssuedUnclaimed),
|
|
58422
|
-
rewardsIssuedCumulative: new BN11(item.rewardsIssuedCumulative),
|
|
58423
|
-
rewardPerShareScaled: new BN11(item.rewardPerShareScaled),
|
|
58424
|
-
placeholder0: new BN11(item.placeholder0),
|
|
58425
|
-
rewardType: item.rewardType,
|
|
58426
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58427
|
-
padding0: item.padding0,
|
|
58428
|
-
padding1: item.padding1.map((p) => new BN11(p))
|
|
58429
|
-
})),
|
|
58430
|
-
numRewardTokens: new BN11(dto.numRewardTokens),
|
|
58431
|
-
numUsers: new BN11(dto.numUsers),
|
|
58432
|
-
totalStakedAmount: new BN11(dto.totalStakedAmount),
|
|
58433
|
-
farmVault: new PublicKey(dto.farmVault),
|
|
58434
|
-
farmVaultsAuthority: new PublicKey(dto.farmVaultsAuthority),
|
|
58435
|
-
farmVaultsAuthorityBump: new BN11(dto.farmVaultsAuthorityBump),
|
|
58436
|
-
delegateAuthority: new PublicKey(dto.delegateAuthority),
|
|
58437
|
-
timeUnit: dto.timeUnit,
|
|
58438
|
-
isFarmFrozen: dto.isFarmFrozen,
|
|
58439
|
-
isFarmDelegated: dto.isFarmDelegated,
|
|
58440
|
-
padding0: dto.padding0,
|
|
58441
|
-
withdrawAuthority: new PublicKey(dto.withdrawAuthority),
|
|
58442
|
-
depositWarmupPeriod: dto.depositWarmupPeriod,
|
|
58443
|
-
withdrawalCooldownPeriod: dto.withdrawalCooldownPeriod,
|
|
58444
|
-
totalActiveStakeScaled: new BN11(dto.totalActiveStakeScaled),
|
|
58445
|
-
totalPendingStakeScaled: new BN11(dto.totalPendingStakeScaled),
|
|
58446
|
-
totalPendingAmount: new BN11(dto.totalPendingAmount),
|
|
58447
|
-
slashedAmountCurrent: new BN11(dto.slashedAmountCurrent),
|
|
58448
|
-
slashedAmountCumulative: new BN11(dto.slashedAmountCumulative),
|
|
58449
|
-
slashedAmountSpillAddress: new PublicKey(dto.slashedAmountSpillAddress),
|
|
58450
|
-
lockingMode: new BN11(dto.lockingMode),
|
|
58451
|
-
lockingStartTimestamp: new BN11(dto.lockingStartTimestamp),
|
|
58452
|
-
lockingDuration: new BN11(dto.lockingDuration),
|
|
58453
|
-
lockingEarlyWithdrawalPenaltyBps: new BN11(
|
|
58454
|
-
dto.lockingEarlyWithdrawalPenaltyBps
|
|
58455
|
-
),
|
|
58456
|
-
depositCapAmount: new BN11(dto.depositCapAmount),
|
|
58457
|
-
scopePrices: new PublicKey(dto.scopePrices),
|
|
58458
|
-
scopeOraclePriceId: new BN11(dto.scopeOraclePriceId),
|
|
58459
|
-
scopeOracleMaxAge: new BN11(dto.scopeOracleMaxAge),
|
|
58460
|
-
pendingFarmAdmin: new PublicKey(dto.pendingFarmAdmin),
|
|
58461
|
-
strategyId: new PublicKey(dto.strategyId),
|
|
58462
|
-
delegatedRpsAdmin: new PublicKey(dto.delegatedRpsAdmin),
|
|
58463
|
-
vaultId: new PublicKey(dto.vaultId),
|
|
58464
|
-
secondDelegatedAuthority: new PublicKey(dto.secondDelegatedAuthority),
|
|
58465
|
-
padding: dto.padding.map((item) => new BN11(item))
|
|
58005
|
+
}
|
|
58006
|
+
}))
|
|
58466
58007
|
};
|
|
58467
58008
|
}
|
|
58468
58009
|
var KAMINO_PROGRAM_ID = new PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
@@ -59137,7 +58678,7 @@ function makePoolAddPermissionlessStakedBankIx2(programId, accounts, remainingAc
|
|
|
59137
58678
|
keys.push(...remainingAccounts);
|
|
59138
58679
|
const data = Buffer.concat([
|
|
59139
58680
|
DISCRIMINATORS.LENDING_POOL_ADD_BANK_PERMISSIONLESS,
|
|
59140
|
-
encodeU64(args.seed || new
|
|
58681
|
+
encodeU64(args.seed || new BN8(0))
|
|
59141
58682
|
]);
|
|
59142
58683
|
return new TransactionInstruction({
|
|
59143
58684
|
keys,
|
|
@@ -60641,7 +60182,7 @@ function deserializeSwapEngineResult(s) {
|
|
|
60641
60182
|
setupInstructions: s.setupInstructions.map(deserializeInstruction),
|
|
60642
60183
|
swapLuts: s.swapLuts.map(deserializeLut),
|
|
60643
60184
|
quoteResponse: s.quoteResponse,
|
|
60644
|
-
outputAmountNative: new
|
|
60185
|
+
outputAmountNative: new BN8(s.outputAmountNative),
|
|
60645
60186
|
provider: s.provider
|
|
60646
60187
|
};
|
|
60647
60188
|
}
|
|
@@ -61440,8 +60981,8 @@ async function buildCandidates(req, apiConfig) {
|
|
|
61440
60981
|
swapInstructions: [deserializeJupiterInstruction2(build.swapInstruction)],
|
|
61441
60982
|
setupInstructions: (build.setupInstructions ?? []).map(deserializeJupiterInstruction2),
|
|
61442
60983
|
luts,
|
|
61443
|
-
outAmountNative: new
|
|
61444
|
-
otherAmountThresholdNative: new
|
|
60984
|
+
outAmountNative: new BN8(build.outAmount),
|
|
60985
|
+
otherAmountThresholdNative: new BN8(build.otherAmountThreshold),
|
|
61445
60986
|
quoteResult: mapBuildToQuoteResult(build),
|
|
61446
60987
|
label: `jupiter:maxAccounts=${maxAccounts}`
|
|
61447
60988
|
};
|
|
@@ -61538,8 +61079,8 @@ async function buildCandidates2(req, apiConfig) {
|
|
|
61538
61079
|
swapInstructions,
|
|
61539
61080
|
setupInstructions: [],
|
|
61540
61081
|
luts,
|
|
61541
|
-
outAmountNative: new
|
|
61542
|
-
otherAmountThresholdNative: new
|
|
61082
|
+
outAmountNative: new BN8(quote.outAmount),
|
|
61083
|
+
otherAmountThresholdNative: new BN8(quote.otherAmountThreshold),
|
|
61543
61084
|
quoteResult: { ...quote, provider: "TITAN" /* TITAN */ },
|
|
61544
61085
|
label: "titan:v3"
|
|
61545
61086
|
}
|
|
@@ -61595,14 +61136,14 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
|
|
|
61595
61136
|
marginfiAccount: marginfiAccountPk,
|
|
61596
61137
|
authority
|
|
61597
61138
|
},
|
|
61598
|
-
{ endIndex: new
|
|
61139
|
+
{ endIndex: new BN8(endIndex) }
|
|
61599
61140
|
) : await instructions_default.makeBeginFlashLoanIx(
|
|
61600
61141
|
program,
|
|
61601
61142
|
{
|
|
61602
61143
|
marginfiAccount: marginfiAccountPk,
|
|
61603
61144
|
authority
|
|
61604
61145
|
},
|
|
61605
|
-
{ endIndex: new
|
|
61146
|
+
{ endIndex: new BN8(endIndex) }
|
|
61606
61147
|
);
|
|
61607
61148
|
return { instructions: [ix], keys: [] };
|
|
61608
61149
|
}
|
|
@@ -62281,7 +61822,7 @@ function computeFlashLoanNonSwapBudget({
|
|
|
62281
61822
|
const beginFlIx = sync_instructions_default.makeBeginFlashLoanIx(
|
|
62282
61823
|
program.programId,
|
|
62283
61824
|
{ marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
|
|
62284
|
-
{ endIndex: new
|
|
61825
|
+
{ endIndex: new BN8(endIndex) }
|
|
62285
61826
|
);
|
|
62286
61827
|
const endFlRemainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
|
|
62287
61828
|
const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
|
|
@@ -62860,7 +62401,7 @@ async function buildLoopFlashloanTx(params) {
|
|
|
62860
62401
|
const engineResult = await runLoopSwapEngine(descriptor, params);
|
|
62861
62402
|
const finalIxs = [...descriptor.innerIxs];
|
|
62862
62403
|
finalIxs.splice(descriptor.swapSlotIndex, 0, ...engineResult.swapInstructions);
|
|
62863
|
-
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new
|
|
62404
|
+
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new BN8(0);
|
|
62864
62405
|
const finalDepositNative = engineResult.outputAmountNative.add(principalNative);
|
|
62865
62406
|
const depositIxPosition = descriptor.depositIxIndex + engineResult.swapInstructions.length;
|
|
62866
62407
|
patchDepositAmount(finalIxs[depositIxPosition], finalDepositNative);
|
|
@@ -63072,7 +62613,7 @@ async function runLoopSwapEngine(descriptor, params) {
|
|
|
63072
62613
|
otherAmountThreshold: "0",
|
|
63073
62614
|
slippageBps: 0
|
|
63074
62615
|
},
|
|
63075
|
-
outputAmountNative: new
|
|
62616
|
+
outputAmountNative: new BN8(0)
|
|
63076
62617
|
};
|
|
63077
62618
|
}
|
|
63078
62619
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
@@ -64093,7 +63634,7 @@ async function buildRollPtFlashloanTx({
|
|
|
64093
63634
|
if (!depositIxToPatch) {
|
|
64094
63635
|
throw new Error("roll-pt: could not locate deposit instruction for amount patching");
|
|
64095
63636
|
}
|
|
64096
|
-
patchDepositAmount(depositIxToPatch, new
|
|
63637
|
+
patchDepositAmount(depositIxToPatch, new BN8(minPtOut.toString()));
|
|
64097
63638
|
const allNonFlIxs = [
|
|
64098
63639
|
...cuRequestIxs,
|
|
64099
63640
|
...withdrawIxs.instructions,
|
|
@@ -66643,9 +66184,9 @@ function dtoToBankMetadataMap(bankMetadataDto) {
|
|
|
66643
66184
|
function dtoToBankMetadata(bankMetadataDto) {
|
|
66644
66185
|
return {
|
|
66645
66186
|
kaminoStates: bankMetadataDto.kaminoStates ? {
|
|
66646
|
-
reserveState:
|
|
66647
|
-
obligationState:
|
|
66648
|
-
farmState: bankMetadataDto.kaminoStates.farmState ?
|
|
66187
|
+
reserveState: dtoToKaminoReserve(bankMetadataDto.kaminoStates.reserveState),
|
|
66188
|
+
obligationState: dtoToKaminoObligation(bankMetadataDto.kaminoStates.obligationState),
|
|
66189
|
+
farmState: bankMetadataDto.kaminoStates.farmState ? dtoToKaminoFarmState(bankMetadataDto.kaminoStates.farmState) : void 0
|
|
66649
66190
|
} : void 0,
|
|
66650
66191
|
driftStates: bankMetadataDto.driftStates ? {
|
|
66651
66192
|
spotMarketState: dtoToDriftSpotMarketRaw(bankMetadataDto.driftStates.spotMarketState),
|
|
@@ -66660,16 +66201,16 @@ function dtoToBankMetadata(bankMetadataDto) {
|
|
|
66660
66201
|
),
|
|
66661
66202
|
jupRewardsRateModel: bankMetadataDto.jupLendStates.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(bankMetadataDto.jupLendStates.jupRewardsRateModel) : null,
|
|
66662
66203
|
jupRateModel: bankMetadataDto.jupLendStates.jupRateModel ? dtoToJupRateModelRaw(bankMetadataDto.jupLendStates.jupRateModel) : null,
|
|
66663
|
-
fTokenTotalSupply: new
|
|
66204
|
+
fTokenTotalSupply: new BN8(bankMetadataDto.jupLendStates.fTokenTotalSupply)
|
|
66664
66205
|
} : void 0
|
|
66665
66206
|
};
|
|
66666
66207
|
}
|
|
66667
66208
|
function bankMetadataToDto(bankMetadata) {
|
|
66668
66209
|
return {
|
|
66669
66210
|
kaminoStates: bankMetadata.kaminoStates ? {
|
|
66670
|
-
reserveState:
|
|
66671
|
-
obligationState:
|
|
66672
|
-
farmState: bankMetadata.kaminoStates.farmState ?
|
|
66211
|
+
reserveState: kaminoReserveToDto(bankMetadata.kaminoStates.reserveState),
|
|
66212
|
+
obligationState: kaminoObligationToDto(bankMetadata.kaminoStates.obligationState),
|
|
66213
|
+
farmState: bankMetadata.kaminoStates.farmState ? kaminoFarmStateToDto(bankMetadata.kaminoStates.farmState) : void 0
|
|
66673
66214
|
} : void 0,
|
|
66674
66215
|
driftStates: bankMetadata.driftStates ? {
|
|
66675
66216
|
spotMarketState: driftSpotMarketRawToDto(bankMetadata.driftStates.spotMarketState),
|
|
@@ -66978,8 +66519,8 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
66978
66519
|
const brokenSwbFeeds = [];
|
|
66979
66520
|
Object.keys(swbOracleAiDataByKey).forEach((oracleKey) => {
|
|
66980
66521
|
const oracleAiData = swbOracleAiDataByKey[oracleKey];
|
|
66981
|
-
const rawPriceBN = new
|
|
66982
|
-
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new
|
|
66522
|
+
const rawPriceBN = new BN8(oracleAiData.rawPrice);
|
|
66523
|
+
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new BN8(1e-6)) || rawPriceBN.eq(new BN8(1e-8));
|
|
66983
66524
|
if (isFeedBroken) {
|
|
66984
66525
|
const bank = switchboardBanks.find(
|
|
66985
66526
|
(bank2) => bank2.config.oracleKeys[0].toBase58() === oracleKey
|
|
@@ -67878,7 +67419,7 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
67878
67419
|
isWritable: false
|
|
67879
67420
|
})),
|
|
67880
67421
|
{
|
|
67881
|
-
seed: new
|
|
67422
|
+
seed: new BN8(0)
|
|
67882
67423
|
}
|
|
67883
67424
|
);
|
|
67884
67425
|
return {
|
|
@@ -68810,9 +68351,9 @@ async function getKaminoMetadata(options) {
|
|
|
68810
68351
|
for (const [bankAddress, state] of Object.entries(kaminoStates)) {
|
|
68811
68352
|
kaminoMetadataMap.set(bankAddress, {
|
|
68812
68353
|
kaminoStates: {
|
|
68813
|
-
reserveState:
|
|
68814
|
-
obligationState:
|
|
68815
|
-
farmState: state.farmState ?
|
|
68354
|
+
reserveState: dtoToKaminoReserve(state.reserveState),
|
|
68355
|
+
obligationState: dtoToKaminoObligation(state.obligationState),
|
|
68356
|
+
farmState: state.farmState ? dtoToKaminoFarmState(state.farmState) : void 0
|
|
68816
68357
|
}
|
|
68817
68358
|
});
|
|
68818
68359
|
}
|
|
@@ -68844,8 +68385,8 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68844
68385
|
bankByFarmKey[reserveState.farmCollateral.toBase58()] = bank.bankAddress;
|
|
68845
68386
|
}
|
|
68846
68387
|
kaminoStatesMap[bank.bankAddress] = {
|
|
68847
|
-
reserveState:
|
|
68848
|
-
obligationState:
|
|
68388
|
+
reserveState: kaminoReserveToDto(reserveState),
|
|
68389
|
+
obligationState: kaminoObligationToDto(obligationState)
|
|
68849
68390
|
};
|
|
68850
68391
|
}
|
|
68851
68392
|
const allFarmKeys = Object.keys(bankByFarmKey);
|
|
@@ -68868,7 +68409,7 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68868
68409
|
const decodedFarmState = decodeFarmDataRaw(farmState.data);
|
|
68869
68410
|
kaminoStatesMap[bankKey] = {
|
|
68870
68411
|
...kaminoState,
|
|
68871
|
-
farmState:
|
|
68412
|
+
farmState: kaminoFarmStateToDto(decodedFarmState)
|
|
68872
68413
|
};
|
|
68873
68414
|
}
|
|
68874
68415
|
}
|
|
@@ -68999,7 +68540,7 @@ async function getJupLendMetadata(options) {
|
|
|
68999
68540
|
jupTokenReserveState: dtoToJupTokenReserveRaw(state.jupTokenReserveState),
|
|
69000
68541
|
jupRewardsRateModel: state.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(state.jupRewardsRateModel) : null,
|
|
69001
68542
|
jupRateModel: state.jupRateModel ? dtoToJupRateModelRaw(state.jupRateModel) : null,
|
|
69002
|
-
fTokenTotalSupply: new
|
|
68543
|
+
fTokenTotalSupply: new BN8(state.fTokenTotalSupply)
|
|
69003
68544
|
}
|
|
69004
68545
|
});
|
|
69005
68546
|
}
|
|
@@ -69114,7 +68655,7 @@ async function getJupLendStatesDto(connection, jupLendBanks) {
|
|
|
69114
68655
|
return jupLendStatesMap;
|
|
69115
68656
|
}
|
|
69116
68657
|
function getJupLendFTokenMultiplier(lendingState, tokenReserve, rewardsModel, fTokenTotalSupply, nowSeconds) {
|
|
69117
|
-
const currentTimestamp = new
|
|
68658
|
+
const currentTimestamp = new BN8(nowSeconds);
|
|
69118
68659
|
const newExchangePrice = calculateJupLendNewExchangePrice(
|
|
69119
68660
|
lendingState,
|
|
69120
68661
|
tokenReserve,
|