@0dotxyz/p0-ts-sdk 2.2.1 → 2.2.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dto-rate-model.types-gN82ZYyC.d.cts → dto-rate-model.types-AQ40wS-P.d.cts} +2 -46
- package/dist/{dto-rate-model.types-gN82ZYyC.d.ts → dto-rate-model.types-AQ40wS-P.d.ts} +2 -46
- package/dist/index-BDDVBMdM.d.cts +48 -0
- package/dist/index-BDDVBMdM.d.ts +48 -0
- package/dist/index.cjs +123 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -15392
- package/dist/index.d.ts +15 -15392
- package/dist/index.js +122 -85
- package/dist/index.js.map +1 -1
- package/dist/instructions.cjs +344 -0
- package/dist/instructions.cjs.map +1 -0
- package/dist/instructions.d.cts +371 -0
- package/dist/instructions.d.ts +371 -0
- package/dist/instructions.js +338 -0
- package/dist/instructions.js.map +1 -0
- package/dist/types-DGWxbPM1.d.ts +15392 -0
- package/dist/types-ZvnTjjh4.d.cts +15392 -0
- package/dist/vendor.d.cts +3 -2
- package/dist/vendor.d.ts +3 -2
- package/package.json +6 -1
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
-
import BN from 'bn.js';
|
|
3
1
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
|
|
5
|
-
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
-
interface CurrentResult {
|
|
7
|
-
value: BN;
|
|
8
|
-
std_dev: BN;
|
|
9
|
-
mean: BN;
|
|
10
|
-
range: BN;
|
|
11
|
-
min_value: BN;
|
|
12
|
-
max_vaalue: BN;
|
|
13
|
-
slot: BN;
|
|
14
|
-
min_slot: BN;
|
|
15
|
-
max_slot: BN;
|
|
16
|
-
}
|
|
17
|
-
interface OracleSubmission {
|
|
18
|
-
oracle: PublicKey;
|
|
19
|
-
slot: BN;
|
|
20
|
-
value: BN;
|
|
21
|
-
}
|
|
22
|
-
interface PullFeedAccountData {
|
|
23
|
-
submissions: OracleSubmission[];
|
|
24
|
-
authority: PublicKey;
|
|
25
|
-
queue: PublicKey;
|
|
26
|
-
feed_hash: Buffer;
|
|
27
|
-
initialized_at: BN;
|
|
28
|
-
permissions: BN;
|
|
29
|
-
max_variance: BN;
|
|
30
|
-
min_responses: number;
|
|
31
|
-
name: Buffer;
|
|
32
|
-
sample_size: number;
|
|
33
|
-
last_update_timestamp: BN;
|
|
34
|
-
lut_slot: BN;
|
|
35
|
-
result: CurrentResult;
|
|
36
|
-
max_staleness: number;
|
|
37
|
-
min_sample_size: number;
|
|
38
|
-
}
|
|
39
|
-
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
-
interface FeedResponse {
|
|
41
|
-
feedHash: string;
|
|
42
|
-
results: number[];
|
|
43
|
-
}
|
|
44
|
-
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
-
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
-
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
2
|
+
import BN from 'bn.js';
|
|
47
3
|
|
|
48
4
|
interface LastUpdateFields {
|
|
49
5
|
/** Last slot when updated */
|
|
@@ -1767,4 +1723,4 @@ interface JupRateModelJSON {
|
|
|
1767
1723
|
rateAtKink2: number;
|
|
1768
1724
|
}
|
|
1769
1725
|
|
|
1770
|
-
export { type
|
|
1726
|
+
export { type ScopeConfigurationJSON as $, type ReserveConfigFields as A, type ReserveFeesFields as B, type CurvePointFields as C, type DriftSpotMarket as D, type BorrowRateCurveFields as E, type FarmStateJSON as F, type PriceHeuristicFields as G, type HistoricalOracleData as H, type InsuranceFund as I, type JupLendingState as J, type ScopeConfigurationFields as K, type SwitchboardConfigurationFields as L, type PythConfigurationFields as M, type ReserveLiquidityJSON as N, type ObligationJSON as O, type PoolBalance as P, type ReserveCollateralJSON as Q, type ReserveRaw as R, type SpotPosition as S, type TokenInfoFields$1 as T, type ReserveConfigJSON as U, type ReserveFeesJSON as V, type WithdrawalCapsFields as W, type BorrowRateCurveJSON as X, type CurvePointJSON as Y, type TokenInfoJSON$1 as Z, type PriceHeuristicJSON as _, type DriftRewards as a, type SwitchboardConfigurationJSON as a0, type PythConfigurationJSON as a1, type WithdrawalCapsJSON as a2, type ObligationLiquidityJSON as a3, type ObligationCollateralJSON as a4, type ObligationOrderJSON as a5, type ObligationCollateralFields as a6, type ObligationLiquidityFields as a7, type ObligationOrderFields as a8, type LastUpdateFields as a9, type BigFractionBytesFields as aa, type LastUpdateJSON as ab, type BigFractionBytesJSON as ac, type RewardPerTimeUnitPointFields as ad, type RewardScheduleCurveFields as ae, type RewardScheduleCurveJSON as af, type RewardPerTimeUnitPointJSON as ag, type UserFeesJSON as ah, type UserFeesFields as ai, isSpotBalanceTypeVariant as aj, type FeeTier as ak, type FeeTierJSON as al, type OrderFillerRewardStructure as am, type OrderFillerRewardStructureJSON as an, type PriceDivergenceGuardRails as ao, type PriceDivergenceGuardRailsJSON as ap, type ValidityGuardRails as aq, type ValidityGuardRailsJSON as ar, type HistoricalOracleDataJSON as as, type HistoricalIndexDataJSON as at, type PoolBalanceJSON as au, type InsuranceFundJSON as av, SpotBalanceType as aw, type SpotPositionJSON as ax, type ReserveJSON as b, type ObligationRaw as c, type FarmStateRaw as d, type DriftSpotMarketJSON as e, type DriftUserJSON as f, type DriftRewardsJSON as g, type DriftUserStatsJSON as h, type DriftUser as i, type DriftUserStats as j, type JupLendingStateJSON as k, type JupTokenReserveJSON as l, type JupLendingRewardsRateModelJSON as m, type JupRateModelJSON as n, type JupTokenReserve as o, type JupLendingRewardsRateModel as p, type JupRateModel as q, type RewardInfoFields as r, type HistoricalIndexData as s, type FeeStructureJSON as t, type OracleGuardRailsJSON as u, type FeeStructure as v, type OracleGuardRails as w, DriftSpotBalanceType as x, type ReserveLiquidityFields as y, type ReserveCollateralFields as z };
|
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
-
import BN from 'bn.js';
|
|
3
1
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
|
|
5
|
-
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
-
interface CurrentResult {
|
|
7
|
-
value: BN;
|
|
8
|
-
std_dev: BN;
|
|
9
|
-
mean: BN;
|
|
10
|
-
range: BN;
|
|
11
|
-
min_value: BN;
|
|
12
|
-
max_vaalue: BN;
|
|
13
|
-
slot: BN;
|
|
14
|
-
min_slot: BN;
|
|
15
|
-
max_slot: BN;
|
|
16
|
-
}
|
|
17
|
-
interface OracleSubmission {
|
|
18
|
-
oracle: PublicKey;
|
|
19
|
-
slot: BN;
|
|
20
|
-
value: BN;
|
|
21
|
-
}
|
|
22
|
-
interface PullFeedAccountData {
|
|
23
|
-
submissions: OracleSubmission[];
|
|
24
|
-
authority: PublicKey;
|
|
25
|
-
queue: PublicKey;
|
|
26
|
-
feed_hash: Buffer;
|
|
27
|
-
initialized_at: BN;
|
|
28
|
-
permissions: BN;
|
|
29
|
-
max_variance: BN;
|
|
30
|
-
min_responses: number;
|
|
31
|
-
name: Buffer;
|
|
32
|
-
sample_size: number;
|
|
33
|
-
last_update_timestamp: BN;
|
|
34
|
-
lut_slot: BN;
|
|
35
|
-
result: CurrentResult;
|
|
36
|
-
max_staleness: number;
|
|
37
|
-
min_sample_size: number;
|
|
38
|
-
}
|
|
39
|
-
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
-
interface FeedResponse {
|
|
41
|
-
feedHash: string;
|
|
42
|
-
results: number[];
|
|
43
|
-
}
|
|
44
|
-
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
-
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
-
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
2
|
+
import BN from 'bn.js';
|
|
47
3
|
|
|
48
4
|
interface LastUpdateFields {
|
|
49
5
|
/** Last slot when updated */
|
|
@@ -1767,4 +1723,4 @@ interface JupRateModelJSON {
|
|
|
1767
1723
|
rateAtKink2: number;
|
|
1768
1724
|
}
|
|
1769
1725
|
|
|
1770
|
-
export { type
|
|
1726
|
+
export { type ScopeConfigurationJSON as $, type ReserveConfigFields as A, type ReserveFeesFields as B, type CurvePointFields as C, type DriftSpotMarket as D, type BorrowRateCurveFields as E, type FarmStateJSON as F, type PriceHeuristicFields as G, type HistoricalOracleData as H, type InsuranceFund as I, type JupLendingState as J, type ScopeConfigurationFields as K, type SwitchboardConfigurationFields as L, type PythConfigurationFields as M, type ReserveLiquidityJSON as N, type ObligationJSON as O, type PoolBalance as P, type ReserveCollateralJSON as Q, type ReserveRaw as R, type SpotPosition as S, type TokenInfoFields$1 as T, type ReserveConfigJSON as U, type ReserveFeesJSON as V, type WithdrawalCapsFields as W, type BorrowRateCurveJSON as X, type CurvePointJSON as Y, type TokenInfoJSON$1 as Z, type PriceHeuristicJSON as _, type DriftRewards as a, type SwitchboardConfigurationJSON as a0, type PythConfigurationJSON as a1, type WithdrawalCapsJSON as a2, type ObligationLiquidityJSON as a3, type ObligationCollateralJSON as a4, type ObligationOrderJSON as a5, type ObligationCollateralFields as a6, type ObligationLiquidityFields as a7, type ObligationOrderFields as a8, type LastUpdateFields as a9, type BigFractionBytesFields as aa, type LastUpdateJSON as ab, type BigFractionBytesJSON as ac, type RewardPerTimeUnitPointFields as ad, type RewardScheduleCurveFields as ae, type RewardScheduleCurveJSON as af, type RewardPerTimeUnitPointJSON as ag, type UserFeesJSON as ah, type UserFeesFields as ai, isSpotBalanceTypeVariant as aj, type FeeTier as ak, type FeeTierJSON as al, type OrderFillerRewardStructure as am, type OrderFillerRewardStructureJSON as an, type PriceDivergenceGuardRails as ao, type PriceDivergenceGuardRailsJSON as ap, type ValidityGuardRails as aq, type ValidityGuardRailsJSON as ar, type HistoricalOracleDataJSON as as, type HistoricalIndexDataJSON as at, type PoolBalanceJSON as au, type InsuranceFundJSON as av, SpotBalanceType as aw, type SpotPositionJSON as ax, type ReserveJSON as b, type ObligationRaw as c, type FarmStateRaw as d, type DriftSpotMarketJSON as e, type DriftUserJSON as f, type DriftRewardsJSON as g, type DriftUserStatsJSON as h, type DriftUser as i, type DriftUserStats as j, type JupLendingStateJSON as k, type JupTokenReserveJSON as l, type JupLendingRewardsRateModelJSON as m, type JupRateModelJSON as n, type JupTokenReserve as o, type JupLendingRewardsRateModel as p, type JupRateModel as q, type RewardInfoFields as r, type HistoricalIndexData as s, type FeeStructureJSON as t, type OracleGuardRailsJSON as u, type FeeStructure as v, type OracleGuardRails as w, DriftSpotBalanceType as x, type ReserveLiquidityFields as y, type ReserveCollateralFields as z };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
+
interface CurrentResult {
|
|
7
|
+
value: BN;
|
|
8
|
+
std_dev: BN;
|
|
9
|
+
mean: BN;
|
|
10
|
+
range: BN;
|
|
11
|
+
min_value: BN;
|
|
12
|
+
max_vaalue: BN;
|
|
13
|
+
slot: BN;
|
|
14
|
+
min_slot: BN;
|
|
15
|
+
max_slot: BN;
|
|
16
|
+
}
|
|
17
|
+
interface OracleSubmission {
|
|
18
|
+
oracle: PublicKey;
|
|
19
|
+
slot: BN;
|
|
20
|
+
value: BN;
|
|
21
|
+
}
|
|
22
|
+
interface PullFeedAccountData {
|
|
23
|
+
submissions: OracleSubmission[];
|
|
24
|
+
authority: PublicKey;
|
|
25
|
+
queue: PublicKey;
|
|
26
|
+
feed_hash: Buffer;
|
|
27
|
+
initialized_at: BN;
|
|
28
|
+
permissions: BN;
|
|
29
|
+
max_variance: BN;
|
|
30
|
+
min_responses: number;
|
|
31
|
+
name: Buffer;
|
|
32
|
+
sample_size: number;
|
|
33
|
+
last_update_timestamp: BN;
|
|
34
|
+
lut_slot: BN;
|
|
35
|
+
result: CurrentResult;
|
|
36
|
+
max_staleness: number;
|
|
37
|
+
min_sample_size: number;
|
|
38
|
+
}
|
|
39
|
+
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
+
interface FeedResponse {
|
|
41
|
+
feedHash: string;
|
|
42
|
+
results: number[];
|
|
43
|
+
}
|
|
44
|
+
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
+
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
+
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
47
|
+
|
|
48
|
+
export { type CurrentResult as C, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type CrossbarSimulatePayload as a, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
+
interface CurrentResult {
|
|
7
|
+
value: BN;
|
|
8
|
+
std_dev: BN;
|
|
9
|
+
mean: BN;
|
|
10
|
+
range: BN;
|
|
11
|
+
min_value: BN;
|
|
12
|
+
max_vaalue: BN;
|
|
13
|
+
slot: BN;
|
|
14
|
+
min_slot: BN;
|
|
15
|
+
max_slot: BN;
|
|
16
|
+
}
|
|
17
|
+
interface OracleSubmission {
|
|
18
|
+
oracle: PublicKey;
|
|
19
|
+
slot: BN;
|
|
20
|
+
value: BN;
|
|
21
|
+
}
|
|
22
|
+
interface PullFeedAccountData {
|
|
23
|
+
submissions: OracleSubmission[];
|
|
24
|
+
authority: PublicKey;
|
|
25
|
+
queue: PublicKey;
|
|
26
|
+
feed_hash: Buffer;
|
|
27
|
+
initialized_at: BN;
|
|
28
|
+
permissions: BN;
|
|
29
|
+
max_variance: BN;
|
|
30
|
+
min_responses: number;
|
|
31
|
+
name: Buffer;
|
|
32
|
+
sample_size: number;
|
|
33
|
+
last_update_timestamp: BN;
|
|
34
|
+
lut_slot: BN;
|
|
35
|
+
result: CurrentResult;
|
|
36
|
+
max_staleness: number;
|
|
37
|
+
min_sample_size: number;
|
|
38
|
+
}
|
|
39
|
+
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
+
interface FeedResponse {
|
|
41
|
+
feedHash: string;
|
|
42
|
+
results: number[];
|
|
43
|
+
}
|
|
44
|
+
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
+
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
+
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
47
|
+
|
|
48
|
+
export { type CurrentResult as C, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type CrossbarSimulatePayload as a, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };
|
package/dist/index.cjs
CHANGED
|
@@ -19996,7 +19996,7 @@ function dtoToOraclePrice(dto) {
|
|
|
19996
19996
|
}
|
|
19997
19997
|
|
|
19998
19998
|
// src/services/price/utils/crankability.utils.ts
|
|
19999
|
-
async function checkBatchOracleCrankability(feedHashes, crossbarUrl = "https://
|
|
19999
|
+
async function checkBatchOracleCrankability(feedHashes, crossbarUrl = "https://crossbar.0.xyz") {
|
|
20000
20000
|
const results = /* @__PURE__ */ new Map();
|
|
20001
20001
|
if (feedHashes.length === 0) {
|
|
20002
20002
|
return results;
|
|
@@ -20528,16 +20528,72 @@ function createActiveEmodePairFromPairs(pairs) {
|
|
|
20528
20528
|
assetWeightInit: bestPair.assetWeightInit
|
|
20529
20529
|
};
|
|
20530
20530
|
}
|
|
20531
|
+
function indexConfiguredPairs(emodePairs) {
|
|
20532
|
+
const configured = [];
|
|
20533
|
+
const liabTagByBank = /* @__PURE__ */ new Map();
|
|
20534
|
+
for (const p of emodePairs) {
|
|
20535
|
+
if (p.collateralBankTag === 0 /* UNSET */ || p.liabilityBankTag === 0 /* UNSET */) {
|
|
20536
|
+
continue;
|
|
20537
|
+
}
|
|
20538
|
+
const liabStr = p.liabilityBank.toBase58();
|
|
20539
|
+
const liabTagStr = p.liabilityBankTag.toString();
|
|
20540
|
+
configured.push({
|
|
20541
|
+
orig: p,
|
|
20542
|
+
liabStr,
|
|
20543
|
+
liabTagStr,
|
|
20544
|
+
collTagStr: p.collateralBankTag.toString(),
|
|
20545
|
+
collStrs: p.collateralBanks.map((b) => b.toBase58())
|
|
20546
|
+
});
|
|
20547
|
+
liabTagByBank.set(liabStr, liabTagStr);
|
|
20548
|
+
}
|
|
20549
|
+
return { configured, liabTagByBank };
|
|
20550
|
+
}
|
|
20551
|
+
function activePairsFromIndex(configured, liabTagByBank, liabSet, collSet) {
|
|
20552
|
+
const requiredTags = /* @__PURE__ */ new Set();
|
|
20553
|
+
for (const liab of liabSet) {
|
|
20554
|
+
const tag = liabTagByBank.get(liab);
|
|
20555
|
+
if (!tag) return [];
|
|
20556
|
+
requiredTags.add(tag);
|
|
20557
|
+
}
|
|
20558
|
+
const possible = configured.filter(
|
|
20559
|
+
(p) => liabSet.has(p.liabStr) && p.collStrs.some((c) => collSet.has(c))
|
|
20560
|
+
);
|
|
20561
|
+
if (possible.length === 0) return [];
|
|
20562
|
+
const byCollTag = {};
|
|
20563
|
+
for (const p of possible) {
|
|
20564
|
+
(byCollTag[p.collTagStr] ||= []).push(p);
|
|
20565
|
+
}
|
|
20566
|
+
const validGroups = [];
|
|
20567
|
+
for (const group of Object.values(byCollTag)) {
|
|
20568
|
+
const supports = new Set(group.map((p) => p.liabTagStr));
|
|
20569
|
+
let coversAll = true;
|
|
20570
|
+
for (const rt of requiredTags) {
|
|
20571
|
+
if (!supports.has(rt)) {
|
|
20572
|
+
coversAll = false;
|
|
20573
|
+
break;
|
|
20574
|
+
}
|
|
20575
|
+
}
|
|
20576
|
+
if (coversAll) validGroups.push(group);
|
|
20577
|
+
}
|
|
20578
|
+
if (validGroups.length === 0) return [];
|
|
20579
|
+
return validGroups.flat().map((p) => p.orig);
|
|
20580
|
+
}
|
|
20531
20581
|
function computeEmodeImpacts(emodePairs, activeLiabilities, activeCollateral, allBanks) {
|
|
20532
|
-
const
|
|
20533
|
-
const
|
|
20534
|
-
const
|
|
20535
|
-
const
|
|
20582
|
+
const liabBaseSet = new Set(activeLiabilities.map((b) => b.toBase58()));
|
|
20583
|
+
const collBaseSet = new Set(activeCollateral.map((b) => b.toBase58()));
|
|
20584
|
+
const { configured, liabTagByBank } = indexConfiguredPairs(emodePairs);
|
|
20585
|
+
const liabTagMapAll = /* @__PURE__ */ new Map();
|
|
20586
|
+
for (const p of emodePairs) {
|
|
20587
|
+
liabTagMapAll.set(p.liabilityBank.toBase58(), p.liabilityBankTag.toString());
|
|
20588
|
+
}
|
|
20589
|
+
const allCollateralBankStrs = /* @__PURE__ */ new Set();
|
|
20536
20590
|
for (const p of emodePairs) {
|
|
20537
|
-
|
|
20591
|
+
for (const c of p.collateralBanks) allCollateralBankStrs.add(c.toBase58());
|
|
20538
20592
|
}
|
|
20593
|
+
const basePairs = activePairsFromIndex(configured, liabTagByBank, liabBaseSet, collBaseSet);
|
|
20594
|
+
const baseOn = basePairs.length > 0;
|
|
20539
20595
|
const existingTags = new Set(
|
|
20540
|
-
|
|
20596
|
+
Array.from(liabBaseSet).map((l) => liabTagMapAll.get(l)).filter((t) => !!t)
|
|
20541
20597
|
);
|
|
20542
20598
|
function minWeight(ps) {
|
|
20543
20599
|
let m = ps[0].assetWeightInit;
|
|
@@ -20554,27 +20610,26 @@ function computeEmodeImpacts(emodePairs, activeLiabilities, activeCollateral, al
|
|
|
20554
20610
|
if (aMin.lt(bMin)) return 3 /* ReduceEmode */;
|
|
20555
20611
|
return 1 /* ExtendEmode */;
|
|
20556
20612
|
}
|
|
20557
|
-
function simulate(
|
|
20558
|
-
|
|
20559
|
-
let L = [...activeLiabilities], C = [...activeCollateral];
|
|
20613
|
+
function simulate(bankStr, action) {
|
|
20614
|
+
const L = new Set(liabBaseSet), C = new Set(collBaseSet);
|
|
20560
20615
|
switch (action) {
|
|
20561
20616
|
case "borrow":
|
|
20562
|
-
|
|
20617
|
+
L.add(bankStr);
|
|
20563
20618
|
break;
|
|
20564
20619
|
case "repay":
|
|
20565
|
-
L
|
|
20620
|
+
L.delete(bankStr);
|
|
20566
20621
|
break;
|
|
20567
20622
|
case "supply":
|
|
20568
|
-
|
|
20623
|
+
C.add(bankStr);
|
|
20569
20624
|
break;
|
|
20570
20625
|
case "withdraw":
|
|
20571
|
-
C
|
|
20626
|
+
C.delete(bankStr);
|
|
20572
20627
|
break;
|
|
20573
20628
|
}
|
|
20574
|
-
const after =
|
|
20629
|
+
const after = activePairsFromIndex(configured, liabTagByBank, L, C);
|
|
20575
20630
|
let status = diffState(basePairs, after);
|
|
20576
20631
|
if (action === "borrow") {
|
|
20577
|
-
const tag =
|
|
20632
|
+
const tag = liabTagMapAll.get(bankStr);
|
|
20578
20633
|
if (!tag) {
|
|
20579
20634
|
status = baseOn ? 4 /* RemoveEmode */ : 5 /* InactiveEmode */;
|
|
20580
20635
|
} else if (baseOn) {
|
|
@@ -20610,66 +20665,29 @@ function computeEmodeImpacts(emodePairs, activeLiabilities, activeCollateral, al
|
|
|
20610
20665
|
}
|
|
20611
20666
|
const result = {};
|
|
20612
20667
|
for (const bank of allBanks) {
|
|
20613
|
-
const key =
|
|
20668
|
+
const key = bank.toBase58();
|
|
20614
20669
|
const impact = {};
|
|
20615
|
-
if (!
|
|
20616
|
-
impact.borrowImpact = simulate(
|
|
20670
|
+
if (!collBaseSet.has(key)) {
|
|
20671
|
+
impact.borrowImpact = simulate(key, "borrow");
|
|
20617
20672
|
}
|
|
20618
|
-
|
|
20619
|
-
|
|
20620
|
-
impact.supplyImpact = simulate(bank, "supply");
|
|
20673
|
+
if (allCollateralBankStrs.has(key) && !collBaseSet.has(key) && !liabBaseSet.has(key)) {
|
|
20674
|
+
impact.supplyImpact = simulate(key, "supply");
|
|
20621
20675
|
}
|
|
20622
|
-
if (
|
|
20623
|
-
impact.repayAllImpact = simulate(
|
|
20676
|
+
if (liabBaseSet.has(key)) {
|
|
20677
|
+
impact.repayAllImpact = simulate(key, "repay");
|
|
20624
20678
|
}
|
|
20625
|
-
if (
|
|
20626
|
-
impact.withdrawAllImpact = simulate(
|
|
20679
|
+
if (collBaseSet.has(key)) {
|
|
20680
|
+
impact.withdrawAllImpact = simulate(key, "withdraw");
|
|
20627
20681
|
}
|
|
20628
20682
|
result[key] = impact;
|
|
20629
20683
|
}
|
|
20630
20684
|
return result;
|
|
20631
20685
|
}
|
|
20632
20686
|
function computeActiveEmodePairs(emodePairs, activeLiabilities, activeCollateral) {
|
|
20633
|
-
const configured = emodePairs
|
|
20634
|
-
|
|
20635
|
-
);
|
|
20636
|
-
|
|
20637
|
-
for (const p of configured) {
|
|
20638
|
-
liabTagByBank.set(p.liabilityBank.toBase58(), p.liabilityBankTag.toString());
|
|
20639
|
-
}
|
|
20640
|
-
const requiredTags = /* @__PURE__ */ new Set();
|
|
20641
|
-
for (const liab of activeLiabilities) {
|
|
20642
|
-
const tag = liabTagByBank.get(liab.toBase58());
|
|
20643
|
-
if (!tag) {
|
|
20644
|
-
return [];
|
|
20645
|
-
}
|
|
20646
|
-
requiredTags.add(tag);
|
|
20647
|
-
}
|
|
20648
|
-
const possible = configured.filter(
|
|
20649
|
-
(p) => activeLiabilities.some((l) => l.equals(p.liabilityBank)) && p.collateralBanks.some((c) => activeCollateral.some((a) => a.equals(c)))
|
|
20650
|
-
);
|
|
20651
|
-
if (possible.length === 0) return [];
|
|
20652
|
-
const byCollTag = {};
|
|
20653
|
-
for (const p of possible) {
|
|
20654
|
-
const ct = p.collateralBankTag.toString();
|
|
20655
|
-
(byCollTag[ct] ||= []).push(p);
|
|
20656
|
-
}
|
|
20657
|
-
const validGroups = [];
|
|
20658
|
-
for (const group of Object.values(byCollTag)) {
|
|
20659
|
-
const supports = new Set(group.map((p) => p.liabilityBankTag.toString()));
|
|
20660
|
-
let coversAll = true;
|
|
20661
|
-
for (const rt of requiredTags) {
|
|
20662
|
-
if (!supports.has(rt)) {
|
|
20663
|
-
coversAll = false;
|
|
20664
|
-
break;
|
|
20665
|
-
}
|
|
20666
|
-
}
|
|
20667
|
-
if (coversAll) {
|
|
20668
|
-
validGroups.push(group);
|
|
20669
|
-
}
|
|
20670
|
-
}
|
|
20671
|
-
if (validGroups.length === 0) return [];
|
|
20672
|
-
return validGroups.flat();
|
|
20687
|
+
const { configured, liabTagByBank } = indexConfiguredPairs(emodePairs);
|
|
20688
|
+
const liabSet = new Set(activeLiabilities.map((b) => b.toBase58()));
|
|
20689
|
+
const collSet = new Set(activeCollateral.map((b) => b.toBase58()));
|
|
20690
|
+
return activePairsFromIndex(configured, liabTagByBank, liabSet, collSet);
|
|
20673
20691
|
}
|
|
20674
20692
|
function computeBalanceUsdValue(params) {
|
|
20675
20693
|
const {
|
|
@@ -21374,7 +21392,10 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
21374
21392
|
if (!bank) {
|
|
21375
21393
|
throw Error(`Bank ${targetBank.toBase58()} not found in bankMap`);
|
|
21376
21394
|
}
|
|
21377
|
-
const
|
|
21395
|
+
const isKaminoWithdraw = decoded.name === "kaminoWithdraw";
|
|
21396
|
+
const assetShareValueMultiplier = isKaminoWithdraw ? new BigNumber3__default.default(1) : assetShareValueMultiplierByBank.get(targetBank.toBase58()) ?? new BigNumber3__default.default(1);
|
|
21397
|
+
const cTokenAmount = withdrawTokenAmount.div(assetShareValueMultiplier);
|
|
21398
|
+
const withdrawShares = getAssetShares(bank, cTokenAmount);
|
|
21378
21399
|
targetBalance.assetShares = BigNumber3__default.default.max(
|
|
21379
21400
|
0,
|
|
21380
21401
|
targetBalance.assetShares.minus(withdrawShares)
|
|
@@ -48773,7 +48794,8 @@ async function getHealthSimulationTransactions({
|
|
|
48773
48794
|
authority,
|
|
48774
48795
|
luts,
|
|
48775
48796
|
includeCrankTx,
|
|
48776
|
-
blockhash
|
|
48797
|
+
blockhash,
|
|
48798
|
+
crossbarUrl
|
|
48777
48799
|
}) {
|
|
48778
48800
|
const additionalTxs = [];
|
|
48779
48801
|
const computeIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
@@ -48785,7 +48807,8 @@ async function getHealthSimulationTransactions({
|
|
|
48785
48807
|
marginfiAccount,
|
|
48786
48808
|
bankMap,
|
|
48787
48809
|
projectedActiveBanks,
|
|
48788
|
-
program.provider
|
|
48810
|
+
program.provider,
|
|
48811
|
+
crossbarUrl
|
|
48789
48812
|
);
|
|
48790
48813
|
}
|
|
48791
48814
|
const activeBanks = marginfiAccount.balances.filter((b) => b.active).map((b) => b.bankPk);
|
|
@@ -49153,7 +49176,7 @@ function computeMaxWithdrawForBank(params) {
|
|
|
49153
49176
|
const maxWithdraw = initUntiedCollateralForBank.div(initWeightedPrice);
|
|
49154
49177
|
return maxWithdraw;
|
|
49155
49178
|
}
|
|
49156
|
-
var TITAN_FEE_WALLET = new web3_js.PublicKey("
|
|
49179
|
+
var TITAN_FEE_WALLET = new web3_js.PublicKey("FEES6XLN7dMz2iBwKab9Hri9Kwc4WJ6TmDAiT4BNhyej");
|
|
49157
49180
|
var getTitanFeeAccount = (mint) => {
|
|
49158
49181
|
return getAssociatedTokenAddressSync(mint, TITAN_FEE_WALLET, true);
|
|
49159
49182
|
};
|
|
@@ -50478,11 +50501,14 @@ async function makeSmartCrankSwbFeedIx(params) {
|
|
|
50478
50501
|
const { instructions: instructions2, luts } = await makeUpdateSwbFeedIx({
|
|
50479
50502
|
swbPullOracles: oraclesToCrank,
|
|
50480
50503
|
feePayer: params.marginfiAccount.authority,
|
|
50481
|
-
connection: params.connection
|
|
50504
|
+
connection: params.connection,
|
|
50505
|
+
crossbarUrl: params.crossbarUrl
|
|
50482
50506
|
});
|
|
50483
50507
|
return { instructions: instructions2, luts };
|
|
50484
50508
|
}
|
|
50485
|
-
|
|
50509
|
+
var DEFAULT_CROSSBAR_URL = "https://crossbar.0.xyz";
|
|
50510
|
+
var DEFAULT_FALLBACK_CROSSBAR_URL = "https://crossbar.switchboard.xyz";
|
|
50511
|
+
async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider, crossbarUrl) {
|
|
50486
50512
|
const activeBanksPk = marginfiAccount.balances.filter((balance) => balance.active).map((balance) => balance.bankPk);
|
|
50487
50513
|
const allActiveBanks = [
|
|
50488
50514
|
...(/* @__PURE__ */ new Set([
|
|
@@ -50501,7 +50527,8 @@ async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider
|
|
|
50501
50527
|
const { instructions: instructions2, luts } = await makeUpdateSwbFeedIx({
|
|
50502
50528
|
swbPullOracles: staleOracles.map((oracle) => ({ key: oracle })),
|
|
50503
50529
|
feePayer: provider.publicKey,
|
|
50504
|
-
connection: provider.connection
|
|
50530
|
+
connection: provider.connection,
|
|
50531
|
+
crossbarUrl
|
|
50505
50532
|
});
|
|
50506
50533
|
return { instructions: instructions2, luts };
|
|
50507
50534
|
}
|
|
@@ -50531,16 +50558,26 @@ async function makeUpdateSwbFeedIx(props) {
|
|
|
50531
50558
|
if (pullFeedInstances.length === 0) {
|
|
50532
50559
|
return { instructions: [], luts: [] };
|
|
50533
50560
|
}
|
|
50534
|
-
const
|
|
50535
|
-
|
|
50536
|
-
|
|
50537
|
-
|
|
50538
|
-
|
|
50539
|
-
|
|
50540
|
-
|
|
50541
|
-
|
|
50542
|
-
|
|
50543
|
-
|
|
50561
|
+
const primaryUrl = props.crossbarUrl ?? DEFAULT_CROSSBAR_URL;
|
|
50562
|
+
const fallbackUrl = props.fallbackCrossbarUrl ?? DEFAULT_FALLBACK_CROSSBAR_URL;
|
|
50563
|
+
try {
|
|
50564
|
+
const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
|
|
50565
|
+
feeds: pullFeedInstances,
|
|
50566
|
+
numSignatures: 1,
|
|
50567
|
+
crossbarClient: new common.CrossbarClient(primaryUrl),
|
|
50568
|
+
payer: props.feePayer
|
|
50569
|
+
});
|
|
50570
|
+
return { instructions: pullIx, luts };
|
|
50571
|
+
} catch (primaryError) {
|
|
50572
|
+
console.warn(`Primary crossbar endpoint failed (${primaryUrl}), trying fallback:`, primaryError);
|
|
50573
|
+
const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
|
|
50574
|
+
feeds: pullFeedInstances,
|
|
50575
|
+
numSignatures: 1,
|
|
50576
|
+
crossbarClient: new common.CrossbarClient(fallbackUrl),
|
|
50577
|
+
payer: props.feePayer
|
|
50578
|
+
});
|
|
50579
|
+
return { instructions: pullIx, luts };
|
|
50580
|
+
}
|
|
50544
50581
|
}
|
|
50545
50582
|
|
|
50546
50583
|
// src/services/price/actions/klend-reserve-refresh.ts
|
|
@@ -51031,7 +51068,7 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
51031
51068
|
} else {
|
|
51032
51069
|
crossbarResponse = await fetchSwbOraclePricesFromCrossbar(
|
|
51033
51070
|
swbFeedIds,
|
|
51034
|
-
opts.crossbarEndpoint || "https://
|
|
51071
|
+
opts.crossbarEndpoint || "https://crossbar.0.xyz",
|
|
51035
51072
|
"https://crossbar.switchboard.xyz"
|
|
51036
51073
|
);
|
|
51037
51074
|
birdeyeResponse = {};
|
|
@@ -55532,6 +55569,8 @@ exports.Bank = Bank;
|
|
|
55532
55569
|
exports.BankConfig = BankConfig;
|
|
55533
55570
|
exports.BankConfigFlag = BankConfigFlag;
|
|
55534
55571
|
exports.BankVaultType = BankVaultType;
|
|
55572
|
+
exports.DEFAULT_CROSSBAR_URL = DEFAULT_CROSSBAR_URL;
|
|
55573
|
+
exports.DEFAULT_FALLBACK_CROSSBAR_URL = DEFAULT_FALLBACK_CROSSBAR_URL;
|
|
55535
55574
|
exports.DEFAULT_ORACLE_MAX_AGE = DEFAULT_ORACLE_MAX_AGE;
|
|
55536
55575
|
exports.DISABLED_FLAG = DISABLED_FLAG;
|
|
55537
55576
|
exports.EMPTY_HEALTH_CACHE = EMPTY_HEALTH_CACHE;
|