@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.js CHANGED
@@ -32322,11 +32322,13 @@ function selectBestRoute(quotes, swapMode) {
32322
32322
  }
32323
32323
  function buildSwapQuoteResult(route, swapMode) {
32324
32324
  const slippageBps = route.slippageBps;
32325
+ const outAmount = Number(route.outAmount);
32326
+ const inAmount = Number(route.inAmount);
32325
32327
  let otherAmountThreshold;
32326
32328
  if (swapMode === "ExactIn") {
32327
- otherAmountThreshold = String(Math.floor(route.outAmount * (1 - slippageBps / 1e4)));
32329
+ otherAmountThreshold = String(Math.floor(outAmount * (1 - slippageBps / 1e4)));
32328
32330
  } else {
32329
- otherAmountThreshold = String(Math.ceil(route.inAmount * (1 + slippageBps / 1e4)));
32331
+ otherAmountThreshold = String(Math.ceil(inAmount * (1 + slippageBps / 1e4)));
32330
32332
  }
32331
32333
  return {
32332
32334
  inAmount: String(route.inAmount),
@@ -39828,6 +39830,153 @@ function deriveExponentEventAuthority() {
39828
39830
  EXPONENT_CORE_PROGRAM_ID
39829
39831
  )[0];
39830
39832
  }
39833
+ var MERGE_DISCRIMINATOR = Buffer.from([5]);
39834
+ function makeExponentMergeIx(accounts, amountNative) {
39835
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39836
+ const eventAuthority = deriveExponentEventAuthority();
39837
+ const data = Buffer.alloc(MERGE_DISCRIMINATOR.length + 8);
39838
+ MERGE_DISCRIMINATOR.copy(data, 0);
39839
+ data.writeBigUInt64LE(amountNative, MERGE_DISCRIMINATOR.length);
39840
+ const keys = [
39841
+ { pubkey: accounts.owner, isSigner: true, isWritable: true },
39842
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39843
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39844
+ { pubkey: accounts.sySrcDstAta, isSigner: false, isWritable: true },
39845
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39846
+ { pubkey: accounts.ytSrcAta, isSigner: false, isWritable: true },
39847
+ { pubkey: accounts.ptSrcAta, isSigner: false, isWritable: true },
39848
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39849
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39850
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39851
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39852
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39853
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39854
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39855
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39856
+ // SY-program CPI accounts (getSyState ++ withdrawSy), ALT-resolved (post-maturity merge
39857
+ // still CPIs into the SY program to move SY out of escrow).
39858
+ ...accounts.remainingAccounts ?? []
39859
+ ];
39860
+ return new TransactionInstruction({
39861
+ keys,
39862
+ programId: EXPONENT_CORE_PROGRAM_ID,
39863
+ data
39864
+ });
39865
+ }
39866
+ var TRADE_PT_DISCRIMINATOR = Buffer.from([17]);
39867
+ function exponentBuyPtArgs({
39868
+ ptOutNative,
39869
+ maxSyInNative
39870
+ }) {
39871
+ return { netTraderPt: ptOutNative, syConstraint: -maxSyInNative };
39872
+ }
39873
+ function makeExponentTradePtIx(accounts, args) {
39874
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39875
+ const eventAuthority = deriveExponentEventAuthority();
39876
+ const data = Buffer.alloc(TRADE_PT_DISCRIMINATOR.length + 16);
39877
+ TRADE_PT_DISCRIMINATOR.copy(data, 0);
39878
+ data.writeBigInt64LE(args.netTraderPt, TRADE_PT_DISCRIMINATOR.length);
39879
+ data.writeBigInt64LE(args.syConstraint, TRADE_PT_DISCRIMINATOR.length + 8);
39880
+ const keys = [
39881
+ { pubkey: accounts.trader, isSigner: true, isWritable: true },
39882
+ { pubkey: accounts.market, isSigner: false, isWritable: true },
39883
+ { pubkey: accounts.tokenSyTrader, isSigner: false, isWritable: true },
39884
+ { pubkey: accounts.tokenPtTrader, isSigner: false, isWritable: true },
39885
+ { pubkey: accounts.tokenSyEscrow, isSigner: false, isWritable: true },
39886
+ { pubkey: accounts.tokenPtEscrow, isSigner: false, isWritable: true },
39887
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39888
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39889
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39890
+ { pubkey: accounts.tokenFeeTreasurySy, isSigner: false, isWritable: true },
39891
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39892
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39893
+ // SY-program CPI accounts (getSyState ++ depositSy ++ withdrawSy), ALT-resolved.
39894
+ ...accounts.remainingAccounts
39895
+ ];
39896
+ return new TransactionInstruction({
39897
+ keys,
39898
+ programId: EXPONENT_CORE_PROGRAM_ID,
39899
+ data
39900
+ });
39901
+ }
39902
+ var STRIP_DISCRIMINATOR = Buffer.from([4]);
39903
+ function makeExponentStripIx(accounts, amountNative) {
39904
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39905
+ const eventAuthority = deriveExponentEventAuthority();
39906
+ const data = Buffer.alloc(STRIP_DISCRIMINATOR.length + 8);
39907
+ STRIP_DISCRIMINATOR.copy(data, 0);
39908
+ data.writeBigUInt64LE(amountNative, STRIP_DISCRIMINATOR.length);
39909
+ const keys = [
39910
+ { pubkey: accounts.depositor, isSigner: true, isWritable: true },
39911
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39912
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39913
+ { pubkey: accounts.sySrc, isSigner: false, isWritable: true },
39914
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39915
+ { pubkey: accounts.ytDst, isSigner: false, isWritable: true },
39916
+ { pubkey: accounts.ptDst, isSigner: false, isWritable: true },
39917
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39918
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39919
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39920
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39921
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39922
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39923
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39924
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39925
+ // SY-program CPI accounts (depositSy), ALT-resolved.
39926
+ ...accounts.remainingAccounts ?? []
39927
+ ];
39928
+ return new TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
39929
+ }
39930
+ var WRAPPER_MERGE_DISCRIMINATOR = Buffer.from([39]);
39931
+ function makeExponentWrapperMergeIx(accounts, args) {
39932
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39933
+ const eventAuthority = deriveExponentEventAuthority();
39934
+ const data = Buffer.alloc(WRAPPER_MERGE_DISCRIMINATOR.length + 9);
39935
+ WRAPPER_MERGE_DISCRIMINATOR.copy(data, 0);
39936
+ data.writeBigUInt64LE(args.amountPyNative, WRAPPER_MERGE_DISCRIMINATOR.length);
39937
+ data.writeUInt8(args.redeemSyAccountsUntil, WRAPPER_MERGE_DISCRIMINATOR.length + 8);
39938
+ const keys = [
39939
+ { pubkey: accounts.owner, isSigner: true, isWritable: true },
39940
+ { pubkey: accounts.syAta, isSigner: false, isWritable: true },
39941
+ { pubkey: accounts.vault, isSigner: false, isWritable: true },
39942
+ { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
39943
+ { pubkey: accounts.ytAta, isSigner: false, isWritable: true },
39944
+ { pubkey: accounts.ptAta, isSigner: false, isWritable: true },
39945
+ { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
39946
+ { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
39947
+ { pubkey: accounts.authority, isSigner: false, isWritable: true },
39948
+ { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
39949
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
39950
+ { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
39951
+ { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
39952
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
39953
+ { pubkey: eventAuthority, isSigner: false, isWritable: false },
39954
+ { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
39955
+ // [...redeem (flavor SY-redeem accounts), ...cpi (withdraw_sy ++ get_sy_state)]
39956
+ ...accounts.remainingAccounts
39957
+ ];
39958
+ return new TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
39959
+ }
39960
+ var SPL_STAKE_POOL_UPDATE_BALANCE_TAG = Buffer.from([7]);
39961
+ function makeSplStakePoolUpdateBalanceIx(accounts) {
39962
+ const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
39963
+ const keys = [
39964
+ { pubkey: accounts.stakePool, isSigner: false, isWritable: true },
39965
+ { pubkey: accounts.withdrawAuthority, isSigner: false, isWritable: false },
39966
+ { pubkey: accounts.validatorList, isSigner: false, isWritable: true },
39967
+ { pubkey: accounts.reserveStake, isSigner: false, isWritable: false },
39968
+ { pubkey: accounts.managerFeeAccount, isSigner: false, isWritable: true },
39969
+ { pubkey: accounts.poolMint, isSigner: false, isWritable: true },
39970
+ { pubkey: tokenProgram, isSigner: false, isWritable: false }
39971
+ ];
39972
+ return new TransactionInstruction({
39973
+ keys,
39974
+ programId: accounts.stakePoolProgram,
39975
+ data: Buffer.from(SPL_STAKE_POOL_UPDATE_BALANCE_TAG)
39976
+ });
39977
+ }
39978
+
39979
+ // src/vendor/exponent/utils/resolve.utils.ts
39831
39980
  function resolveCpiMetas(contexts, altAddresses, altKey) {
39832
39981
  return contexts.map((ctx) => {
39833
39982
  const pubkey = altAddresses[ctx.altIndex];
@@ -39839,6 +39988,22 @@ function resolveCpiMetas(contexts, altAddresses, altKey) {
39839
39988
  return { pubkey, isSigner: false, isWritable: ctx.isWritable };
39840
39989
  });
39841
39990
  }
39991
+ function uniqueRemainingAccounts(metas) {
39992
+ const seen = /* @__PURE__ */ new Map();
39993
+ for (const m of metas) {
39994
+ const key = m.pubkey.toBase58();
39995
+ const prev = seen.get(key);
39996
+ if (prev) prev.isWritable = prev.isWritable || m.isWritable;
39997
+ else seen.set(key, { ...m });
39998
+ }
39999
+ return [...seen.values()];
40000
+ }
40001
+ var STAKE_POOL_OFFSETS = {
40002
+ validatorList: 98,
40003
+ reserveStake: 130,
40004
+ poolMint: 162,
40005
+ managerFeeAccount: 194
40006
+ };
39842
40007
  async function resolveExponentMergeContext(params) {
39843
40008
  const { connection, owner } = params;
39844
40009
  const ptYtTokenProgram = params.ptYtTokenProgram ?? TOKEN_PROGRAM_ID;
@@ -40013,104 +40178,119 @@ async function resolveExponentStripContext(params) {
40013
40178
  }
40014
40179
  };
40015
40180
  }
40016
- var MERGE_DISCRIMINATOR = Buffer.from([5]);
40017
- function makeExponentMergeIx(accounts, amountNative) {
40018
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40019
- const eventAuthority = deriveExponentEventAuthority();
40020
- const data = Buffer.alloc(MERGE_DISCRIMINATOR.length + 8);
40021
- MERGE_DISCRIMINATOR.copy(data, 0);
40022
- data.writeBigUInt64LE(amountNative, MERGE_DISCRIMINATOR.length);
40023
- const keys = [
40024
- { pubkey: accounts.owner, isSigner: true, isWritable: true },
40025
- { pubkey: accounts.authority, isSigner: false, isWritable: true },
40026
- { pubkey: accounts.vault, isSigner: false, isWritable: true },
40027
- { pubkey: accounts.sySrcDstAta, isSigner: false, isWritable: true },
40028
- { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
40029
- { pubkey: accounts.ytSrcAta, isSigner: false, isWritable: true },
40030
- { pubkey: accounts.ptSrcAta, isSigner: false, isWritable: true },
40031
- { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
40032
- { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
40033
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40034
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40035
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40036
- { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
40037
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40038
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40039
- // SY-program CPI accounts (getSyState ++ withdrawSy), ALT-resolved (post-maturity merge
40040
- // still CPIs into the SY program to move SY out of escrow).
40041
- ...accounts.remainingAccounts ?? []
40042
- ];
40043
- return new TransactionInstruction({
40044
- keys,
40045
- programId: EXPONENT_CORE_PROGRAM_ID,
40046
- data
40047
- });
40048
- }
40049
- var TRADE_PT_DISCRIMINATOR = Buffer.from([17]);
40050
- function exponentBuyPtArgs({
40051
- ptOutNative,
40052
- maxSyInNative
40053
- }) {
40054
- return { netTraderPt: ptOutNative, syConstraint: -maxSyInNative };
40055
- }
40056
- function makeExponentTradePtIx(accounts, args) {
40057
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40058
- const eventAuthority = deriveExponentEventAuthority();
40059
- const data = Buffer.alloc(TRADE_PT_DISCRIMINATOR.length + 16);
40060
- TRADE_PT_DISCRIMINATOR.copy(data, 0);
40061
- data.writeBigInt64LE(args.netTraderPt, TRADE_PT_DISCRIMINATOR.length);
40062
- data.writeBigInt64LE(args.syConstraint, TRADE_PT_DISCRIMINATOR.length + 8);
40063
- const keys = [
40064
- { pubkey: accounts.trader, isSigner: true, isWritable: true },
40065
- { pubkey: accounts.market, isSigner: false, isWritable: true },
40066
- { pubkey: accounts.tokenSyTrader, isSigner: false, isWritable: true },
40067
- { pubkey: accounts.tokenPtTrader, isSigner: false, isWritable: true },
40068
- { pubkey: accounts.tokenSyEscrow, isSigner: false, isWritable: true },
40069
- { pubkey: accounts.tokenPtEscrow, isSigner: false, isWritable: true },
40070
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40071
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40072
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40073
- { pubkey: accounts.tokenFeeTreasurySy, isSigner: false, isWritable: true },
40074
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40075
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40076
- // SY-program CPI accounts (getSyState ++ depositSy ++ withdrawSy), ALT-resolved.
40077
- ...accounts.remainingAccounts
40078
- ];
40079
- return new TransactionInstruction({
40080
- keys,
40081
- programId: EXPONENT_CORE_PROGRAM_ID,
40082
- data
40181
+ async function resolveSplStakePoolRefreshIx(connection, stakePool) {
40182
+ const info = await connection.getAccountInfo(stakePool);
40183
+ if (!info) throw new Error(`SPL stake pool account not found: ${stakePool.toBase58()}`);
40184
+ const stakePoolProgram = info.owner;
40185
+ const at = (off) => new PublicKey(info.data.subarray(off, off + 32));
40186
+ const [withdrawAuthority] = PublicKey.findProgramAddressSync(
40187
+ [stakePool.toBuffer(), Buffer.from("withdraw")],
40188
+ stakePoolProgram
40189
+ );
40190
+ return makeSplStakePoolUpdateBalanceIx({
40191
+ stakePoolProgram,
40192
+ stakePool,
40193
+ withdrawAuthority,
40194
+ validatorList: at(STAKE_POOL_OFFSETS.validatorList),
40195
+ reserveStake: at(STAKE_POOL_OFFSETS.reserveStake),
40196
+ managerFeeAccount: at(STAKE_POOL_OFFSETS.managerFeeAccount),
40197
+ poolMint: at(STAKE_POOL_OFFSETS.poolMint)
40083
40198
  });
40084
40199
  }
40085
- var STRIP_DISCRIMINATOR = Buffer.from([4]);
40086
- function makeExponentStripIx(accounts, amountNative) {
40087
- const tokenProgram = accounts.tokenProgram ?? TOKEN_PROGRAM_ID;
40088
- const eventAuthority = deriveExponentEventAuthority();
40089
- const data = Buffer.alloc(STRIP_DISCRIMINATOR.length + 8);
40090
- STRIP_DISCRIMINATOR.copy(data, 0);
40091
- data.writeBigUInt64LE(amountNative, STRIP_DISCRIMINATOR.length);
40092
- const keys = [
40093
- { pubkey: accounts.depositor, isSigner: true, isWritable: true },
40094
- { pubkey: accounts.authority, isSigner: false, isWritable: true },
40095
- { pubkey: accounts.vault, isSigner: false, isWritable: true },
40096
- { pubkey: accounts.sySrc, isSigner: false, isWritable: true },
40097
- { pubkey: accounts.escrowSy, isSigner: false, isWritable: true },
40098
- { pubkey: accounts.ytDst, isSigner: false, isWritable: true },
40099
- { pubkey: accounts.ptDst, isSigner: false, isWritable: true },
40100
- { pubkey: accounts.mintYt, isSigner: false, isWritable: true },
40101
- { pubkey: accounts.mintPt, isSigner: false, isWritable: true },
40102
- { pubkey: tokenProgram, isSigner: false, isWritable: false },
40103
- { pubkey: accounts.addressLookupTable, isSigner: false, isWritable: false },
40104
- { pubkey: accounts.syProgram, isSigner: false, isWritable: false },
40105
- { pubkey: accounts.yieldPosition, isSigner: false, isWritable: true },
40106
- { pubkey: eventAuthority, isSigner: false, isWritable: false },
40107
- { pubkey: EXPONENT_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
40108
- // SY-program CPI accounts (depositSy), ALT-resolved.
40109
- ...accounts.remainingAccounts ?? []
40200
+ async function resolveExponentWrapperMergeContext(params) {
40201
+ const { connection, owner, baseMint } = params;
40202
+ const ptYtTokenProgram = params.ptYtTokenProgram ?? TOKEN_PROGRAM_ID;
40203
+ const syTokenProgram = params.syTokenProgram ?? TOKEN_PROGRAM_ID;
40204
+ const baseTokenProgram = params.baseTokenProgram ?? TOKEN_PROGRAM_ID;
40205
+ let vaultAddress;
40206
+ let vault;
40207
+ if (params.vault) {
40208
+ vaultAddress = params.vault;
40209
+ vault = await fetchExponentVault(connection, vaultAddress);
40210
+ } else if (params.market) {
40211
+ const res = await fetchExponentVaultFromMarket(connection, params.market);
40212
+ vaultAddress = res.vault;
40213
+ vault = res.account;
40214
+ } else {
40215
+ throw new Error("resolveExponentWrapperMergeContext: one of `vault` or `market` is required");
40216
+ }
40217
+ const altResult = await connection.getAddressLookupTable(vault.addressLookupTable);
40218
+ const alt = altResult.value;
40219
+ if (!alt) {
40220
+ throw new Error(
40221
+ `Exponent vault address lookup table not found: ${vault.addressLookupTable.toBase58()}`
40222
+ );
40223
+ }
40224
+ const altKey = vault.addressLookupTable;
40225
+ const getSyState = resolveCpiMetas(vault.cpiAccounts.getSyState, alt.state.addresses, altKey);
40226
+ const withdrawSy = resolveCpiMetas(vault.cpiAccounts.withdrawSy, alt.state.addresses, altKey);
40227
+ if (getSyState.length < 4) {
40228
+ throw new Error(
40229
+ "resolveExponentWrapperMergeContext: unexpected get_sy_state shape (expected the generic SPL-stake-pool flavor: [syState, mintSy, tokenSyEscrow, stakePool])"
40230
+ );
40231
+ }
40232
+ const syState = getSyState[0].pubkey;
40233
+ const stakePool = getSyState[3].pubkey;
40234
+ const syAta = getAssociatedTokenAddressSync(vault.mintSy, owner, true, syTokenProgram);
40235
+ const ptAta = getAssociatedTokenAddressSync(vault.mintPt, owner, true, ptYtTokenProgram);
40236
+ const ytAta = getAssociatedTokenAddressSync(vault.mintYt, owner, true, ptYtTokenProgram);
40237
+ const baseAta = getAssociatedTokenAddressSync(baseMint, owner, true, baseTokenProgram);
40238
+ const baseEscrow = getAssociatedTokenAddressSync(baseMint, syState, true, baseTokenProgram);
40239
+ const redeem = [
40240
+ { pubkey: owner, isSigner: true, isWritable: true },
40241
+ { pubkey: syState, isSigner: false, isWritable: true },
40242
+ { pubkey: baseAta, isSigner: false, isWritable: true },
40243
+ { pubkey: baseEscrow, isSigner: false, isWritable: true },
40244
+ { pubkey: syAta, isSigner: false, isWritable: true },
40245
+ { pubkey: vault.mintSy, isSigner: false, isWritable: true },
40246
+ { pubkey: baseMint, isSigner: false, isWritable: false },
40247
+ { pubkey: syTokenProgram, isSigner: false, isWritable: false },
40248
+ { pubkey: baseTokenProgram, isSigner: false, isWritable: false },
40249
+ { pubkey: stakePool, isSigner: false, isWritable: true }
40110
40250
  ];
40111
- return new TransactionInstruction({ keys, programId: EXPONENT_CORE_PROGRAM_ID, data });
40251
+ const cpi = uniqueRemainingAccounts([...withdrawSy, ...getSyState]);
40252
+ const wrapperMergeAccounts = {
40253
+ owner,
40254
+ syAta,
40255
+ vault: vaultAddress,
40256
+ escrowSy: vault.escrowSy,
40257
+ ytAta,
40258
+ ptAta,
40259
+ mintYt: vault.mintYt,
40260
+ mintPt: vault.mintPt,
40261
+ authority: vault.authority,
40262
+ addressLookupTable: vault.addressLookupTable,
40263
+ yieldPosition: vault.yieldPosition,
40264
+ syProgram: vault.syProgram,
40265
+ tokenProgram: ptYtTokenProgram,
40266
+ remainingAccounts: [...redeem, ...cpi],
40267
+ redeemSyAccountsUntil: redeem.length
40268
+ };
40269
+ const [baseDecimals, stakePoolRefreshIx] = await Promise.all([
40270
+ getMintDecimals(connection, baseMint),
40271
+ resolveSplStakePoolRefreshIx(connection, stakePool)
40272
+ ]);
40273
+ return {
40274
+ vaultAddress,
40275
+ vault,
40276
+ wrapperMergeAccounts,
40277
+ preInstructions: [stakePoolRefreshIx],
40278
+ addressLookupTable: alt,
40279
+ baseToken: { mint: baseMint, decimals: baseDecimals, tokenProgram: baseTokenProgram },
40280
+ setupMints: [
40281
+ { mint: baseMint, tokenProgram: baseTokenProgram },
40282
+ { mint: vault.mintSy, tokenProgram: syTokenProgram },
40283
+ { mint: vault.mintPt, tokenProgram: ptYtTokenProgram },
40284
+ { mint: vault.mintYt, tokenProgram: ptYtTokenProgram }
40285
+ ],
40286
+ computeRedeemedBaseNative(ptAmountNative) {
40287
+ if (vault.ptSupply === 0n) return 0n;
40288
+ const base = new BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(BigNumber.ROUND_FLOOR);
40289
+ return BigInt(base.toFixed(0));
40290
+ }
40291
+ };
40112
40292
  }
40113
40293
 
40114
- export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout, AccountState, AccountType, ConnectionClosed, CorpAction, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, DriftSpotBalanceType, EXPONENT_CLMM_PROGRAM_ID, EXPONENT_CORE_IDL, EXPONENT_CORE_PROGRAM_ID, EXPONENT_EVENT_AUTHORITY_SEED, EXPONENT_GENERIC_SY_PROGRAM_ID, EXPONENT_JITO_RESTAKING_SY_PROGRAM_ID, EXPONENT_KAMINO_SY_PROGRAM_ID, EXPONENT_MARGINFI_SY_PROGRAM_ID, EXPONENT_NUMBER_DENOM, EXPONENT_ORDERBOOK_PROGRAM_ID, EXPONENT_PERENA_SY_PROGRAM_ID, EXPONENT_VAULTS_PROGRAM_ID, ErrorResponse, ExtensionType, FARMS_PROGRAM_ID, JUP_EXCHANGE_PRICES_PRECISION, JUP_LEND_IDL, JUP_LEND_PROGRAM_ID, JUP_LIQUIDITY_IDL, JUP_LIQUIDITY_PROGRAM_ID, JUP_MAX_REWARDS_RATE, JUP_REWARDS_PROGRAM_ID, JUP_SECONDS_PER_YEAR, KFARMS_IDL, KLEND_ACCOUNT_CODER, KLEND_IDL, KLEND_PROGRAM_ID, LENGTH_SIZE, MAX_SLOT_DIFFERENCE, MEMO_PROGRAM_ID, MINT_SIZE, MULTISIG_SIZE, MintLayout, MultisigLayout, NATIVE_MINT, ONE, ONE_HUNDRED_PCT_IN_BPS, ONE_YEAR, PERCENTAGE_PRECISION, PERCENTAGE_PRECISION_EXP, PriceStatus, PriceType, REFRESH_OBLIGATION_DISCRIMINATOR, SEED_BASE_REFERRER_STATE, SEED_BASE_REFERRER_TOKEN_STATE, SEED_BASE_SHORT_URL, SEED_BASE_USER_METADATA, SEED_DRIFT_SIGNER, SEED_DRIFT_STATE, SEED_FEE_RECEIVER, SEED_F_TOKEN_MINT, SEED_LENDING, SEED_LENDING_ADMIN, SEED_LENDING_MARKET_AUTH, SEED_LENDING_REWARDS_RATE_MODEL, SEED_LIQUIDITY, SEED_RATE_MODEL, SEED_RESERVE, SEED_RESERVE_COLL_MINT, SEED_RESERVE_COLL_SUPPLY, SEED_RESERVE_LIQ_SUPPLY, SEED_SPOT_MARKET, SEED_SPOT_MARKET_VAULT, SEED_USER, SEED_USER_CLAIM, SEED_USER_STATE, SEED_USER_STATS, SEED_USER_SUPPLY_POSITION, SLOTS_PER_DAY, SLOTS_PER_HOUR, SLOTS_PER_MINUTE, SLOTS_PER_SECOND, SLOTS_PER_YEAR, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_RATE_PRECISION_EXP, SPOT_MARKET_UTILIZATION_PRECISION, SPOT_MARKET_UTILIZATION_PRECISION_EXP, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION, SinglePoolInstruction, SplAccountType, SpotBalanceType, StreamError, SwapMode, SwapVersion, TEN, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, TYPE_SIZE, TokenAccountNotFoundError, TokenError, TokenInstruction, TokenInvalidAccountError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError, TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, TokenInvalidMintError, TokenInvalidOwnerError, TokenOwnerOffCurveError, TokenUnsupportedInstructionError, V1Client, ZERO, addSigners, approveInstructionData, buildSwapQuoteResult, buildTitanTemplate, calculateAPYFromAPR, calculateDriftBorrowAPR, calculateDriftBorrowAPY, calculateDriftBorrowRate, calculateDriftDepositRate, calculateDriftInterestRate, calculateDriftLendingAPR, calculateDriftLendingAPY, calculateDriftUtilization, calculateJupLendBorrowRate, calculateJupLendLiquiditySupplyRate, calculateJupLendNewExchangePrice, calculateJupLendRewardsRate, calculateJupLendRewardsRateForExchangePrice, calculateJupLendSupplyAPY, calculateJupLendSupplyRate, calculateJupLendTotalAssets, calculateKaminoEstimatedBorrowRate, calculateKaminoEstimatedSupplyRate, calculateKaminoSupplyAPY, calculateRewardApy, calculateSlotAdjustmentFactor, calculateUtilizationRatio, closeAccountInstructionData, createAccountIx, createApproveInstruction, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createCloseAccountInstruction, createInitializeAccountInstruction, createMemoInstruction, createPoolOnrampIx, createSyncNativeInstruction, createTransferCheckedInstruction, decodeDriftSpotMarketData, decodeDriftStateData, decodeDriftUserData, decodeDriftUserStatsData, decodeExponentMarketTwo, decodeExponentMarketVault, decodeExponentVault, decodeFarmDataRaw, decodeJupLendingRewardsRateModelData, decodeJupLendingStateData, decodeJupRateModelData, decodeJupTokenReserveData, decodeKlendObligationData, decodeKlendReserveData, decodeSwitchboardPullFeedData, deriveBaseObligation, deriveDriftSigner, deriveDriftSpotMarket, deriveDriftSpotMarketVault, deriveDriftState, deriveDriftUser, deriveDriftUserStats, deriveExponentEventAuthority, deriveFeeReceiver, deriveJupLendClaimAccount, deriveJupLendFTokenMint, deriveJupLendLending, deriveJupLendLendingAdmin, deriveJupLendLendingPdas, deriveJupLendLendingRewardsRateModel, deriveJupLendLiquidity, deriveJupLendLiquiditySupplyPositionPda, deriveJupLendLiquidityVaultAta, deriveJupLendRateModel, deriveJupLendTokenReserve, deriveLendingMarketAuthority, deriveObligation, deriveReferrerState, deriveReferrerTokenState, deriveReserveCollateralMint, deriveReserveCollateralSupply, deriveReserveLiquiditySupply, deriveShortUrl, deriveUserMetadata, deriveUserState, deserializeSerializedInstruction, deserializeTitanWireInstruction, driftRewardsRawToDto, driftSpotMarketRawToDto, driftStateRawToDto, driftUserRawToDto, driftUserStatsRawToDto, dtoToDriftRewardsRaw, dtoToDriftSpotMarketRaw, dtoToDriftStateRaw, dtoToDriftUserRaw, dtoToDriftUserStatsRaw, dtoToFarmRaw, dtoToJupLendingRewardsRateModelRaw, dtoToJupLendingStateRaw, dtoToJupRateModelRaw, dtoToJupTokenReserveRaw, dtoToObligationRaw, dtoToReserveRaw, encodeTitanTemplate, exponentBuyPtArgs, exponentNumberToBigNumber, farmRawToDto, fetchExponentMarketTwo, fetchExponentVault, fetchExponentVaultFromMarket, fetchTitanQuoteSwapV3, findMplMetadataAddress, findPoolAddress, findPoolMintAddress, findPoolMintAddressByVoteAccount, findPoolMintAuthorityAddress, findPoolMplAuthorityAddress, findPoolOnRampAddress, findPoolStakeAddress, findPoolStakeAuthorityAddress, generateDriftReserveCurve, generateJupLendSupplyCurve, generateKaminoReserveCurve, getAccount, getAccountLen, getAllDerivedDriftAccounts, getAllDerivedJupLendAccounts, getAllDerivedKaminoAccounts, getAllRequiredMarkets, getAssociatedTokenAddressSync, getDriftRewards, getDriftTokenAmount, getFixedHostInterestRate, getJupLendRewards, getKaminoBorrowRate, getKaminoTotalSupply, getMinimumBalanceForRentExemptAccount, getMinimumBalanceForRentExemptAccountWithExtensions, getMint, getMintDecimals, getMultipleAccounts, getProtocolTakeRatePct, getReserveRewardsApy, getRewardPerTimeUnitSecond, getStakeAccount, getSwitchboardProgram, initializeAccountInstructionData, initializeStakedPoolIxs, initializeStakedPoolTx, instructionToTitanWire, interpolateLinear, isSpotBalanceTypeVariant, jupLendingRewardsRateModelRawToDto, jupLendingStateRawToDto, jupRateModelRawToDto, jupTokenReserveRawToDto, layout, lutToTitanWire, makeExponentMergeIx, makeExponentStripIx, makeExponentTradePtIx, makeRefreshObligationIx, makeRefreshReservesBatchIx, makeRefreshingIxs, makeUpdateJupLendRate, makeUpdateJupLendRateIx, makeUpdateSpotMarketCumulativeInterestIx, makeUpdateSpotMarketIx, obligationRawToDto, parsePriceData, parsePriceInfo2 as parsePriceInfo, replenishPoolIx, reserveRawToDto, resolveExponentMergeContext, resolveExponentStripContext, resolveExponentTradePtContext, resolveLookupTables, scaledSupplies, selectBestRoute, selectGatewayRoute, slotAdjustmentFactor, switchboardAccountCoder, syncNativeInstructionData, transferCheckedInstructionData, truncateBorrowCurve, unpackAccount };
40294
+ export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout, AccountState, AccountType, ConnectionClosed, CorpAction, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, DriftSpotBalanceType, EXPONENT_CLMM_PROGRAM_ID, EXPONENT_CORE_IDL, EXPONENT_CORE_PROGRAM_ID, EXPONENT_EVENT_AUTHORITY_SEED, EXPONENT_GENERIC_SY_PROGRAM_ID, EXPONENT_JITO_RESTAKING_SY_PROGRAM_ID, EXPONENT_KAMINO_SY_PROGRAM_ID, EXPONENT_MARGINFI_SY_PROGRAM_ID, EXPONENT_NUMBER_DENOM, EXPONENT_ORDERBOOK_PROGRAM_ID, EXPONENT_PERENA_SY_PROGRAM_ID, EXPONENT_VAULTS_PROGRAM_ID, ErrorResponse, ExtensionType, FARMS_PROGRAM_ID, JUP_EXCHANGE_PRICES_PRECISION, JUP_LEND_IDL, JUP_LEND_PROGRAM_ID, JUP_LIQUIDITY_IDL, JUP_LIQUIDITY_PROGRAM_ID, JUP_MAX_REWARDS_RATE, JUP_REWARDS_PROGRAM_ID, JUP_SECONDS_PER_YEAR, KFARMS_IDL, KLEND_ACCOUNT_CODER, KLEND_IDL, KLEND_PROGRAM_ID, LENGTH_SIZE, MAX_SLOT_DIFFERENCE, MEMO_PROGRAM_ID, MINT_SIZE, MULTISIG_SIZE, MintLayout, MultisigLayout, NATIVE_MINT, ONE, ONE_HUNDRED_PCT_IN_BPS, ONE_YEAR, PERCENTAGE_PRECISION, PERCENTAGE_PRECISION_EXP, PriceStatus, PriceType, REFRESH_OBLIGATION_DISCRIMINATOR, SEED_BASE_REFERRER_STATE, SEED_BASE_REFERRER_TOKEN_STATE, SEED_BASE_SHORT_URL, SEED_BASE_USER_METADATA, SEED_DRIFT_SIGNER, SEED_DRIFT_STATE, SEED_FEE_RECEIVER, SEED_F_TOKEN_MINT, SEED_LENDING, SEED_LENDING_ADMIN, SEED_LENDING_MARKET_AUTH, SEED_LENDING_REWARDS_RATE_MODEL, SEED_LIQUIDITY, SEED_RATE_MODEL, SEED_RESERVE, SEED_RESERVE_COLL_MINT, SEED_RESERVE_COLL_SUPPLY, SEED_RESERVE_LIQ_SUPPLY, SEED_SPOT_MARKET, SEED_SPOT_MARKET_VAULT, SEED_USER, SEED_USER_CLAIM, SEED_USER_STATE, SEED_USER_STATS, SEED_USER_SUPPLY_POSITION, SLOTS_PER_DAY, SLOTS_PER_HOUR, SLOTS_PER_MINUTE, SLOTS_PER_SECOND, SLOTS_PER_YEAR, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_RATE_PRECISION_EXP, SPOT_MARKET_UTILIZATION_PRECISION, SPOT_MARKET_UTILIZATION_PRECISION_EXP, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION, SinglePoolInstruction, SplAccountType, SpotBalanceType, StreamError, SwapMode, SwapVersion, TEN, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, TYPE_SIZE, TokenAccountNotFoundError, TokenError, TokenInstruction, TokenInvalidAccountError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError, TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, TokenInvalidMintError, TokenInvalidOwnerError, TokenOwnerOffCurveError, TokenUnsupportedInstructionError, V1Client, ZERO, addSigners, approveInstructionData, buildSwapQuoteResult, buildTitanTemplate, calculateAPYFromAPR, calculateDriftBorrowAPR, calculateDriftBorrowAPY, calculateDriftBorrowRate, calculateDriftDepositRate, calculateDriftInterestRate, calculateDriftLendingAPR, calculateDriftLendingAPY, calculateDriftUtilization, calculateJupLendBorrowRate, calculateJupLendLiquiditySupplyRate, calculateJupLendNewExchangePrice, calculateJupLendRewardsRate, calculateJupLendRewardsRateForExchangePrice, calculateJupLendSupplyAPY, calculateJupLendSupplyRate, calculateJupLendTotalAssets, calculateKaminoEstimatedBorrowRate, calculateKaminoEstimatedSupplyRate, calculateKaminoSupplyAPY, calculateRewardApy, calculateSlotAdjustmentFactor, calculateUtilizationRatio, closeAccountInstructionData, createAccountIx, createApproveInstruction, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createCloseAccountInstruction, createInitializeAccountInstruction, createMemoInstruction, createPoolOnrampIx, createSyncNativeInstruction, createTransferCheckedInstruction, decodeDriftSpotMarketData, decodeDriftStateData, decodeDriftUserData, decodeDriftUserStatsData, decodeExponentMarketTwo, decodeExponentMarketVault, decodeExponentVault, decodeFarmDataRaw, decodeJupLendingRewardsRateModelData, decodeJupLendingStateData, decodeJupRateModelData, decodeJupTokenReserveData, decodeKlendObligationData, decodeKlendReserveData, decodeSwitchboardPullFeedData, deriveBaseObligation, deriveDriftSigner, deriveDriftSpotMarket, deriveDriftSpotMarketVault, deriveDriftState, deriveDriftUser, deriveDriftUserStats, deriveExponentEventAuthority, deriveFeeReceiver, deriveJupLendClaimAccount, deriveJupLendFTokenMint, deriveJupLendLending, deriveJupLendLendingAdmin, deriveJupLendLendingPdas, deriveJupLendLendingRewardsRateModel, deriveJupLendLiquidity, deriveJupLendLiquiditySupplyPositionPda, deriveJupLendLiquidityVaultAta, deriveJupLendRateModel, deriveJupLendTokenReserve, deriveLendingMarketAuthority, deriveObligation, deriveReferrerState, deriveReferrerTokenState, deriveReserveCollateralMint, deriveReserveCollateralSupply, deriveReserveLiquiditySupply, deriveShortUrl, deriveUserMetadata, deriveUserState, deserializeSerializedInstruction, deserializeTitanWireInstruction, driftRewardsRawToDto, driftSpotMarketRawToDto, driftStateRawToDto, driftUserRawToDto, driftUserStatsRawToDto, dtoToDriftRewardsRaw, dtoToDriftSpotMarketRaw, dtoToDriftStateRaw, dtoToDriftUserRaw, dtoToDriftUserStatsRaw, dtoToFarmRaw, dtoToJupLendingRewardsRateModelRaw, dtoToJupLendingStateRaw, dtoToJupRateModelRaw, dtoToJupTokenReserveRaw, dtoToObligationRaw, dtoToReserveRaw, encodeTitanTemplate, exponentBuyPtArgs, exponentNumberToBigNumber, farmRawToDto, fetchExponentMarketTwo, fetchExponentVault, fetchExponentVaultFromMarket, fetchTitanQuoteSwapV3, findMplMetadataAddress, findPoolAddress, findPoolMintAddress, findPoolMintAddressByVoteAccount, findPoolMintAuthorityAddress, findPoolMplAuthorityAddress, findPoolOnRampAddress, findPoolStakeAddress, findPoolStakeAuthorityAddress, generateDriftReserveCurve, generateJupLendSupplyCurve, generateKaminoReserveCurve, getAccount, getAccountLen, getAllDerivedDriftAccounts, getAllDerivedJupLendAccounts, getAllDerivedKaminoAccounts, getAllRequiredMarkets, getAssociatedTokenAddressSync, getDriftRewards, getDriftTokenAmount, getFixedHostInterestRate, getJupLendRewards, getKaminoBorrowRate, getKaminoTotalSupply, getMinimumBalanceForRentExemptAccount, getMinimumBalanceForRentExemptAccountWithExtensions, getMint, getMintDecimals, getMultipleAccounts, getProtocolTakeRatePct, getReserveRewardsApy, getRewardPerTimeUnitSecond, getStakeAccount, getSwitchboardProgram, initializeAccountInstructionData, initializeStakedPoolIxs, initializeStakedPoolTx, instructionToTitanWire, interpolateLinear, isSpotBalanceTypeVariant, jupLendingRewardsRateModelRawToDto, jupLendingStateRawToDto, jupRateModelRawToDto, jupTokenReserveRawToDto, layout, lutToTitanWire, makeExponentMergeIx, makeExponentStripIx, makeExponentTradePtIx, makeExponentWrapperMergeIx, makeRefreshObligationIx, makeRefreshReservesBatchIx, makeRefreshingIxs, makeSplStakePoolUpdateBalanceIx, makeUpdateJupLendRate, makeUpdateJupLendRateIx, makeUpdateSpotMarketCumulativeInterestIx, makeUpdateSpotMarketIx, obligationRawToDto, parsePriceData, parsePriceInfo2 as parsePriceInfo, replenishPoolIx, reserveRawToDto, resolveExponentMergeContext, resolveExponentStripContext, resolveExponentTradePtContext, resolveExponentWrapperMergeContext, resolveLookupTables, scaledSupplies, selectBestRoute, selectGatewayRoute, slotAdjustmentFactor, switchboardAccountCoder, syncNativeInstructionData, transferCheckedInstructionData, truncateBorrowCurve, unpackAccount };
40115
40295
  //# sourceMappingURL=vendor.js.map
40116
40296
  //# sourceMappingURL=vendor.js.map