@wireio/stake 1.3.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/README.md +2 -0
- package/lib/stake.browser.js +117 -32
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +31 -1
- package/lib/stake.js +152 -47
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +117 -32
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/ethereum/clients/instaswap.client.ts +8 -1
- package/src/networks/ethereum/clients/pretoken.client.ts +8 -3
- package/src/networks/ethereum/clients/stake.client.ts +33 -6
- package/src/networks/ethereum/utils.ts +53 -1
- package/src/networks/solana/clients/outpost.client.ts +43 -24
package/lib/stake.m.js
CHANGED
|
@@ -19618,6 +19618,34 @@ class LeaderboardClient {
|
|
|
19618
19618
|
}
|
|
19619
19619
|
}
|
|
19620
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
|
+
}
|
|
19621
19649
|
class OutpostClient {
|
|
19622
19650
|
constructor(provider, pgs) {
|
|
19623
19651
|
this.provider = provider;
|
|
@@ -19699,30 +19727,14 @@ class OutpostClient {
|
|
|
19699
19727
|
throw new Error("OutpostClient.buildStakeIx: wireAccount is required");
|
|
19700
19728
|
}
|
|
19701
19729
|
const a = await this.buildAccounts(user);
|
|
19702
|
-
return program.methods.syndicateLiqsolToWire(wireAccount.trim(), new BN(amountLamports.toString())).accounts(
|
|
19703
|
-
|
|
19704
|
-
|
|
19705
|
-
|
|
19706
|
-
|
|
19707
|
-
|
|
19708
|
-
|
|
19709
|
-
|
|
19710
|
-
liqsolPoolAta: a.liqsolPoolAta,
|
|
19711
|
-
poolUserRecord: a.liqsolPoolUserRecord,
|
|
19712
|
-
bridgeState: a.bridgeState,
|
|
19713
|
-
extraAccountMetaList: a.extraAccountMetaList,
|
|
19714
|
-
liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
|
|
19715
|
-
transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
|
|
19716
|
-
bucketAuthority: a.bucketAuthority,
|
|
19717
|
-
bucketTokenAccount: a.bucketTokenAccount,
|
|
19718
|
-
bucketUserRecord: a.bucketUserRecord,
|
|
19719
|
-
tokenProgram: TOKEN_2022_PROGRAM_ID,
|
|
19720
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
19721
|
-
systemProgram: SystemProgram.programId,
|
|
19722
|
-
globalConfig: a.globalConfig,
|
|
19723
|
-
oppEpochState: a.oppEpochState,
|
|
19724
|
-
pendingAttestations: a.pendingAttestations
|
|
19725
|
-
}).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();
|
|
19726
19738
|
}
|
|
19727
19739
|
async buildUnstakeIx(amountLamports, user) {
|
|
19728
19740
|
const program = this.program;
|
|
@@ -71244,6 +71256,8 @@ class EthereumContractService {
|
|
|
71244
71256
|
}
|
|
71245
71257
|
|
|
71246
71258
|
BigInt(1e4);
|
|
71259
|
+
const DEFAULT_WRITE_GAS_PADDING_BPS = 2e3;
|
|
71260
|
+
const DEFAULT_WRITE_GAS_FALLBACK_LIMIT = ethers.BigNumber.from(8e6);
|
|
71247
71261
|
function formatContractErrors(err) {
|
|
71248
71262
|
if (err.errorName && err.errorArgs) {
|
|
71249
71263
|
const errorObj = {
|
|
@@ -71313,6 +71327,39 @@ async function sendOPPFinalize(opp, gasLimit) {
|
|
|
71313
71327
|
throw err;
|
|
71314
71328
|
}
|
|
71315
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
|
+
}
|
|
71316
71363
|
const BPS_DENOM = BigInt(1e4);
|
|
71317
71364
|
const USD_ONCHAIN_SCALE = BigInt(1e18);
|
|
71318
71365
|
const USD_CLIENT_SCALE = BigInt(1e8);
|
|
@@ -72726,11 +72773,17 @@ class EthereumInstaswapClient {
|
|
|
72726
72773
|
destinationAddress,
|
|
72727
72774
|
minOut
|
|
72728
72775
|
);
|
|
72776
|
+
const txOverrides = await resolveContractWriteOverrides(
|
|
72777
|
+
depositorWrite,
|
|
72778
|
+
"instaswapCrossChain",
|
|
72779
|
+
[amountIn, destinationChain, destinationAddress, minOut]
|
|
72780
|
+
);
|
|
72729
72781
|
const swapTx = await depositorWrite["instaswapCrossChain"](
|
|
72730
72782
|
amountIn,
|
|
72731
72783
|
destinationChain,
|
|
72732
72784
|
destinationAddress,
|
|
72733
|
-
minOut
|
|
72785
|
+
minOut,
|
|
72786
|
+
txOverrides
|
|
72734
72787
|
);
|
|
72735
72788
|
await hooks?.onSubmitted?.(swapTx.hash);
|
|
72736
72789
|
const receipt = await swapTx.wait();
|
|
@@ -73026,7 +73079,12 @@ class StakeClient {
|
|
|
73026
73079
|
let errorObj = formatContractErrors(err);
|
|
73027
73080
|
throw new Error(errorObj.name ?? errorObj.raw);
|
|
73028
73081
|
}
|
|
73029
|
-
const
|
|
73082
|
+
const txOverrides = await resolveContractWriteOverrides(
|
|
73083
|
+
this.contract.Depositor,
|
|
73084
|
+
"stakeLiqETH",
|
|
73085
|
+
[amountWei]
|
|
73086
|
+
);
|
|
73087
|
+
const tx = await this.contract.Depositor.stakeLiqETH(amountWei, txOverrides);
|
|
73030
73088
|
const receipt = await tx.wait(1);
|
|
73031
73089
|
let staked;
|
|
73032
73090
|
const ev = receipt.events?.find((e) => e.event === "Staked");
|
|
@@ -73073,7 +73131,12 @@ class StakeClient {
|
|
|
73073
73131
|
let errorObj = formatContractErrors(err);
|
|
73074
73132
|
throw new Error(`StakeClient.performStakeToWire: ${errorObj.name ?? errorObj.raw}`);
|
|
73075
73133
|
}
|
|
73076
|
-
const
|
|
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);
|
|
73077
73140
|
const receipt = await tx.wait(1);
|
|
73078
73141
|
let staked;
|
|
73079
73142
|
const ev = receipt.events?.find((e) => e.event === "Staked");
|
|
@@ -73118,7 +73181,13 @@ class StakeClient {
|
|
|
73118
73181
|
let errorObj = formatContractErrors(err);
|
|
73119
73182
|
throw new Error(errorObj.name ?? errorObj.raw);
|
|
73120
73183
|
}
|
|
73121
|
-
const
|
|
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);
|
|
73122
73191
|
const receipt = await tx.wait(1);
|
|
73123
73192
|
let staked;
|
|
73124
73193
|
const ev = receipt.events?.find((e) => e.event === "Staked");
|
|
@@ -73165,7 +73234,13 @@ class StakeClient {
|
|
|
73165
73234
|
let errorObj = formatContractErrors(err);
|
|
73166
73235
|
throw new Error(errorObj.name ?? errorObj.raw);
|
|
73167
73236
|
}
|
|
73168
|
-
const
|
|
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);
|
|
73169
73244
|
const receipt = await tx.wait(1);
|
|
73170
73245
|
return { txHash: tx.hash, receipt };
|
|
73171
73246
|
}
|
|
@@ -73176,7 +73251,12 @@ class StakeClient {
|
|
|
73176
73251
|
let errorObj = formatContractErrors(err);
|
|
73177
73252
|
throw new Error(errorObj.name ?? errorObj.raw);
|
|
73178
73253
|
}
|
|
73179
|
-
const
|
|
73254
|
+
const txOverrides = await resolveContractWriteOverrides(
|
|
73255
|
+
this.contract.Depositor,
|
|
73256
|
+
"unstakeAndRequestWithdraw",
|
|
73257
|
+
[tokenId]
|
|
73258
|
+
);
|
|
73259
|
+
const tx = await this.contract.Depositor.unstakeAndRequestWithdraw(tokenId, txOverrides);
|
|
73180
73260
|
const receipt = await tx.wait(1);
|
|
73181
73261
|
return { txHash: tx.hash, receipt };
|
|
73182
73262
|
}
|
|
@@ -73225,7 +73305,12 @@ class PretokenClient {
|
|
|
73225
73305
|
}
|
|
73226
73306
|
let tx, receipt;
|
|
73227
73307
|
try {
|
|
73228
|
-
|
|
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);
|
|
73229
73314
|
receipt = await tx.wait(1);
|
|
73230
73315
|
} catch (err) {
|
|
73231
73316
|
let errorObj = formatContractErrors(err);
|
|
@@ -74117,5 +74202,5 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
74117
74202
|
__proto__: null
|
|
74118
74203
|
});
|
|
74119
74204
|
|
|
74120
|
-
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, 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 };
|
|
74121
74206
|
//# sourceMappingURL=stake.m.js.map
|