@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.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);
|
|
@@ -432,7 +432,7 @@ function bigNumberToWrappedI80F48(value) {
|
|
|
432
432
|
let decimalValue = new Decimal3.Decimal(value.toString());
|
|
433
433
|
const isNegative = decimalValue.isNegative();
|
|
434
434
|
decimalValue = decimalValue.times(I80F48_DIVISOR);
|
|
435
|
-
let wrappedValue = new
|
|
435
|
+
let wrappedValue = new BN8__default.default(decimalValue.round().toFixed()).toArray();
|
|
436
436
|
if (wrappedValue.length < I80F48_TOTAL_BYTES) {
|
|
437
437
|
const padding = Array(I80F48_TOTAL_BYTES - wrappedValue.length).fill(0);
|
|
438
438
|
wrappedValue.unshift(...padding);
|
|
@@ -466,7 +466,7 @@ function toBigNumber(amount) {
|
|
|
466
466
|
}
|
|
467
467
|
function uiToNative(amount, decimals) {
|
|
468
468
|
let amt = toBigNumber(amount);
|
|
469
|
-
return new
|
|
469
|
+
return new BN8__default.default(amt.times(10 ** decimals).toFixed(0, BigNumber3__default.default.ROUND_FLOOR));
|
|
470
470
|
}
|
|
471
471
|
function uiToNativeBigNumber(amount, decimals) {
|
|
472
472
|
let amt = toBigNumber(amount);
|
|
@@ -15807,7 +15807,7 @@ async function makePoolAddPermissionlessStakedBankIx(mfProgram, accounts, remain
|
|
|
15807
15807
|
tokenProgram = TOKEN_PROGRAM_ID,
|
|
15808
15808
|
...optionalAccounts
|
|
15809
15809
|
} = accounts;
|
|
15810
|
-
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new
|
|
15810
|
+
return mfProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new BN8__default.default(0)).accounts({
|
|
15811
15811
|
stakedSettings,
|
|
15812
15812
|
feePayer,
|
|
15813
15813
|
bankMint,
|
|
@@ -15871,7 +15871,7 @@ var instructions = {
|
|
|
15871
15871
|
var instructions_default = instructions;
|
|
15872
15872
|
function serializeBankConfigOpt(bankConfigOpt) {
|
|
15873
15873
|
const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
|
|
15874
|
-
const toBN = (value) => value && new
|
|
15874
|
+
const toBN = (value) => value && new BN8__default.default(value.toString());
|
|
15875
15875
|
return {
|
|
15876
15876
|
assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
|
|
15877
15877
|
assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
|
|
@@ -16224,16 +16224,16 @@ function bankConfigToBankConfigRaw(config) {
|
|
|
16224
16224
|
assetWeightMaint: bigNumberToWrappedI80F48(config.assetWeightMaint),
|
|
16225
16225
|
liabilityWeightInit: bigNumberToWrappedI80F48(config.liabilityWeightInit),
|
|
16226
16226
|
liabilityWeightMaint: bigNumberToWrappedI80F48(config.liabilityWeightMaint),
|
|
16227
|
-
depositLimit: new
|
|
16227
|
+
depositLimit: new BN8__default.default(config.depositLimit.toString()),
|
|
16228
16228
|
interestRateConfig: serializeInterestRateConfig(config.interestRateConfig),
|
|
16229
16229
|
operationalState: serializeOperationalState(config.operationalState),
|
|
16230
16230
|
oracleSetup: serializeOracleSetup(config.oracleSetup),
|
|
16231
16231
|
oracleKeys: config.oracleKeys,
|
|
16232
16232
|
configFlags: config.configFlags,
|
|
16233
|
-
borrowLimit: new
|
|
16233
|
+
borrowLimit: new BN8__default.default(config.borrowLimit.toString()),
|
|
16234
16234
|
riskTier: serializeRiskTier(config.riskTier),
|
|
16235
16235
|
assetTag: config.assetTag,
|
|
16236
|
-
totalAssetValueInitLimit: new
|
|
16236
|
+
totalAssetValueInitLimit: new BN8__default.default(config.totalAssetValueInitLimit.toString()),
|
|
16237
16237
|
oracleMaxAge: config.oracleMaxAge,
|
|
16238
16238
|
oracleMaxConfidence: config.oracleMaxConfidence,
|
|
16239
16239
|
fixedPrice: bigNumberToWrappedI80F48(config.fixedPrice)
|
|
@@ -16565,12 +16565,12 @@ function dtoToBankRaw(bankDto) {
|
|
|
16565
16565
|
feeVaultBump: bankDto.feeVaultBump,
|
|
16566
16566
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
16567
16567
|
collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
|
|
16568
|
-
lastUpdate: new
|
|
16568
|
+
lastUpdate: new BN8__default.default(bankDto.lastUpdate),
|
|
16569
16569
|
config: dtoToBankConfigRaw(bankDto.config),
|
|
16570
16570
|
totalAssetShares: bankDto.totalAssetShares,
|
|
16571
16571
|
totalLiabilityShares: bankDto.totalLiabilityShares,
|
|
16572
|
-
flags: new
|
|
16573
|
-
emissionsRate: new
|
|
16572
|
+
flags: new BN8__default.default(bankDto.flags),
|
|
16573
|
+
emissionsRate: new BN8__default.default(bankDto.emissionsRate),
|
|
16574
16574
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
16575
16575
|
emissionsMint: new web3_js.PublicKey(bankDto.emissionsMint),
|
|
16576
16576
|
collectedProgramFeesOutstanding: bankDto.collectedProgramFeesOutstanding,
|
|
@@ -16586,11 +16586,11 @@ function dtoToBankRaw(bankDto) {
|
|
|
16586
16586
|
}
|
|
16587
16587
|
function dtoToRateLimitWindowRaw(window) {
|
|
16588
16588
|
return {
|
|
16589
|
-
maxOutflow: new
|
|
16590
|
-
windowDuration: new
|
|
16591
|
-
windowStart: new
|
|
16592
|
-
prevWindowOutflow: new
|
|
16593
|
-
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)
|
|
16594
16594
|
};
|
|
16595
16595
|
}
|
|
16596
16596
|
function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
@@ -16602,8 +16602,8 @@ function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
|
16602
16602
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
16603
16603
|
return {
|
|
16604
16604
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
16605
|
-
timestamp: new
|
|
16606
|
-
flags: new
|
|
16605
|
+
timestamp: new BN8__default.default(emodeSettingsDto.timestamp),
|
|
16606
|
+
flags: new BN8__default.default(emodeSettingsDto.flags),
|
|
16607
16607
|
emodeConfig: {
|
|
16608
16608
|
entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
|
|
16609
16609
|
return {
|
|
@@ -16622,11 +16622,11 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
16622
16622
|
assetWeightMaint: bankConfigDto.assetWeightMaint,
|
|
16623
16623
|
liabilityWeightInit: bankConfigDto.liabilityWeightInit,
|
|
16624
16624
|
liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
|
|
16625
|
-
depositLimit: new
|
|
16626
|
-
borrowLimit: new
|
|
16625
|
+
depositLimit: new BN8__default.default(bankConfigDto.depositLimit),
|
|
16626
|
+
borrowLimit: new BN8__default.default(bankConfigDto.borrowLimit),
|
|
16627
16627
|
riskTier: bankConfigDto.riskTier,
|
|
16628
16628
|
operationalState: bankConfigDto.operationalState,
|
|
16629
|
-
totalAssetValueInitLimit: new
|
|
16629
|
+
totalAssetValueInitLimit: new BN8__default.default(bankConfigDto.totalAssetValueInitLimit),
|
|
16630
16630
|
assetTag: bankConfigDto.assetTag,
|
|
16631
16631
|
configFlags: bankConfigDto.configFlags,
|
|
16632
16632
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
@@ -16774,7 +16774,7 @@ function getActiveEmodeFlags(flags) {
|
|
|
16774
16774
|
return activeFlags;
|
|
16775
16775
|
}
|
|
16776
16776
|
function hasEmodeFlag(flags, flag) {
|
|
16777
|
-
return !flags.and(new
|
|
16777
|
+
return !flags.and(new BN8__default.default(flag)).isZero();
|
|
16778
16778
|
}
|
|
16779
16779
|
function getActiveEmodeEntryFlags(flags) {
|
|
16780
16780
|
const activeFlags = [];
|
|
@@ -19763,8 +19763,8 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
|
|
|
19763
19763
|
const crossbarData = crossbarResponse[oracleFeed]?.results;
|
|
19764
19764
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19765
19765
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19766
|
-
crossbarData ?? new
|
|
19767
|
-
new
|
|
19766
|
+
crossbarData ?? new BN8__default.default(oracleData.rawPrice),
|
|
19767
|
+
new BN8__default.default(oracleData.stdev),
|
|
19768
19768
|
timestamp,
|
|
19769
19769
|
oracleData
|
|
19770
19770
|
);
|
|
@@ -19790,7 +19790,7 @@ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse
|
|
|
19790
19790
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
19791
19791
|
const oraclePrice = parseSwbOraclePriceData(
|
|
19792
19792
|
[birdeyeData],
|
|
19793
|
-
new
|
|
19793
|
+
new BN8__default.default(oracleData.stdev),
|
|
19794
19794
|
timestamp,
|
|
19795
19795
|
oracleData
|
|
19796
19796
|
);
|
|
@@ -20406,7 +20406,7 @@ var EMPTY_HEALTH_CACHE = {
|
|
|
20406
20406
|
liabilityValue: {
|
|
20407
20407
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
20408
20408
|
},
|
|
20409
|
-
timestamp: new
|
|
20409
|
+
timestamp: new BN8__default.default(0),
|
|
20410
20410
|
flags: 0,
|
|
20411
20411
|
prices: [],
|
|
20412
20412
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
@@ -20493,7 +20493,7 @@ function getActiveAccountFlags(flags) {
|
|
|
20493
20493
|
return activeFlags;
|
|
20494
20494
|
}
|
|
20495
20495
|
function hasAccountFlag(flags, flag) {
|
|
20496
|
-
return !flags.and(new
|
|
20496
|
+
return !flags.and(new BN8__default.default(flag)).isZero();
|
|
20497
20497
|
}
|
|
20498
20498
|
function getActiveHealthCacheFlags(flags) {
|
|
20499
20499
|
const activeFlags = [];
|
|
@@ -20563,7 +20563,7 @@ function dtoToHealthCache(healthCacheDto) {
|
|
|
20563
20563
|
};
|
|
20564
20564
|
}
|
|
20565
20565
|
function accountFlagToBN(flag) {
|
|
20566
|
-
return new
|
|
20566
|
+
return new BN8__default.default(flag);
|
|
20567
20567
|
}
|
|
20568
20568
|
function marginfiAccountToDto(marginfiAccount) {
|
|
20569
20569
|
return {
|
|
@@ -35753,23 +35753,23 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35753
35753
|
authority: new web3_js.PublicKey(userStatsDto.authority),
|
|
35754
35754
|
referrer: new web3_js.PublicKey(userStatsDto.referrer),
|
|
35755
35755
|
fees: {
|
|
35756
|
-
totalFeePaid: new
|
|
35757
|
-
totalFeeRebate: new
|
|
35758
|
-
totalTokenDiscount: new
|
|
35759
|
-
totalRefereeDiscount: new
|
|
35760
|
-
totalReferrerReward: new
|
|
35761
|
-
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(
|
|
35762
35762
|
userStatsDto.fees.currentEpochReferrerReward
|
|
35763
35763
|
)
|
|
35764
35764
|
},
|
|
35765
|
-
nextEpochTs: new
|
|
35766
|
-
makerVolume30d: new
|
|
35767
|
-
takerVolume30d: new
|
|
35768
|
-
fillerVolume30d: new
|
|
35769
|
-
lastMakerVolume30dTs: new
|
|
35770
|
-
lastTakerVolume30dTs: new
|
|
35771
|
-
lastFillerVolume30dTs: new
|
|
35772
|
-
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),
|
|
35773
35773
|
numberOfSubAccounts: userStatsDto.numberOfSubAccounts,
|
|
35774
35774
|
numberOfSubAccountsCreated: userStatsDto.numberOfSubAccountsCreated,
|
|
35775
35775
|
referrerStatus: userStatsDto.referrerStatus,
|
|
@@ -35782,7 +35782,7 @@ function dtoToDriftUserStatsRaw(userStatsDto) {
|
|
|
35782
35782
|
fuelPositions: userStatsDto.fuelPositions,
|
|
35783
35783
|
fuelTaker: userStatsDto.fuelTaker,
|
|
35784
35784
|
fuelMaker: userStatsDto.fuelMaker,
|
|
35785
|
-
ifStakedGovTokenAmount: new
|
|
35785
|
+
ifStakedGovTokenAmount: new BN8__default.default(userStatsDto.ifStakedGovTokenAmount),
|
|
35786
35786
|
lastFuelIfBonusUpdateTs: userStatsDto.lastFuelIfBonusUpdateTs,
|
|
35787
35787
|
padding: userStatsDto.padding
|
|
35788
35788
|
};
|
|
@@ -35791,10 +35791,10 @@ function dtoToDriftUserRaw(userDto) {
|
|
|
35791
35791
|
return {
|
|
35792
35792
|
authority: new web3_js.PublicKey(userDto.authority),
|
|
35793
35793
|
spotPositions: userDto.spotPositions.map((p) => ({
|
|
35794
|
-
scaledBalance: new
|
|
35795
|
-
openBids: new
|
|
35796
|
-
openAsks: new
|
|
35797
|
-
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),
|
|
35798
35798
|
marketIndex: p.marketIndex,
|
|
35799
35799
|
balanceType: p.balanceType,
|
|
35800
35800
|
openOrders: p.openOrders,
|
|
@@ -35809,10 +35809,10 @@ function dtoToDriftRewardsRaw(rewardsDto) {
|
|
|
35809
35809
|
spotMarket: new web3_js.PublicKey(rewardsDto.spotMarket),
|
|
35810
35810
|
mint: new web3_js.PublicKey(rewardsDto.mint),
|
|
35811
35811
|
spotPosition: {
|
|
35812
|
-
scaledBalance: new
|
|
35813
|
-
openBids: new
|
|
35814
|
-
openAsks: new
|
|
35815
|
-
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),
|
|
35816
35816
|
marketIndex: rewardsDto.spotPosition.marketIndex,
|
|
35817
35817
|
balanceType: rewardsDto.spotPosition.balanceType,
|
|
35818
35818
|
openOrders: rewardsDto.spotPosition.openOrders,
|
|
@@ -35826,11 +35826,11 @@ function dtoToDriftSpotMarketRaw(spotMarketDto) {
|
|
|
35826
35826
|
oracle: new web3_js.PublicKey(spotMarketDto.oracle),
|
|
35827
35827
|
mint: new web3_js.PublicKey(spotMarketDto.mint),
|
|
35828
35828
|
decimals: spotMarketDto.decimals,
|
|
35829
|
-
cumulativeDepositInterest: new
|
|
35829
|
+
cumulativeDepositInterest: new BN8__default.default(spotMarketDto.cumulativeDepositInterest),
|
|
35830
35830
|
marketIndex: spotMarketDto.marketIndex,
|
|
35831
|
-
depositBalance: new
|
|
35832
|
-
borrowBalance: new
|
|
35833
|
-
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),
|
|
35834
35834
|
optimalUtilization: spotMarketDto.optimalUtilization,
|
|
35835
35835
|
optimalBorrowRate: spotMarketDto.optimalBorrowRate,
|
|
35836
35836
|
maxBorrowRate: spotMarketDto.maxBorrowRate,
|
|
@@ -35919,10 +35919,10 @@ function decodeDriftUserData(data) {
|
|
|
35919
35919
|
return {
|
|
35920
35920
|
authority: decoded.authority,
|
|
35921
35921
|
spotPositions: decoded.spot_positions.map((p) => ({
|
|
35922
|
-
scaledBalance: new
|
|
35923
|
-
openBids: new
|
|
35924
|
-
openAsks: new
|
|
35925
|
-
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),
|
|
35926
35926
|
marketIndex: p.market_index,
|
|
35927
35927
|
balanceType: p.balance_type,
|
|
35928
35928
|
openOrders: p.open_orders,
|
|
@@ -35992,7 +35992,7 @@ function deriveDriftSpotMarket(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
35992
35992
|
return web3_js.PublicKey.findProgramAddressSync(
|
|
35993
35993
|
[
|
|
35994
35994
|
Buffer.from(SEED_SPOT_MARKET),
|
|
35995
|
-
new
|
|
35995
|
+
new BN8__default.default(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
35996
35996
|
],
|
|
35997
35997
|
programId
|
|
35998
35998
|
);
|
|
@@ -36001,7 +36001,7 @@ function deriveDriftSpotMarketVault(marketIndex, programId = DRIFT_PROGRAM_ID) {
|
|
|
36001
36001
|
return web3_js.PublicKey.findProgramAddressSync(
|
|
36002
36002
|
[
|
|
36003
36003
|
Buffer.from(SEED_SPOT_MARKET_VAULT),
|
|
36004
|
-
new
|
|
36004
|
+
new BN8__default.default(marketIndex).toArrayLike(Buffer, "le", 2)
|
|
36005
36005
|
],
|
|
36006
36006
|
programId
|
|
36007
36007
|
);
|
|
@@ -36395,7 +36395,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36395
36395
|
assetShares: dummyWrappedI80F48,
|
|
36396
36396
|
liabilityShares: dummyWrappedI80F48,
|
|
36397
36397
|
emissionsOutstanding: dummyWrappedI80F48,
|
|
36398
|
-
lastUpdate: new
|
|
36398
|
+
lastUpdate: new BN8__default.default(0)
|
|
36399
36399
|
});
|
|
36400
36400
|
const rawAccount = {
|
|
36401
36401
|
group,
|
|
@@ -36408,7 +36408,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36408
36408
|
liabilityValue: {
|
|
36409
36409
|
value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
36410
36410
|
},
|
|
36411
|
-
timestamp: new
|
|
36411
|
+
timestamp: new BN8__default.default(0),
|
|
36412
36412
|
flags: 0,
|
|
36413
36413
|
prices: [],
|
|
36414
36414
|
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
@@ -36422,7 +36422,7 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
36422
36422
|
mrgnErr: 0
|
|
36423
36423
|
},
|
|
36424
36424
|
emissionsDestinationAccount: new web3_js.PublicKey("11111111111111111111111111111111"),
|
|
36425
|
-
accountFlags: new
|
|
36425
|
+
accountFlags: new BN8__default.default([0, 0, 0])
|
|
36426
36426
|
};
|
|
36427
36427
|
return parseMarginfiAccountRaw(accountKey, rawAccount);
|
|
36428
36428
|
}
|
|
@@ -36455,233 +36455,65 @@ async function makeRefreshingIxs({
|
|
|
36455
36455
|
}
|
|
36456
36456
|
|
|
36457
36457
|
// src/vendor/klend/utils/klend/serialize.utils.ts
|
|
36458
|
-
function
|
|
36458
|
+
function kaminoObligationToDto(obligation) {
|
|
36459
36459
|
return {
|
|
36460
|
-
|
|
36461
|
-
|
|
36462
|
-
|
|
36463
|
-
|
|
36464
|
-
|
|
36465
|
-
|
|
36466
|
-
},
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
|
|
36470
|
-
|
|
36471
|
-
)
|
|
36472
|
-
lowestReserveDepositLiquidationLtv: obligationRaw.lowestReserveDepositLiquidationLtv.toString(),
|
|
36473
|
-
depositedValueSf: obligationRaw.depositedValueSf.toString(),
|
|
36474
|
-
borrows: obligationRaw.borrows.map(
|
|
36475
|
-
(item) => obligationLiquidityToDto(item)
|
|
36476
|
-
),
|
|
36477
|
-
borrowFactorAdjustedDebtValueSf: obligationRaw.borrowFactorAdjustedDebtValueSf.toString(),
|
|
36478
|
-
borrowedAssetsMarketValueSf: obligationRaw.borrowedAssetsMarketValueSf.toString(),
|
|
36479
|
-
allowedBorrowValueSf: obligationRaw.allowedBorrowValueSf.toString(),
|
|
36480
|
-
unhealthyBorrowValueSf: obligationRaw.unhealthyBorrowValueSf.toString(),
|
|
36481
|
-
depositsAssetTiers: obligationRaw.depositsAssetTiers,
|
|
36482
|
-
borrowsAssetTiers: obligationRaw.borrowsAssetTiers,
|
|
36483
|
-
elevationGroup: obligationRaw.elevationGroup,
|
|
36484
|
-
numOfObsoleteDepositReserves: obligationRaw.numOfObsoleteDepositReserves,
|
|
36485
|
-
hasDebt: obligationRaw.hasDebt,
|
|
36486
|
-
referrer: obligationRaw.referrer.toBase58(),
|
|
36487
|
-
borrowingDisabled: obligationRaw.borrowingDisabled,
|
|
36488
|
-
autodeleverageTargetLtvPct: obligationRaw.autodeleverageTargetLtvPct,
|
|
36489
|
-
lowestReserveDepositMaxLtvPct: obligationRaw.lowestReserveDepositMaxLtvPct,
|
|
36490
|
-
numOfObsoleteBorrowReserves: obligationRaw.numOfObsoleteBorrowReserves,
|
|
36491
|
-
reserved: obligationRaw.reserved,
|
|
36492
|
-
highestBorrowFactorPct: obligationRaw.highestBorrowFactorPct.toString(),
|
|
36493
|
-
autodeleverageMarginCallStartedTimestamp: obligationRaw.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
36494
|
-
orders: obligationRaw.orders.map((item) => obligationOrderToDto(item)),
|
|
36495
|
-
padding3: obligationRaw.padding3.map((item) => item.toString())
|
|
36496
|
-
};
|
|
36497
|
-
}
|
|
36498
|
-
function reserveRawToDto(reserveRaw) {
|
|
36499
|
-
return {
|
|
36500
|
-
version: reserveRaw.version.toString(),
|
|
36501
|
-
lastUpdate: {
|
|
36502
|
-
slot: reserveRaw.lastUpdate.slot.toString(),
|
|
36503
|
-
stale: reserveRaw.lastUpdate.stale,
|
|
36504
|
-
priceStatus: reserveRaw.lastUpdate.priceStatus,
|
|
36505
|
-
placeholder: reserveRaw.lastUpdate.placeholder
|
|
36506
|
-
},
|
|
36507
|
-
lendingMarket: reserveRaw.lendingMarket.toBase58(),
|
|
36508
|
-
farmCollateral: reserveRaw.farmCollateral.toBase58(),
|
|
36509
|
-
farmDebt: reserveRaw.farmDebt.toBase58(),
|
|
36510
|
-
liquidity: reserveLiquidityFieldsToDto(reserveRaw.liquidity),
|
|
36511
|
-
reserveLiquidityPadding: reserveRaw.reserveLiquidityPadding.map(
|
|
36512
|
-
(item) => item.toString()
|
|
36513
|
-
),
|
|
36514
|
-
collateral: {
|
|
36515
|
-
mintPubkey: reserveRaw.collateral.mintPubkey.toBase58(),
|
|
36516
|
-
mintTotalSupply: reserveRaw.collateral.mintTotalSupply.toString(),
|
|
36517
|
-
supplyVault: reserveRaw.collateral.supplyVault.toBase58(),
|
|
36518
|
-
padding1: reserveRaw.collateral.padding1.map((item) => item.toString()),
|
|
36519
|
-
padding2: reserveRaw.collateral.padding2.map((item) => item.toString())
|
|
36520
|
-
},
|
|
36521
|
-
reserveCollateralPadding: reserveRaw.reserveCollateralPadding.map(
|
|
36522
|
-
(item) => item.toString()
|
|
36523
|
-
),
|
|
36524
|
-
config: reserveConfigFieldsToDto(reserveRaw.config),
|
|
36525
|
-
configPadding: reserveRaw.configPadding.map((item) => item.toString()),
|
|
36526
|
-
borrowedAmountOutsideElevationGroup: reserveRaw.borrowedAmountOutsideElevationGroup.toString(),
|
|
36527
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveRaw.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
36528
|
-
(item) => item.toString()
|
|
36529
|
-
),
|
|
36530
|
-
padding: reserveRaw.padding.map((item) => item.toString())
|
|
36531
|
-
};
|
|
36532
|
-
}
|
|
36533
|
-
function reserveLiquidityFieldsToDto(reserveLiquidityFields) {
|
|
36534
|
-
return {
|
|
36535
|
-
mintPubkey: reserveLiquidityFields.mintPubkey.toBase58(),
|
|
36536
|
-
supplyVault: reserveLiquidityFields.supplyVault.toBase58(),
|
|
36537
|
-
feeVault: reserveLiquidityFields.feeVault.toBase58(),
|
|
36538
|
-
availableAmount: reserveLiquidityFields.availableAmount.toString(),
|
|
36539
|
-
borrowedAmountSf: reserveLiquidityFields.borrowedAmountSf.toString(),
|
|
36540
|
-
marketPriceSf: reserveLiquidityFields.marketPriceSf.toString(),
|
|
36541
|
-
marketPriceLastUpdatedTs: reserveLiquidityFields.marketPriceLastUpdatedTs.toString(),
|
|
36542
|
-
mintDecimals: reserveLiquidityFields.mintDecimals.toString(),
|
|
36543
|
-
depositLimitCrossedTimestamp: reserveLiquidityFields.depositLimitCrossedTimestamp.toString(),
|
|
36544
|
-
borrowLimitCrossedTimestamp: reserveLiquidityFields.borrowLimitCrossedTimestamp.toString(),
|
|
36545
|
-
cumulativeBorrowRateBsf: {
|
|
36546
|
-
value: reserveLiquidityFields.cumulativeBorrowRateBsf.value.map(
|
|
36547
|
-
(item) => item.toString()
|
|
36548
|
-
),
|
|
36549
|
-
padding: reserveLiquidityFields.cumulativeBorrowRateBsf.padding.map(
|
|
36550
|
-
(item) => item.toString()
|
|
36551
|
-
)
|
|
36552
|
-
},
|
|
36553
|
-
accumulatedProtocolFeesSf: reserveLiquidityFields.accumulatedProtocolFeesSf.toString(),
|
|
36554
|
-
accumulatedReferrerFeesSf: reserveLiquidityFields.accumulatedReferrerFeesSf.toString(),
|
|
36555
|
-
pendingReferrerFeesSf: reserveLiquidityFields.pendingReferrerFeesSf.toString(),
|
|
36556
|
-
absoluteReferralRateSf: reserveLiquidityFields.absoluteReferralRateSf.toString(),
|
|
36557
|
-
tokenProgram: reserveLiquidityFields.tokenProgram.toBase58(),
|
|
36558
|
-
padding2: reserveLiquidityFields.padding2.map((item) => item.toString()),
|
|
36559
|
-
padding3: reserveLiquidityFields.padding3.map((item) => item.toString())
|
|
36560
|
-
};
|
|
36561
|
-
}
|
|
36562
|
-
function reserveConfigFieldsToDto(reserveConfigFields) {
|
|
36563
|
-
return {
|
|
36564
|
-
status: reserveConfigFields.status,
|
|
36565
|
-
assetTier: reserveConfigFields.assetTier,
|
|
36566
|
-
hostFixedInterestRateBps: reserveConfigFields.hostFixedInterestRateBps,
|
|
36567
|
-
reserved2: reserveConfigFields.reserved2,
|
|
36568
|
-
protocolOrderExecutionFeePct: reserveConfigFields.protocolOrderExecutionFeePct,
|
|
36569
|
-
protocolTakeRatePct: reserveConfigFields.protocolTakeRatePct,
|
|
36570
|
-
protocolLiquidationFeePct: reserveConfigFields.protocolLiquidationFeePct,
|
|
36571
|
-
loanToValuePct: reserveConfigFields.loanToValuePct,
|
|
36572
|
-
liquidationThresholdPct: reserveConfigFields.liquidationThresholdPct,
|
|
36573
|
-
minLiquidationBonusBps: reserveConfigFields.minLiquidationBonusBps,
|
|
36574
|
-
maxLiquidationBonusBps: reserveConfigFields.maxLiquidationBonusBps,
|
|
36575
|
-
badDebtLiquidationBonusBps: reserveConfigFields.badDebtLiquidationBonusBps,
|
|
36576
|
-
deleveragingMarginCallPeriodSecs: reserveConfigFields.deleveragingMarginCallPeriodSecs.toString(),
|
|
36577
|
-
deleveragingThresholdDecreaseBpsPerDay: reserveConfigFields.deleveragingThresholdDecreaseBpsPerDay.toString(),
|
|
36578
|
-
fees: {
|
|
36579
|
-
borrowFeeSf: reserveConfigFields.fees.borrowFeeSf.toString(),
|
|
36580
|
-
flashLoanFeeSf: reserveConfigFields.fees.flashLoanFeeSf.toString(),
|
|
36581
|
-
padding: reserveConfigFields.fees.padding
|
|
36582
|
-
},
|
|
36583
|
-
borrowRateCurve: {
|
|
36584
|
-
points: reserveConfigFields.borrowRateCurve.points.map((item) => ({
|
|
36585
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
36586
|
-
borrowRateBps: item.borrowRateBps
|
|
36587
|
-
}))
|
|
36588
|
-
},
|
|
36589
|
-
borrowFactorPct: reserveConfigFields.borrowFactorPct.toString(),
|
|
36590
|
-
depositLimit: reserveConfigFields.depositLimit.toString(),
|
|
36591
|
-
borrowLimit: reserveConfigFields.borrowLimit.toString(),
|
|
36592
|
-
tokenInfo: tokenInfoFieldsToDto(reserveConfigFields.tokenInfo),
|
|
36593
|
-
depositWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36594
|
-
reserveConfigFields.depositWithdrawalCap
|
|
36595
|
-
),
|
|
36596
|
-
debtWithdrawalCap: withdrawalCapsFieldsToDto(
|
|
36597
|
-
reserveConfigFields.debtWithdrawalCap
|
|
36598
|
-
),
|
|
36599
|
-
elevationGroups: reserveConfigFields.elevationGroups,
|
|
36600
|
-
disableUsageAsCollOutsideEmode: reserveConfigFields.disableUsageAsCollOutsideEmode,
|
|
36601
|
-
utilizationLimitBlockBorrowingAbovePct: reserveConfigFields.utilizationLimitBlockBorrowingAbovePct,
|
|
36602
|
-
autodeleverageEnabled: reserveConfigFields.autodeleverageEnabled,
|
|
36603
|
-
reserved1: reserveConfigFields.reserved1,
|
|
36604
|
-
borrowLimitOutsideElevationGroup: reserveConfigFields.borrowLimitOutsideElevationGroup.toString(),
|
|
36605
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveConfigFields.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
36606
|
-
(item) => item.toString()
|
|
36607
|
-
),
|
|
36608
|
-
deleveragingBonusIncreaseBpsPerDay: reserveConfigFields.deleveragingBonusIncreaseBpsPerDay.toString()
|
|
36609
|
-
};
|
|
36610
|
-
}
|
|
36611
|
-
function tokenInfoFieldsToDto(tokenInfoFields) {
|
|
36612
|
-
return {
|
|
36613
|
-
name: tokenInfoFields.name,
|
|
36614
|
-
heuristic: {
|
|
36615
|
-
lower: tokenInfoFields.heuristic.lower.toString(),
|
|
36616
|
-
upper: tokenInfoFields.heuristic.upper.toString(),
|
|
36617
|
-
exp: tokenInfoFields.heuristic.exp.toString()
|
|
36618
|
-
},
|
|
36619
|
-
maxTwapDivergenceBps: tokenInfoFields.maxTwapDivergenceBps.toString(),
|
|
36620
|
-
maxAgePriceSeconds: tokenInfoFields.maxAgePriceSeconds.toString(),
|
|
36621
|
-
maxAgeTwapSeconds: tokenInfoFields.maxAgeTwapSeconds.toString(),
|
|
36622
|
-
scopeConfiguration: {
|
|
36623
|
-
priceFeed: tokenInfoFields.scopeConfiguration.priceFeed.toBase58(),
|
|
36624
|
-
priceChain: tokenInfoFields.scopeConfiguration.priceChain,
|
|
36625
|
-
twapChain: tokenInfoFields.scopeConfiguration.twapChain
|
|
36626
|
-
},
|
|
36627
|
-
switchboardConfiguration: {
|
|
36628
|
-
priceAggregator: tokenInfoFields.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36629
|
-
twapAggregator: tokenInfoFields.switchboardConfiguration.twapAggregator.toBase58()
|
|
36630
|
-
},
|
|
36631
|
-
pythConfiguration: {
|
|
36632
|
-
price: tokenInfoFields.pythConfiguration.price.toBase58()
|
|
36633
|
-
},
|
|
36634
|
-
blockPriceUsage: tokenInfoFields.blockPriceUsage,
|
|
36635
|
-
reserved: tokenInfoFields.reserved,
|
|
36636
|
-
padding: tokenInfoFields.padding.map((item) => item.toString())
|
|
36637
|
-
};
|
|
36638
|
-
}
|
|
36639
|
-
function withdrawalCapsFieldsToDto(withdrawalCapsFields) {
|
|
36640
|
-
return {
|
|
36641
|
-
configCapacity: withdrawalCapsFields.configCapacity.toString(),
|
|
36642
|
-
currentTotal: withdrawalCapsFields.currentTotal.toString(),
|
|
36643
|
-
lastIntervalStartTimestamp: withdrawalCapsFields.lastIntervalStartTimestamp.toString(),
|
|
36644
|
-
configIntervalLengthSeconds: withdrawalCapsFields.configIntervalLengthSeconds.toString()
|
|
36645
|
-
};
|
|
36646
|
-
}
|
|
36647
|
-
function obligationCollateralToDto(obligationCollateralFields) {
|
|
36648
|
-
return {
|
|
36649
|
-
depositReserve: obligationCollateralFields.depositReserve.toBase58(),
|
|
36650
|
-
depositedAmount: obligationCollateralFields.depositedAmount.toString(),
|
|
36651
|
-
marketValueSf: obligationCollateralFields.marketValueSf.toString(),
|
|
36652
|
-
borrowedAmountAgainstThisCollateralInElevationGroup: obligationCollateralFields.borrowedAmountAgainstThisCollateralInElevationGroup.toString(),
|
|
36653
|
-
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
|
+
}))
|
|
36654
36472
|
};
|
|
36655
36473
|
}
|
|
36656
|
-
function
|
|
36474
|
+
function kaminoReserveToDto(reserve) {
|
|
36657
36475
|
return {
|
|
36658
|
-
|
|
36659
|
-
|
|
36660
|
-
|
|
36661
|
-
|
|
36662
|
-
),
|
|
36663
|
-
|
|
36664
|
-
|
|
36665
|
-
)
|
|
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()
|
|
36666
36487
|
},
|
|
36667
|
-
|
|
36668
|
-
|
|
36669
|
-
|
|
36670
|
-
|
|
36671
|
-
|
|
36672
|
-
|
|
36673
|
-
|
|
36674
|
-
|
|
36675
|
-
|
|
36676
|
-
|
|
36677
|
-
|
|
36678
|
-
|
|
36679
|
-
|
|
36680
|
-
|
|
36681
|
-
|
|
36682
|
-
|
|
36683
|
-
|
|
36684
|
-
|
|
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
|
+
depositLimit: reserve.config.depositLimit.toString(),
|
|
36497
|
+
borrowLimit: reserve.config.borrowLimit.toString(),
|
|
36498
|
+
borrowRateCurve: {
|
|
36499
|
+
points: reserve.config.borrowRateCurve.points.map((item) => ({
|
|
36500
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
36501
|
+
borrowRateBps: item.borrowRateBps
|
|
36502
|
+
}))
|
|
36503
|
+
},
|
|
36504
|
+
tokenInfo: {
|
|
36505
|
+
scopeConfiguration: {
|
|
36506
|
+
priceFeed: reserve.config.tokenInfo.scopeConfiguration.priceFeed.toBase58()
|
|
36507
|
+
},
|
|
36508
|
+
switchboardConfiguration: {
|
|
36509
|
+
priceAggregator: reserve.config.tokenInfo.switchboardConfiguration.priceAggregator.toBase58(),
|
|
36510
|
+
twapAggregator: reserve.config.tokenInfo.switchboardConfiguration.twapAggregator.toBase58()
|
|
36511
|
+
},
|
|
36512
|
+
pythConfiguration: {
|
|
36513
|
+
price: reserve.config.tokenInfo.pythConfiguration.price.toBase58()
|
|
36514
|
+
}
|
|
36515
|
+
}
|
|
36516
|
+
}
|
|
36685
36517
|
};
|
|
36686
36518
|
}
|
|
36687
36519
|
|
|
@@ -43179,267 +43011,78 @@ function decodeKlendObligationData(data) {
|
|
|
43179
43011
|
const dec = obligationLayout.decode(data.slice(8));
|
|
43180
43012
|
return dec;
|
|
43181
43013
|
}
|
|
43182
|
-
function
|
|
43014
|
+
function dtoToKaminoObligation(obligationDto) {
|
|
43183
43015
|
return {
|
|
43184
|
-
tag: new BN11__default.default(obligationDto.tag),
|
|
43185
|
-
lastUpdate: {
|
|
43186
|
-
slot: new BN11__default.default(obligationDto.lastUpdate.slot),
|
|
43187
|
-
stale: obligationDto.lastUpdate.stale,
|
|
43188
|
-
priceStatus: obligationDto.lastUpdate.priceStatus,
|
|
43189
|
-
placeholder: obligationDto.lastUpdate.placeholder
|
|
43190
|
-
},
|
|
43191
43016
|
lendingMarket: new web3_js.PublicKey(obligationDto.lendingMarket),
|
|
43192
43017
|
owner: new web3_js.PublicKey(obligationDto.owner),
|
|
43193
|
-
|
|
43194
|
-
|
|
43195
|
-
|
|
43196
|
-
|
|
43197
|
-
|
|
43198
|
-
),
|
|
43199
|
-
|
|
43200
|
-
|
|
43201
|
-
|
|
43202
|
-
|
|
43203
|
-
|
|
43204
|
-
obligationDto.borrowFactorAdjustedDebtValueSf
|
|
43205
|
-
),
|
|
43206
|
-
borrowedAssetsMarketValueSf: new BN11__default.default(
|
|
43207
|
-
obligationDto.borrowedAssetsMarketValueSf
|
|
43208
|
-
),
|
|
43209
|
-
allowedBorrowValueSf: new BN11__default.default(obligationDto.allowedBorrowValueSf),
|
|
43210
|
-
unhealthyBorrowValueSf: new BN11__default.default(obligationDto.unhealthyBorrowValueSf),
|
|
43211
|
-
depositsAssetTiers: obligationDto.depositsAssetTiers,
|
|
43212
|
-
borrowsAssetTiers: obligationDto.borrowsAssetTiers,
|
|
43213
|
-
elevationGroup: obligationDto.elevationGroup,
|
|
43214
|
-
numOfObsoleteDepositReserves: obligationDto.numOfObsoleteDepositReserves,
|
|
43215
|
-
hasDebt: obligationDto.hasDebt,
|
|
43216
|
-
referrer: new web3_js.PublicKey(obligationDto.referrer),
|
|
43217
|
-
borrowingDisabled: obligationDto.borrowingDisabled,
|
|
43218
|
-
autodeleverageTargetLtvPct: obligationDto.autodeleverageTargetLtvPct,
|
|
43219
|
-
lowestReserveDepositMaxLtvPct: obligationDto.lowestReserveDepositMaxLtvPct,
|
|
43220
|
-
numOfObsoleteBorrowReserves: obligationDto.numOfObsoleteBorrowReserves,
|
|
43221
|
-
reserved: obligationDto.reserved,
|
|
43222
|
-
highestBorrowFactorPct: new BN11__default.default(obligationDto.highestBorrowFactorPct),
|
|
43223
|
-
autodeleverageMarginCallStartedTimestamp: new BN11__default.default(
|
|
43224
|
-
obligationDto.autodeleverageMarginCallStartedTimestamp
|
|
43225
|
-
),
|
|
43226
|
-
orders: obligationDto.orders.map(
|
|
43227
|
-
(item) => dtoToObligationOrderFields(item)
|
|
43228
|
-
),
|
|
43229
|
-
padding3: obligationDto.padding3.map((item) => new BN11__default.default(item))
|
|
43018
|
+
// Hosted endpoints may prune empty position arrays from the payload
|
|
43019
|
+
deposits: (obligationDto.deposits ?? []).map((item) => ({
|
|
43020
|
+
depositReserve: new web3_js.PublicKey(item.depositReserve),
|
|
43021
|
+
depositedAmount: new BN8__default.default(item.depositedAmount),
|
|
43022
|
+
marketValueSf: new BN8__default.default(item.marketValueSf)
|
|
43023
|
+
})),
|
|
43024
|
+
borrows: (obligationDto.borrows ?? []).map((item) => ({
|
|
43025
|
+
borrowReserve: new web3_js.PublicKey(item.borrowReserve),
|
|
43026
|
+
borrowedAmountSf: new BN8__default.default(item.borrowedAmountSf),
|
|
43027
|
+
marketValueSf: new BN8__default.default(item.marketValueSf)
|
|
43028
|
+
}))
|
|
43230
43029
|
};
|
|
43231
43030
|
}
|
|
43232
|
-
function
|
|
43031
|
+
function dtoToKaminoReserve(reserveDto) {
|
|
43233
43032
|
return {
|
|
43234
|
-
version: new BN11__default.default(reserveDto.version),
|
|
43235
|
-
lastUpdate: {
|
|
43236
|
-
slot: new BN11__default.default(reserveDto.lastUpdate.slot),
|
|
43237
|
-
stale: reserveDto.lastUpdate.stale,
|
|
43238
|
-
priceStatus: reserveDto.lastUpdate.priceStatus,
|
|
43239
|
-
placeholder: reserveDto.lastUpdate.placeholder
|
|
43240
|
-
},
|
|
43241
43033
|
lendingMarket: new web3_js.PublicKey(reserveDto.lendingMarket),
|
|
43242
43034
|
farmCollateral: new web3_js.PublicKey(reserveDto.farmCollateral),
|
|
43243
|
-
|
|
43244
|
-
|
|
43245
|
-
|
|
43246
|
-
|
|
43247
|
-
|
|
43248
|
-
|
|
43249
|
-
|
|
43250
|
-
|
|
43251
|
-
supplyVault: new web3_js.PublicKey(reserveDto.collateral.supplyVault),
|
|
43252
|
-
padding1: reserveDto.collateral.padding1.map((item) => new BN11__default.default(item)),
|
|
43253
|
-
padding2: reserveDto.collateral.padding2.map((item) => new BN11__default.default(item))
|
|
43254
|
-
},
|
|
43255
|
-
reserveCollateralPadding: reserveDto.reserveCollateralPadding.map(
|
|
43256
|
-
(item) => new BN11__default.default(item)
|
|
43257
|
-
),
|
|
43258
|
-
config: dtoToReserveConfigFields(reserveDto.config),
|
|
43259
|
-
configPadding: reserveDto.configPadding.map((item) => new BN11__default.default(item)),
|
|
43260
|
-
borrowedAmountOutsideElevationGroup: new BN11__default.default(
|
|
43261
|
-
reserveDto.borrowedAmountOutsideElevationGroup
|
|
43262
|
-
),
|
|
43263
|
-
borrowedAmountsAgainstThisReserveInElevationGroups: reserveDto.borrowedAmountsAgainstThisReserveInElevationGroups.map(
|
|
43264
|
-
(item) => new BN11__default.default(item)
|
|
43265
|
-
),
|
|
43266
|
-
padding: reserveDto.padding.map((item) => new BN11__default.default(item))
|
|
43267
|
-
};
|
|
43268
|
-
}
|
|
43269
|
-
function dtoToReserveLiquidityFields(reserveDto) {
|
|
43270
|
-
return {
|
|
43271
|
-
mintPubkey: new web3_js.PublicKey(reserveDto.mintPubkey),
|
|
43272
|
-
supplyVault: new web3_js.PublicKey(reserveDto.supplyVault),
|
|
43273
|
-
feeVault: new web3_js.PublicKey(reserveDto.feeVault),
|
|
43274
|
-
availableAmount: new BN11__default.default(reserveDto.availableAmount),
|
|
43275
|
-
borrowedAmountSf: new BN11__default.default(reserveDto.borrowedAmountSf),
|
|
43276
|
-
marketPriceSf: new BN11__default.default(reserveDto.marketPriceSf),
|
|
43277
|
-
marketPriceLastUpdatedTs: new BN11__default.default(reserveDto.marketPriceLastUpdatedTs),
|
|
43278
|
-
mintDecimals: new BN11__default.default(reserveDto.mintDecimals),
|
|
43279
|
-
depositLimitCrossedTimestamp: new BN11__default.default(
|
|
43280
|
-
reserveDto.depositLimitCrossedTimestamp
|
|
43281
|
-
),
|
|
43282
|
-
borrowLimitCrossedTimestamp: new BN11__default.default(reserveDto.borrowLimitCrossedTimestamp),
|
|
43283
|
-
cumulativeBorrowRateBsf: {
|
|
43284
|
-
value: reserveDto.cumulativeBorrowRateBsf.value.map(
|
|
43285
|
-
(item) => new BN11__default.default(item)
|
|
43035
|
+
liquidity: {
|
|
43036
|
+
mintPubkey: new web3_js.PublicKey(reserveDto.liquidity.mintPubkey),
|
|
43037
|
+
supplyVault: new web3_js.PublicKey(reserveDto.liquidity.supplyVault),
|
|
43038
|
+
mintDecimals: new BN8__default.default(reserveDto.liquidity.mintDecimals),
|
|
43039
|
+
availableAmount: new BN8__default.default(reserveDto.liquidity.availableAmount),
|
|
43040
|
+
borrowedAmountSf: new BN8__default.default(reserveDto.liquidity.borrowedAmountSf),
|
|
43041
|
+
accumulatedProtocolFeesSf: new BN8__default.default(
|
|
43042
|
+
reserveDto.liquidity.accumulatedProtocolFeesSf
|
|
43286
43043
|
),
|
|
43287
|
-
|
|
43288
|
-
|
|
43289
|
-
)
|
|
43290
|
-
},
|
|
43291
|
-
accumulatedProtocolFeesSf: new BN11__default.default(reserveDto.accumulatedProtocolFeesSf),
|
|
43292
|
-
accumulatedReferrerFeesSf: new BN11__default.default(reserveDto.accumulatedReferrerFeesSf),
|
|
43293
|
-
pendingReferrerFeesSf: new BN11__default.default(reserveDto.pendingReferrerFeesSf),
|
|
43294
|
-
absoluteReferralRateSf: new BN11__default.default(reserveDto.absoluteReferralRateSf),
|
|
43295
|
-
tokenProgram: new web3_js.PublicKey(reserveDto.tokenProgram),
|
|
43296
|
-
padding2: reserveDto.padding2.map((item) => new BN11__default.default(item)),
|
|
43297
|
-
padding3: reserveDto.padding3.map((item) => new BN11__default.default(item))
|
|
43298
|
-
};
|
|
43299
|
-
}
|
|
43300
|
-
function dtoToReserveConfigFields(reserveDto) {
|
|
43301
|
-
return {
|
|
43302
|
-
status: reserveDto.status,
|
|
43303
|
-
assetTier: reserveDto.assetTier,
|
|
43304
|
-
hostFixedInterestRateBps: reserveDto.hostFixedInterestRateBps,
|
|
43305
|
-
reserved2: reserveDto.reserved2,
|
|
43306
|
-
protocolOrderExecutionFeePct: reserveDto.protocolOrderExecutionFeePct,
|
|
43307
|
-
protocolTakeRatePct: reserveDto.protocolTakeRatePct,
|
|
43308
|
-
protocolLiquidationFeePct: reserveDto.protocolLiquidationFeePct,
|
|
43309
|
-
loanToValuePct: reserveDto.loanToValuePct,
|
|
43310
|
-
liquidationThresholdPct: reserveDto.liquidationThresholdPct,
|
|
43311
|
-
minLiquidationBonusBps: reserveDto.minLiquidationBonusBps,
|
|
43312
|
-
maxLiquidationBonusBps: reserveDto.maxLiquidationBonusBps,
|
|
43313
|
-
badDebtLiquidationBonusBps: reserveDto.badDebtLiquidationBonusBps,
|
|
43314
|
-
deleveragingMarginCallPeriodSecs: new BN11__default.default(
|
|
43315
|
-
reserveDto.deleveragingMarginCallPeriodSecs
|
|
43316
|
-
),
|
|
43317
|
-
deleveragingThresholdDecreaseBpsPerDay: new BN11__default.default(
|
|
43318
|
-
reserveDto.deleveragingThresholdDecreaseBpsPerDay
|
|
43319
|
-
),
|
|
43320
|
-
fees: {
|
|
43321
|
-
borrowFeeSf: new BN11__default.default(reserveDto.fees.borrowFeeSf),
|
|
43322
|
-
flashLoanFeeSf: new BN11__default.default(reserveDto.fees.flashLoanFeeSf),
|
|
43323
|
-
padding: reserveDto.fees.padding
|
|
43324
|
-
},
|
|
43325
|
-
borrowRateCurve: {
|
|
43326
|
-
points: reserveDto.borrowRateCurve.points.map((item) => ({
|
|
43327
|
-
utilizationRateBps: item.utilizationRateBps,
|
|
43328
|
-
borrowRateBps: item.borrowRateBps
|
|
43329
|
-
}))
|
|
43330
|
-
},
|
|
43331
|
-
borrowFactorPct: new BN11__default.default(reserveDto.borrowFactorPct),
|
|
43332
|
-
depositLimit: new BN11__default.default(reserveDto.depositLimit),
|
|
43333
|
-
borrowLimit: new BN11__default.default(reserveDto.borrowLimit),
|
|
43334
|
-
tokenInfo: dtoToTokenInfoFields(reserveDto.tokenInfo),
|
|
43335
|
-
depositWithdrawalCap: dtoToWithdrawalCapsFields(
|
|
43336
|
-
reserveDto.depositWithdrawalCap
|
|
43337
|
-
),
|
|
43338
|
-
debtWithdrawalCap: dtoToWithdrawalCapsFields(reserveDto.debtWithdrawalCap),
|
|
43339
|
-
elevationGroups: reserveDto.elevationGroups,
|
|
43340
|
-
disableUsageAsCollOutsideEmode: reserveDto.disableUsageAsCollOutsideEmode,
|
|
43341
|
-
utilizationLimitBlockBorrowingAbovePct: reserveDto.utilizationLimitBlockBorrowingAbovePct,
|
|
43342
|
-
autodeleverageEnabled: reserveDto.autodeleverageEnabled,
|
|
43343
|
-
reserved1: reserveDto.reserved1,
|
|
43344
|
-
borrowLimitOutsideElevationGroup: new BN11__default.default(
|
|
43345
|
-
reserveDto.borrowLimitOutsideElevationGroup
|
|
43346
|
-
),
|
|
43347
|
-
borrowLimitAgainstThisCollateralInElevationGroup: reserveDto.borrowLimitAgainstThisCollateralInElevationGroup.map(
|
|
43348
|
-
(item) => new BN11__default.default(item)
|
|
43349
|
-
),
|
|
43350
|
-
deleveragingBonusIncreaseBpsPerDay: new BN11__default.default(
|
|
43351
|
-
reserveDto.deleveragingBonusIncreaseBpsPerDay
|
|
43352
|
-
)
|
|
43353
|
-
};
|
|
43354
|
-
}
|
|
43355
|
-
function dtoToTokenInfoFields(tokenInfoDto) {
|
|
43356
|
-
return {
|
|
43357
|
-
name: tokenInfoDto.name,
|
|
43358
|
-
heuristic: {
|
|
43359
|
-
lower: new BN11__default.default(tokenInfoDto.heuristic.lower),
|
|
43360
|
-
upper: new BN11__default.default(tokenInfoDto.heuristic.upper),
|
|
43361
|
-
exp: new BN11__default.default(tokenInfoDto.heuristic.exp)
|
|
43362
|
-
},
|
|
43363
|
-
maxTwapDivergenceBps: new BN11__default.default(tokenInfoDto.maxTwapDivergenceBps),
|
|
43364
|
-
maxAgePriceSeconds: new BN11__default.default(tokenInfoDto.maxAgePriceSeconds),
|
|
43365
|
-
maxAgeTwapSeconds: new BN11__default.default(tokenInfoDto.maxAgeTwapSeconds),
|
|
43366
|
-
scopeConfiguration: {
|
|
43367
|
-
priceFeed: new web3_js.PublicKey(tokenInfoDto.scopeConfiguration.priceFeed),
|
|
43368
|
-
priceChain: tokenInfoDto.scopeConfiguration.priceChain,
|
|
43369
|
-
twapChain: tokenInfoDto.scopeConfiguration.twapChain
|
|
43370
|
-
},
|
|
43371
|
-
switchboardConfiguration: {
|
|
43372
|
-
priceAggregator: new web3_js.PublicKey(
|
|
43373
|
-
tokenInfoDto.switchboardConfiguration.priceAggregator
|
|
43044
|
+
accumulatedReferrerFeesSf: new BN8__default.default(
|
|
43045
|
+
reserveDto.liquidity.accumulatedReferrerFeesSf
|
|
43374
43046
|
),
|
|
43375
|
-
|
|
43376
|
-
tokenInfoDto.switchboardConfiguration.twapAggregator
|
|
43377
|
-
)
|
|
43047
|
+
pendingReferrerFeesSf: new BN8__default.default(reserveDto.liquidity.pendingReferrerFeesSf)
|
|
43378
43048
|
},
|
|
43379
|
-
|
|
43380
|
-
|
|
43381
|
-
|
|
43382
|
-
|
|
43383
|
-
|
|
43384
|
-
|
|
43385
|
-
|
|
43386
|
-
|
|
43387
|
-
|
|
43388
|
-
|
|
43389
|
-
|
|
43390
|
-
|
|
43391
|
-
|
|
43392
|
-
|
|
43393
|
-
|
|
43394
|
-
|
|
43395
|
-
|
|
43396
|
-
|
|
43397
|
-
|
|
43398
|
-
|
|
43399
|
-
|
|
43400
|
-
|
|
43401
|
-
|
|
43402
|
-
|
|
43403
|
-
|
|
43404
|
-
|
|
43405
|
-
|
|
43406
|
-
|
|
43407
|
-
|
|
43408
|
-
|
|
43409
|
-
|
|
43410
|
-
|
|
43411
|
-
|
|
43412
|
-
|
|
43413
|
-
|
|
43414
|
-
|
|
43415
|
-
|
|
43416
|
-
),
|
|
43417
|
-
padding: obligationLiquidityDto.cumulativeBorrowRateBsf.padding.map(
|
|
43418
|
-
(item) => new BN11__default.default(item)
|
|
43419
|
-
)
|
|
43420
|
-
},
|
|
43421
|
-
padding: new BN11__default.default(obligationLiquidityDto.padding),
|
|
43422
|
-
borrowedAmountSf: new BN11__default.default(obligationLiquidityDto.borrowedAmountSf),
|
|
43423
|
-
marketValueSf: new BN11__default.default(obligationLiquidityDto.marketValueSf),
|
|
43424
|
-
borrowFactorAdjustedMarketValueSf: new BN11__default.default(
|
|
43425
|
-
obligationLiquidityDto.borrowFactorAdjustedMarketValueSf
|
|
43426
|
-
),
|
|
43427
|
-
borrowedAmountOutsideElevationGroups: new BN11__default.default(
|
|
43428
|
-
obligationLiquidityDto.borrowedAmountOutsideElevationGroups
|
|
43429
|
-
),
|
|
43430
|
-
padding2: obligationLiquidityDto.padding2.map((item) => new BN11__default.default(item))
|
|
43431
|
-
};
|
|
43432
|
-
}
|
|
43433
|
-
function dtoToObligationOrderFields(obligationOrderDto) {
|
|
43434
|
-
return {
|
|
43435
|
-
conditionThresholdSf: new BN11__default.default(obligationOrderDto.conditionThresholdSf),
|
|
43436
|
-
opportunityParameterSf: new BN11__default.default(obligationOrderDto.opportunityParameterSf),
|
|
43437
|
-
minExecutionBonusBps: obligationOrderDto.minExecutionBonusBps,
|
|
43438
|
-
maxExecutionBonusBps: obligationOrderDto.maxExecutionBonusBps,
|
|
43439
|
-
conditionType: obligationOrderDto.conditionType,
|
|
43440
|
-
opportunityType: obligationOrderDto.opportunityType,
|
|
43441
|
-
padding1: obligationOrderDto.padding1,
|
|
43442
|
-
padding2: obligationOrderDto.padding2.map((item) => new BN11__default.default(item))
|
|
43049
|
+
collateral: {
|
|
43050
|
+
mintPubkey: new web3_js.PublicKey(reserveDto.collateral.mintPubkey),
|
|
43051
|
+
mintTotalSupply: new BN8__default.default(reserveDto.collateral.mintTotalSupply),
|
|
43052
|
+
supplyVault: new web3_js.PublicKey(reserveDto.collateral.supplyVault)
|
|
43053
|
+
},
|
|
43054
|
+
config: {
|
|
43055
|
+
protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
|
|
43056
|
+
hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
|
|
43057
|
+
depositLimit: new BN8__default.default(reserveDto.config.depositLimit),
|
|
43058
|
+
borrowLimit: new BN8__default.default(reserveDto.config.borrowLimit),
|
|
43059
|
+
borrowRateCurve: {
|
|
43060
|
+
points: reserveDto.config.borrowRateCurve.points.map((item) => ({
|
|
43061
|
+
utilizationRateBps: item.utilizationRateBps,
|
|
43062
|
+
borrowRateBps: item.borrowRateBps
|
|
43063
|
+
}))
|
|
43064
|
+
},
|
|
43065
|
+
tokenInfo: {
|
|
43066
|
+
scopeConfiguration: {
|
|
43067
|
+
priceFeed: new web3_js.PublicKey(
|
|
43068
|
+
reserveDto.config.tokenInfo.scopeConfiguration.priceFeed
|
|
43069
|
+
)
|
|
43070
|
+
},
|
|
43071
|
+
switchboardConfiguration: {
|
|
43072
|
+
priceAggregator: new web3_js.PublicKey(
|
|
43073
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.priceAggregator
|
|
43074
|
+
),
|
|
43075
|
+
twapAggregator: new web3_js.PublicKey(
|
|
43076
|
+
reserveDto.config.tokenInfo.switchboardConfiguration.twapAggregator
|
|
43077
|
+
)
|
|
43078
|
+
},
|
|
43079
|
+
pythConfiguration: {
|
|
43080
|
+
price: new web3_js.PublicKey(
|
|
43081
|
+
reserveDto.config.tokenInfo.pythConfiguration.price
|
|
43082
|
+
)
|
|
43083
|
+
}
|
|
43084
|
+
}
|
|
43085
|
+
}
|
|
43443
43086
|
};
|
|
43444
43087
|
}
|
|
43445
43088
|
var SEED_LENDING_MARKET_AUTH = "lma";
|
|
@@ -43506,9 +43149,9 @@ var Fraction = class _Fraction {
|
|
|
43506
43149
|
static MAX_SIZE_BF = 256;
|
|
43507
43150
|
static FRACTIONS = 60;
|
|
43508
43151
|
static MULTIPLIER = new FractionDecimal(2).pow(_Fraction.FRACTIONS);
|
|
43509
|
-
static MAX_F_BN = new
|
|
43510
|
-
static MAX_BF_BN = new
|
|
43511
|
-
static MIN_BN = new
|
|
43152
|
+
static MAX_F_BN = new BN8__default.default(2).pow(new BN8__default.default(_Fraction.MAX_SIZE_F)).sub(new BN8__default.default(1));
|
|
43153
|
+
static MAX_BF_BN = new BN8__default.default(2).pow(new BN8__default.default(_Fraction.MAX_SIZE_BF)).sub(new BN8__default.default(1));
|
|
43154
|
+
static MIN_BN = new BN8__default.default(0);
|
|
43512
43155
|
valueSf;
|
|
43513
43156
|
constructor(valueSf) {
|
|
43514
43157
|
if (valueSf.lt(_Fraction.MIN_BN) || valueSf.gt(_Fraction.MAX_BF_BN)) {
|
|
@@ -43524,7 +43167,7 @@ var Fraction = class _Fraction {
|
|
|
43524
43167
|
static fromDecimal(n) {
|
|
43525
43168
|
const scaledDecimal = new FractionDecimal(n).mul(_Fraction.MULTIPLIER);
|
|
43526
43169
|
const roundedScaledDecimal = roundNearest(scaledDecimal);
|
|
43527
|
-
const scaledValue = new
|
|
43170
|
+
const scaledValue = new BN8__default.default(roundedScaledDecimal.toFixed());
|
|
43528
43171
|
return new _Fraction(scaledValue);
|
|
43529
43172
|
}
|
|
43530
43173
|
static fromBps(n) {
|
|
@@ -43554,7 +43197,7 @@ var Fraction = class _Fraction {
|
|
|
43554
43197
|
return this.valueSf.eq(x.getValue());
|
|
43555
43198
|
}
|
|
43556
43199
|
};
|
|
43557
|
-
new Fraction(new
|
|
43200
|
+
new Fraction(new BN8__default.default(0));
|
|
43558
43201
|
function roundNearest(decimal) {
|
|
43559
43202
|
return decimal.toDecimalPlaces(0, Decimal3__default.default.ROUND_HALF_CEIL);
|
|
43560
43203
|
}
|
|
@@ -43637,7 +43280,7 @@ var SinglePoolInstruction = {
|
|
|
43637
43280
|
const data = Buffer.concat([
|
|
43638
43281
|
Buffer.from([3 /* WithdrawStake */]),
|
|
43639
43282
|
userStakeAuthority.toBuffer(),
|
|
43640
|
-
Buffer.from(new
|
|
43283
|
+
Buffer.from(new BN8.BN(rawAmount.toString()).toArray("le", 8))
|
|
43641
43284
|
]);
|
|
43642
43285
|
return createTransactionInstruction(
|
|
43643
43286
|
SINGLE_POOL_PROGRAM_ID,
|
|
@@ -44154,29 +43797,29 @@ function decodeJupTokenReserveData(data, pubkey) {
|
|
|
44154
43797
|
offset += 2;
|
|
44155
43798
|
const lastUtilization = data.readUInt16LE(offset);
|
|
44156
43799
|
offset += 2;
|
|
44157
|
-
const lastUpdateTimestamp = new
|
|
43800
|
+
const lastUpdateTimestamp = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44158
43801
|
offset += 8;
|
|
44159
|
-
const supplyExchangePrice = new
|
|
43802
|
+
const supplyExchangePrice = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44160
43803
|
offset += 8;
|
|
44161
|
-
const borrowExchangePrice = new
|
|
43804
|
+
const borrowExchangePrice = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44162
43805
|
offset += 8;
|
|
44163
43806
|
const maxUtilization = data.readUInt16LE(offset);
|
|
44164
43807
|
offset += 2;
|
|
44165
|
-
const totalSupplyWithInterest = new
|
|
43808
|
+
const totalSupplyWithInterest = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44166
43809
|
offset += 8;
|
|
44167
|
-
const totalSupplyInterestFree = new
|
|
43810
|
+
const totalSupplyInterestFree = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44168
43811
|
offset += 8;
|
|
44169
|
-
const totalBorrowWithInterest = new
|
|
43812
|
+
const totalBorrowWithInterest = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44170
43813
|
offset += 8;
|
|
44171
|
-
const totalBorrowInterestFree = new
|
|
43814
|
+
const totalBorrowInterestFree = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44172
43815
|
offset += 8;
|
|
44173
|
-
const totalClaimAmount = new
|
|
43816
|
+
const totalClaimAmount = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44174
43817
|
offset += 8;
|
|
44175
43818
|
const interactingProtocol = new web3_js.PublicKey(data.slice(offset, offset + 32));
|
|
44176
43819
|
offset += 32;
|
|
44177
|
-
const interactingTimestamp = new
|
|
43820
|
+
const interactingTimestamp = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44178
43821
|
offset += 8;
|
|
44179
|
-
const interactingBalance = new
|
|
43822
|
+
const interactingBalance = new BN8__default.default(data.slice(offset, offset + 8), "le");
|
|
44180
43823
|
return {
|
|
44181
43824
|
pubkey,
|
|
44182
43825
|
mint,
|
|
@@ -44238,9 +43881,9 @@ function dtoToJupLendingStateRaw(dto) {
|
|
|
44238
43881
|
lendingId: dto.lendingId,
|
|
44239
43882
|
decimals: dto.decimals,
|
|
44240
43883
|
rewardsRateModel: new web3_js.PublicKey(dto.rewardsRateModel),
|
|
44241
|
-
liquidityExchangePrice: new
|
|
44242
|
-
tokenExchangePrice: new
|
|
44243
|
-
lastUpdateTimestamp: new
|
|
43884
|
+
liquidityExchangePrice: new BN8__default.default(dto.liquidityExchangePrice),
|
|
43885
|
+
tokenExchangePrice: new BN8__default.default(dto.tokenExchangePrice),
|
|
43886
|
+
lastUpdateTimestamp: new BN8__default.default(dto.lastUpdateTimestamp),
|
|
44244
43887
|
tokenReservesLiquidity: new web3_js.PublicKey(dto.tokenReservesLiquidity),
|
|
44245
43888
|
supplyPositionOnLiquidity: new web3_js.PublicKey(dto.supplyPositionOnLiquidity)
|
|
44246
43889
|
};
|
|
@@ -44253,30 +43896,30 @@ function dtoToJupTokenReserveRaw(dto) {
|
|
|
44253
43896
|
borrowRate: dto.borrowRate,
|
|
44254
43897
|
feeOnInterest: dto.feeOnInterest,
|
|
44255
43898
|
lastUtilization: dto.lastUtilization,
|
|
44256
|
-
lastUpdateTimestamp: new
|
|
44257
|
-
supplyExchangePrice: new
|
|
44258
|
-
borrowExchangePrice: new
|
|
43899
|
+
lastUpdateTimestamp: new BN8__default.default(dto.lastUpdateTimestamp),
|
|
43900
|
+
supplyExchangePrice: new BN8__default.default(dto.supplyExchangePrice),
|
|
43901
|
+
borrowExchangePrice: new BN8__default.default(dto.borrowExchangePrice),
|
|
44259
43902
|
maxUtilization: dto.maxUtilization,
|
|
44260
|
-
totalSupplyWithInterest: new
|
|
44261
|
-
totalSupplyInterestFree: new
|
|
44262
|
-
totalBorrowWithInterest: new
|
|
44263
|
-
totalBorrowInterestFree: new
|
|
44264
|
-
totalClaimAmount: new
|
|
43903
|
+
totalSupplyWithInterest: new BN8__default.default(dto.totalSupplyWithInterest),
|
|
43904
|
+
totalSupplyInterestFree: new BN8__default.default(dto.totalSupplyInterestFree),
|
|
43905
|
+
totalBorrowWithInterest: new BN8__default.default(dto.totalBorrowWithInterest),
|
|
43906
|
+
totalBorrowInterestFree: new BN8__default.default(dto.totalBorrowInterestFree),
|
|
43907
|
+
totalClaimAmount: new BN8__default.default(dto.totalClaimAmount),
|
|
44265
43908
|
interactingProtocol: new web3_js.PublicKey(dto.interactingProtocol),
|
|
44266
|
-
interactingTimestamp: new
|
|
44267
|
-
interactingBalance: new
|
|
43909
|
+
interactingTimestamp: new BN8__default.default(dto.interactingTimestamp),
|
|
43910
|
+
interactingBalance: new BN8__default.default(dto.interactingBalance)
|
|
44268
43911
|
};
|
|
44269
43912
|
}
|
|
44270
43913
|
function dtoToJupLendingRewardsRateModelRaw(dto) {
|
|
44271
43914
|
return {
|
|
44272
43915
|
pubkey: new web3_js.PublicKey(dto.pubkey),
|
|
44273
43916
|
mint: new web3_js.PublicKey(dto.mint),
|
|
44274
|
-
startTvl: new
|
|
44275
|
-
duration: new
|
|
44276
|
-
startTime: new
|
|
44277
|
-
yearlyReward: new
|
|
44278
|
-
nextDuration: new
|
|
44279
|
-
nextRewardAmount: new
|
|
43917
|
+
startTvl: new BN8__default.default(dto.startTvl),
|
|
43918
|
+
duration: new BN8__default.default(dto.duration),
|
|
43919
|
+
startTime: new BN8__default.default(dto.startTime),
|
|
43920
|
+
yearlyReward: new BN8__default.default(dto.yearlyReward),
|
|
43921
|
+
nextDuration: new BN8__default.default(dto.nextDuration),
|
|
43922
|
+
nextRewardAmount: new BN8__default.default(dto.nextRewardAmount)
|
|
44280
43923
|
};
|
|
44281
43924
|
}
|
|
44282
43925
|
function dtoToJupRateModelRaw(dto) {
|
|
@@ -44367,14 +44010,14 @@ function deriveJupLendLiquiditySupplyPositionPda(underlyingMint, lendingPda, liq
|
|
|
44367
44010
|
liquidityProgramId
|
|
44368
44011
|
);
|
|
44369
44012
|
}
|
|
44370
|
-
var JUP_EXCHANGE_PRICES_PRECISION = new
|
|
44371
|
-
var JUP_SECONDS_PER_YEAR = new
|
|
44372
|
-
var JUP_MAX_REWARDS_RATE = new
|
|
44013
|
+
var JUP_EXCHANGE_PRICES_PRECISION = new BN8__default.default("1000000000000");
|
|
44014
|
+
var JUP_SECONDS_PER_YEAR = new BN8__default.default(31536e3);
|
|
44015
|
+
var JUP_MAX_REWARDS_RATE = new BN8__default.default("50000000000000");
|
|
44373
44016
|
function calculateJupLendTotalAssets(lendingState, fTokenTotalSupply) {
|
|
44374
44017
|
return lendingState.tokenExchangePrice.mul(fTokenTotalSupply).div(JUP_EXCHANGE_PRICES_PRECISION);
|
|
44375
44018
|
}
|
|
44376
44019
|
function calculateJupLendRewardsRateForExchangePrice(rewardsModel, totalAssets, currentTimestamp) {
|
|
44377
|
-
const defaultResult = { rate: new
|
|
44020
|
+
const defaultResult = { rate: new BN8__default.default(0), rewardsStartTime: rewardsModel.startTime };
|
|
44378
44021
|
if (rewardsModel.startTime.isZero() || rewardsModel.duration.isZero()) {
|
|
44379
44022
|
return defaultResult;
|
|
44380
44023
|
}
|
|
@@ -44394,7 +44037,7 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44394
44037
|
const oldTokenExchangePrice = lendingState.tokenExchangePrice;
|
|
44395
44038
|
const oldLiquidityExchangePrice = lendingState.liquidityExchangePrice;
|
|
44396
44039
|
const currentLiquidityExchangePrice = tokenReserve.supplyExchangePrice;
|
|
44397
|
-
let rewardsRate = new
|
|
44040
|
+
let rewardsRate = new BN8__default.default(0);
|
|
44398
44041
|
let rewardsStartTime = lendingState.lastUpdateTimestamp;
|
|
44399
44042
|
if (rewardsModel) {
|
|
44400
44043
|
const totalAssets = calculateJupLendTotalAssets(lendingState, fTokenTotalSupply);
|
|
@@ -44411,12 +44054,12 @@ function calculateJupLendNewExchangePrice(lendingState, tokenReserve, rewardsMod
|
|
|
44411
44054
|
lastUpdateTime = rewardsStartTime;
|
|
44412
44055
|
}
|
|
44413
44056
|
const secondsElapsed = currentTimestamp.sub(lastUpdateTime);
|
|
44414
|
-
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new
|
|
44057
|
+
let totalReturnPercent = rewardsRate.mul(secondsElapsed).div(JUP_SECONDS_PER_YEAR).mul(new BN8__default.default(100));
|
|
44415
44058
|
const delta = currentLiquidityExchangePrice.sub(oldLiquidityExchangePrice);
|
|
44416
44059
|
totalReturnPercent = totalReturnPercent.add(
|
|
44417
|
-
delta.mul(new
|
|
44060
|
+
delta.mul(new BN8__default.default(1e14)).div(oldLiquidityExchangePrice)
|
|
44418
44061
|
);
|
|
44419
|
-
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new
|
|
44062
|
+
return oldTokenExchangePrice.add(oldTokenExchangePrice.mul(totalReturnPercent).div(new BN8__default.default(1e14)));
|
|
44420
44063
|
}
|
|
44421
44064
|
var UPDATE_RATE_DISCRIMINATOR = Buffer.from([
|
|
44422
44065
|
24,
|
|
@@ -57897,7 +57540,7 @@ function exponentNumberToBigNumber(raw) {
|
|
|
57897
57540
|
let value = new BigNumber3.BigNumber(0);
|
|
57898
57541
|
const TWO_64 = new BigNumber3.BigNumber(2).pow(64);
|
|
57899
57542
|
words.forEach((w, i) => {
|
|
57900
|
-
const word = new BigNumber3.BigNumber(
|
|
57543
|
+
const word = new BigNumber3.BigNumber(BN8__default.default.isBN(w) ? w.toString() : String(w));
|
|
57901
57544
|
value = value.plus(word.times(TWO_64.pow(i)));
|
|
57902
57545
|
});
|
|
57903
57546
|
return value.div(EXPONENT_NUMBER_DENOM);
|
|
@@ -57908,7 +57551,7 @@ function pk(v) {
|
|
|
57908
57551
|
function decodeExponentVault(data) {
|
|
57909
57552
|
const d = EXPONENT_ACCOUNTS_CODER.decode("Vault", data);
|
|
57910
57553
|
const get = (snake, camel) => d[snake] ?? d[camel];
|
|
57911
|
-
const u646 = (v) => BigInt(
|
|
57554
|
+
const u646 = (v) => BigInt(BN8__default.default.isBN(v) ? v.toString() : String(v ?? 0));
|
|
57912
57555
|
const cpi = get("cpi_accounts", "cpiAccounts") ?? {};
|
|
57913
57556
|
return {
|
|
57914
57557
|
authority: pk(get("authority", "authority")),
|
|
@@ -58255,76 +57898,26 @@ function scaledSupplies(state) {
|
|
|
58255
57898
|
}
|
|
58256
57899
|
|
|
58257
57900
|
// src/vendor/klend/utils/farms/serialize.utils.ts
|
|
58258
|
-
function
|
|
57901
|
+
function kaminoFarmStateToDto(farmState) {
|
|
58259
57902
|
return {
|
|
58260
|
-
farmAdmin: farmRaw.farmAdmin.toBase58(),
|
|
58261
|
-
globalConfig: farmRaw.globalConfig.toBase58(),
|
|
58262
57903
|
token: {
|
|
58263
|
-
mint:
|
|
58264
|
-
decimals:
|
|
58265
|
-
tokenProgram: farmRaw.token.tokenProgram.toBase58(),
|
|
58266
|
-
padding: farmRaw.token.padding.map((p) => p.toString())
|
|
57904
|
+
mint: farmState.token.mint.toBase58(),
|
|
57905
|
+
decimals: farmState.token.decimals.toString()
|
|
58267
57906
|
},
|
|
58268
|
-
rewardInfos:
|
|
57907
|
+
rewardInfos: farmState.rewardInfos.map((item) => ({
|
|
58269
57908
|
token: {
|
|
58270
57909
|
mint: item.token.mint.toBase58(),
|
|
58271
|
-
decimals: item.token.decimals.toString()
|
|
58272
|
-
tokenProgram: item.token.tokenProgram.toBase58(),
|
|
58273
|
-
padding: item.token.padding.map((p) => p.toString())
|
|
57910
|
+
decimals: item.token.decimals.toString()
|
|
58274
57911
|
},
|
|
58275
|
-
rewardsVault: item.rewardsVault.toBase58(),
|
|
58276
57912
|
rewardsAvailable: item.rewardsAvailable.toString(),
|
|
57913
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58277
57914
|
rewardScheduleCurve: {
|
|
58278
57915
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58279
57916
|
tsStart: p.tsStart.toString(),
|
|
58280
57917
|
rewardPerTimeUnit: p.rewardPerTimeUnit.toString()
|
|
58281
57918
|
}))
|
|
58282
|
-
}
|
|
58283
|
-
|
|
58284
|
-
lastIssuanceTs: item.lastIssuanceTs.toString(),
|
|
58285
|
-
rewardsIssuedUnclaimed: item.rewardsIssuedUnclaimed.toString(),
|
|
58286
|
-
rewardsIssuedCumulative: item.rewardsIssuedCumulative.toString(),
|
|
58287
|
-
rewardPerShareScaled: item.rewardPerShareScaled.toString(),
|
|
58288
|
-
placeholder0: item.placeholder0.toString(),
|
|
58289
|
-
rewardType: item.rewardType,
|
|
58290
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58291
|
-
padding0: item.padding0,
|
|
58292
|
-
padding1: item.padding1.map((p) => p.toString())
|
|
58293
|
-
})),
|
|
58294
|
-
numRewardTokens: farmRaw.numRewardTokens.toString(),
|
|
58295
|
-
numUsers: farmRaw.numUsers.toString(),
|
|
58296
|
-
totalStakedAmount: farmRaw.totalStakedAmount.toString(),
|
|
58297
|
-
farmVault: farmRaw.farmVault.toBase58(),
|
|
58298
|
-
farmVaultsAuthority: farmRaw.farmVaultsAuthority.toBase58(),
|
|
58299
|
-
farmVaultsAuthorityBump: farmRaw.farmVaultsAuthorityBump.toString(),
|
|
58300
|
-
delegateAuthority: farmRaw.delegateAuthority.toBase58(),
|
|
58301
|
-
timeUnit: farmRaw.timeUnit,
|
|
58302
|
-
isFarmFrozen: farmRaw.isFarmFrozen,
|
|
58303
|
-
isFarmDelegated: farmRaw.isFarmDelegated,
|
|
58304
|
-
padding0: farmRaw.padding0,
|
|
58305
|
-
withdrawAuthority: farmRaw.withdrawAuthority.toBase58(),
|
|
58306
|
-
depositWarmupPeriod: farmRaw.depositWarmupPeriod,
|
|
58307
|
-
withdrawalCooldownPeriod: farmRaw.withdrawalCooldownPeriod,
|
|
58308
|
-
totalActiveStakeScaled: farmRaw.totalActiveStakeScaled.toString(),
|
|
58309
|
-
totalPendingStakeScaled: farmRaw.totalPendingStakeScaled.toString(),
|
|
58310
|
-
totalPendingAmount: farmRaw.totalPendingAmount.toString(),
|
|
58311
|
-
slashedAmountCurrent: farmRaw.slashedAmountCurrent.toString(),
|
|
58312
|
-
slashedAmountCumulative: farmRaw.slashedAmountCumulative.toString(),
|
|
58313
|
-
slashedAmountSpillAddress: farmRaw.slashedAmountSpillAddress.toBase58(),
|
|
58314
|
-
lockingMode: farmRaw.lockingMode.toString(),
|
|
58315
|
-
lockingStartTimestamp: farmRaw.lockingStartTimestamp.toString(),
|
|
58316
|
-
lockingDuration: farmRaw.lockingDuration.toString(),
|
|
58317
|
-
lockingEarlyWithdrawalPenaltyBps: farmRaw.lockingEarlyWithdrawalPenaltyBps.toString(),
|
|
58318
|
-
depositCapAmount: farmRaw.depositCapAmount.toString(),
|
|
58319
|
-
scopePrices: farmRaw.scopePrices.toBase58(),
|
|
58320
|
-
scopeOraclePriceId: farmRaw.scopeOraclePriceId.toString(),
|
|
58321
|
-
scopeOracleMaxAge: farmRaw.scopeOracleMaxAge.toString(),
|
|
58322
|
-
pendingFarmAdmin: farmRaw.pendingFarmAdmin.toBase58(),
|
|
58323
|
-
strategyId: farmRaw.strategyId.toBase58(),
|
|
58324
|
-
delegatedRpsAdmin: farmRaw.delegatedRpsAdmin.toBase58(),
|
|
58325
|
-
vaultId: farmRaw.vaultId.toBase58(),
|
|
58326
|
-
secondDelegatedAuthority: farmRaw.secondDelegatedAuthority.toBase58(),
|
|
58327
|
-
padding: farmRaw.padding.map((item) => item.toString())
|
|
57919
|
+
}
|
|
57920
|
+
}))
|
|
58328
57921
|
};
|
|
58329
57922
|
}
|
|
58330
57923
|
var farmDiscriminator = Buffer.from([198, 102, 216, 74, 63, 66, 163, 190]);
|
|
@@ -58419,78 +58012,26 @@ function decodeFarmDataRaw(data) {
|
|
|
58419
58012
|
const dec = farmLayout.decode(data.slice(8));
|
|
58420
58013
|
return dec;
|
|
58421
58014
|
}
|
|
58422
|
-
function
|
|
58015
|
+
function dtoToKaminoFarmState(dto) {
|
|
58423
58016
|
return {
|
|
58424
|
-
farmAdmin: new web3_js.PublicKey(dto.farmAdmin),
|
|
58425
|
-
globalConfig: new web3_js.PublicKey(dto.globalConfig),
|
|
58426
58017
|
token: {
|
|
58427
58018
|
mint: new web3_js.PublicKey(dto.token.mint),
|
|
58428
|
-
decimals: new
|
|
58429
|
-
tokenProgram: new web3_js.PublicKey(dto.token.tokenProgram),
|
|
58430
|
-
padding: dto.token.padding.map((item) => new BN11__default.default(item))
|
|
58019
|
+
decimals: new BN8__default.default(dto.token.decimals)
|
|
58431
58020
|
},
|
|
58432
58021
|
rewardInfos: dto.rewardInfos.map((item) => ({
|
|
58433
58022
|
token: {
|
|
58434
58023
|
mint: new web3_js.PublicKey(item.token.mint),
|
|
58435
|
-
decimals: new
|
|
58436
|
-
tokenProgram: new web3_js.PublicKey(item.token.tokenProgram),
|
|
58437
|
-
padding: item.token.padding.map((p) => new BN11__default.default(p))
|
|
58024
|
+
decimals: new BN8__default.default(item.token.decimals)
|
|
58438
58025
|
},
|
|
58439
|
-
|
|
58440
|
-
|
|
58026
|
+
rewardsAvailable: new BN8__default.default(item.rewardsAvailable),
|
|
58027
|
+
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58441
58028
|
rewardScheduleCurve: {
|
|
58442
58029
|
points: item.rewardScheduleCurve.points.map((p) => ({
|
|
58443
|
-
tsStart: new
|
|
58444
|
-
rewardPerTimeUnit: new
|
|
58030
|
+
tsStart: new BN8__default.default(p.tsStart),
|
|
58031
|
+
rewardPerTimeUnit: new BN8__default.default(p.rewardPerTimeUnit)
|
|
58445
58032
|
}))
|
|
58446
|
-
}
|
|
58447
|
-
|
|
58448
|
-
lastIssuanceTs: new BN11__default.default(item.lastIssuanceTs),
|
|
58449
|
-
rewardsIssuedUnclaimed: new BN11__default.default(item.rewardsIssuedUnclaimed),
|
|
58450
|
-
rewardsIssuedCumulative: new BN11__default.default(item.rewardsIssuedCumulative),
|
|
58451
|
-
rewardPerShareScaled: new BN11__default.default(item.rewardPerShareScaled),
|
|
58452
|
-
placeholder0: new BN11__default.default(item.placeholder0),
|
|
58453
|
-
rewardType: item.rewardType,
|
|
58454
|
-
rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
|
|
58455
|
-
padding0: item.padding0,
|
|
58456
|
-
padding1: item.padding1.map((p) => new BN11__default.default(p))
|
|
58457
|
-
})),
|
|
58458
|
-
numRewardTokens: new BN11__default.default(dto.numRewardTokens),
|
|
58459
|
-
numUsers: new BN11__default.default(dto.numUsers),
|
|
58460
|
-
totalStakedAmount: new BN11__default.default(dto.totalStakedAmount),
|
|
58461
|
-
farmVault: new web3_js.PublicKey(dto.farmVault),
|
|
58462
|
-
farmVaultsAuthority: new web3_js.PublicKey(dto.farmVaultsAuthority),
|
|
58463
|
-
farmVaultsAuthorityBump: new BN11__default.default(dto.farmVaultsAuthorityBump),
|
|
58464
|
-
delegateAuthority: new web3_js.PublicKey(dto.delegateAuthority),
|
|
58465
|
-
timeUnit: dto.timeUnit,
|
|
58466
|
-
isFarmFrozen: dto.isFarmFrozen,
|
|
58467
|
-
isFarmDelegated: dto.isFarmDelegated,
|
|
58468
|
-
padding0: dto.padding0,
|
|
58469
|
-
withdrawAuthority: new web3_js.PublicKey(dto.withdrawAuthority),
|
|
58470
|
-
depositWarmupPeriod: dto.depositWarmupPeriod,
|
|
58471
|
-
withdrawalCooldownPeriod: dto.withdrawalCooldownPeriod,
|
|
58472
|
-
totalActiveStakeScaled: new BN11__default.default(dto.totalActiveStakeScaled),
|
|
58473
|
-
totalPendingStakeScaled: new BN11__default.default(dto.totalPendingStakeScaled),
|
|
58474
|
-
totalPendingAmount: new BN11__default.default(dto.totalPendingAmount),
|
|
58475
|
-
slashedAmountCurrent: new BN11__default.default(dto.slashedAmountCurrent),
|
|
58476
|
-
slashedAmountCumulative: new BN11__default.default(dto.slashedAmountCumulative),
|
|
58477
|
-
slashedAmountSpillAddress: new web3_js.PublicKey(dto.slashedAmountSpillAddress),
|
|
58478
|
-
lockingMode: new BN11__default.default(dto.lockingMode),
|
|
58479
|
-
lockingStartTimestamp: new BN11__default.default(dto.lockingStartTimestamp),
|
|
58480
|
-
lockingDuration: new BN11__default.default(dto.lockingDuration),
|
|
58481
|
-
lockingEarlyWithdrawalPenaltyBps: new BN11__default.default(
|
|
58482
|
-
dto.lockingEarlyWithdrawalPenaltyBps
|
|
58483
|
-
),
|
|
58484
|
-
depositCapAmount: new BN11__default.default(dto.depositCapAmount),
|
|
58485
|
-
scopePrices: new web3_js.PublicKey(dto.scopePrices),
|
|
58486
|
-
scopeOraclePriceId: new BN11__default.default(dto.scopeOraclePriceId),
|
|
58487
|
-
scopeOracleMaxAge: new BN11__default.default(dto.scopeOracleMaxAge),
|
|
58488
|
-
pendingFarmAdmin: new web3_js.PublicKey(dto.pendingFarmAdmin),
|
|
58489
|
-
strategyId: new web3_js.PublicKey(dto.strategyId),
|
|
58490
|
-
delegatedRpsAdmin: new web3_js.PublicKey(dto.delegatedRpsAdmin),
|
|
58491
|
-
vaultId: new web3_js.PublicKey(dto.vaultId),
|
|
58492
|
-
secondDelegatedAuthority: new web3_js.PublicKey(dto.secondDelegatedAuthority),
|
|
58493
|
-
padding: dto.padding.map((item) => new BN11__default.default(item))
|
|
58033
|
+
}
|
|
58034
|
+
}))
|
|
58494
58035
|
};
|
|
58495
58036
|
}
|
|
58496
58037
|
var KAMINO_PROGRAM_ID = new web3_js.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
@@ -59165,7 +58706,7 @@ function makePoolAddPermissionlessStakedBankIx2(programId, accounts, remainingAc
|
|
|
59165
58706
|
keys.push(...remainingAccounts);
|
|
59166
58707
|
const data = Buffer.concat([
|
|
59167
58708
|
DISCRIMINATORS.LENDING_POOL_ADD_BANK_PERMISSIONLESS,
|
|
59168
|
-
encodeU64(args.seed || new
|
|
58709
|
+
encodeU64(args.seed || new BN8__default.default(0))
|
|
59169
58710
|
]);
|
|
59170
58711
|
return new web3_js.TransactionInstruction({
|
|
59171
58712
|
keys,
|
|
@@ -60669,7 +60210,7 @@ function deserializeSwapEngineResult(s) {
|
|
|
60669
60210
|
setupInstructions: s.setupInstructions.map(deserializeInstruction),
|
|
60670
60211
|
swapLuts: s.swapLuts.map(deserializeLut),
|
|
60671
60212
|
quoteResponse: s.quoteResponse,
|
|
60672
|
-
outputAmountNative: new
|
|
60213
|
+
outputAmountNative: new BN8__default.default(s.outputAmountNative),
|
|
60673
60214
|
provider: s.provider
|
|
60674
60215
|
};
|
|
60675
60216
|
}
|
|
@@ -61468,8 +61009,8 @@ async function buildCandidates(req, apiConfig) {
|
|
|
61468
61009
|
swapInstructions: [deserializeJupiterInstruction2(build.swapInstruction)],
|
|
61469
61010
|
setupInstructions: (build.setupInstructions ?? []).map(deserializeJupiterInstruction2),
|
|
61470
61011
|
luts,
|
|
61471
|
-
outAmountNative: new
|
|
61472
|
-
otherAmountThresholdNative: new
|
|
61012
|
+
outAmountNative: new BN8__default.default(build.outAmount),
|
|
61013
|
+
otherAmountThresholdNative: new BN8__default.default(build.otherAmountThreshold),
|
|
61473
61014
|
quoteResult: mapBuildToQuoteResult(build),
|
|
61474
61015
|
label: `jupiter:maxAccounts=${maxAccounts}`
|
|
61475
61016
|
};
|
|
@@ -61566,8 +61107,8 @@ async function buildCandidates2(req, apiConfig) {
|
|
|
61566
61107
|
swapInstructions,
|
|
61567
61108
|
setupInstructions: [],
|
|
61568
61109
|
luts,
|
|
61569
|
-
outAmountNative: new
|
|
61570
|
-
otherAmountThresholdNative: new
|
|
61110
|
+
outAmountNative: new BN8__default.default(quote.outAmount),
|
|
61111
|
+
otherAmountThresholdNative: new BN8__default.default(quote.otherAmountThreshold),
|
|
61571
61112
|
quoteResult: { ...quote, provider: "TITAN" /* TITAN */ },
|
|
61572
61113
|
label: "titan:v3"
|
|
61573
61114
|
}
|
|
@@ -61623,14 +61164,14 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
|
|
|
61623
61164
|
marginfiAccount: marginfiAccountPk,
|
|
61624
61165
|
authority
|
|
61625
61166
|
},
|
|
61626
|
-
{ endIndex: new
|
|
61167
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
61627
61168
|
) : await instructions_default.makeBeginFlashLoanIx(
|
|
61628
61169
|
program,
|
|
61629
61170
|
{
|
|
61630
61171
|
marginfiAccount: marginfiAccountPk,
|
|
61631
61172
|
authority
|
|
61632
61173
|
},
|
|
61633
|
-
{ endIndex: new
|
|
61174
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
61634
61175
|
);
|
|
61635
61176
|
return { instructions: [ix], keys: [] };
|
|
61636
61177
|
}
|
|
@@ -62309,7 +61850,7 @@ function computeFlashLoanNonSwapBudget({
|
|
|
62309
61850
|
const beginFlIx = sync_instructions_default.makeBeginFlashLoanIx(
|
|
62310
61851
|
program.programId,
|
|
62311
61852
|
{ marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
|
|
62312
|
-
{ endIndex: new
|
|
61853
|
+
{ endIndex: new BN8__default.default(endIndex) }
|
|
62313
61854
|
);
|
|
62314
61855
|
const endFlRemainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
|
|
62315
61856
|
const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
|
|
@@ -62888,7 +62429,7 @@ async function buildLoopFlashloanTx(params) {
|
|
|
62888
62429
|
const engineResult = await runLoopSwapEngine(descriptor, params);
|
|
62889
62430
|
const finalIxs = [...descriptor.innerIxs];
|
|
62890
62431
|
finalIxs.splice(descriptor.swapSlotIndex, 0, ...engineResult.swapInstructions);
|
|
62891
|
-
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new
|
|
62432
|
+
const principalNative = depositOpts.loopMode === "DEPOSIT" ? uiToNative(depositOpts.inputDepositAmount, depositOpts.depositBank.mintDecimals) : new BN8__default.default(0);
|
|
62892
62433
|
const finalDepositNative = engineResult.outputAmountNative.add(principalNative);
|
|
62893
62434
|
const depositIxPosition = descriptor.depositIxIndex + engineResult.swapInstructions.length;
|
|
62894
62435
|
patchDepositAmount(finalIxs[depositIxPosition], finalDepositNative);
|
|
@@ -63100,7 +62641,7 @@ async function runLoopSwapEngine(descriptor, params) {
|
|
|
63100
62641
|
otherAmountThreshold: "0",
|
|
63101
62642
|
slippageBps: 0
|
|
63102
62643
|
},
|
|
63103
|
-
outputAmountNative: new
|
|
62644
|
+
outputAmountNative: new BN8__default.default(0)
|
|
63104
62645
|
};
|
|
63105
62646
|
}
|
|
63106
62647
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
@@ -64121,7 +63662,7 @@ async function buildRollPtFlashloanTx({
|
|
|
64121
63662
|
if (!depositIxToPatch) {
|
|
64122
63663
|
throw new Error("roll-pt: could not locate deposit instruction for amount patching");
|
|
64123
63664
|
}
|
|
64124
|
-
patchDepositAmount(depositIxToPatch, new
|
|
63665
|
+
patchDepositAmount(depositIxToPatch, new BN8__default.default(minPtOut.toString()));
|
|
64125
63666
|
const allNonFlIxs = [
|
|
64126
63667
|
...cuRequestIxs,
|
|
64127
63668
|
...withdrawIxs.instructions,
|
|
@@ -66671,9 +66212,9 @@ function dtoToBankMetadataMap(bankMetadataDto) {
|
|
|
66671
66212
|
function dtoToBankMetadata(bankMetadataDto) {
|
|
66672
66213
|
return {
|
|
66673
66214
|
kaminoStates: bankMetadataDto.kaminoStates ? {
|
|
66674
|
-
reserveState:
|
|
66675
|
-
obligationState:
|
|
66676
|
-
farmState: bankMetadataDto.kaminoStates.farmState ?
|
|
66215
|
+
reserveState: dtoToKaminoReserve(bankMetadataDto.kaminoStates.reserveState),
|
|
66216
|
+
obligationState: dtoToKaminoObligation(bankMetadataDto.kaminoStates.obligationState),
|
|
66217
|
+
farmState: bankMetadataDto.kaminoStates.farmState ? dtoToKaminoFarmState(bankMetadataDto.kaminoStates.farmState) : void 0
|
|
66677
66218
|
} : void 0,
|
|
66678
66219
|
driftStates: bankMetadataDto.driftStates ? {
|
|
66679
66220
|
spotMarketState: dtoToDriftSpotMarketRaw(bankMetadataDto.driftStates.spotMarketState),
|
|
@@ -66688,16 +66229,16 @@ function dtoToBankMetadata(bankMetadataDto) {
|
|
|
66688
66229
|
),
|
|
66689
66230
|
jupRewardsRateModel: bankMetadataDto.jupLendStates.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(bankMetadataDto.jupLendStates.jupRewardsRateModel) : null,
|
|
66690
66231
|
jupRateModel: bankMetadataDto.jupLendStates.jupRateModel ? dtoToJupRateModelRaw(bankMetadataDto.jupLendStates.jupRateModel) : null,
|
|
66691
|
-
fTokenTotalSupply: new
|
|
66232
|
+
fTokenTotalSupply: new BN8__default.default(bankMetadataDto.jupLendStates.fTokenTotalSupply)
|
|
66692
66233
|
} : void 0
|
|
66693
66234
|
};
|
|
66694
66235
|
}
|
|
66695
66236
|
function bankMetadataToDto(bankMetadata) {
|
|
66696
66237
|
return {
|
|
66697
66238
|
kaminoStates: bankMetadata.kaminoStates ? {
|
|
66698
|
-
reserveState:
|
|
66699
|
-
obligationState:
|
|
66700
|
-
farmState: bankMetadata.kaminoStates.farmState ?
|
|
66239
|
+
reserveState: kaminoReserveToDto(bankMetadata.kaminoStates.reserveState),
|
|
66240
|
+
obligationState: kaminoObligationToDto(bankMetadata.kaminoStates.obligationState),
|
|
66241
|
+
farmState: bankMetadata.kaminoStates.farmState ? kaminoFarmStateToDto(bankMetadata.kaminoStates.farmState) : void 0
|
|
66701
66242
|
} : void 0,
|
|
66702
66243
|
driftStates: bankMetadata.driftStates ? {
|
|
66703
66244
|
spotMarketState: driftSpotMarketRawToDto(bankMetadata.driftStates.spotMarketState),
|
|
@@ -67006,8 +66547,8 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
67006
66547
|
const brokenSwbFeeds = [];
|
|
67007
66548
|
Object.keys(swbOracleAiDataByKey).forEach((oracleKey) => {
|
|
67008
66549
|
const oracleAiData = swbOracleAiDataByKey[oracleKey];
|
|
67009
|
-
const rawPriceBN = new
|
|
67010
|
-
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new
|
|
66550
|
+
const rawPriceBN = new BN8__default.default(oracleAiData.rawPrice);
|
|
66551
|
+
const isFeedBroken = rawPriceBN.isZero() || rawPriceBN.eq(new BN8__default.default(1e-6)) || rawPriceBN.eq(new BN8__default.default(1e-8));
|
|
67011
66552
|
if (isFeedBroken) {
|
|
67012
66553
|
const bank = switchboardBanks.find(
|
|
67013
66554
|
(bank2) => bank2.config.oracleKeys[0].toBase58() === oracleKey
|
|
@@ -67906,7 +67447,7 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
67906
67447
|
isWritable: false
|
|
67907
67448
|
})),
|
|
67908
67449
|
{
|
|
67909
|
-
seed: new
|
|
67450
|
+
seed: new BN8__default.default(0)
|
|
67910
67451
|
}
|
|
67911
67452
|
);
|
|
67912
67453
|
return {
|
|
@@ -68838,9 +68379,9 @@ async function getKaminoMetadata(options) {
|
|
|
68838
68379
|
for (const [bankAddress, state] of Object.entries(kaminoStates)) {
|
|
68839
68380
|
kaminoMetadataMap.set(bankAddress, {
|
|
68840
68381
|
kaminoStates: {
|
|
68841
|
-
reserveState:
|
|
68842
|
-
obligationState:
|
|
68843
|
-
farmState: state.farmState ?
|
|
68382
|
+
reserveState: dtoToKaminoReserve(state.reserveState),
|
|
68383
|
+
obligationState: dtoToKaminoObligation(state.obligationState),
|
|
68384
|
+
farmState: state.farmState ? dtoToKaminoFarmState(state.farmState) : void 0
|
|
68844
68385
|
}
|
|
68845
68386
|
});
|
|
68846
68387
|
}
|
|
@@ -68872,8 +68413,8 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68872
68413
|
bankByFarmKey[reserveState.farmCollateral.toBase58()] = bank.bankAddress;
|
|
68873
68414
|
}
|
|
68874
68415
|
kaminoStatesMap[bank.bankAddress] = {
|
|
68875
|
-
reserveState:
|
|
68876
|
-
obligationState:
|
|
68416
|
+
reserveState: kaminoReserveToDto(reserveState),
|
|
68417
|
+
obligationState: kaminoObligationToDto(obligationState)
|
|
68877
68418
|
};
|
|
68878
68419
|
}
|
|
68879
68420
|
const allFarmKeys = Object.keys(bankByFarmKey);
|
|
@@ -68896,7 +68437,7 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
68896
68437
|
const decodedFarmState = decodeFarmDataRaw(farmState.data);
|
|
68897
68438
|
kaminoStatesMap[bankKey] = {
|
|
68898
68439
|
...kaminoState,
|
|
68899
|
-
farmState:
|
|
68440
|
+
farmState: kaminoFarmStateToDto(decodedFarmState)
|
|
68900
68441
|
};
|
|
68901
68442
|
}
|
|
68902
68443
|
}
|
|
@@ -69027,7 +68568,7 @@ async function getJupLendMetadata(options) {
|
|
|
69027
68568
|
jupTokenReserveState: dtoToJupTokenReserveRaw(state.jupTokenReserveState),
|
|
69028
68569
|
jupRewardsRateModel: state.jupRewardsRateModel ? dtoToJupLendingRewardsRateModelRaw(state.jupRewardsRateModel) : null,
|
|
69029
68570
|
jupRateModel: state.jupRateModel ? dtoToJupRateModelRaw(state.jupRateModel) : null,
|
|
69030
|
-
fTokenTotalSupply: new
|
|
68571
|
+
fTokenTotalSupply: new BN8__default.default(state.fTokenTotalSupply)
|
|
69031
68572
|
}
|
|
69032
68573
|
});
|
|
69033
68574
|
}
|
|
@@ -69142,7 +68683,7 @@ async function getJupLendStatesDto(connection, jupLendBanks) {
|
|
|
69142
68683
|
return jupLendStatesMap;
|
|
69143
68684
|
}
|
|
69144
68685
|
function getJupLendFTokenMultiplier(lendingState, tokenReserve, rewardsModel, fTokenTotalSupply, nowSeconds) {
|
|
69145
|
-
const currentTimestamp = new
|
|
68686
|
+
const currentTimestamp = new BN8__default.default(nowSeconds);
|
|
69146
68687
|
const newExchangePrice = calculateJupLendNewExchangePrice(
|
|
69147
68688
|
lendingState,
|
|
69148
68689
|
tokenReserve,
|