@wireio/stake 1.2.69 → 1.4.69

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.m.js CHANGED
@@ -19204,6 +19204,38 @@ class DistributionClient {
19204
19204
 
19205
19205
  const commitment$1 = "confirmed";
19206
19206
  const DEFAULT_SOLANA_EPOCH_CAP = 32;
19207
+ function buildSolanaInstaswapCrossChainAccounts(params) {
19208
+ const {
19209
+ user,
19210
+ accounts,
19211
+ liqsolCoreProgram,
19212
+ transferHookProgram,
19213
+ pendingAttestations
19214
+ } = params;
19215
+ return {
19216
+ user,
19217
+ globalState: accounts.globalState,
19218
+ liqsolMint: accounts.liqsolMint,
19219
+ distributionState: accounts.distributionState,
19220
+ userAta: accounts.userAta,
19221
+ senderUserRecord: accounts.userUserRecord,
19222
+ bridgeAuthority: accounts.bridgeAuthority,
19223
+ bridgeVaultAta: accounts.bridgeVaultAta,
19224
+ bridgeUserRecord: accounts.bridgeUserRecord,
19225
+ bridgeState: accounts.bridgeState,
19226
+ extraAccountMetaList: accounts.extraAccountMetaList,
19227
+ liqsolCoreProgram,
19228
+ transferHookProgram,
19229
+ bucketAuthority: accounts.bucketAuthority,
19230
+ bucketTokenAccount: accounts.bucketTokenAccount,
19231
+ bucketUserRecord: accounts.bucketUserRecord,
19232
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
19233
+ systemProgram: SystemProgram.programId,
19234
+ globalConfig: accounts.globalConfig,
19235
+ oppEpochState: accounts.oppEpochState,
19236
+ pendingAttestations
19237
+ };
19238
+ }
19207
19239
  class SolanaInstaswapClient {
19208
19240
  constructor(provider, pgs, submitInstructions) {
19209
19241
  this.provider = provider;
@@ -19232,29 +19264,15 @@ class SolanaInstaswapClient {
19232
19264
  destinationChain,
19233
19265
  destinationAddress,
19234
19266
  minOut
19235
- ).accounts({
19236
- user,
19237
- globalState: accounts.globalState,
19238
- liqsolMint: accounts.liqsolMint,
19239
- distributionState: accounts.distributionState,
19240
- userAta: accounts.userAta,
19241
- senderUserRecord: accounts.userUserRecord,
19242
- poolAuthority: accounts.poolAuthority,
19243
- liqsolPoolAta: accounts.liqsolPoolAta,
19244
- poolUserRecord: accounts.liqsolPoolUserRecord,
19245
- bridgeState: accounts.bridgeState,
19246
- extraAccountMetaList: accounts.extraAccountMetaList,
19247
- liqsolCoreProgram: this.program.programId,
19248
- transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
19249
- bucketAuthority: accounts.bucketAuthority,
19250
- bucketTokenAccount: accounts.bucketTokenAccount,
19251
- bucketUserRecord: accounts.bucketUserRecord,
19252
- tokenProgram: TOKEN_2022_PROGRAM_ID,
19253
- systemProgram: SystemProgram.programId,
19254
- globalConfig: accounts.globalConfig,
19255
- oppEpochState: accounts.oppEpochState,
19256
- pendingAttestations
19257
- }).preInstructions([
19267
+ ).accounts(
19268
+ buildSolanaInstaswapCrossChainAccounts({
19269
+ user,
19270
+ accounts,
19271
+ liqsolCoreProgram: this.program.programId,
19272
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
19273
+ pendingAttestations
19274
+ })
19275
+ ).preInstructions([
19258
19276
  ComputeBudgetProgram.setComputeUnitLimit({ units: 9e5 })
19259
19277
  ]).rpc()
19260
19278
  );
@@ -19271,29 +19289,15 @@ class SolanaInstaswapClient {
19271
19289
  destinationChain,
19272
19290
  destinationAddress,
19273
19291
  minOut
19274
- ).accounts({
19275
- user,
19276
- globalState: accounts.globalState,
19277
- liqsolMint: accounts.liqsolMint,
19278
- distributionState: accounts.distributionState,
19279
- userAta: accounts.userAta,
19280
- senderUserRecord: accounts.userUserRecord,
19281
- poolAuthority: accounts.poolAuthority,
19282
- liqsolPoolAta: accounts.liqsolPoolAta,
19283
- poolUserRecord: accounts.liqsolPoolUserRecord,
19284
- bridgeState: accounts.bridgeState,
19285
- extraAccountMetaList: accounts.extraAccountMetaList,
19286
- liqsolCoreProgram: this.program.programId,
19287
- transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
19288
- bucketAuthority: accounts.bucketAuthority,
19289
- bucketTokenAccount: accounts.bucketTokenAccount,
19290
- bucketUserRecord: accounts.bucketUserRecord,
19291
- tokenProgram: TOKEN_2022_PROGRAM_ID,
19292
- systemProgram: SystemProgram.programId,
19293
- globalConfig: accounts.globalConfig,
19294
- oppEpochState: accounts.oppEpochState,
19295
- pendingAttestations
19296
- }).preInstructions([
19292
+ ).accounts(
19293
+ buildSolanaInstaswapCrossChainAccounts({
19294
+ user,
19295
+ accounts,
19296
+ liqsolCoreProgram: this.program.programId,
19297
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
19298
+ pendingAttestations
19299
+ })
19300
+ ).preInstructions([
19297
19301
  ComputeBudgetProgram.setComputeUnitLimit({ units: 9e5 })
19298
19302
  ]).rpc()
19299
19303
  );
@@ -19614,6 +19618,34 @@ class LeaderboardClient {
19614
19618
  }
19615
19619
  }
19616
19620
 
19621
+ function buildSolanaSyndicateAccounts(params) {
19622
+ const { user, accounts, liqsolCoreProgram, transferHookProgram } = params;
19623
+ return {
19624
+ user,
19625
+ liqsolMint: accounts.liqsolMint,
19626
+ distributionState: accounts.distributionState,
19627
+ globalState: accounts.globalState,
19628
+ userAta: accounts.userAta,
19629
+ senderUserRecord: accounts.userUserRecord,
19630
+ bridgeAuthority: accounts.bridgeAuthority,
19631
+ bridgeVaultAta: accounts.bridgeVaultAta,
19632
+ bridgeUserRecord: accounts.bridgeUserRecord,
19633
+ bridgeState: accounts.bridgeState,
19634
+ outpostAccount: accounts.outpostAccount,
19635
+ extraAccountMetaList: accounts.extraAccountMetaList,
19636
+ liqsolCoreProgram,
19637
+ transferHookProgram,
19638
+ bucketAuthority: accounts.bucketAuthority,
19639
+ bucketTokenAccount: accounts.bucketTokenAccount,
19640
+ bucketUserRecord: accounts.bucketUserRecord,
19641
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
19642
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
19643
+ systemProgram: SystemProgram.programId,
19644
+ globalConfig: accounts.globalConfig,
19645
+ oppEpochState: accounts.oppEpochState,
19646
+ pendingAttestations: accounts.pendingAttestations
19647
+ };
19648
+ }
19617
19649
  class OutpostClient {
19618
19650
  constructor(provider, pgs) {
19619
19651
  this.provider = provider;
@@ -19695,30 +19727,14 @@ class OutpostClient {
19695
19727
  throw new Error("OutpostClient.buildStakeIx: wireAccount is required");
19696
19728
  }
19697
19729
  const a = await this.buildAccounts(user);
19698
- return program.methods.syndicateLiqsolToWire(wireAccount.trim(), new BN(amountLamports.toString())).accounts({
19699
- user,
19700
- liqsolMint: a.liqsolMint,
19701
- distributionState: a.distributionState,
19702
- globalState: a.globalState,
19703
- userAta: a.userAta,
19704
- senderUserRecord: a.userUserRecord,
19705
- poolAuthority: a.poolAuthority,
19706
- liqsolPoolAta: a.liqsolPoolAta,
19707
- poolUserRecord: a.liqsolPoolUserRecord,
19708
- bridgeState: a.bridgeState,
19709
- extraAccountMetaList: a.extraAccountMetaList,
19710
- liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
19711
- transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
19712
- bucketAuthority: a.bucketAuthority,
19713
- bucketTokenAccount: a.bucketTokenAccount,
19714
- bucketUserRecord: a.bucketUserRecord,
19715
- tokenProgram: TOKEN_2022_PROGRAM_ID,
19716
- associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
19717
- systemProgram: SystemProgram.programId,
19718
- globalConfig: a.globalConfig,
19719
- oppEpochState: a.oppEpochState,
19720
- pendingAttestations: a.pendingAttestations
19721
- }).instruction();
19730
+ return program.methods.syndicateLiqsolToWire(wireAccount.trim(), new BN(amountLamports.toString())).accounts(
19731
+ buildSolanaSyndicateAccounts({
19732
+ user,
19733
+ accounts: a,
19734
+ liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
19735
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK
19736
+ })
19737
+ ).instruction();
19722
19738
  }
19723
19739
  async buildUnstakeIx(amountLamports, user) {
19724
19740
  const program = this.program;
@@ -71240,6 +71256,8 @@ class EthereumContractService {
71240
71256
  }
71241
71257
 
71242
71258
  BigInt(1e4);
71259
+ const DEFAULT_WRITE_GAS_PADDING_BPS = 2e3;
71260
+ const DEFAULT_WRITE_GAS_FALLBACK_LIMIT = ethers.BigNumber.from(8e6);
71243
71261
  function formatContractErrors(err) {
71244
71262
  if (err.errorName && err.errorArgs) {
71245
71263
  const errorObj = {
@@ -71309,6 +71327,39 @@ async function sendOPPFinalize(opp, gasLimit) {
71309
71327
  throw err;
71310
71328
  }
71311
71329
  }
71330
+ async function resolveContractWriteOverrides(contract, method, args = [], overrides = {}, options) {
71331
+ if (overrides["gasLimit"] != null) {
71332
+ return overrides;
71333
+ }
71334
+ const paddingBps = options?.paddingBps ?? DEFAULT_WRITE_GAS_PADDING_BPS;
71335
+ const fallbackGasLimit = ethers.BigNumber.from(
71336
+ options?.fallbackGasLimit ?? DEFAULT_WRITE_GAS_FALLBACK_LIMIT
71337
+ );
71338
+ try {
71339
+ const estimateGas = contract.estimateGas?.[method];
71340
+ if (typeof estimateGas !== "function") {
71341
+ return {
71342
+ ...overrides,
71343
+ gasLimit: fallbackGasLimit
71344
+ };
71345
+ }
71346
+ const estimated = await estimateGas(...args, overrides);
71347
+ const gasLimit = ethers.BigNumber.from(estimated).mul(1e4 + paddingBps).div(1e4);
71348
+ return {
71349
+ ...overrides,
71350
+ gasLimit
71351
+ };
71352
+ } catch (error) {
71353
+ console.warn(
71354
+ `[EthereumGas] estimateGas.${method} failed, using fallback gasLimit ${fallbackGasLimit.toString()}`,
71355
+ error
71356
+ );
71357
+ return {
71358
+ ...overrides,
71359
+ gasLimit: fallbackGasLimit
71360
+ };
71361
+ }
71362
+ }
71312
71363
  const BPS_DENOM = BigInt(1e4);
71313
71364
  const USD_ONCHAIN_SCALE = BigInt(1e18);
71314
71365
  const USD_CLIENT_SCALE = BigInt(1e8);
@@ -72722,11 +72773,17 @@ class EthereumInstaswapClient {
72722
72773
  destinationAddress,
72723
72774
  minOut
72724
72775
  );
72776
+ const txOverrides = await resolveContractWriteOverrides(
72777
+ depositorWrite,
72778
+ "instaswapCrossChain",
72779
+ [amountIn, destinationChain, destinationAddress, minOut]
72780
+ );
72725
72781
  const swapTx = await depositorWrite["instaswapCrossChain"](
72726
72782
  amountIn,
72727
72783
  destinationChain,
72728
72784
  destinationAddress,
72729
- minOut
72785
+ minOut,
72786
+ txOverrides
72730
72787
  );
72731
72788
  await hooks?.onSubmitted?.(swapTx.hash);
72732
72789
  const receipt = await swapTx.wait();
@@ -73022,7 +73079,12 @@ class StakeClient {
73022
73079
  let errorObj = formatContractErrors(err);
73023
73080
  throw new Error(errorObj.name ?? errorObj.raw);
73024
73081
  }
73025
- const tx = await this.contract.Depositor.stakeLiqETH(amountWei);
73082
+ const txOverrides = await resolveContractWriteOverrides(
73083
+ this.contract.Depositor,
73084
+ "stakeLiqETH",
73085
+ [amountWei]
73086
+ );
73087
+ const tx = await this.contract.Depositor.stakeLiqETH(amountWei, txOverrides);
73026
73088
  const receipt = await tx.wait(1);
73027
73089
  let staked;
73028
73090
  const ev = receipt.events?.find((e) => e.event === "Staked");
@@ -73069,7 +73131,12 @@ class StakeClient {
73069
73131
  let errorObj = formatContractErrors(err);
73070
73132
  throw new Error(`StakeClient.performStakeToWire: ${errorObj.name ?? errorObj.raw}`);
73071
73133
  }
73072
- const tx = await this.contract.Depositor.stakeLiqETHToWire(amountWei, wireAccount);
73134
+ const txOverrides = await resolveContractWriteOverrides(
73135
+ this.contract.Depositor,
73136
+ "stakeLiqETHToWire",
73137
+ [amountWei, wireAccount]
73138
+ );
73139
+ const tx = await this.contract.Depositor.stakeLiqETHToWire(amountWei, wireAccount, txOverrides);
73073
73140
  const receipt = await tx.wait(1);
73074
73141
  let staked;
73075
73142
  const ev = receipt.events?.find((e) => e.event === "Staked");
@@ -73114,7 +73181,13 @@ class StakeClient {
73114
73181
  let errorObj = formatContractErrors(err);
73115
73182
  throw new Error(errorObj.name ?? errorObj.raw);
73116
73183
  }
73117
- const tx = await this.contract.Depositor.depositAndStake({ value: amountWei });
73184
+ const txOverrides = await resolveContractWriteOverrides(
73185
+ this.contract.Depositor,
73186
+ "depositAndStake",
73187
+ [],
73188
+ { value: amountWei }
73189
+ );
73190
+ const tx = await this.contract.Depositor.depositAndStake(txOverrides);
73118
73191
  const receipt = await tx.wait(1);
73119
73192
  let staked;
73120
73193
  const ev = receipt.events?.find((e) => e.event === "Staked");
@@ -73161,7 +73234,13 @@ class StakeClient {
73161
73234
  let errorObj = formatContractErrors(err);
73162
73235
  throw new Error(errorObj.name ?? errorObj.raw);
73163
73236
  }
73164
- const tx = await this.contract.Depositor.depositAndPurchase({ value: amountWei });
73237
+ const txOverrides = await resolveContractWriteOverrides(
73238
+ this.contract.Depositor,
73239
+ "depositAndPurchase",
73240
+ [],
73241
+ { value: amountWei }
73242
+ );
73243
+ const tx = await this.contract.Depositor.depositAndPurchase(txOverrides);
73165
73244
  const receipt = await tx.wait(1);
73166
73245
  return { txHash: tx.hash, receipt };
73167
73246
  }
@@ -73172,7 +73251,12 @@ class StakeClient {
73172
73251
  let errorObj = formatContractErrors(err);
73173
73252
  throw new Error(errorObj.name ?? errorObj.raw);
73174
73253
  }
73175
- const tx = await this.contract.Depositor.unstakeAndRequestWithdraw(tokenId);
73254
+ const txOverrides = await resolveContractWriteOverrides(
73255
+ this.contract.Depositor,
73256
+ "unstakeAndRequestWithdraw",
73257
+ [tokenId]
73258
+ );
73259
+ const tx = await this.contract.Depositor.unstakeAndRequestWithdraw(tokenId, txOverrides);
73176
73260
  const receipt = await tx.wait(1);
73177
73261
  return { txHash: tx.hash, receipt };
73178
73262
  }
@@ -73221,7 +73305,12 @@ class PretokenClient {
73221
73305
  }
73222
73306
  let tx, receipt;
73223
73307
  try {
73224
- tx = await this.contract.Depositor.purchasePretokensWithLiqETH(amountLiq, buyer);
73308
+ const txOverrides = await resolveContractWriteOverrides(
73309
+ this.contract.Depositor,
73310
+ "purchasePretokensWithLiqETH",
73311
+ [amountLiq, buyer]
73312
+ );
73313
+ tx = await this.contract.Depositor.purchasePretokensWithLiqETH(amountLiq, buyer, txOverrides);
73225
73314
  receipt = await tx.wait(1);
73226
73315
  } catch (err) {
73227
73316
  let errorObj = formatContractErrors(err);
@@ -74113,5 +74202,5 @@ var types = /*#__PURE__*/Object.freeze({
74113
74202
  __proto__: null
74114
74203
  });
74115
74204
 
74116
- export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumInstaswapClient, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as 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, SolanaInstaswapClient, 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 };
74205
+ export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumInstaswapClient, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as 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, SolanaInstaswapClient, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaInstaswapCrossChainAccounts, buildSolanaSyndicateAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, safeFetch, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
74117
74206
  //# sourceMappingURL=stake.m.js.map