@0dotxyz/p0-ts-sdk 2.10.1-alpha.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +104 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -15
- package/dist/index.d.ts +28 -15
- package/dist/index.js +104 -103
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-DQD0k0pr.d.cts → types-BO-ZFk04.d.cts} +8 -1
- package/dist/{types--m9sTr2x.d.ts → types-DgVpJ2nB.d.ts} +8 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as superstruct from 'superstruct';
|
|
2
2
|
import { Infer } from 'superstruct';
|
|
3
|
-
import { c as BankType, R as RiskTier, A as AssetTag, d as BankConfigFlag, e as OperationalState, f as OracleSetup, E as EmodeTag, g as EmodeEntryFlags, h as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, i as OperationalStateRaw, j as OracleSetupRaw, k as RiskTierRaw, M as MarginfiProgram, l as InterestRateConfig, m as BankConfigType, n as BankConfigRaw, o as BankConfigOpt, p as BankConfigOptRaw, q as EmodeSettingsType, r as BankRateLimiterType, s as BankRaw, t as BankRateLimiterRaw, u as EmodeSettingsRaw, v as MarginfiIdlType, H as HealthCacheFlags, w as HealthCacheStatus, x as AccountFlags, y as MarginfiAccountType, z as OraclePrice, P as PriceWithConfidence, C as PriceBias, D as OraclePriceDto, F as BankIntegrationMetadataMap, G as OrderType, J as BalanceType, K as HealthCacheType, L as EmodePair, N as ActiveEmodePair, Q as ActionEmodeImpact, S as MarginRequirementType, a as BankConfigFastRaw, b as BankConfigGovRaw, T as Amount, U as EmodeImpactStatus, O as OrderTrigger, V as TypedAmount, X as BankVaultType, Y as RateLimitWindowType, Z as BankIntegrationMetadataMapDto, _ as BankIntegrationMetadataDto, $ as BankIntegrationMetadata, a0 as Bank, a1 as Environment, a2 as Project0Config, a3 as MintData } from './types-
|
|
4
|
-
export { aC as AccountType, aH as AmountType, aB as BankAddress, a4 as BankConfig, B as BankConfigCompactRaw, aE as BankMap, aA as BankMetadata, a7 as BankMetadataRaw, as as ComputeAssetUsdValueParams, aq as ComputeLiabilityUsdValueParams, ao as ComputeUsdValueParams, ac as EmodeConfigRaw, af as EmodeEntry, ah as EmodeImpact, a5 as EmodeSettings, aj as GetAssetWeightParams, a9 as InterestRateConfigCompactRaw, ae as InterestRateConfigOpt, aa as InterestRateConfigOptRaw, aD as KaminoStates, ax as MARGINFI_IDL, aG as MintDataMap, ag as OracleConfigOpt, ab as OracleConfigOptRaw, aF as OraclePriceMap, av as OrderTriggerKind, aw as PriceWithConfidenceDto, ay as Program, a6 as RateLimitWindowRaw, ad as RatePoint, a8 as RatePointRaw, az as Wallet, at as computeAssetUsdValue, ar as computeLiabilityUsdValue, an as computeLoopingParams, am as computeMaxLeverage, au as computeTvl, ap as computeUsdValue, ak as getAssetWeight, al as getLiabilityWeight, ai as isWeightedPrice, aI as resolveAmount } from './types-
|
|
3
|
+
import { c as BankType, R as RiskTier, A as AssetTag, d as BankConfigFlag, e as OperationalState, f as OracleSetup, E as EmodeTag, g as EmodeEntryFlags, h as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, i as OperationalStateRaw, j as OracleSetupRaw, k as RiskTierRaw, M as MarginfiProgram, l as InterestRateConfig, m as BankConfigType, n as BankConfigRaw, o as BankConfigOpt, p as BankConfigOptRaw, q as EmodeSettingsType, r as BankRateLimiterType, s as BankRaw, t as BankRateLimiterRaw, u as EmodeSettingsRaw, v as MarginfiIdlType, H as HealthCacheFlags, w as HealthCacheStatus, x as AccountFlags, y as MarginfiAccountType, z as OraclePrice, P as PriceWithConfidence, C as PriceBias, D as OraclePriceDto, F as BankIntegrationMetadataMap, G as OrderType, J as BalanceType, K as HealthCacheType, L as EmodePair, N as ActiveEmodePair, Q as ActionEmodeImpact, S as MarginRequirementType, a as BankConfigFastRaw, b as BankConfigGovRaw, T as Amount, U as EmodeImpactStatus, O as OrderTrigger, V as TypedAmount, X as BankVaultType, Y as RateLimitWindowType, Z as BankIntegrationMetadataMapDto, _ as BankIntegrationMetadataDto, $ as BankIntegrationMetadata, a0 as Bank, a1 as Environment, a2 as Project0Config, a3 as MintData } from './types-BO-ZFk04.cjs';
|
|
4
|
+
export { aC as AccountType, aH as AmountType, aB as BankAddress, a4 as BankConfig, B as BankConfigCompactRaw, aE as BankMap, aA as BankMetadata, a7 as BankMetadataRaw, as as ComputeAssetUsdValueParams, aq as ComputeLiabilityUsdValueParams, ao as ComputeUsdValueParams, ac as EmodeConfigRaw, af as EmodeEntry, ah as EmodeImpact, a5 as EmodeSettings, aj as GetAssetWeightParams, a9 as InterestRateConfigCompactRaw, ae as InterestRateConfigOpt, aa as InterestRateConfigOptRaw, aD as KaminoStates, ax as MARGINFI_IDL, aG as MintDataMap, ag as OracleConfigOpt, ab as OracleConfigOptRaw, aF as OraclePriceMap, av as OrderTriggerKind, aw as PriceWithConfidenceDto, ay as Program, a6 as RateLimitWindowRaw, ad as RatePoint, a8 as RatePointRaw, az as Wallet, at as computeAssetUsdValue, ar as computeLiabilityUsdValue, an as computeLoopingParams, am as computeMaxLeverage, au as computeTvl, ap as computeUsdValue, ak as getAssetWeight, al as getLiabilityWeight, ai as isWeightedPrice, aI as resolveAmount } from './types-BO-ZFk04.cjs';
|
|
5
5
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
6
6
|
import { VersionedTransaction, Transaction, PublicKey, TransactionError, TransactionInstruction, Keypair, Signer, AddressLookupTableAccount, Blockhash, TransactionMessage, Connection, AccountInfo } from '@solana/web3.js';
|
|
7
7
|
import { Idl, Instruction, Address } from '@coral-xyz/anchor';
|
|
@@ -2776,7 +2776,7 @@ declare const getTitanExactOutEstimate: (params: GetTitanExactOutEstimateParams)
|
|
|
2776
2776
|
interface ResolvedPinnedSwapRoute {
|
|
2777
2777
|
swapInstructions: TransactionInstruction[];
|
|
2778
2778
|
setupInstructions: TransactionInstruction[];
|
|
2779
|
-
|
|
2779
|
+
swapLuts: AddressLookupTableAccount[];
|
|
2780
2780
|
quoteResponse: SwapQuoteResult;
|
|
2781
2781
|
/** The route's guaranteed min-out (native) — what sizes the follow-up amount (deposit patch). */
|
|
2782
2782
|
outputAmountNative: BN;
|
|
@@ -2787,13 +2787,15 @@ interface ResolvedPinnedSwapRoute {
|
|
|
2787
2787
|
*
|
|
2788
2788
|
* - `otherAmountThreshold` (min-out) must be a positive integer — it becomes the loop's deposit
|
|
2789
2789
|
* byte-patch, exactly like an engine-selected route's min-out.
|
|
2790
|
-
* - `inAmount` must equal the flow's swap input (e.g. the loop's borrow,
|
|
2791
|
-
* mismatch means the route was quoted for a different size than the flow will
|
|
2790
|
+
* - `inAmount` must equal `expectedInAmountNative`, the flow's swap input (e.g. the loop's borrow,
|
|
2791
|
+
* native units) — a mismatch means the route was quoted for a different size than the flow will
|
|
2792
|
+
* actually swap. Omit it when the route's input sets the swap's size, as in a debt swap, which
|
|
2793
|
+
* borrows what the route takes in.
|
|
2792
2794
|
*
|
|
2793
2795
|
* Throws plain `Error`s (not `TransactionBuildingError`) so caller-input mistakes are never
|
|
2794
2796
|
* classified as decomposable swap failures (which would wrongly engage the bridged fallback).
|
|
2795
2797
|
*/
|
|
2796
|
-
declare function resolvePinnedSwapRoute(swapIxs: NonNullable<SwapOpts["swapIxs"]>, expectedInAmountNative
|
|
2798
|
+
declare function resolvePinnedSwapRoute(swapIxs: NonNullable<SwapOpts["swapIxs"]>, expectedInAmountNative?: BN | number): ResolvedPinnedSwapRoute;
|
|
2797
2799
|
type GetSwapIxsForFlashloanParams = {
|
|
2798
2800
|
inputMint: string;
|
|
2799
2801
|
outputMint: string;
|
|
@@ -2826,10 +2828,18 @@ type ExactOutEstimateResult = {
|
|
|
2826
2828
|
declare const getExactOutEstimate: (params: GetExactOutEstimateParams) => Promise<ExactOutEstimateResult>;
|
|
2827
2829
|
declare function mapJupiterQuoteToSwapQuoteResult(quote: QuoteResponse): SwapQuoteResult;
|
|
2828
2830
|
|
|
2831
|
+
/**
|
|
2832
|
+
* The position's `amount` (UI units) rounded to whole native units: down for a deposit (no more
|
|
2833
|
+
* can be withdrawn), up for a debt (no less repays it).
|
|
2834
|
+
*/
|
|
2829
2835
|
declare function computeClosePositionTokenAmount(position: {
|
|
2830
2836
|
amount: number;
|
|
2831
2837
|
isLending: boolean;
|
|
2832
2838
|
}, mintDecimals: number): number;
|
|
2839
|
+
/**
|
|
2840
|
+
* Whether `amount` (UI units) covers the whole position: at least
|
|
2841
|
+
* {@link computeClosePositionTokenAmount}.
|
|
2842
|
+
*/
|
|
2833
2843
|
declare function isWholePosition(position: {
|
|
2834
2844
|
amount: number;
|
|
2835
2845
|
isLending: boolean;
|
|
@@ -4208,8 +4218,8 @@ interface SwapOpts {
|
|
|
4208
4218
|
* Pin an exact, caller-reviewed swap route instead of running the swap engine.
|
|
4209
4219
|
*
|
|
4210
4220
|
* The caller owns ATA setup for the route, the route's input amount MUST equal the flow's swap
|
|
4211
|
-
* input (
|
|
4212
|
-
* token account. `quoteResponse.otherAmountThreshold` (guaranteed min-out, native units) sizes
|
|
4221
|
+
* input (the loop's borrow, the collateral swap's withdrawal; a debt swap borrows what the route
|
|
4222
|
+
* takes in), and the route MUST pay out to the flow's destination token account. `quoteResponse.otherAmountThreshold` (guaranteed min-out, native units) sizes
|
|
4213
4223
|
* the follow-up amount — e.g. the loop's deposit byte-patch — exactly like an engine-selected
|
|
4214
4224
|
* route would. For dynamic caller-controlled routing (inspect/veto routes at build time),
|
|
4215
4225
|
* prefer `swapEngineRunner`.
|
|
@@ -5390,21 +5400,24 @@ declare function getValidatorVoteAccountByBank(): Record<string, string>;
|
|
|
5390
5400
|
*/
|
|
5391
5401
|
interface StakedBankLike {
|
|
5392
5402
|
address: PublicKey;
|
|
5403
|
+
stakedOracleUsesOnramp?: boolean;
|
|
5393
5404
|
}
|
|
5394
5405
|
/**
|
|
5395
|
-
* Computes the asset-share multiplier (
|
|
5396
|
-
*
|
|
5397
|
-
*
|
|
5398
|
-
*
|
|
5406
|
+
* Computes the asset-share multiplier (SOL per LST) for each staked bank, as the program prices it:
|
|
5407
|
+
* - with on-ramp pricing (`stakedOracleUsesOnramp`): the lamports of the pool's stake account and
|
|
5408
|
+
* on-ramp above rent, over the LST supply plus the pool's 1 SOL phantom supply;
|
|
5409
|
+
* - otherwise: the pool's delegated stake above its 1 SOL bootstrap, over the LST supply. This
|
|
5410
|
+
* legacy rate is slightly below what the pool redeems an LST for, since it leaves out
|
|
5411
|
+
* undelegated and on-ramp lamports.
|
|
5399
5412
|
*
|
|
5400
|
-
* Banks whose metadata cannot be resolved,
|
|
5401
|
-
* fetched, default to a multiplier of 1.
|
|
5413
|
+
* Banks whose metadata cannot be resolved, whose pool stake account or LST mint cannot be
|
|
5414
|
+
* fetched, or whose LST supply is zero default to a multiplier of 1.
|
|
5402
5415
|
*
|
|
5403
5416
|
* @param stakedBanks - Banks with `assetTag === AssetTag.STAKED`
|
|
5404
5417
|
* @param connection - Solana RPC connection
|
|
5405
5418
|
* @returns Map of bank address (base58) → BigNumber multiplier
|
|
5406
5419
|
*/
|
|
5407
|
-
declare function computeStakedBankMultipliers(stakedBanks: StakedBankLike[], connection: Connection): Promise<Map<string, BigNumber
|
|
5420
|
+
declare function computeStakedBankMultipliers(stakedBanks: StakedBankLike[], connection: Connection): Promise<Map<string, BigNumber>>;
|
|
5408
5421
|
|
|
5409
5422
|
/**
|
|
5410
5423
|
* Creates instructions to convert a native stake account into LST tokens.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as superstruct from 'superstruct';
|
|
2
2
|
import { Infer } from 'superstruct';
|
|
3
|
-
import { c as BankType, R as RiskTier, A as AssetTag, d as BankConfigFlag, e as OperationalState, f as OracleSetup, E as EmodeTag, g as EmodeEntryFlags, h as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, i as OperationalStateRaw, j as OracleSetupRaw, k as RiskTierRaw, M as MarginfiProgram, l as InterestRateConfig, m as BankConfigType, n as BankConfigRaw, o as BankConfigOpt, p as BankConfigOptRaw, q as EmodeSettingsType, r as BankRateLimiterType, s as BankRaw, t as BankRateLimiterRaw, u as EmodeSettingsRaw, v as MarginfiIdlType, H as HealthCacheFlags, w as HealthCacheStatus, x as AccountFlags, y as MarginfiAccountType, z as OraclePrice, P as PriceWithConfidence, C as PriceBias, D as OraclePriceDto, F as BankIntegrationMetadataMap, G as OrderType, J as BalanceType, K as HealthCacheType, L as EmodePair, N as ActiveEmodePair, Q as ActionEmodeImpact, S as MarginRequirementType, a as BankConfigFastRaw, b as BankConfigGovRaw, T as Amount, U as EmodeImpactStatus, O as OrderTrigger, V as TypedAmount, X as BankVaultType, Y as RateLimitWindowType, Z as BankIntegrationMetadataMapDto, _ as BankIntegrationMetadataDto, $ as BankIntegrationMetadata, a0 as Bank, a1 as Environment, a2 as Project0Config, a3 as MintData } from './types
|
|
4
|
-
export { aC as AccountType, aH as AmountType, aB as BankAddress, a4 as BankConfig, B as BankConfigCompactRaw, aE as BankMap, aA as BankMetadata, a7 as BankMetadataRaw, as as ComputeAssetUsdValueParams, aq as ComputeLiabilityUsdValueParams, ao as ComputeUsdValueParams, ac as EmodeConfigRaw, af as EmodeEntry, ah as EmodeImpact, a5 as EmodeSettings, aj as GetAssetWeightParams, a9 as InterestRateConfigCompactRaw, ae as InterestRateConfigOpt, aa as InterestRateConfigOptRaw, aD as KaminoStates, ax as MARGINFI_IDL, aG as MintDataMap, ag as OracleConfigOpt, ab as OracleConfigOptRaw, aF as OraclePriceMap, av as OrderTriggerKind, aw as PriceWithConfidenceDto, ay as Program, a6 as RateLimitWindowRaw, ad as RatePoint, a8 as RatePointRaw, az as Wallet, at as computeAssetUsdValue, ar as computeLiabilityUsdValue, an as computeLoopingParams, am as computeMaxLeverage, au as computeTvl, ap as computeUsdValue, ak as getAssetWeight, al as getLiabilityWeight, ai as isWeightedPrice, aI as resolveAmount } from './types
|
|
3
|
+
import { c as BankType, R as RiskTier, A as AssetTag, d as BankConfigFlag, e as OperationalState, f as OracleSetup, E as EmodeTag, g as EmodeEntryFlags, h as EmodeFlags, W as WrappedI80F48, I as InterestRateConfigRaw, i as OperationalStateRaw, j as OracleSetupRaw, k as RiskTierRaw, M as MarginfiProgram, l as InterestRateConfig, m as BankConfigType, n as BankConfigRaw, o as BankConfigOpt, p as BankConfigOptRaw, q as EmodeSettingsType, r as BankRateLimiterType, s as BankRaw, t as BankRateLimiterRaw, u as EmodeSettingsRaw, v as MarginfiIdlType, H as HealthCacheFlags, w as HealthCacheStatus, x as AccountFlags, y as MarginfiAccountType, z as OraclePrice, P as PriceWithConfidence, C as PriceBias, D as OraclePriceDto, F as BankIntegrationMetadataMap, G as OrderType, J as BalanceType, K as HealthCacheType, L as EmodePair, N as ActiveEmodePair, Q as ActionEmodeImpact, S as MarginRequirementType, a as BankConfigFastRaw, b as BankConfigGovRaw, T as Amount, U as EmodeImpactStatus, O as OrderTrigger, V as TypedAmount, X as BankVaultType, Y as RateLimitWindowType, Z as BankIntegrationMetadataMapDto, _ as BankIntegrationMetadataDto, $ as BankIntegrationMetadata, a0 as Bank, a1 as Environment, a2 as Project0Config, a3 as MintData } from './types-DgVpJ2nB.js';
|
|
4
|
+
export { aC as AccountType, aH as AmountType, aB as BankAddress, a4 as BankConfig, B as BankConfigCompactRaw, aE as BankMap, aA as BankMetadata, a7 as BankMetadataRaw, as as ComputeAssetUsdValueParams, aq as ComputeLiabilityUsdValueParams, ao as ComputeUsdValueParams, ac as EmodeConfigRaw, af as EmodeEntry, ah as EmodeImpact, a5 as EmodeSettings, aj as GetAssetWeightParams, a9 as InterestRateConfigCompactRaw, ae as InterestRateConfigOpt, aa as InterestRateConfigOptRaw, aD as KaminoStates, ax as MARGINFI_IDL, aG as MintDataMap, ag as OracleConfigOpt, ab as OracleConfigOptRaw, aF as OraclePriceMap, av as OrderTriggerKind, aw as PriceWithConfidenceDto, ay as Program, a6 as RateLimitWindowRaw, ad as RatePoint, a8 as RatePointRaw, az as Wallet, at as computeAssetUsdValue, ar as computeLiabilityUsdValue, an as computeLoopingParams, am as computeMaxLeverage, au as computeTvl, ap as computeUsdValue, ak as getAssetWeight, al as getLiabilityWeight, ai as isWeightedPrice, aI as resolveAmount } from './types-DgVpJ2nB.js';
|
|
5
5
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
6
6
|
import { VersionedTransaction, Transaction, PublicKey, TransactionError, TransactionInstruction, Keypair, Signer, AddressLookupTableAccount, Blockhash, TransactionMessage, Connection, AccountInfo } from '@solana/web3.js';
|
|
7
7
|
import { Idl, Instruction, Address } from '@coral-xyz/anchor';
|
|
@@ -2776,7 +2776,7 @@ declare const getTitanExactOutEstimate: (params: GetTitanExactOutEstimateParams)
|
|
|
2776
2776
|
interface ResolvedPinnedSwapRoute {
|
|
2777
2777
|
swapInstructions: TransactionInstruction[];
|
|
2778
2778
|
setupInstructions: TransactionInstruction[];
|
|
2779
|
-
|
|
2779
|
+
swapLuts: AddressLookupTableAccount[];
|
|
2780
2780
|
quoteResponse: SwapQuoteResult;
|
|
2781
2781
|
/** The route's guaranteed min-out (native) — what sizes the follow-up amount (deposit patch). */
|
|
2782
2782
|
outputAmountNative: BN;
|
|
@@ -2787,13 +2787,15 @@ interface ResolvedPinnedSwapRoute {
|
|
|
2787
2787
|
*
|
|
2788
2788
|
* - `otherAmountThreshold` (min-out) must be a positive integer — it becomes the loop's deposit
|
|
2789
2789
|
* byte-patch, exactly like an engine-selected route's min-out.
|
|
2790
|
-
* - `inAmount` must equal the flow's swap input (e.g. the loop's borrow,
|
|
2791
|
-
* mismatch means the route was quoted for a different size than the flow will
|
|
2790
|
+
* - `inAmount` must equal `expectedInAmountNative`, the flow's swap input (e.g. the loop's borrow,
|
|
2791
|
+
* native units) — a mismatch means the route was quoted for a different size than the flow will
|
|
2792
|
+
* actually swap. Omit it when the route's input sets the swap's size, as in a debt swap, which
|
|
2793
|
+
* borrows what the route takes in.
|
|
2792
2794
|
*
|
|
2793
2795
|
* Throws plain `Error`s (not `TransactionBuildingError`) so caller-input mistakes are never
|
|
2794
2796
|
* classified as decomposable swap failures (which would wrongly engage the bridged fallback).
|
|
2795
2797
|
*/
|
|
2796
|
-
declare function resolvePinnedSwapRoute(swapIxs: NonNullable<SwapOpts["swapIxs"]>, expectedInAmountNative
|
|
2798
|
+
declare function resolvePinnedSwapRoute(swapIxs: NonNullable<SwapOpts["swapIxs"]>, expectedInAmountNative?: BN | number): ResolvedPinnedSwapRoute;
|
|
2797
2799
|
type GetSwapIxsForFlashloanParams = {
|
|
2798
2800
|
inputMint: string;
|
|
2799
2801
|
outputMint: string;
|
|
@@ -2826,10 +2828,18 @@ type ExactOutEstimateResult = {
|
|
|
2826
2828
|
declare const getExactOutEstimate: (params: GetExactOutEstimateParams) => Promise<ExactOutEstimateResult>;
|
|
2827
2829
|
declare function mapJupiterQuoteToSwapQuoteResult(quote: QuoteResponse): SwapQuoteResult;
|
|
2828
2830
|
|
|
2831
|
+
/**
|
|
2832
|
+
* The position's `amount` (UI units) rounded to whole native units: down for a deposit (no more
|
|
2833
|
+
* can be withdrawn), up for a debt (no less repays it).
|
|
2834
|
+
*/
|
|
2829
2835
|
declare function computeClosePositionTokenAmount(position: {
|
|
2830
2836
|
amount: number;
|
|
2831
2837
|
isLending: boolean;
|
|
2832
2838
|
}, mintDecimals: number): number;
|
|
2839
|
+
/**
|
|
2840
|
+
* Whether `amount` (UI units) covers the whole position: at least
|
|
2841
|
+
* {@link computeClosePositionTokenAmount}.
|
|
2842
|
+
*/
|
|
2833
2843
|
declare function isWholePosition(position: {
|
|
2834
2844
|
amount: number;
|
|
2835
2845
|
isLending: boolean;
|
|
@@ -4208,8 +4218,8 @@ interface SwapOpts {
|
|
|
4208
4218
|
* Pin an exact, caller-reviewed swap route instead of running the swap engine.
|
|
4209
4219
|
*
|
|
4210
4220
|
* The caller owns ATA setup for the route, the route's input amount MUST equal the flow's swap
|
|
4211
|
-
* input (
|
|
4212
|
-
* token account. `quoteResponse.otherAmountThreshold` (guaranteed min-out, native units) sizes
|
|
4221
|
+
* input (the loop's borrow, the collateral swap's withdrawal; a debt swap borrows what the route
|
|
4222
|
+
* takes in), and the route MUST pay out to the flow's destination token account. `quoteResponse.otherAmountThreshold` (guaranteed min-out, native units) sizes
|
|
4213
4223
|
* the follow-up amount — e.g. the loop's deposit byte-patch — exactly like an engine-selected
|
|
4214
4224
|
* route would. For dynamic caller-controlled routing (inspect/veto routes at build time),
|
|
4215
4225
|
* prefer `swapEngineRunner`.
|
|
@@ -5390,21 +5400,24 @@ declare function getValidatorVoteAccountByBank(): Record<string, string>;
|
|
|
5390
5400
|
*/
|
|
5391
5401
|
interface StakedBankLike {
|
|
5392
5402
|
address: PublicKey;
|
|
5403
|
+
stakedOracleUsesOnramp?: boolean;
|
|
5393
5404
|
}
|
|
5394
5405
|
/**
|
|
5395
|
-
* Computes the asset-share multiplier (
|
|
5396
|
-
*
|
|
5397
|
-
*
|
|
5398
|
-
*
|
|
5406
|
+
* Computes the asset-share multiplier (SOL per LST) for each staked bank, as the program prices it:
|
|
5407
|
+
* - with on-ramp pricing (`stakedOracleUsesOnramp`): the lamports of the pool's stake account and
|
|
5408
|
+
* on-ramp above rent, over the LST supply plus the pool's 1 SOL phantom supply;
|
|
5409
|
+
* - otherwise: the pool's delegated stake above its 1 SOL bootstrap, over the LST supply. This
|
|
5410
|
+
* legacy rate is slightly below what the pool redeems an LST for, since it leaves out
|
|
5411
|
+
* undelegated and on-ramp lamports.
|
|
5399
5412
|
*
|
|
5400
|
-
* Banks whose metadata cannot be resolved,
|
|
5401
|
-
* fetched, default to a multiplier of 1.
|
|
5413
|
+
* Banks whose metadata cannot be resolved, whose pool stake account or LST mint cannot be
|
|
5414
|
+
* fetched, or whose LST supply is zero default to a multiplier of 1.
|
|
5402
5415
|
*
|
|
5403
5416
|
* @param stakedBanks - Banks with `assetTag === AssetTag.STAKED`
|
|
5404
5417
|
* @param connection - Solana RPC connection
|
|
5405
5418
|
* @returns Map of bank address (base58) → BigNumber multiplier
|
|
5406
5419
|
*/
|
|
5407
|
-
declare function computeStakedBankMultipliers(stakedBanks: StakedBankLike[], connection: Connection): Promise<Map<string, BigNumber
|
|
5420
|
+
declare function computeStakedBankMultipliers(stakedBanks: StakedBankLike[], connection: Connection): Promise<Map<string, BigNumber>>;
|
|
5408
5421
|
|
|
5409
5422
|
/**
|
|
5410
5423
|
* Creates instructions to convert a native stake account into LST tokens.
|
package/dist/index.js
CHANGED
|
@@ -76826,18 +76826,12 @@ function computeHealthComponentsFromBalances(params) {
|
|
|
76826
76826
|
let totalLiabilities = new BigNumber3(0);
|
|
76827
76827
|
for (const accountBalance of filteredBalances) {
|
|
76828
76828
|
const bankKey = accountBalance.bankPk.toBase58();
|
|
76829
|
-
const bank = banksMap.
|
|
76830
|
-
if (!bank) {
|
|
76831
|
-
console.warn(
|
|
76832
|
-
`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`
|
|
76833
|
-
);
|
|
76834
|
-
continue;
|
|
76835
|
-
}
|
|
76829
|
+
const bank = requireBank(banksMap, accountBalance.bankPk);
|
|
76836
76830
|
const oraclePrice = oraclePricesByBank.get(bankKey);
|
|
76837
76831
|
if (!oraclePrice) {
|
|
76838
|
-
|
|
76839
|
-
`
|
|
76840
|
-
|
|
76832
|
+
if (accountBalance.liabilityShares.gt(0)) {
|
|
76833
|
+
throw Error(`Oracle price for ${bankKey} not found`);
|
|
76834
|
+
}
|
|
76841
76835
|
continue;
|
|
76842
76836
|
}
|
|
76843
76837
|
const emodeWeight = activeEmodeWeightsByBank?.get(bankKey);
|
|
@@ -77046,7 +77040,7 @@ function computeLiquidationPriceForBank(params) {
|
|
|
77046
77040
|
const { bank, oraclePrice, marginfiAccount, assetShareValueMultiplier, activeEmodeWeights } = params;
|
|
77047
77041
|
const balance = getBalance(bank.address, marginfiAccount.balances);
|
|
77048
77042
|
if (!balance.active) return null;
|
|
77049
|
-
const { assets: assetBank, liabilities: liabilitiesBank } =
|
|
77043
|
+
const { assets: assetBank, liabilities: liabilitiesBank } = getBalanceUsdValueWithPriceBias({
|
|
77050
77044
|
balance,
|
|
77051
77045
|
bank,
|
|
77052
77046
|
oraclePrice,
|
|
@@ -77060,7 +77054,8 @@ function computeLiquidationPriceForBank(params) {
|
|
|
77060
77054
|
const isLending = balance.liabilityShares.isZero();
|
|
77061
77055
|
const { assets: assetQuantityUi, liabilities: liabQuantitiesUi } = computeQuantityUi(
|
|
77062
77056
|
balance,
|
|
77063
|
-
bank
|
|
77057
|
+
bank,
|
|
77058
|
+
assetShareValueMultiplier
|
|
77064
77059
|
);
|
|
77065
77060
|
let liquidationPrice;
|
|
77066
77061
|
if (isLending) {
|
|
@@ -77166,6 +77161,8 @@ function computeBankRiskAccountKeys(bank) {
|
|
|
77166
77161
|
} else if (bank.stakedOracleUsesOnramp && bank.stakedIntegrationAccounts && !bank.stakedIntegrationAccounts.validatorVoteAccount.equals(PublicKey.default)) {
|
|
77167
77162
|
const pool = findPoolAddress(bank.stakedIntegrationAccounts.validatorVoteAccount);
|
|
77168
77163
|
keys.push(findPoolOnRampAddress(pool));
|
|
77164
|
+
} else {
|
|
77165
|
+
keys.push(PublicKey.default);
|
|
77169
77166
|
}
|
|
77170
77167
|
}
|
|
77171
77168
|
return keys;
|
|
@@ -78204,7 +78201,6 @@ function createJupiterClient(config = {}) {
|
|
|
78204
78201
|
// src/services/account/utils/swap.utils.ts
|
|
78205
78202
|
function resolvePinnedSwapRoute(swapIxs, expectedInAmountNative) {
|
|
78206
78203
|
const { quoteResponse } = swapIxs;
|
|
78207
|
-
const expectedIn = new BN8(expectedInAmountNative);
|
|
78208
78204
|
let minOut;
|
|
78209
78205
|
try {
|
|
78210
78206
|
minOut = new BN8(quoteResponse.otherAmountThreshold);
|
|
@@ -78217,15 +78213,15 @@ function resolvePinnedSwapRoute(swapIxs, expectedInAmountNative) {
|
|
|
78217
78213
|
);
|
|
78218
78214
|
}
|
|
78219
78215
|
const pinnedIn = new BN8(quoteResponse.inAmount);
|
|
78220
|
-
if (!pinnedIn.eq(
|
|
78216
|
+
if (expectedInAmountNative !== void 0 && !pinnedIn.eq(new BN8(expectedInAmountNative))) {
|
|
78221
78217
|
throw new Error(
|
|
78222
|
-
`Pinned swap route (swapOpts.swapIxs) was quoted for a different input amount than the flow will swap: quote inAmount=${pinnedIn.toString()}, flow swap input=${
|
|
78218
|
+
`Pinned swap route (swapOpts.swapIxs) was quoted for a different input amount than the flow will swap: quote inAmount=${pinnedIn.toString()}, flow swap input=${expectedInAmountNative.toString()} (native units). Re-quote the pinned route for the exact flow amount.`
|
|
78223
78219
|
);
|
|
78224
78220
|
}
|
|
78225
78221
|
return {
|
|
78226
78222
|
swapInstructions: swapIxs.instructions,
|
|
78227
78223
|
setupInstructions: [],
|
|
78228
|
-
|
|
78224
|
+
swapLuts: swapIxs.lookupTables,
|
|
78229
78225
|
quoteResponse,
|
|
78230
78226
|
outputAmountNative: minOut
|
|
78231
78227
|
};
|
|
@@ -78339,7 +78335,7 @@ var getSwapIxsForFlashloan = async (params) => {
|
|
|
78339
78335
|
return {
|
|
78340
78336
|
swapInstructions: pinned.swapInstructions,
|
|
78341
78337
|
setupInstructions: pinned.setupInstructions,
|
|
78342
|
-
addressLookupTableAddresses: pinned.
|
|
78338
|
+
addressLookupTableAddresses: pinned.swapLuts,
|
|
78343
78339
|
quoteResponse: pinned.quoteResponse
|
|
78344
78340
|
};
|
|
78345
78341
|
}
|
|
@@ -78537,17 +78533,8 @@ var getJupiterSwapIxsForFlashloan = async ({
|
|
|
78537
78533
|
quoteResponse: mapJupiterQuoteToSwapQuoteResult(swapQuote)
|
|
78538
78534
|
};
|
|
78539
78535
|
};
|
|
78540
|
-
|
|
78541
|
-
// src/services/account/utils/misc.utils.ts
|
|
78542
|
-
function floor(value, decimals) {
|
|
78543
|
-
return Math.floor(value * 10 ** decimals) / 10 ** decimals;
|
|
78544
|
-
}
|
|
78545
|
-
function ceil(value, decimals) {
|
|
78546
|
-
return Math.ceil(value * 10 ** decimals) / 10 ** decimals;
|
|
78547
|
-
}
|
|
78548
78536
|
function computeClosePositionTokenAmount(position, mintDecimals) {
|
|
78549
|
-
|
|
78550
|
-
return closePositionTokenAmount;
|
|
78537
|
+
return new BigNumber(position.amount).decimalPlaces(mintDecimals, position.isLending ? BigNumber.ROUND_FLOOR : BigNumber.ROUND_CEIL).toNumber();
|
|
78551
78538
|
}
|
|
78552
78539
|
function isWholePosition(position, amount, mintDecimals) {
|
|
78553
78540
|
const closePositionTokenAmount = computeClosePositionTokenAmount(position, mintDecimals);
|
|
@@ -83959,7 +83946,7 @@ async function buildSwapDebtFlashloanTx({
|
|
|
83959
83946
|
opts: { wrapAndUnwrapSol: false, overrideInferAccounts }
|
|
83960
83947
|
});
|
|
83961
83948
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
83962
|
-
const engineResult = await runEngine({
|
|
83949
|
+
const engineResult = swapOpts.swapIxs ? resolvePinnedSwapRoute(swapOpts.swapIxs) : await runEngine({
|
|
83963
83950
|
inputMint: borrowBank.mint.toBase58(),
|
|
83964
83951
|
outputMint: repayBank.mint.toBase58(),
|
|
83965
83952
|
amountNative: uiToNative(estimatedBorrowAmount, borrowBank.mintDecimals).toNumber(),
|
|
@@ -83985,7 +83972,8 @@ async function buildSwapDebtFlashloanTx({
|
|
|
83985
83972
|
const quoteResponse = engineResult.quoteResponse;
|
|
83986
83973
|
const outAmount = nativeToUi(quoteResponse.outAmount, repayBank.mintDecimals);
|
|
83987
83974
|
const outAmountThreshold = nativeToUi(quoteResponse.otherAmountThreshold, repayBank.mintDecimals);
|
|
83988
|
-
const
|
|
83975
|
+
const repayAll = outAmount > totalPositionAmount;
|
|
83976
|
+
const amountToRepay = repayAll ? totalPositionAmount : outAmountThreshold;
|
|
83989
83977
|
const borrowAmount = nativeToUi(quoteResponse.inAmount, borrowBank.mintDecimals);
|
|
83990
83978
|
const borrowIxs = await makeBorrowIx3({
|
|
83991
83979
|
program,
|
|
@@ -84009,14 +83997,7 @@ async function buildSwapDebtFlashloanTx({
|
|
|
84009
83997
|
amount: amountToRepay,
|
|
84010
83998
|
accountAddress: marginfiAccount.address,
|
|
84011
83999
|
authority: marginfiAccount.authority,
|
|
84012
|
-
repayAll
|
|
84013
|
-
{
|
|
84014
|
-
amount: totalPositionAmount,
|
|
84015
|
-
isLending: false
|
|
84016
|
-
},
|
|
84017
|
-
amountToRepay,
|
|
84018
|
-
repayBank.mintDecimals
|
|
84019
|
-
),
|
|
84000
|
+
repayAll,
|
|
84020
84001
|
isSync: true,
|
|
84021
84002
|
opts: {
|
|
84022
84003
|
wrapAndUnwrapSol: false,
|
|
@@ -84475,16 +84456,7 @@ async function buildDepositIxs(params, amountUi) {
|
|
|
84475
84456
|
}
|
|
84476
84457
|
async function runLoopSwapEngine(descriptor, params) {
|
|
84477
84458
|
const { connection, swapOpts, marginfiAccount, swapEngineRunner } = params;
|
|
84478
|
-
if (swapOpts.swapIxs)
|
|
84479
|
-
const pinned = resolvePinnedSwapRoute(swapOpts.swapIxs, descriptor.inAmountNative);
|
|
84480
|
-
return {
|
|
84481
|
-
swapInstructions: pinned.swapInstructions,
|
|
84482
|
-
setupInstructions: pinned.setupInstructions,
|
|
84483
|
-
swapLuts: pinned.lookupTables,
|
|
84484
|
-
quoteResponse: pinned.quoteResponse,
|
|
84485
|
-
outputAmountNative: pinned.outputAmountNative
|
|
84486
|
-
};
|
|
84487
|
-
}
|
|
84459
|
+
if (swapOpts.swapIxs) return resolvePinnedSwapRoute(swapOpts.swapIxs, descriptor.inAmountNative);
|
|
84488
84460
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
84489
84461
|
const engineResult = await runEngine({
|
|
84490
84462
|
inputMint: descriptor.inputMint,
|
|
@@ -84980,10 +84952,11 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
84980
84952
|
});
|
|
84981
84953
|
sizeConstraintUsed = swapConstraints.sizeConstraint;
|
|
84982
84954
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
84983
|
-
const
|
|
84955
|
+
const amountNative = uiToNative(actualWithdrawAmount, withdrawBank.mintDecimals);
|
|
84956
|
+
const engineResult = swapOpts.swapIxs ? resolvePinnedSwapRoute(swapOpts.swapIxs, amountNative) : await runEngine({
|
|
84984
84957
|
inputMint: withdrawBank.mint.toBase58(),
|
|
84985
84958
|
outputMint: depositBank.mint.toBase58(),
|
|
84986
|
-
amountNative:
|
|
84959
|
+
amountNative: amountNative.toNumber(),
|
|
84987
84960
|
inputDecimals: withdrawBank.mintDecimals,
|
|
84988
84961
|
outputDecimals: depositBank.mintDecimals,
|
|
84989
84962
|
...swapEngineQuoteFieldsFromOpts(swapOpts),
|
|
@@ -84991,7 +84964,11 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
84991
84964
|
destinationTokenAccount,
|
|
84992
84965
|
connection,
|
|
84993
84966
|
footprint: {
|
|
84994
|
-
instructions: [
|
|
84967
|
+
instructions: [
|
|
84968
|
+
...cuRequestIxs,
|
|
84969
|
+
...withdrawIxs.instructions,
|
|
84970
|
+
...depositIxs.instructions
|
|
84971
|
+
],
|
|
84995
84972
|
luts: addressLookupTableAccounts ?? [],
|
|
84996
84973
|
payer: marginfiAccount.authority,
|
|
84997
84974
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
@@ -86690,7 +86667,7 @@ var fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) => {
|
|
|
86690
86667
|
});
|
|
86691
86668
|
const poolStakeAddressKeys = Object.keys(poolStakeAddressRecord);
|
|
86692
86669
|
const poolStakeAccounts = Object.fromEntries(
|
|
86693
|
-
(await
|
|
86670
|
+
(await chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, poolStakeAddressKeys)).map((ai, index) => {
|
|
86694
86671
|
const key = poolStakeAddressKeys[index];
|
|
86695
86672
|
const validatorVote = key ? poolStakeAddressRecord[key] : void 0;
|
|
86696
86673
|
return [validatorVote, ai?.data || null];
|
|
@@ -86698,7 +86675,8 @@ var fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) => {
|
|
|
86698
86675
|
);
|
|
86699
86676
|
validatorVoteAccounts.map((validatorVoteAccount) => {
|
|
86700
86677
|
const voteAccountKey = validatorVoteAccount.toBase58();
|
|
86701
|
-
const
|
|
86678
|
+
const stakeData = poolStakeAccounts[voteAccountKey];
|
|
86679
|
+
const stakeAccount = stakeData ? fetchStakeAccount(stakeData) : null;
|
|
86702
86680
|
const poolMintAddress = poolMintAddressRecord[voteAccountKey];
|
|
86703
86681
|
if (!poolMintAddress) {
|
|
86704
86682
|
return;
|
|
@@ -86785,26 +86763,28 @@ var fetchStakePoolMev = async (connection, validatorVoteAccounts) => {
|
|
|
86785
86763
|
const allAddresses = [...poolStakeAddresses, ...onRampAddresses].map(
|
|
86786
86764
|
(address) => address.toBase58()
|
|
86787
86765
|
);
|
|
86788
|
-
return
|
|
86789
|
-
|
|
86790
|
-
|
|
86791
|
-
|
|
86792
|
-
|
|
86793
|
-
|
|
86794
|
-
|
|
86795
|
-
|
|
86796
|
-
|
|
86797
|
-
|
|
86798
|
-
|
|
86799
|
-
|
|
86800
|
-
|
|
86801
|
-
|
|
86802
|
-
|
|
86803
|
-
|
|
86804
|
-
|
|
86805
|
-
|
|
86806
|
-
|
|
86807
|
-
|
|
86766
|
+
return chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, allAddresses).then(
|
|
86767
|
+
(accountInfos) => {
|
|
86768
|
+
const poolStakeInfos = accountInfos.slice(0, poolStakeAddresses.length);
|
|
86769
|
+
const onRampInfos = accountInfos.slice(poolStakeAddresses.length);
|
|
86770
|
+
const rent = 2282280;
|
|
86771
|
+
validatorVoteAccounts.forEach((validatorVoteAccount, index) => {
|
|
86772
|
+
const poolStakeInfo = poolStakeInfos[index];
|
|
86773
|
+
const onRampInfo = onRampInfos[index];
|
|
86774
|
+
if (poolStakeInfo && onRampInfo) {
|
|
86775
|
+
const stakeDecoded = fetchStakeAccount(poolStakeInfo.data);
|
|
86776
|
+
const onrampDecoded = fetchStakeAccount(onRampInfo.data);
|
|
86777
|
+
const poolLamps = poolStakeInfo.lamports - rent - Number(stakeDecoded.stake.delegation.stake.toString());
|
|
86778
|
+
const onrampStake = Number(onrampDecoded.stake.delegation.stake.toString());
|
|
86779
|
+
mev.set(validatorVoteAccount.toBase58(), {
|
|
86780
|
+
pool: poolLamps >= 1e3 ? poolLamps : 0,
|
|
86781
|
+
onramp: onrampStake
|
|
86782
|
+
});
|
|
86783
|
+
}
|
|
86784
|
+
});
|
|
86785
|
+
return mev;
|
|
86786
|
+
}
|
|
86787
|
+
);
|
|
86808
86788
|
};
|
|
86809
86789
|
|
|
86810
86790
|
// src/services/native-stake/utils/serialize.utils.ts
|
|
@@ -87244,55 +87224,67 @@ function getValidatorVoteAccountByBank() {
|
|
|
87244
87224
|
}
|
|
87245
87225
|
return _voteAccountByBank;
|
|
87246
87226
|
}
|
|
87227
|
+
var POOL_BOOTSTRAP_LAMPORTS = 1000000000n;
|
|
87228
|
+
var STAKE_STATE_DELEGATED = 2;
|
|
87247
87229
|
async function computeStakedBankMultipliers(stakedBanks, connection) {
|
|
87248
87230
|
const multiplierByBank = /* @__PURE__ */ new Map();
|
|
87249
87231
|
if (stakedBanks.length === 0) {
|
|
87250
87232
|
return multiplierByBank;
|
|
87251
87233
|
}
|
|
87252
87234
|
const metadataMap = getStakedBankMetadataMap();
|
|
87253
|
-
const
|
|
87235
|
+
const resolvedBanks = [];
|
|
87254
87236
|
const poolStakeAddresses = [];
|
|
87255
87237
|
const lstMintAddresses = [];
|
|
87238
|
+
const onrampAddresses = [];
|
|
87256
87239
|
for (const bank of stakedBanks) {
|
|
87257
87240
|
const metadata = metadataMap.get(bank.address.toBase58());
|
|
87258
87241
|
if (!metadata) {
|
|
87259
|
-
multiplierByBank.set(bank.address.toBase58(), new
|
|
87242
|
+
multiplierByBank.set(bank.address.toBase58(), new BigNumber(1));
|
|
87260
87243
|
continue;
|
|
87261
87244
|
}
|
|
87262
87245
|
const pool = findPoolAddress(new PublicKey(metadata.validatorVoteAccount));
|
|
87263
|
-
|
|
87246
|
+
resolvedBanks.push(bank);
|
|
87264
87247
|
poolStakeAddresses.push(findPoolStakeAddress(pool));
|
|
87265
87248
|
lstMintAddresses.push(findPoolMintAddress(pool));
|
|
87249
|
+
onrampAddresses.push(findPoolOnRampAddress(pool));
|
|
87266
87250
|
}
|
|
87267
|
-
if (
|
|
87251
|
+
if (resolvedBanks.length === 0) {
|
|
87268
87252
|
return multiplierByBank;
|
|
87269
87253
|
}
|
|
87270
|
-
const allAddresses = [
|
|
87271
|
-
|
|
87272
|
-
|
|
87273
|
-
]
|
|
87274
|
-
|
|
87275
|
-
|
|
87276
|
-
|
|
87277
|
-
|
|
87278
|
-
|
|
87279
|
-
|
|
87280
|
-
const
|
|
87281
|
-
|
|
87282
|
-
|
|
87283
|
-
|
|
87254
|
+
const allAddresses = [...poolStakeAddresses, ...lstMintAddresses, ...onrampAddresses].map(
|
|
87255
|
+
(a) => a.toBase58()
|
|
87256
|
+
);
|
|
87257
|
+
const [accountInfos, stakeRent] = await Promise.all([
|
|
87258
|
+
chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, allAddresses),
|
|
87259
|
+
resolvedBanks.some((bank) => bank.stakedOracleUsesOnramp) ? connection.getMinimumBalanceForRentExemption(StakeProgram.space) : 0
|
|
87260
|
+
]);
|
|
87261
|
+
const count = resolvedBanks.length;
|
|
87262
|
+
const aboveRent = (lamports) => Math.max(lamports - stakeRent, 0);
|
|
87263
|
+
resolvedBanks.forEach((bank, i) => {
|
|
87264
|
+
const bankAddr = bank.address.toBase58();
|
|
87265
|
+
const poolStakeInfo = accountInfos[i];
|
|
87266
|
+
const lstMintInfo = accountInfos[count + i];
|
|
87267
|
+
const onrampInfo = accountInfos[2 * count + i];
|
|
87268
|
+
const lstMintSupply = lstMintInfo ? Buffer$1.from(lstMintInfo.data.subarray(36, 44)).readBigUInt64LE(0) : 0n;
|
|
87269
|
+
if (!poolStakeInfo || lstMintSupply === 0n) {
|
|
87270
|
+
multiplierByBank.set(bankAddr, new BigNumber(1));
|
|
87271
|
+
return;
|
|
87284
87272
|
}
|
|
87285
|
-
|
|
87286
|
-
|
|
87287
|
-
|
|
87288
|
-
|
|
87289
|
-
|
|
87290
|
-
|
|
87273
|
+
if (bank.stakedOracleUsesOnramp) {
|
|
87274
|
+
const value = aboveRent(poolStakeInfo.lamports) + (onrampInfo ? aboveRent(onrampInfo.lamports) : 0);
|
|
87275
|
+
multiplierByBank.set(
|
|
87276
|
+
bankAddr,
|
|
87277
|
+
new BigNumber(value).dividedBy((lstMintSupply + POOL_BOOTSTRAP_LAMPORTS).toString())
|
|
87278
|
+
);
|
|
87279
|
+
return;
|
|
87291
87280
|
}
|
|
87292
|
-
const
|
|
87293
|
-
const
|
|
87294
|
-
multiplierByBank.set(
|
|
87295
|
-
|
|
87281
|
+
const delegated = poolStakeInfo.data.readUInt32LE(0) === STAKE_STATE_DELEGATED ? fetchStakeAccount(poolStakeInfo.data).stake.delegation.stake : 0n;
|
|
87282
|
+
const delegatedAboveBootstrap = delegated > POOL_BOOTSTRAP_LAMPORTS ? delegated - POOL_BOOTSTRAP_LAMPORTS : 0n;
|
|
87283
|
+
multiplierByBank.set(
|
|
87284
|
+
bankAddr,
|
|
87285
|
+
new BigNumber(delegatedAboveBootstrap.toString()).dividedBy(lstMintSupply.toString())
|
|
87286
|
+
);
|
|
87287
|
+
});
|
|
87296
87288
|
return multiplierByBank;
|
|
87297
87289
|
}
|
|
87298
87290
|
var SYSVAR_CLOCK_ID2 = new PublicKey("SysvarC1ock11111111111111111111111111111111");
|
|
@@ -88121,7 +88113,7 @@ async function fetchBankIntegrationMetadata(options) {
|
|
|
88121
88113
|
|
|
88122
88114
|
// src/models/bank.ts
|
|
88123
88115
|
var Bank = class _Bank {
|
|
88124
|
-
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
88116
|
+
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol, stakedOracleDisabled, stakedOracleUsesOnramp, stakedIntegrationAccounts) {
|
|
88125
88117
|
this.address = address;
|
|
88126
88118
|
this.mint = mint;
|
|
88127
88119
|
this.mintDecimals = mintDecimals;
|
|
@@ -88164,6 +88156,9 @@ var Bank = class _Bank {
|
|
|
88164
88156
|
this.lendingPositionCount = lendingPositionCount;
|
|
88165
88157
|
this.borrowingPositionCount = borrowingPositionCount;
|
|
88166
88158
|
this.tokenSymbol = tokenSymbol;
|
|
88159
|
+
this.stakedOracleDisabled = stakedOracleDisabled;
|
|
88160
|
+
this.stakedOracleUsesOnramp = stakedOracleUsesOnramp;
|
|
88161
|
+
this.stakedIntegrationAccounts = stakedIntegrationAccounts;
|
|
88167
88162
|
}
|
|
88168
88163
|
static async fetch(address, program, bankMetadata) {
|
|
88169
88164
|
const data = await program.account.bank.fetch(address);
|
|
@@ -88239,7 +88234,10 @@ var Bank = class _Bank {
|
|
|
88239
88234
|
bankType.feesDestinationAccount,
|
|
88240
88235
|
bankType.lendingPositionCount,
|
|
88241
88236
|
bankType.borrowingPositionCount,
|
|
88242
|
-
bankType.tokenSymbol
|
|
88237
|
+
bankType.tokenSymbol,
|
|
88238
|
+
bankType.stakedOracleDisabled,
|
|
88239
|
+
bankType.stakedOracleUsesOnramp,
|
|
88240
|
+
bankType.stakedIntegrationAccounts
|
|
88243
88241
|
);
|
|
88244
88242
|
}
|
|
88245
88243
|
static fromAccountParsed(address, accountParsed, bankMetadata) {
|
|
@@ -88286,7 +88284,10 @@ var Bank = class _Bank {
|
|
|
88286
88284
|
props.feesDestinationAccount,
|
|
88287
88285
|
props.lendingPositionCount,
|
|
88288
88286
|
props.borrowingPositionCount,
|
|
88289
|
-
props.tokenSymbol
|
|
88287
|
+
props.tokenSymbol,
|
|
88288
|
+
props.stakedOracleDisabled,
|
|
88289
|
+
props.stakedOracleUsesOnramp,
|
|
88290
|
+
props.stakedIntegrationAccounts
|
|
88290
88291
|
);
|
|
88291
88292
|
}
|
|
88292
88293
|
static withEmodeWeights(bank, emodeWeights) {
|