@wireio/stake 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/stake.browser.js +17 -9
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +8 -0
- package/lib/stake.js +27 -17
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +17 -9
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +31 -1
- package/src/networks/solana/solana.ts +0 -9
package/lib/stake.d.ts
CHANGED
|
@@ -16697,6 +16697,14 @@ declare class OutpostClient {
|
|
|
16697
16697
|
* Internal helper: get raw token balance (BN) for a given ATA.
|
|
16698
16698
|
*/
|
|
16699
16699
|
private getTokenBalance;
|
|
16700
|
+
/**
|
|
16701
|
+
* Fetch an OutpostAccount, handling legacy accounts that pre-date the
|
|
16702
|
+
* three trailing Option<u64> fields. If the normal decode throws a
|
|
16703
|
+
* RangeError we re-fetch the raw data, pad it to the expected size
|
|
16704
|
+
* (zeros → Option::None for each missing field), and let Anchor's
|
|
16705
|
+
* coder decode the padded buffer.
|
|
16706
|
+
*/
|
|
16707
|
+
private fetchOutpostAccount;
|
|
16700
16708
|
/**
|
|
16701
16709
|
* Fetch the core "Wire state" for Outpost / pretokens for a given user.
|
|
16702
16710
|
*/
|
package/lib/stake.js
CHANGED
|
@@ -16579,6 +16579,24 @@ class OutpostClient {
|
|
|
16579
16579
|
return new anchor.BN(bal.value.amount);
|
|
16580
16580
|
});
|
|
16581
16581
|
}
|
|
16582
|
+
fetchOutpostAccount(address) {
|
|
16583
|
+
return __async$c(this, null, function* () {
|
|
16584
|
+
try {
|
|
16585
|
+
return yield this.program.account.outpostAccount.fetchNullable(address);
|
|
16586
|
+
} catch (e) {
|
|
16587
|
+
if (!(e instanceof RangeError)) throw e;
|
|
16588
|
+
const info = yield this.connection.getAccountInfo(address);
|
|
16589
|
+
if (!info) return null;
|
|
16590
|
+
const EXPECTED_SIZE = info.data.length + 3;
|
|
16591
|
+
const padded = Buffer.alloc(EXPECTED_SIZE);
|
|
16592
|
+
info.data.copy(padded);
|
|
16593
|
+
return this.program.coder.accounts.decode(
|
|
16594
|
+
"outpostAccount",
|
|
16595
|
+
padded
|
|
16596
|
+
);
|
|
16597
|
+
}
|
|
16598
|
+
});
|
|
16599
|
+
}
|
|
16582
16600
|
fetchWireState(user) {
|
|
16583
16601
|
return __async$c(this, null, function* () {
|
|
16584
16602
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
@@ -16594,7 +16612,7 @@ class OutpostClient {
|
|
|
16594
16612
|
userLiqsolBalance
|
|
16595
16613
|
] = yield Promise.all([
|
|
16596
16614
|
safeFetch(this.program.account.globalState.fetch(pdas.globalState), "globalState"),
|
|
16597
|
-
safeFetch(this.
|
|
16615
|
+
safeFetch(this.fetchOutpostAccount(pdas.outpostAccount), "outpostAccount"),
|
|
16598
16616
|
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), "distributionState"),
|
|
16599
16617
|
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), "userPretokenRecord"),
|
|
16600
16618
|
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), "trancheState"),
|
|
@@ -17383,7 +17401,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17383
17401
|
}
|
|
17384
17402
|
getPortfolio(address) {
|
|
17385
17403
|
return __async$9(this, null, function* () {
|
|
17386
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
17404
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
17387
17405
|
try {
|
|
17388
17406
|
const user = address ? new web3_js.PublicKey(address) : !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17389
17407
|
const reservePoolPDA = this.program.deriveReservePoolPda();
|
|
@@ -17410,17 +17428,9 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17410
17428
|
const userPretokenRecord = (_f = snapshot == null ? void 0 : snapshot.userPretokenRecord) != null ? _f : null;
|
|
17411
17429
|
const stakedLiqsolStr = (_i = (_h = (_g = outpostAccount == null ? void 0 : outpostAccount.stakedLiqsol) == null ? void 0 : _g.toString) == null ? void 0 : _h.call(_g)) != null ? _i : "0";
|
|
17412
17430
|
const wirePretokensStr = (_l = (_k = (_j = userPretokenRecord == null ? void 0 : userPretokenRecord.totalPretokensPurchased) == null ? void 0 : _j.toString) == null ? void 0 : _k.call(_j)) != null ? _l : "0";
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17416
|
-
if (userPretokenRecord) {
|
|
17417
|
-
for (const [key, value] of Object.entries(userPretokenRecord)) {
|
|
17418
|
-
console.log(`userPretokenRecord.${key}: ${(_o = (_n = value == null ? void 0 : value.toString) == null ? void 0 : _n.call(value)) != null ? _o : value}`);
|
|
17419
|
-
}
|
|
17420
|
-
}
|
|
17421
|
-
const currentIndexStr = (_r = (_q = (_p = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _p.toString) == null ? void 0 : _q.call(_p)) != null ? _r : "0";
|
|
17422
|
-
const totalSharesStr = (_u = (_t = (_s = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _s.toString) == null ? void 0 : _t.call(_s)) != null ? _u : "0";
|
|
17423
|
-
const userSharesStr = (_x = (_w = (_v = outpostAccount == null ? void 0 : outpostAccount.stakedShares) == null ? void 0 : _v.toString) == null ? void 0 : _w.call(_v)) != null ? _x : "0";
|
|
17431
|
+
const currentIndexStr = (_o = (_n = (_m = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _m.toString) == null ? void 0 : _n.call(_m)) != null ? _o : "0";
|
|
17432
|
+
const totalSharesStr = (_r = (_q = (_p = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _p.toString) == null ? void 0 : _q.call(_p)) != null ? _r : "0";
|
|
17433
|
+
const userSharesStr = (_u = (_t = (_s = outpostAccount == null ? void 0 : outpostAccount.stakedShares) == null ? void 0 : _s.toString) == null ? void 0 : _t.call(_s)) != null ? _u : "0";
|
|
17424
17434
|
const stakedLiqsol = BigInt(stakedLiqsolStr);
|
|
17425
17435
|
const currentIndex = BigInt(currentIndexStr);
|
|
17426
17436
|
const totalShares = BigInt(totalSharesStr);
|
|
@@ -17473,10 +17483,10 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17473
17483
|
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
17474
17484
|
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
17475
17485
|
vaultPDA: vaultPDA.toBase58(),
|
|
17476
|
-
globalIndex: (
|
|
17477
|
-
totalShares: (
|
|
17478
|
-
currentTrancheNumber: (
|
|
17479
|
-
currentTranchePriceUsd: (
|
|
17486
|
+
globalIndex: (_v = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _v.toString(),
|
|
17487
|
+
totalShares: (_w = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _w.toString(),
|
|
17488
|
+
currentTrancheNumber: (_x = trancheState == null ? void 0 : trancheState.currentTrancheNumber) == null ? void 0 : _x.toString(),
|
|
17489
|
+
currentTranchePriceUsd: (_y = trancheState == null ? void 0 : trancheState.currentTranchePriceUsd) == null ? void 0 : _y.toString()
|
|
17480
17490
|
},
|
|
17481
17491
|
chainID: this.network.chainId
|
|
17482
17492
|
};
|