@wireio/stake 2.4.4 → 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 +52 -39
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +19 -6
- package/lib/stake.js +53 -37
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +52 -39
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +61 -42
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
package/lib/stake.d.ts
CHANGED
|
@@ -784,7 +784,11 @@ type ParsedAccountInfo = {
|
|
|
784
784
|
* fetching all relevant on-chain accounts for a given user.
|
|
785
785
|
*/
|
|
786
786
|
type OutpostWireStateSnapshot = {
|
|
787
|
-
|
|
787
|
+
/**
|
|
788
|
+
* Global Wire/outpost state.
|
|
789
|
+
* May be null if the fetch fails.
|
|
790
|
+
*/
|
|
791
|
+
globalState: GlobalState | null;
|
|
788
792
|
/**
|
|
789
793
|
* Per-user Outpost account (old “wire receipt”), or null if user
|
|
790
794
|
* hasn’t interacted yet.
|
|
@@ -804,10 +808,10 @@ type OutpostWireStateSnapshot = {
|
|
|
804
808
|
* May be null if the user never purchased.
|
|
805
809
|
*/
|
|
806
810
|
userPretokenRecord: UserPretokenRecord | null;
|
|
807
|
-
/** liqSOL in the pool ATA (Token-2022 raw amount) */
|
|
808
|
-
liqsolPoolBalance: BN;
|
|
809
|
-
/** liqSOL in the user’s ATA (Token-2022 raw amount) */
|
|
810
|
-
userLiqsolBalance: BN;
|
|
811
|
+
/** liqSOL in the pool ATA (Token-2022 raw amount), or null on fetch failure */
|
|
812
|
+
liqsolPoolBalance: BN | null;
|
|
813
|
+
/** liqSOL in the user’s ATA (Token-2022 raw amount), or null on fetch failure */
|
|
814
|
+
userLiqsolBalance: BN | null;
|
|
811
815
|
};
|
|
812
816
|
/**
|
|
813
817
|
* ============================================================
|
|
@@ -16660,6 +16664,7 @@ interface ScheduleConfig {
|
|
|
16660
16664
|
}
|
|
16661
16665
|
declare function ceilDiv(n: BN, d: BN): BN;
|
|
16662
16666
|
declare function normalizeToBigInt(x: any): bigint;
|
|
16667
|
+
declare const safeFetch: <T>(promise: Promise<T>, label?: string) => Promise<T | null>;
|
|
16663
16668
|
|
|
16664
16669
|
/**
|
|
16665
16670
|
* OutpostClient
|
|
@@ -16692,6 +16697,14 @@ declare class OutpostClient {
|
|
|
16692
16697
|
* Internal helper: get raw token balance (BN) for a given ATA.
|
|
16693
16698
|
*/
|
|
16694
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;
|
|
16695
16708
|
/**
|
|
16696
16709
|
* Fetch the core "Wire state" for Outpost / pretokens for a given user.
|
|
16697
16710
|
*/
|
|
@@ -16979,5 +16992,5 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
16979
16992
|
private getSingleTxFeeLamports;
|
|
16980
16993
|
}
|
|
16981
16994
|
|
|
16982
|
-
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
16995
|
+
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, safeFetch, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
16983
16996
|
export type { BalanceView, ChainSymbol, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OPPAssertion, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, SolanaProgramIds, SquadsXConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, WithdrawReceipt$1 as WithdrawReceipt, WithdrawStatus, YieldView };
|
package/lib/stake.js
CHANGED
|
@@ -15915,6 +15915,14 @@ function normalizeToBigInt(x) {
|
|
|
15915
15915
|
if (typeof x === "number") return BigInt(x);
|
|
15916
15916
|
throw new Error(`normalizeToBigInt: unsupported type ${typeof x}`);
|
|
15917
15917
|
}
|
|
15918
|
+
const safeFetch = (promise, label) => __async$g(null, null, function* () {
|
|
15919
|
+
try {
|
|
15920
|
+
return yield promise;
|
|
15921
|
+
} catch (err) {
|
|
15922
|
+
console.error(`Safe Fetch Failed${label ? ` (${label})` : ""}:`, err);
|
|
15923
|
+
return null;
|
|
15924
|
+
}
|
|
15925
|
+
});
|
|
15918
15926
|
|
|
15919
15927
|
var __pow = Math.pow;
|
|
15920
15928
|
var __async$f = (__this, __arguments, generator) => {
|
|
@@ -16566,53 +16574,60 @@ class OutpostClient {
|
|
|
16566
16574
|
});
|
|
16567
16575
|
}
|
|
16568
16576
|
getTokenBalance(ata) {
|
|
16577
|
+
return __async$c(this, null, function* () {
|
|
16578
|
+
const bal = yield this.connection.getTokenAccountBalance(ata);
|
|
16579
|
+
return new anchor.BN(bal.value.amount);
|
|
16580
|
+
});
|
|
16581
|
+
}
|
|
16582
|
+
fetchOutpostAccount(address) {
|
|
16569
16583
|
return __async$c(this, null, function* () {
|
|
16570
16584
|
try {
|
|
16571
|
-
|
|
16572
|
-
return new anchor.BN(bal.value.amount);
|
|
16585
|
+
return yield this.program.account.outpostAccount.fetchNullable(address);
|
|
16573
16586
|
} catch (e) {
|
|
16574
|
-
|
|
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
|
+
);
|
|
16575
16597
|
}
|
|
16576
16598
|
});
|
|
16577
16599
|
}
|
|
16578
16600
|
fetchWireState(user) {
|
|
16579
16601
|
return __async$c(this, null, function* () {
|
|
16580
16602
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
16581
|
-
if (!userPk)
|
|
16582
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16583
|
-
}
|
|
16603
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16584
16604
|
const pdas = yield this.buildAccounts(userPk);
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16590
|
-
|
|
16591
|
-
|
|
16592
|
-
|
|
16593
|
-
|
|
16594
|
-
|
|
16595
|
-
|
|
16596
|
-
|
|
16597
|
-
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
|
|
16610
|
-
|
|
16611
|
-
};
|
|
16612
|
-
} catch (err) {
|
|
16613
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16614
|
-
throw err;
|
|
16615
|
-
}
|
|
16605
|
+
const [
|
|
16606
|
+
globalState,
|
|
16607
|
+
outpostAccount,
|
|
16608
|
+
distributionState,
|
|
16609
|
+
userPretokenRecord,
|
|
16610
|
+
trancheState,
|
|
16611
|
+
liqsolPoolBalance,
|
|
16612
|
+
userLiqsolBalance
|
|
16613
|
+
] = yield Promise.all([
|
|
16614
|
+
safeFetch(this.program.account.globalState.fetch(pdas.globalState), "globalState"),
|
|
16615
|
+
safeFetch(this.fetchOutpostAccount(pdas.outpostAccount), "outpostAccount"),
|
|
16616
|
+
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), "distributionState"),
|
|
16617
|
+
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), "userPretokenRecord"),
|
|
16618
|
+
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), "trancheState"),
|
|
16619
|
+
safeFetch(this.getTokenBalance(pdas.liqsolPoolAta), "liqsolPoolAta"),
|
|
16620
|
+
safeFetch(this.getTokenBalance(pdas.userAta), "userAta")
|
|
16621
|
+
]);
|
|
16622
|
+
return {
|
|
16623
|
+
globalState,
|
|
16624
|
+
outpostAccount,
|
|
16625
|
+
distributionState,
|
|
16626
|
+
trancheState,
|
|
16627
|
+
userPretokenRecord,
|
|
16628
|
+
liqsolPoolBalance,
|
|
16629
|
+
userLiqsolBalance
|
|
16630
|
+
};
|
|
16616
16631
|
});
|
|
16617
16632
|
}
|
|
16618
16633
|
buildStakeIx(_0) {
|
|
@@ -43699,6 +43714,7 @@ exports.getProgramIds = getProgramIds;
|
|
|
43699
43714
|
exports.lamportsToSol = lamportsToSol;
|
|
43700
43715
|
exports.msToEpochEnd = msToEpochEnd;
|
|
43701
43716
|
exports.normalizeToBigInt = normalizeToBigInt;
|
|
43717
|
+
exports.safeFetch = safeFetch;
|
|
43702
43718
|
exports.scheduledInstruction = scheduledInstruction;
|
|
43703
43719
|
exports.sleep = sleep;
|
|
43704
43720
|
exports.solToLamports = solToLamports;
|