@pyefi/sdk 0.1.3 → 0.1.5
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/{chunk-2NO7PNVV.js → chunk-GXXXUTDQ.js} +206 -83
- package/dist/chunk-GXXXUTDQ.js.map +1 -0
- package/dist/index.d.ts +88 -3
- package/dist/index.js +114 -3
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +16 -2
- package/dist/react.js +72 -6
- package/dist/react.js.map +1 -1
- package/dist/{apy-store-CNq9A4Xc.d.ts → validator-store-CirN3_Ac.d.ts} +98 -50
- package/package.json +1 -1
- package/dist/chunk-2NO7PNVV.js.map +0 -1
|
@@ -253,7 +253,7 @@ var validators = {
|
|
|
253
253
|
symbol: "DAWN",
|
|
254
254
|
vote_account: "8zuMRTXThoPTTPLLvaiKiJshLLCqGMt9BdRjjCL19xBc",
|
|
255
255
|
pt_sol: "https://assets.pye.fi/ysol_psol_logos/sol_psol.png",
|
|
256
|
-
is_allowed:
|
|
256
|
+
is_allowed: true,
|
|
257
257
|
type: "validator",
|
|
258
258
|
rt_sol: "https://assets.pye.fi/ysol_psol_logos/sol_ysol.png"
|
|
259
259
|
},
|
|
@@ -1352,7 +1352,7 @@ var validators = {
|
|
|
1352
1352
|
symbol: "VALID",
|
|
1353
1353
|
vote_account: "6hkfqeNAbURk7CmAQsP4Qm6WwHVF4LxHupEvQf7Tkrf1",
|
|
1354
1354
|
pt_sol: "https://assets.pye.fi/ysol_psol_logos/valid_blocks_psol.png",
|
|
1355
|
-
is_allowed:
|
|
1355
|
+
is_allowed: true,
|
|
1356
1356
|
type: "validator",
|
|
1357
1357
|
rt_sol: "https://assets.pye.fi/ysol_psol_logos/valid_blocks_ysol.png"
|
|
1358
1358
|
},
|
|
@@ -3127,35 +3127,24 @@ function parseOrderBook(marketPubkey, hexData) {
|
|
|
3127
3127
|
|
|
3128
3128
|
// src/lib/market-service.ts
|
|
3129
3129
|
import { createClient } from "@supabase/supabase-js";
|
|
3130
|
-
var MATURITY_TOLERANCE = 86400;
|
|
3131
|
-
var voteAccountToValidatorId2 = /* @__PURE__ */ new Map();
|
|
3132
|
-
for (const v of ALLOWED_VALIDATORS) {
|
|
3133
|
-
voteAccountToValidatorId2.set(v.vote_account, v.id);
|
|
3134
|
-
}
|
|
3135
|
-
function matchMaturity(maturityTs) {
|
|
3136
|
-
for (const id of maturityIdsArray) {
|
|
3137
|
-
const m = maturities[id];
|
|
3138
|
-
const mTs = Number(m.maturity_timestamp);
|
|
3139
|
-
if (Math.abs(maturityTs - mTs) <= MATURITY_TOLERANCE) {
|
|
3140
|
-
return id;
|
|
3141
|
-
}
|
|
3142
|
-
}
|
|
3143
|
-
return null;
|
|
3144
|
-
}
|
|
3145
3130
|
async function fetchManifestMarkets() {
|
|
3146
|
-
var _a, _b;
|
|
3131
|
+
var _a, _b, _c;
|
|
3147
3132
|
const config = getPyeConfig();
|
|
3148
3133
|
const supabase = createClient(config.supabaseUrl, config.supabaseAnonKey);
|
|
3149
|
-
const
|
|
3150
|
-
const [marketsRes, bondsRes] = await Promise.all([
|
|
3134
|
+
const [marketsRes, bondsRes, validatorsRes] = await Promise.all([
|
|
3151
3135
|
supabase.from("manifest_markets").select("pubkey, base_mint, account_data"),
|
|
3152
3136
|
supabase.from("solo_validator_bonds").select(
|
|
3153
|
-
"pubkey, validator_vote_account, principal_token_mint, yield_token_mint,
|
|
3154
|
-
).
|
|
3137
|
+
"pubkey, validator_vote_account, principal_token_mint, yield_token_mint, canonical_label"
|
|
3138
|
+
).not("canonical_label", "is", null).eq("is_hidden", false),
|
|
3139
|
+
supabase.from("validator_metadata_configs").select("vote_pubkey").eq("widget", true)
|
|
3155
3140
|
]);
|
|
3156
3141
|
if (marketsRes.error) throw marketsRes.error;
|
|
3157
3142
|
if (bondsRes.error) throw bondsRes.error;
|
|
3143
|
+
if (validatorsRes.error) throw validatorsRes.error;
|
|
3158
3144
|
if (!((_a = marketsRes.data) == null ? void 0 : _a.length) || !((_b = bondsRes.data) == null ? void 0 : _b.length)) return [];
|
|
3145
|
+
const allowedVoteAccounts = new Set(
|
|
3146
|
+
((_c = validatorsRes.data) != null ? _c : []).map((r) => r.vote_pubkey)
|
|
3147
|
+
);
|
|
3159
3148
|
const ptMintToBond = /* @__PURE__ */ new Map();
|
|
3160
3149
|
const rtMintToBond = /* @__PURE__ */ new Map();
|
|
3161
3150
|
for (const bond of bondsRes.data) {
|
|
@@ -3168,10 +3157,9 @@ async function fetchManifestMarkets() {
|
|
|
3168
3157
|
const rtBond = rtMintToBond.get(market.base_mint);
|
|
3169
3158
|
const bond = ptBond != null ? ptBond : rtBond;
|
|
3170
3159
|
if (!bond) continue;
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
const
|
|
3174
|
-
if (!maturityId) continue;
|
|
3160
|
+
if (!allowedVoteAccounts.has(bond.validator_vote_account)) continue;
|
|
3161
|
+
const tokenType = ptBond ? "PT" : "RT";
|
|
3162
|
+
const mint = tokenType === "PT" ? bond.principal_token_mint : bond.yield_token_mint;
|
|
3175
3163
|
let orderBook = {
|
|
3176
3164
|
totalAskSize: 0,
|
|
3177
3165
|
bestAskPrice: null,
|
|
@@ -3195,9 +3183,10 @@ async function fetchManifestMarkets() {
|
|
|
3195
3183
|
matched.push(__spreadValues({
|
|
3196
3184
|
marketPubkey: market.pubkey,
|
|
3197
3185
|
bondPubkey: bond.pubkey,
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
tokenType
|
|
3186
|
+
voteAccount: bond.validator_vote_account,
|
|
3187
|
+
canonicalLabel: bond.canonical_label,
|
|
3188
|
+
tokenType,
|
|
3189
|
+
mint
|
|
3201
3190
|
}, orderBook));
|
|
3202
3191
|
}
|
|
3203
3192
|
return matched;
|
|
@@ -3205,7 +3194,7 @@ async function fetchManifestMarkets() {
|
|
|
3205
3194
|
function buildMarketLookup(markets) {
|
|
3206
3195
|
const lookup = {};
|
|
3207
3196
|
for (const m of markets) {
|
|
3208
|
-
const key = `${m.
|
|
3197
|
+
const key = `${m.voteAccount}-${m.canonicalLabel}-${m.tokenType}`;
|
|
3209
3198
|
if (!lookup[key]) {
|
|
3210
3199
|
lookup[key] = __spreadValues({}, m);
|
|
3211
3200
|
}
|
|
@@ -3221,22 +3210,10 @@ function getSupabase() {
|
|
|
3221
3210
|
const config = getPyeConfig();
|
|
3222
3211
|
return createClient2(config.supabaseUrl, config.supabaseAnonKey);
|
|
3223
3212
|
}
|
|
3224
|
-
function buildInitialRtBacking() {
|
|
3225
|
-
const backing = {};
|
|
3226
|
-
const allowed = allowedLockups();
|
|
3227
|
-
for (const mats of Object.values(allowed)) {
|
|
3228
|
-
if (!mats) continue;
|
|
3229
|
-
for (const bond of Object.values(mats)) {
|
|
3230
|
-
if (!bond) continue;
|
|
3231
|
-
backing[bond.pubkey] = 0;
|
|
3232
|
-
}
|
|
3233
|
-
}
|
|
3234
|
-
return backing;
|
|
3235
|
-
}
|
|
3236
3213
|
var initialState2 = {
|
|
3237
3214
|
markets: {},
|
|
3238
3215
|
pubkeyIndex: {},
|
|
3239
|
-
rtBacking:
|
|
3216
|
+
rtBacking: {},
|
|
3240
3217
|
loading: false,
|
|
3241
3218
|
lastFetched: null
|
|
3242
3219
|
};
|
|
@@ -3286,9 +3263,9 @@ function createMarketStore() {
|
|
|
3286
3263
|
}
|
|
3287
3264
|
});
|
|
3288
3265
|
},
|
|
3289
|
-
getMarket(
|
|
3266
|
+
getMarket(voteAccount, canonicalLabel, tokenType) {
|
|
3290
3267
|
var _a;
|
|
3291
|
-
const key = `${
|
|
3268
|
+
const key = `${voteAccount}-${canonicalLabel}-${tokenType}`;
|
|
3292
3269
|
return (_a = get().markets[key]) != null ? _a : null;
|
|
3293
3270
|
},
|
|
3294
3271
|
updateMarketOrderBook(marketPubkey, summary) {
|
|
@@ -3361,22 +3338,133 @@ function createApyStore() {
|
|
|
3361
3338
|
);
|
|
3362
3339
|
}
|
|
3363
3340
|
|
|
3341
|
+
// src/stores/validator-store.ts
|
|
3342
|
+
import { createStore as createStore5 } from "zustand/vanilla";
|
|
3343
|
+
import { immer as immer5 } from "zustand/middleware/immer";
|
|
3344
|
+
import { createClient as createClient4 } from "@supabase/supabase-js";
|
|
3345
|
+
function getSupabase3() {
|
|
3346
|
+
const config = getPyeConfig();
|
|
3347
|
+
return createClient4(config.supabaseUrl, config.supabaseAnonKey);
|
|
3348
|
+
}
|
|
3349
|
+
var initialState4 = {
|
|
3350
|
+
validators: {},
|
|
3351
|
+
loading: false,
|
|
3352
|
+
lastFetched: null,
|
|
3353
|
+
error: null
|
|
3354
|
+
};
|
|
3355
|
+
function createValidatorStore() {
|
|
3356
|
+
return createStore5()(
|
|
3357
|
+
immer5((set) => __spreadProps(__spreadValues({}, initialState4), {
|
|
3358
|
+
async fetchAll() {
|
|
3359
|
+
set((s) => {
|
|
3360
|
+
s.loading = true;
|
|
3361
|
+
s.error = null;
|
|
3362
|
+
});
|
|
3363
|
+
try {
|
|
3364
|
+
const supabase = getSupabase3();
|
|
3365
|
+
const { data, error } = await supabase.from("validator_metadata_configs").select(
|
|
3366
|
+
"vote_pubkey, name, symbol, pt_image_url, yt_image_url, base_image_url, alt_pubkey, widget, app"
|
|
3367
|
+
);
|
|
3368
|
+
if (error) throw error;
|
|
3369
|
+
set((s) => {
|
|
3370
|
+
s.validators = {};
|
|
3371
|
+
for (const row of data != null ? data : []) {
|
|
3372
|
+
s.validators[row.vote_pubkey] = row;
|
|
3373
|
+
}
|
|
3374
|
+
s.lastFetched = Date.now();
|
|
3375
|
+
});
|
|
3376
|
+
} catch (err) {
|
|
3377
|
+
const msg = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : JSON.stringify(err);
|
|
3378
|
+
console.error("[ValidatorStore] fetch failed:", msg, err);
|
|
3379
|
+
set((s) => {
|
|
3380
|
+
s.error = msg;
|
|
3381
|
+
});
|
|
3382
|
+
} finally {
|
|
3383
|
+
set((s) => {
|
|
3384
|
+
s.loading = false;
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
}))
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
function selectWidgetValidators(state) {
|
|
3392
|
+
return Object.values(state.validators).filter((v) => v.widget).sort((a, b) => a.name.localeCompare(b.name));
|
|
3393
|
+
}
|
|
3394
|
+
function selectWidgetValidator(state, votePubkey) {
|
|
3395
|
+
const row = state.validators[votePubkey];
|
|
3396
|
+
return row && row.widget ? row : null;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
// src/stores/lockup-store.ts
|
|
3400
|
+
import { createStore as createStore6 } from "zustand/vanilla";
|
|
3401
|
+
import { immer as immer6 } from "zustand/middleware/immer";
|
|
3402
|
+
import { createClient as createClient5 } from "@supabase/supabase-js";
|
|
3403
|
+
function getSupabase4() {
|
|
3404
|
+
const config = getPyeConfig();
|
|
3405
|
+
return createClient5(config.supabaseUrl, config.supabaseAnonKey);
|
|
3406
|
+
}
|
|
3407
|
+
function keyOf(votePubkey, label) {
|
|
3408
|
+
return `${votePubkey}:${label}`;
|
|
3409
|
+
}
|
|
3410
|
+
var initialState5 = {
|
|
3411
|
+
bonds: {},
|
|
3412
|
+
loading: false,
|
|
3413
|
+
lastFetched: null,
|
|
3414
|
+
error: null
|
|
3415
|
+
};
|
|
3416
|
+
function createLockupStore() {
|
|
3417
|
+
return createStore6()(
|
|
3418
|
+
immer6((set) => __spreadProps(__spreadValues({}, initialState5), {
|
|
3419
|
+
async fetchAll() {
|
|
3420
|
+
set((s) => {
|
|
3421
|
+
s.loading = true;
|
|
3422
|
+
s.error = null;
|
|
3423
|
+
});
|
|
3424
|
+
try {
|
|
3425
|
+
const supabase = getSupabase4();
|
|
3426
|
+
const { data, error } = await supabase.from("solo_validator_bonds").select(
|
|
3427
|
+
"pubkey, validator_vote_account, pt_mint:principal_token_mint, rt_mint:yield_token_mint, maturity_ts, canonical_label, is_hidden, standard"
|
|
3428
|
+
).not("canonical_label", "is", null).eq("is_hidden", false);
|
|
3429
|
+
if (error) throw error;
|
|
3430
|
+
set((s) => {
|
|
3431
|
+
s.bonds = {};
|
|
3432
|
+
for (const row of data != null ? data : []) {
|
|
3433
|
+
s.bonds[keyOf(row.validator_vote_account, row.canonical_label)] = row;
|
|
3434
|
+
}
|
|
3435
|
+
s.lastFetched = Date.now();
|
|
3436
|
+
});
|
|
3437
|
+
} catch (err) {
|
|
3438
|
+
const msg = err instanceof Error ? err.message : err && typeof err === "object" && "message" in err ? String(err.message) : JSON.stringify(err);
|
|
3439
|
+
console.error("[LockupStore] fetch failed:", msg, err);
|
|
3440
|
+
set((s) => {
|
|
3441
|
+
s.error = msg;
|
|
3442
|
+
});
|
|
3443
|
+
} finally {
|
|
3444
|
+
set((s) => {
|
|
3445
|
+
s.loading = false;
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
}))
|
|
3450
|
+
);
|
|
3451
|
+
}
|
|
3452
|
+
function selectBondsForValidator(state, votePubkey) {
|
|
3453
|
+
return Object.values(state.bonds).filter((b) => b.validator_vote_account === votePubkey).sort((a, b) => a.maturity_ts - b.maturity_ts);
|
|
3454
|
+
}
|
|
3455
|
+
function selectBond(state, votePubkey, label) {
|
|
3456
|
+
var _a;
|
|
3457
|
+
return (_a = state.bonds[keyOf(votePubkey, label)]) != null ? _a : null;
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3364
3460
|
// src/lib/fetch-user-stake-accounts.ts
|
|
3365
3461
|
import { PublicKey as PublicKey2 } from "@solana/web3.js";
|
|
3366
|
-
import { createClient as
|
|
3462
|
+
import { createClient as createClient6 } from "@supabase/supabase-js";
|
|
3367
3463
|
var STAKE_PROGRAM_ID = new PublicKey2(
|
|
3368
3464
|
"Stake11111111111111111111111111111111111111"
|
|
3369
3465
|
);
|
|
3370
|
-
var voteAccountToValidator = /* @__PURE__ */ new Map();
|
|
3371
|
-
for (const [id, v] of Object.entries(validators)) {
|
|
3372
|
-
voteAccountToValidator.set(v.vote_account, {
|
|
3373
|
-
id,
|
|
3374
|
-
name: v.name,
|
|
3375
|
-
icon: v.pt_sol
|
|
3376
|
-
});
|
|
3377
|
-
}
|
|
3378
3466
|
async function fetchUserStakeAccounts(connection, owner) {
|
|
3379
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
3467
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3380
3468
|
const config = getPyeConfig();
|
|
3381
3469
|
const filterVoteAccount = config.voteAccount;
|
|
3382
3470
|
const ownerBase58 = owner.toBase58();
|
|
@@ -3412,7 +3500,6 @@ async function fetchUserStakeAccounts(connection, owner) {
|
|
|
3412
3500
|
const delegation = (_b = (_a = parsed == null ? void 0 : parsed.info) == null ? void 0 : _a.stake) == null ? void 0 : _b.delegation;
|
|
3413
3501
|
if (!(delegation == null ? void 0 : delegation.voter)) continue;
|
|
3414
3502
|
if (filterVoteAccount && delegation.voter !== filterVoteAccount) continue;
|
|
3415
|
-
const validatorInfo = voteAccountToValidator.get(delegation.voter);
|
|
3416
3503
|
const activationEpoch = BigInt((_c = delegation.activationEpoch) != null ? _c : "0");
|
|
3417
3504
|
const deactivationEpoch = BigInt(
|
|
3418
3505
|
(_d = delegation.deactivationEpoch) != null ? _d : U64_MAX.toString()
|
|
@@ -3430,11 +3517,11 @@ async function fetchUserStakeAccounts(connection, owner) {
|
|
|
3430
3517
|
results.push({
|
|
3431
3518
|
pubkey: pubkey.toBase58(),
|
|
3432
3519
|
validatorVoteAccount: delegation.voter,
|
|
3433
|
-
validatorName:
|
|
3434
|
-
validatorIcon:
|
|
3520
|
+
validatorName: "Unknown Validator",
|
|
3521
|
+
validatorIcon: "/solana-token.png",
|
|
3435
3522
|
validatorLogo: null,
|
|
3436
3523
|
validatorAltPubkey: null,
|
|
3437
|
-
lamports: Number((
|
|
3524
|
+
lamports: Number((_e = delegation.stake) != null ? _e : account.lamports),
|
|
3438
3525
|
state
|
|
3439
3526
|
});
|
|
3440
3527
|
}
|
|
@@ -3442,22 +3529,28 @@ async function fetchUserStakeAccounts(connection, owner) {
|
|
|
3442
3529
|
new Set(results.map((r) => r.validatorVoteAccount))
|
|
3443
3530
|
);
|
|
3444
3531
|
if (voteAccounts.length > 0) {
|
|
3445
|
-
const supabase =
|
|
3446
|
-
const { data, error } = await supabase.from("validator_metadata_configs").select("vote_pubkey, base_image_url, alt_pubkey").in("vote_pubkey", voteAccounts);
|
|
3532
|
+
const supabase = createClient6(config.supabaseUrl, config.supabaseAnonKey);
|
|
3533
|
+
const { data, error } = await supabase.from("validator_metadata_configs").select("vote_pubkey, name, pt_image_url, base_image_url, alt_pubkey").in("vote_pubkey", voteAccounts);
|
|
3447
3534
|
if (error) {
|
|
3448
3535
|
console.warn("[fetchUserStakeAccounts] metadata fetch failed:", error);
|
|
3449
3536
|
} else if (data) {
|
|
3450
3537
|
const metaByVote = /* @__PURE__ */ new Map();
|
|
3451
3538
|
for (const row of data) {
|
|
3452
3539
|
metaByVote.set(row.vote_pubkey, {
|
|
3453
|
-
|
|
3454
|
-
|
|
3540
|
+
name: row.name,
|
|
3541
|
+
icon: row.pt_image_url,
|
|
3542
|
+
logo: (_f = row.base_image_url) != null ? _f : null,
|
|
3543
|
+
alt: (_g = row.alt_pubkey) != null ? _g : null
|
|
3455
3544
|
});
|
|
3456
3545
|
}
|
|
3457
3546
|
for (const r of results) {
|
|
3458
3547
|
const meta = metaByVote.get(r.validatorVoteAccount);
|
|
3459
|
-
|
|
3460
|
-
|
|
3548
|
+
if (meta) {
|
|
3549
|
+
r.validatorName = meta.name;
|
|
3550
|
+
r.validatorIcon = meta.icon;
|
|
3551
|
+
r.validatorLogo = meta.logo;
|
|
3552
|
+
r.validatorAltPubkey = meta.alt;
|
|
3553
|
+
}
|
|
3461
3554
|
}
|
|
3462
3555
|
}
|
|
3463
3556
|
}
|
|
@@ -3519,6 +3612,41 @@ async function fetchBalancesForMints(connection, owner, mints) {
|
|
|
3519
3612
|
return balances;
|
|
3520
3613
|
}
|
|
3521
3614
|
|
|
3615
|
+
// src/lib/wallet-balances-cache.ts
|
|
3616
|
+
var STORAGE_PREFIX = "pye.walletBalances.v1.";
|
|
3617
|
+
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
3618
|
+
function getStorage() {
|
|
3619
|
+
try {
|
|
3620
|
+
if (typeof window === "undefined") return null;
|
|
3621
|
+
return window.localStorage;
|
|
3622
|
+
} catch (e) {
|
|
3623
|
+
return null;
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
function readCachedWalletBalances(publicKey) {
|
|
3627
|
+
const storage = getStorage();
|
|
3628
|
+
if (!storage) return null;
|
|
3629
|
+
try {
|
|
3630
|
+
const raw = storage.getItem(STORAGE_PREFIX + publicKey);
|
|
3631
|
+
if (!raw) return null;
|
|
3632
|
+
const parsed = JSON.parse(raw);
|
|
3633
|
+
if (!(parsed == null ? void 0 : parsed.timestamp) || !parsed.balances || typeof parsed.balances !== "object") return null;
|
|
3634
|
+
if (Date.now() - parsed.timestamp > MAX_AGE_MS) return null;
|
|
3635
|
+
return parsed.balances;
|
|
3636
|
+
} catch (e) {
|
|
3637
|
+
return null;
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
function writeCachedWalletBalances(publicKey, balances) {
|
|
3641
|
+
const storage = getStorage();
|
|
3642
|
+
if (!storage) return;
|
|
3643
|
+
try {
|
|
3644
|
+
const payload = { timestamp: Date.now(), balances };
|
|
3645
|
+
storage.setItem(STORAGE_PREFIX + publicKey, JSON.stringify(payload));
|
|
3646
|
+
} catch (e) {
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3522
3650
|
// src/lib/fetch-exchange-balances.ts
|
|
3523
3651
|
import { PublicKey as PublicKey4 } from "@solana/web3.js";
|
|
3524
3652
|
import { Market as Market2 } from "@cks-systems/manifest-sdk";
|
|
@@ -3532,13 +3660,6 @@ async function fetchExchangeBalances(connection, owner, markets) {
|
|
|
3532
3660
|
const perMarketBaseBalances = {};
|
|
3533
3661
|
const SOL_MINT2 = "So11111111111111111111111111111111111111112";
|
|
3534
3662
|
if (markets.length === 0) return { exchangeBalances, openOrdersBalances, solBalances, solOpenOrdersBalances, openOrders, perMarketBaseBalances };
|
|
3535
|
-
const lockups2 = allowedLockups();
|
|
3536
|
-
function getMintAddress(validatorId, maturityId, tokenType) {
|
|
3537
|
-
var _a2;
|
|
3538
|
-
const bond = (_a2 = lockups2[validatorId]) == null ? void 0 : _a2[maturityId];
|
|
3539
|
-
if (!bond) return null;
|
|
3540
|
-
return tokenType === "PT" ? bond.pt_address : bond.rt_address;
|
|
3541
|
-
}
|
|
3542
3663
|
const marketPubkeys = markets.map((m) => new PublicKey4(m.marketPubkey));
|
|
3543
3664
|
const accountInfos = await connection.getMultipleAccountsInfo(marketPubkeys);
|
|
3544
3665
|
let totalSolBalance = 0;
|
|
@@ -3546,7 +3667,7 @@ async function fetchExchangeBalances(connection, owner, markets) {
|
|
|
3546
3667
|
const entry = markets[i];
|
|
3547
3668
|
const info = accountInfos[i];
|
|
3548
3669
|
if (!info) continue;
|
|
3549
|
-
const storeKey = `${entry.
|
|
3670
|
+
const storeKey = `${entry.voteAccount}-${entry.canonicalLabel}-${entry.tokenType}`;
|
|
3550
3671
|
try {
|
|
3551
3672
|
const market = Market2.loadFromBuffer({
|
|
3552
3673
|
address: marketPubkeys[i],
|
|
@@ -3555,15 +3676,9 @@ async function fetchExchangeBalances(connection, owner, markets) {
|
|
|
3555
3676
|
const traderBalances = market.getBalances(owner);
|
|
3556
3677
|
const baseWithdrawable = traderBalances.baseWithdrawableBalanceTokens;
|
|
3557
3678
|
const baseOpenOrders = traderBalances.baseOpenOrdersBalanceTokens;
|
|
3558
|
-
const mint =
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
entry.tokenType
|
|
3562
|
-
);
|
|
3563
|
-
if (mint) {
|
|
3564
|
-
exchangeBalances[mint] = ((_a = exchangeBalances[mint]) != null ? _a : 0) + baseWithdrawable;
|
|
3565
|
-
openOrdersBalances[mint] = ((_b = openOrdersBalances[mint]) != null ? _b : 0) + baseOpenOrders;
|
|
3566
|
-
}
|
|
3679
|
+
const mint = entry.mint;
|
|
3680
|
+
exchangeBalances[mint] = ((_a = exchangeBalances[mint]) != null ? _a : 0) + baseWithdrawable;
|
|
3681
|
+
openOrdersBalances[mint] = ((_b = openOrdersBalances[mint]) != null ? _b : 0) + baseOpenOrders;
|
|
3567
3682
|
perMarketBaseBalances[entry.marketPubkey] = baseWithdrawable;
|
|
3568
3683
|
const quoteWithdrawable = traderBalances.quoteWithdrawableBalanceTokens;
|
|
3569
3684
|
const quoteOpenOrders = traderBalances.quoteOpenOrdersBalanceTokens;
|
|
@@ -3625,9 +3740,17 @@ export {
|
|
|
3625
3740
|
buildMarketLookup,
|
|
3626
3741
|
createMarketStore,
|
|
3627
3742
|
createApyStore,
|
|
3743
|
+
createValidatorStore,
|
|
3744
|
+
selectWidgetValidators,
|
|
3745
|
+
selectWidgetValidator,
|
|
3746
|
+
createLockupStore,
|
|
3747
|
+
selectBondsForValidator,
|
|
3748
|
+
selectBond,
|
|
3628
3749
|
fetchUserStakeAccounts,
|
|
3629
3750
|
fetchBalances,
|
|
3630
3751
|
fetchBalancesForMints,
|
|
3752
|
+
readCachedWalletBalances,
|
|
3753
|
+
writeCachedWalletBalances,
|
|
3631
3754
|
fetchExchangeBalances
|
|
3632
3755
|
};
|
|
3633
|
-
//# sourceMappingURL=chunk-
|
|
3756
|
+
//# sourceMappingURL=chunk-GXXXUTDQ.js.map
|