@0dotxyz/p0-ts-sdk 2.3.0-alpha.1 → 2.3.0-alpha.2

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/index.d.cts CHANGED
@@ -8,7 +8,7 @@ import { Idl, Instruction, AnchorProvider, Address } from '@coral-xyz/anchor';
8
8
  import BN from 'bn.js';
9
9
  import BigNumber$1 from 'bignumber.js';
10
10
  import { R as ReserveRaw, D as DriftSpotMarket, b as DriftRewards, J as JupLendingState, g as ReserveJSON, h as ObligationJSON, i as FarmStateJSON, O as ObligationRaw, F as FarmStateRaw, j as DriftSpotMarketJSON, k as DriftUserJSON, l as DriftRewardsJSON, m as DriftUserStatsJSON, a as DriftUser, c as DriftUserStats, n as JupLendingStateJSON, o as JupTokenReserveJSON, p as JupLendingRewardsRateModelJSON, q as JupRateModelJSON, d as JupTokenReserve, e as JupLendingRewardsRateModel, f as JupRateModel } from './dto-rate-model.types-DveIB9Ll.cjs';
11
- import { F as FeedResponse, b as ExponentMergeAccounts } from './merge.types-BS8s5Ck0.cjs';
11
+ import { F as FeedResponse, b as ExponentMergeAccounts } from './merge.types-Coz1eQZg.cjs';
12
12
  import { JupiterClientConfig, QuoteGetRequest, QuoteResponse } from './jupiter.cjs';
13
13
 
14
14
  interface RpcSimulateBundleTransactionResult {
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { Idl, Instruction, AnchorProvider, Address } from '@coral-xyz/anchor';
8
8
  import BN from 'bn.js';
9
9
  import BigNumber$1 from 'bignumber.js';
10
10
  import { R as ReserveRaw, D as DriftSpotMarket, b as DriftRewards, J as JupLendingState, g as ReserveJSON, h as ObligationJSON, i as FarmStateJSON, O as ObligationRaw, F as FarmStateRaw, j as DriftSpotMarketJSON, k as DriftUserJSON, l as DriftRewardsJSON, m as DriftUserStatsJSON, a as DriftUser, c as DriftUserStats, n as JupLendingStateJSON, o as JupTokenReserveJSON, p as JupLendingRewardsRateModelJSON, q as JupRateModelJSON, d as JupTokenReserve, e as JupLendingRewardsRateModel, f as JupRateModel } from './dto-rate-model.types-DveIB9Ll.js';
11
- import { F as FeedResponse, b as ExponentMergeAccounts } from './merge.types-BS8s5Ck0.js';
11
+ import { F as FeedResponse, b as ExponentMergeAccounts } from './merge.types-Coz1eQZg.js';
12
12
  import { JupiterClientConfig, QuoteGetRequest, QuoteResponse } from './jupiter.js';
13
13
 
14
14
  interface RpcSimulateBundleTransactionResult {
@@ -56,7 +56,14 @@ interface ExponentVault {
56
56
  escrowSy: PublicKey;
57
57
  yieldPosition: PublicKey;
58
58
  addressLookupTable: PublicKey;
59
- /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber. */
59
+ /**
60
+ * Total SY backing all PT (native u64). The PT→SY redemption rate is
61
+ * `sy_for_pt / pt_supply` (Exponent's `Vault::pt_redemption_rate`).
62
+ */
63
+ syForPt: bigint;
64
+ /** Total PT supply (native u64). */
65
+ ptSupply: bigint;
66
+ /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber (informational). */
60
67
  finalSyExchangeRate: BigNumber;
61
68
  /** Raw status byte. */
62
69
  status: number;
@@ -115,7 +122,7 @@ interface ResolveExponentMergeContextParams {
115
122
  /**
116
123
  * Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
117
124
  * accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
118
- * redeemed SY amount from `Vault.final_sy_exchange_rate`.
125
+ * redeemed SY amount from the vault's PT redemption rate.
119
126
  */
120
127
  interface ExponentMergeContext {
121
128
  vaultAddress: PublicKey;
@@ -127,9 +134,9 @@ interface ExponentMergeContext {
127
134
  tokenProgram: PublicKey;
128
135
  };
129
136
  /**
130
- * Native SY that `merge` yields for a given native PT amount, at the matured rate:
131
- * `floor(ptAmountNative × final_sy_exchange_rate)`. Assumes PT and SY share decimals
132
- * (true for Exponent vaults). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
137
+ * Native SY that `merge` yields for a given native PT amount, mirroring Exponent's
138
+ * on-chain math: `floor(ptAmountNative × sy_for_pt / pt_supply)`
139
+ * (`Vault::pt_redemption_rate`). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
133
140
  */
134
141
  computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
135
142
  }
@@ -56,7 +56,14 @@ interface ExponentVault {
56
56
  escrowSy: PublicKey;
57
57
  yieldPosition: PublicKey;
58
58
  addressLookupTable: PublicKey;
59
- /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber. */
59
+ /**
60
+ * Total SY backing all PT (native u64). The PT→SY redemption rate is
61
+ * `sy_for_pt / pt_supply` (Exponent's `Vault::pt_redemption_rate`).
62
+ */
63
+ syForPt: bigint;
64
+ /** Total PT supply (native u64). */
65
+ ptSupply: bigint;
66
+ /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber (informational). */
60
67
  finalSyExchangeRate: BigNumber;
61
68
  /** Raw status byte. */
62
69
  status: number;
@@ -115,7 +122,7 @@ interface ResolveExponentMergeContextParams {
115
122
  /**
116
123
  * Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
117
124
  * accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
118
- * redeemed SY amount from `Vault.final_sy_exchange_rate`.
125
+ * redeemed SY amount from the vault's PT redemption rate.
119
126
  */
120
127
  interface ExponentMergeContext {
121
128
  vaultAddress: PublicKey;
@@ -127,9 +134,9 @@ interface ExponentMergeContext {
127
134
  tokenProgram: PublicKey;
128
135
  };
129
136
  /**
130
- * Native SY that `merge` yields for a given native PT amount, at the matured rate:
131
- * `floor(ptAmountNative × final_sy_exchange_rate)`. Assumes PT and SY share decimals
132
- * (true for Exponent vaults). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
137
+ * Native SY that `merge` yields for a given native PT amount, mirroring Exponent's
138
+ * on-chain math: `floor(ptAmountNative × sy_for_pt / pt_supply)`
139
+ * (`Vault::pt_redemption_rate`). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
133
140
  */
134
141
  computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
135
142
  }
package/dist/vendor.cjs CHANGED
@@ -39745,6 +39745,7 @@ function pk(v) {
39745
39745
  function decodeExponentVault(data) {
39746
39746
  const d = EXPONENT_ACCOUNTS_CODER.decode("Vault", data);
39747
39747
  const get = (snake, camel) => d[snake] ?? d[camel];
39748
+ const u646 = (v) => BigInt(BN2__default.default.isBN(v) ? v.toString() : String(v ?? 0));
39748
39749
  return {
39749
39750
  authority: pk(get("authority", "authority")),
39750
39751
  syProgram: pk(get("sy_program", "syProgram")),
@@ -39754,6 +39755,8 @@ function decodeExponentVault(data) {
39754
39755
  escrowSy: pk(get("escrow_sy", "escrowSy")),
39755
39756
  yieldPosition: pk(get("yield_position", "yieldPosition")),
39756
39757
  addressLookupTable: pk(get("address_lookup_table", "addressLookupTable")),
39758
+ syForPt: u646(get("sy_for_pt", "syForPt")),
39759
+ ptSupply: u646(get("pt_supply", "ptSupply")),
39757
39760
  finalSyExchangeRate: exponentNumberToBigNumber(
39758
39761
  get("final_sy_exchange_rate", "finalSyExchangeRate")
39759
39762
  ),
@@ -39827,7 +39830,8 @@ async function resolveExponentMergeContext(params) {
39827
39830
  mergeAccounts,
39828
39831
  underlying: { mint: vault.mintSy, decimals, tokenProgram: syTokenProgram },
39829
39832
  computeRedeemedAmountNative(ptAmountNative) {
39830
- const sy = new bignumber_js.BigNumber(ptAmountNative.toString()).times(vault.finalSyExchangeRate).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
39833
+ if (vault.ptSupply === 0n) return 0n;
39834
+ const sy = new bignumber_js.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
39831
39835
  return BigInt(sy.toFixed(0));
39832
39836
  }
39833
39837
  };