@0dotxyz/p0-ts-sdk 2.3.0-alpha.3 → 2.3.0-alpha.4

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/vendor.cjs CHANGED
@@ -32348,11 +32348,13 @@ function selectBestRoute(quotes, swapMode) {
32348
32348
  }
32349
32349
  function buildSwapQuoteResult(route, swapMode) {
32350
32350
  const slippageBps = route.slippageBps;
32351
+ const outAmount = Number(route.outAmount);
32352
+ const inAmount = Number(route.inAmount);
32351
32353
  let otherAmountThreshold;
32352
32354
  if (swapMode === "ExactIn") {
32353
- otherAmountThreshold = String(Math.floor(route.outAmount * (1 - slippageBps / 1e4)));
32355
+ otherAmountThreshold = String(Math.floor(outAmount * (1 - slippageBps / 1e4)));
32354
32356
  } else {
32355
- otherAmountThreshold = String(Math.ceil(route.inAmount * (1 + slippageBps / 1e4)));
32357
+ otherAmountThreshold = String(Math.ceil(inAmount * (1 + slippageBps / 1e4)));
32356
32358
  }
32357
32359
  return {
32358
32360
  inAmount: String(route.inAmount),
@@ -39854,6 +39856,153 @@ function deriveExponentEventAuthority() {
39854
39856
  EXPONENT_CORE_PROGRAM_ID
39855
39857
  )[0];
39856
39858
  }
39859
+ var MERGE_DISCRIMINATOR = Buffer.from([5]);
39860
+ function makeExponentMergeIx(accounts, amountNative) {
39861
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39862
+ const eventAuthority = deriveExponentEventAuthority();
39863
+ const data = Buffer.alloc(MERGE_DISCRIMINATOR.length + 8);
39864
+ MERGE_DISCRIMINATOR.copy(data, 0);
39865
+ data.writeBigUInt64LE(amountNative, MERGE_DISCRIMINATOR.length);
39866
+ const keys = [
39867
+ { pubkey: accounts.owner, isSigner: true, isWritable: true },
39868
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39869
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39870
+ { pubkey: accounts.sySrcDstAta, isSigner: false, isWritable: true },
39871
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39872
+ { pubkey: accounts.ytSrcAta, isSigner: false, isWritable: true },
39873
+ { pubkey: accounts.ptSrcAta, isSigner: false, isWritable: true },
39874
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39875
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39876
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39877
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39878
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39879
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39880
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39881
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39882
+ // SY-program CPI accounts (getSyState ++ withdrawSy), ALT-resolved (post-maturity merge
39883
+ // still CPIs into the SY program to move SY out of escrow).
39884
+ ...accounts.remainingAccounts ?? []
39885
+ ];
39886
+ return new web3_js.TransactionInstruction({
39887
+ keys,
39888
+ programId: EXPONENT_CORE_PROGRAM_ID,
39889
+ data
39890
+ });
39891
+ }
39892
+ var TRADE_PT_DISCRIMINATOR = Buffer.from([17]);
39893
+ function exponentBuyPtArgs({
39894
+ ptOutNative,
39895
+ maxSyInNative
39896
+ }) {
39897
+ return { netTraderPt: ptOutNative, syConstraint: -maxSyInNative };
39898
+ }
39899
+ function makeExponentTradePtIx(accounts, args) {
39900
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39901
+ const eventAuthority = deriveExponentEventAuthority();
39902
+ const data = Buffer.alloc(TRADE_PT_DISCRIMINATOR.length + 16);
39903
+ TRADE_PT_DISCRIMINATOR.copy(data, 0);
39904
+ data.writeBigInt64LE(args.netTraderPt, TRADE_PT_DISCRIMINATOR.length);
39905
+ data.writeBigInt64LE(args.syConstraint, TRADE_PT_DISCRIMINATOR.length + 8);
39906
+ const keys = [
39907
+ { pubkey: accounts.trader, isSigner: true, isWritable: true },
39908
+ { pubkey: accounts.market, isSigner: false, isWritable: true },
39909
+ { pubkey: accounts.tokenSyTrader, isSigner: false, isWritable: true },
39910
+ { pubkey: accounts.tokenPtTrader, isSigner: false, isWritable: true },
39911
+ { pubkey: accounts.tokenSyEscrow, isSigner: false, isWritable: true },
39912
+ { pubkey: accounts.tokenPtEscrow, isSigner: false, isWritable: true },
39913
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39914
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39915
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39916
+ { pubkey: accounts.tokenFeeTreasurySy, isSigner: false, isWritable: true },
39917
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39918
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39919
+ // SY-program CPI accounts (getSyState ++ depositSy ++ withdrawSy), ALT-resolved.
39920
+ ...accounts.remainingAccounts
39921
+ ];
39922
+ return new web3_js.TransactionInstruction({
39923
+ keys,
39924
+ programId: EXPONENT_CORE_PROGRAM_ID,
39925
+ data
39926
+ });
39927
+ }
39928
+ var STRIP_DISCRIMINATOR = Buffer.from([4]);
39929
+ function makeExponentStripIx(accounts, amountNative) {
39930
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39931
+ const eventAuthority = deriveExponentEventAuthority();
39932
+ const data = Buffer.alloc(STRIP_DISCRIMINATOR.length + 8);
39933
+ STRIP_DISCRIMINATOR.copy(data, 0);
39934
+ data.writeBigUInt64LE(amountNative, STRIP_DISCRIMINATOR.length);
39935
+ const keys = [
39936
+ { pubkey: accounts.depositor, isSigner: true, isWritable: true },
39937
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39938
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39939
+ { pubkey: accounts.sySrc, isSigner: false, isWritable: true },
39940
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39941
+ { pubkey: accounts.ytDst, isSigner: false, isWritable: true },
39942
+ { pubkey: accounts.ptDst, isSigner: false, isWritable: true },
39943
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39944
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39945
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39946
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39947
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39948
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39949
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39950
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39951
+ // SY-program CPI accounts (depositSy), ALT-resolved.
39952
+ ...accounts.remainingAccounts ?? []
39953
+ ];
39954
+ return new web3_js.TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
39955
+ }
39956
+ var WRAPPER_MERGE_DISCRIMINATOR = Buffer.from([39]);
39957
+ function makeExponentWrapperMergeIx(accounts, args) {
39958
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39959
+ const eventAuthority = deriveExponentEventAuthority();
39960
+ const data = Buffer.alloc(WRAPPER_MERGE_DISCRIMINATOR.length + 9);
39961
+ WRAPPER_MERGE_DISCRIMINATOR.copy(data, 0);
39962
+ data.writeBigUInt64LE(args.amountPyNative, WRAPPER_MERGE_DISCRIMINATOR.length);
39963
+ data.writeUInt8(args.redeemSyAccountsUntil, WRAPPER_MERGE_DISCRIMINATOR.length + 8);
39964
+ const keys = [
39965
+ { pubkey: accounts.owner, isSigner: true, isWritable: true },
39966
+ { pubkey: accounts.syAta, isSigner: false, isWritable: true },
39967
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39968
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39969
+ { pubkey: accounts.ytAta, isSigner: false, isWritable: true },
39970
+ { pubkey: accounts.ptAta, isSigner: false, isWritable: true },
39971
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39972
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39973
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39974
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39975
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39976
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39977
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39978
+ { pubkey: web3_js.SystemProgram.programId, isSigner: false, isWritable: false },
39979
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39980
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39981
+ // [...redeem (flavor SY-redeem accounts), ...cpi (withdraw_sy ++ get_sy_state)]
39982
+ ...accounts.remainingAccounts
39983
+ ];
39984
+ return new web3_js.TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
39985
+ }
39986
+ var SPL_STAKE_POOL_UPDATE_BALANCE_TAG = Buffer.from([7]);
39987
+ function makeSplStakePoolUpdateBalanceIx(accounts) {
39988
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39989
+ const keys = [
39990
+ { pubkey: accounts.stakePool, isSigner: false, isWritable: true },
39991
+ { pubkey: accounts.withdrawAuthority, isSigner: false, isWritable: false },
39992
+ { pubkey: accounts.validatorList, isSigner: false, isWritable: true },
39993
+ { pubkey: accounts.reserveStake, isSigner: false, isWritable: false },
39994
+ { pubkey: accounts.managerFeeAccount, isSigner: false, isWritable: true },
39995
+ { pubkey: accounts.poolMint, isSigner: false, isWritable: true },
39996
+ { pubkey: tokenProgram, isSigner: false, isWritable: false }
39997
+ ];
39998
+ return new web3_js.TransactionInstruction({
39999
+ keys,
40000
+ programId: accounts.stakePoolProgram,
40001
+ data: Buffer.from(SPL_STAKE_POOL_UPDATE_BALANCE_TAG)
40002
+ });
40003
+ }
40004
+
40005
+ // src/vendor/exponent/utils/resolve.utils.ts
39857
40006
  function resolveCpiMetas(contexts, altAddresses, altKey) {
39858
40007
  return contexts.map((ctx) => {
39859
40008
  const pubkey = altAddresses[ctx.altIndex];
@@ -39865,6 +40014,22 @@ function resolveCpiMetas(contexts, altAddresses, altKey) {
39865
40014
  return { pubkey, isSigner: false, isWritable: ctx.isWritable };
39866
40015
  });
39867
40016
  }
40017
+ function uniqueRemainingAccounts(metas) {
40018
+ const seen = /* @__PURE__ */ new Map();
40019
+ for (const m of metas) {
40020
+ const key = m.pubkey.toBase58();
40021
+ const prev = seen.get(key);
40022
+ if (prev) prev.isWritable = prev.isWritable || m.isWritable;
40023
+ else seen.set(key, { ...m });
40024
+ }
40025
+ return [...seen.values()];
40026
+ }
40027
+ var STAKE_POOL_OFFSETS = {
40028
+ validatorList: 98,
40029
+ reserveStake: 130,
40030
+ poolMint: 162,
40031
+ managerFeeAccount: 194
40032
+ };
39868
40033
  async function resolveExponentMergeContext(params) {
39869
40034
  const { connection, owner } = params;
39870
40035
  const ptYtTokenProgram = params.ptYtTokenProgram ?? TOKEN_PROGRAM_ID;
@@ -40039,102 +40204,117 @@ async function resolveExponentStripContext(params) {
40039
40204
  }
40040
40205
  };
40041
40206
  }
40042
- var MERGE_DISCRIMINATOR = Buffer.from([5]);
40043
- function makeExponentMergeIx(accounts, amountNative) {
40044
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40045
- const eventAuthority = deriveExponentEventAuthority();
40046
- const data = Buffer.alloc(MERGE_DISCRIMINATOR.length + 8);
40047
- MERGE_DISCRIMINATOR.copy(data, 0);
40048
- data.writeBigUInt64LE(amountNative, MERGE_DISCRIMINATOR.length);
40049
- const keys = [
40050
- { pubkey: accounts.owner, isSigner: true, isWritable: true },
40051
- { pubkey: accounts.authority, isSigner: false, isWritable: true },
40052
- { pubkey: accounts.vault, isSigner: false, isWritable: true },
40053
- { pubkey: accounts.sySrcDstAta, isSigner: false, isWritable: true },
40054
- { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
40055
- { pubkey: accounts.ytSrcAta, isSigner: false, isWritable: true },
40056
- { pubkey: accounts.ptSrcAta, isSigner: false, isWritable: true },
40057
- { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
40058
- { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
40059
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40060
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40061
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40062
- { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
40063
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40064
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40065
- // SY-program CPI accounts (getSyState ++ withdrawSy), ALT-resolved (post-maturity merge
40066
- // still CPIs into the SY program to move SY out of escrow).
40067
- ...accounts.remainingAccounts ?? []
40068
- ];
40069
- return new web3_js.TransactionInstruction({
40070
- keys,
40071
- programId: EXPONENT_CORE_PROGRAM_ID,
40072
- data
40073
- });
40074
- }
40075
- var TRADE_PT_DISCRIMINATOR = Buffer.from([17]);
40076
- function exponentBuyPtArgs({
40077
- ptOutNative,
40078
- maxSyInNative
40079
- }) {
40080
- return { netTraderPt: ptOutNative, syConstraint: -maxSyInNative };
40081
- }
40082
- function makeExponentTradePtIx(accounts, args) {
40083
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40084
- const eventAuthority = deriveExponentEventAuthority();
40085
- const data = Buffer.alloc(TRADE_PT_DISCRIMINATOR.length + 16);
40086
- TRADE_PT_DISCRIMINATOR.copy(data, 0);
40087
- data.writeBigInt64LE(args.netTraderPt, TRADE_PT_DISCRIMINATOR.length);
40088
- data.writeBigInt64LE(args.syConstraint, TRADE_PT_DISCRIMINATOR.length + 8);
40089
- const keys = [
40090
- { pubkey: accounts.trader, isSigner: true, isWritable: true },
40091
- { pubkey: accounts.market, isSigner: false, isWritable: true },
40092
- { pubkey: accounts.tokenSyTrader, isSigner: false, isWritable: true },
40093
- { pubkey: accounts.tokenPtTrader, isSigner: false, isWritable: true },
40094
- { pubkey: accounts.tokenSyEscrow, isSigner: false, isWritable: true },
40095
- { pubkey: accounts.tokenPtEscrow, isSigner: false, isWritable: true },
40096
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40097
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40098
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40099
- { pubkey: accounts.tokenFeeTreasurySy, isSigner: false, isWritable: true },
40100
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40101
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40102
- // SY-program CPI accounts (getSyState ++ depositSy ++ withdrawSy), ALT-resolved.
40103
- ...accounts.remainingAccounts
40104
- ];
40105
- return new web3_js.TransactionInstruction({
40106
- keys,
40107
- programId: EXPONENT_CORE_PROGRAM_ID,
40108
- data
40207
+ async function resolveSplStakePoolRefreshIx(connection, stakePool) {
40208
+ const info = await connection.getAccountInfo(stakePool);
40209
+ if (!info) throw new Error(`SPL stake pool account not found: ${stakePool.toBase58()}`);
40210
+ const stakePoolProgram = info.owner;
40211
+ const at = (off) => new web3_js.PublicKey(info.data.subarray(off, off + 32));
40212
+ const [withdrawAuthority] = web3_js.PublicKey.findProgramAddressSync(
40213
+ [stakePool.toBuffer(), Buffer.from("withdraw")],
40214
+ stakePoolProgram
40215
+ );
40216
+ return makeSplStakePoolUpdateBalanceIx({
40217
+ stakePoolProgram,
40218
+ stakePool,
40219
+ withdrawAuthority,
40220
+ validatorList: at(STAKE_POOL_OFFSETS.validatorList),
40221
+ reserveStake: at(STAKE_POOL_OFFSETS.reserveStake),
40222
+ managerFeeAccount: at(STAKE_POOL_OFFSETS.managerFeeAccount),
40223
+ poolMint: at(STAKE_POOL_OFFSETS.poolMint)
40109
40224
  });
40110
40225
  }
40111
- var STRIP_DISCRIMINATOR = Buffer.from([4]);
40112
- function makeExponentStripIx(accounts, amountNative) {
40113
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40114
- const eventAuthority = deriveExponentEventAuthority();
40115
- const data = Buffer.alloc(STRIP_DISCRIMINATOR.length + 8);
40116
- STRIP_DISCRIMINATOR.copy(data, 0);
40117
- data.writeBigUInt64LE(amountNative, STRIP_DISCRIMINATOR.length);
40118
- const keys = [
40119
- { pubkey: accounts.depositor, isSigner: true, isWritable: true },
40120
- { pubkey: accounts.authority, isSigner: false, isWritable: true },
40121
- { pubkey: accounts.vault, isSigner: false, isWritable: true },
40122
- { pubkey: accounts.sySrc, isSigner: false, isWritable: true },
40123
- { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
40124
- { pubkey: accounts.ytDst, isSigner: false, isWritable: true },
40125
- { pubkey: accounts.ptDst, isSigner: false, isWritable: true },
40126
- { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
40127
- { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
40128
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40129
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40130
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40131
- { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
40132
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40133
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40134
- // SY-program CPI accounts (depositSy), ALT-resolved.
40135
- ...accounts.remainingAccounts ?? []
40226
+ async function resolveExponentWrapperMergeContext(params) {
40227
+ const { connection, owner, baseMint } = params;
40228
+ const ptYtTokenProgram = params.ptYtTokenProgram ?? TOKEN_PROGRAM_ID;
40229
+ const syTokenProgram = params.syTokenProgram ?? TOKEN_PROGRAM_ID;
40230
+ const baseTokenProgram = params.baseTokenProgram ?? TOKEN_PROGRAM_ID;
40231
+ let vaultAddress;
40232
+ let vault;
40233
+ if (params.vault) {
40234
+ vaultAddress = params.vault;
40235
+ vault = await fetchExponentVault(connection, vaultAddress);
40236
+ } else if (params.market) {
40237
+ const res = await fetchExponentVaultFromMarket(connection, params.market);
40238
+ vaultAddress = res.vault;
40239
+ vault = res.account;
40240
+ } else {
40241
+ throw new Error("resolveExponentWrapperMergeContext: one of `vault` or `market` is required");
40242
+ }
40243
+ const altResult = await connection.getAddressLookupTable(vault.addressLookupTable);
40244
+ const alt = altResult.value;
40245
+ if (!alt) {
40246
+ throw new Error(
40247
+ `Exponent vault address lookup table not found: ${vault.addressLookupTable.toBase58()}`
40248
+ );
40249
+ }
40250
+ const altKey = vault.addressLookupTable;
40251
+ const getSyState = resolveCpiMetas(vault.cpiAccounts.getSyState, alt.state.addresses, altKey);
40252
+ const withdrawSy = resolveCpiMetas(vault.cpiAccounts.withdrawSy, alt.state.addresses, altKey);
40253
+ if (getSyState.length < 4) {
40254
+ throw new Error(
40255
+ "resolveExponentWrapperMergeContext: unexpected get_sy_state shape (expected the generic SPL-stake-pool flavor: [syState, mintSy, tokenSyEscrow, stakePool])"
40256
+ );
40257
+ }
40258
+ const syState = getSyState[0].pubkey;
40259
+ const stakePool = getSyState[3].pubkey;
40260
+ const syAta = getAssociatedTokenAddressSync(vault.mintSy, owner, true, syTokenProgram);
40261
+ const ptAta = getAssociatedTokenAddressSync(vault.mintPt, owner, true, ptYtTokenProgram);
40262
+ const ytAta = getAssociatedTokenAddressSync(vault.mintYt, owner, true, ptYtTokenProgram);
40263
+ const baseAta = getAssociatedTokenAddressSync(baseMint, owner, true, baseTokenProgram);
40264
+ const baseEscrow = getAssociatedTokenAddressSync(baseMint, syState, true, baseTokenProgram);
40265
+ const redeem = [
40266
+ { pubkey: owner, isSigner: true, isWritable: true },
40267
+ { pubkey: syState, isSigner: false, isWritable: true },
40268
+ { pubkey: baseAta, isSigner: false, isWritable: true },
40269
+ { pubkey: baseEscrow, isSigner: false, isWritable: true },
40270
+ { pubkey: syAta, isSigner: false, isWritable: true },
40271
+ { pubkey: vault.mintSy, isSigner: false, isWritable: true },
40272
+ { pubkey: baseMint, isSigner: false, isWritable: false },
40273
+ { pubkey: syTokenProgram, isSigner: false, isWritable: false },
40274
+ { pubkey: baseTokenProgram, isSigner: false, isWritable: false },
40275
+ { pubkey: stakePool, isSigner: false, isWritable: true }
40136
40276
  ];
40137
- return new web3_js.TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
40277
+ const cpi = uniqueRemainingAccounts([...withdrawSy, ...getSyState]);
40278
+ const wrapperMergeAccounts = {
40279
+ owner,
40280
+ syAta,
40281
+ vault: vaultAddress,
40282
+ escrowSy: vault.escrowSy,
40283
+ ytAta,
40284
+ ptAta,
40285
+ mintYt: vault.mintYt,
40286
+ mintPt: vault.mintPt,
40287
+ authority: vault.authority,
40288
+ addressLookupTable: vault.addressLookupTable,
40289
+ yieldPosition: vault.yieldPosition,
40290
+ syProgram: vault.syProgram,
40291
+ tokenProgram: ptYtTokenProgram,
40292
+ remainingAccounts: [...redeem, ...cpi],
40293
+ redeemSyAccountsUntil: redeem.length
40294
+ };
40295
+ const [baseDecimals, stakePoolRefreshIx] = await Promise.all([
40296
+ getMintDecimals(connection, baseMint),
40297
+ resolveSplStakePoolRefreshIx(connection, stakePool)
40298
+ ]);
40299
+ return {
40300
+ vaultAddress,
40301
+ vault,
40302
+ wrapperMergeAccounts,
40303
+ preInstructions: [stakePoolRefreshIx],
40304
+ addressLookupTable: alt,
40305
+ baseToken: { mint: baseMint, decimals: baseDecimals, tokenProgram: baseTokenProgram },
40306
+ setupMints: [
40307
+ { mint: baseMint, tokenProgram: baseTokenProgram },
40308
+ { mint: vault.mintSy, tokenProgram: syTokenProgram },
40309
+ { mint: vault.mintPt, tokenProgram: ptYtTokenProgram },
40310
+ { mint: vault.mintYt, tokenProgram: ptYtTokenProgram }
40311
+ ],
40312
+ computeRedeemedBaseNative(ptAmountNative) {
40313
+ if (vault.ptSupply === 0n) return 0n;
40314
+ const base = new bignumber_js.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
40315
+ return BigInt(base.toFixed(0));
40316
+ }
40317
+ };
40138
40318
  }
40139
40319
 
40140
40320
  exports.ACCOUNT_SIZE = ACCOUNT_SIZE;
@@ -40413,9 +40593,11 @@ exports.lutToTitanWire = lutToTitanWire;
40413
40593
  exports.makeExponentMergeIx = makeExponentMergeIx;
40414
40594
  exports.makeExponentStripIx = makeExponentStripIx;
40415
40595
  exports.makeExponentTradePtIx = makeExponentTradePtIx;
40596
+ exports.makeExponentWrapperMergeIx = makeExponentWrapperMergeIx;
40416
40597
  exports.makeRefreshObligationIx = makeRefreshObligationIx;
40417
40598
  exports.makeRefreshReservesBatchIx = makeRefreshReservesBatchIx;
40418
40599
  exports.makeRefreshingIxs = makeRefreshingIxs;
40600
+ exports.makeSplStakePoolUpdateBalanceIx = makeSplStakePoolUpdateBalanceIx;
40419
40601
  exports.makeUpdateJupLendRate = makeUpdateJupLendRate;
40420
40602
  exports.makeUpdateJupLendRateIx = makeUpdateJupLendRateIx;
40421
40603
  exports.makeUpdateSpotMarketCumulativeInterestIx = makeUpdateSpotMarketCumulativeInterestIx;
@@ -40428,6 +40610,7 @@ exports.reserveRawToDto = reserveRawToDto;
40428
40610
  exports.resolveExponentMergeContext = resolveExponentMergeContext;
40429
40611
  exports.resolveExponentStripContext = resolveExponentStripContext;
40430
40612
  exports.resolveExponentTradePtContext = resolveExponentTradePtContext;
40613
+ exports.resolveExponentWrapperMergeContext = resolveExponentWrapperMergeContext;
40431
40614
  exports.resolveLookupTables = resolveLookupTables;
40432
40615
  exports.scaledSupplies = scaledSupplies;
40433
40616
  exports.selectBestRoute = selectBestRoute;