@0dotxyz/p0-ts-sdk 2.3.0-alpha.0 → 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.
@@ -0,0 +1,144 @@
1
+ import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
2
+ import BN from 'bn.js';
3
+ import { PublicKey, Connection } from '@solana/web3.js';
4
+
5
+ declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
6
+ interface CurrentResult {
7
+ value: BN;
8
+ std_dev: BN;
9
+ mean: BN;
10
+ range: BN;
11
+ min_value: BN;
12
+ max_vaalue: BN;
13
+ slot: BN;
14
+ min_slot: BN;
15
+ max_slot: BN;
16
+ }
17
+ interface OracleSubmission {
18
+ oracle: PublicKey;
19
+ slot: BN;
20
+ value: BN;
21
+ }
22
+ interface PullFeedAccountData {
23
+ submissions: OracleSubmission[];
24
+ authority: PublicKey;
25
+ queue: PublicKey;
26
+ feed_hash: Buffer;
27
+ initialized_at: BN;
28
+ permissions: BN;
29
+ max_variance: BN;
30
+ min_responses: number;
31
+ name: Buffer;
32
+ sample_size: number;
33
+ last_update_timestamp: BN;
34
+ lut_slot: BN;
35
+ result: CurrentResult;
36
+ max_staleness: number;
37
+ min_sample_size: number;
38
+ }
39
+ type CrossbarSimulatePayload = FeedResponse[];
40
+ interface FeedResponse {
41
+ feedHash: string;
42
+ results: number[];
43
+ }
44
+ declare const switchboardAccountCoder: BorshCoder<string, string>;
45
+ declare function getSwitchboardProgram(provider: Provider): Program;
46
+ declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
47
+
48
+ /** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
49
+ interface ExponentVault {
50
+ /** Vault signer authority (`merge.authority`, via `has_one = authority`). */
51
+ authority: PublicKey;
52
+ syProgram: PublicKey;
53
+ mintSy: PublicKey;
54
+ mintYt: PublicKey;
55
+ mintPt: PublicKey;
56
+ escrowSy: PublicKey;
57
+ yieldPosition: PublicKey;
58
+ addressLookupTable: PublicKey;
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). */
67
+ finalSyExchangeRate: BigNumber;
68
+ /** Raw status byte. */
69
+ status: number;
70
+ }
71
+
72
+ /**
73
+ * Accounts required by `merge`. Most are read off the maturity's `Vault` account
74
+ * (`mintYt`, `mintPt`, `escrowSy`, `syProgram`, `addressLookupTable`, `yieldPosition`,
75
+ * `authority`); the `*Ata` accounts are the owner's token accounts.
76
+ *
77
+ * After maturity, `merge` burns PT only (the YT burn is skipped because the vault is
78
+ * inactive) — but the YT accounts are still required by the instruction, so `ytSrcAta`
79
+ * must be a valid (possibly empty, freshly-created) YT token account.
80
+ */
81
+ interface ExponentMergeAccounts {
82
+ /** Position owner / signer (the marginfi account authority). */
83
+ owner: PublicKey;
84
+ /** Vault signer authority (`Vault.authority`). */
85
+ authority: PublicKey;
86
+ /** The maturity vault address. */
87
+ vault: PublicKey;
88
+ /** Owner's SY token account (destination of the redeemed SY). */
89
+ sySrcDstAta: PublicKey;
90
+ /** `Vault.escrow_sy`. */
91
+ escrowSy: PublicKey;
92
+ /** Owner's YT token account (source; empty/0 after maturity). */
93
+ ytSrcAta: PublicKey;
94
+ /** Owner's PT token account (source; holds the withdrawn PT). */
95
+ ptSrcAta: PublicKey;
96
+ /** `Vault.mint_yt`. */
97
+ mintYt: PublicKey;
98
+ /** `Vault.mint_pt`. */
99
+ mintPt: PublicKey;
100
+ /** `Vault.sy_program`. */
101
+ syProgram: PublicKey;
102
+ /** `Vault.address_lookup_table`. */
103
+ addressLookupTable: PublicKey;
104
+ /** `Vault.yield_position`. */
105
+ yieldPosition: PublicKey;
106
+ /** SPL token program for PT/YT/SY mints (defaults to the classic token program). */
107
+ tokenProgram?: PublicKey;
108
+ }
109
+ interface ResolveExponentMergeContextParams {
110
+ connection: Connection;
111
+ /** Position owner / signer (the marginfi account authority). */
112
+ owner: PublicKey;
113
+ /** The maturity vault, or… */
114
+ vault?: PublicKey;
115
+ /** …the `MarketTwo` address (its `vault` will be read). One of `vault`/`market` is required. */
116
+ market?: PublicKey;
117
+ /** Token program for the PT/YT mints (Exponent's `merge` uses the classic Token program). */
118
+ ptYtTokenProgram?: PublicKey;
119
+ /** Token program for the SY mint (may be token-2022). Defaults to classic Token. */
120
+ syTokenProgram?: PublicKey;
121
+ }
122
+ /**
123
+ * Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
124
+ * accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
125
+ * redeemed SY amount from the vault's PT redemption rate.
126
+ */
127
+ interface ExponentMergeContext {
128
+ vaultAddress: PublicKey;
129
+ vault: ExponentVault;
130
+ mergeAccounts: ExponentMergeAccounts;
131
+ underlying: {
132
+ mint: PublicKey;
133
+ decimals: number;
134
+ tokenProgram: PublicKey;
135
+ };
136
+ /**
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`.
140
+ */
141
+ computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
142
+ }
143
+
144
+ export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentMergeContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentMergeContext as a, type ExponentMergeAccounts as b, type CrossbarSimulatePayload as c, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };
@@ -0,0 +1,144 @@
1
+ import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
2
+ import BN from 'bn.js';
3
+ import { PublicKey, Connection } from '@solana/web3.js';
4
+
5
+ declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
6
+ interface CurrentResult {
7
+ value: BN;
8
+ std_dev: BN;
9
+ mean: BN;
10
+ range: BN;
11
+ min_value: BN;
12
+ max_vaalue: BN;
13
+ slot: BN;
14
+ min_slot: BN;
15
+ max_slot: BN;
16
+ }
17
+ interface OracleSubmission {
18
+ oracle: PublicKey;
19
+ slot: BN;
20
+ value: BN;
21
+ }
22
+ interface PullFeedAccountData {
23
+ submissions: OracleSubmission[];
24
+ authority: PublicKey;
25
+ queue: PublicKey;
26
+ feed_hash: Buffer;
27
+ initialized_at: BN;
28
+ permissions: BN;
29
+ max_variance: BN;
30
+ min_responses: number;
31
+ name: Buffer;
32
+ sample_size: number;
33
+ last_update_timestamp: BN;
34
+ lut_slot: BN;
35
+ result: CurrentResult;
36
+ max_staleness: number;
37
+ min_sample_size: number;
38
+ }
39
+ type CrossbarSimulatePayload = FeedResponse[];
40
+ interface FeedResponse {
41
+ feedHash: string;
42
+ results: number[];
43
+ }
44
+ declare const switchboardAccountCoder: BorshCoder<string, string>;
45
+ declare function getSwitchboardProgram(provider: Provider): Program;
46
+ declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
47
+
48
+ /** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
49
+ interface ExponentVault {
50
+ /** Vault signer authority (`merge.authority`, via `has_one = authority`). */
51
+ authority: PublicKey;
52
+ syProgram: PublicKey;
53
+ mintSy: PublicKey;
54
+ mintYt: PublicKey;
55
+ mintPt: PublicKey;
56
+ escrowSy: PublicKey;
57
+ yieldPosition: PublicKey;
58
+ addressLookupTable: PublicKey;
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). */
67
+ finalSyExchangeRate: BigNumber;
68
+ /** Raw status byte. */
69
+ status: number;
70
+ }
71
+
72
+ /**
73
+ * Accounts required by `merge`. Most are read off the maturity's `Vault` account
74
+ * (`mintYt`, `mintPt`, `escrowSy`, `syProgram`, `addressLookupTable`, `yieldPosition`,
75
+ * `authority`); the `*Ata` accounts are the owner's token accounts.
76
+ *
77
+ * After maturity, `merge` burns PT only (the YT burn is skipped because the vault is
78
+ * inactive) — but the YT accounts are still required by the instruction, so `ytSrcAta`
79
+ * must be a valid (possibly empty, freshly-created) YT token account.
80
+ */
81
+ interface ExponentMergeAccounts {
82
+ /** Position owner / signer (the marginfi account authority). */
83
+ owner: PublicKey;
84
+ /** Vault signer authority (`Vault.authority`). */
85
+ authority: PublicKey;
86
+ /** The maturity vault address. */
87
+ vault: PublicKey;
88
+ /** Owner's SY token account (destination of the redeemed SY). */
89
+ sySrcDstAta: PublicKey;
90
+ /** `Vault.escrow_sy`. */
91
+ escrowSy: PublicKey;
92
+ /** Owner's YT token account (source; empty/0 after maturity). */
93
+ ytSrcAta: PublicKey;
94
+ /** Owner's PT token account (source; holds the withdrawn PT). */
95
+ ptSrcAta: PublicKey;
96
+ /** `Vault.mint_yt`. */
97
+ mintYt: PublicKey;
98
+ /** `Vault.mint_pt`. */
99
+ mintPt: PublicKey;
100
+ /** `Vault.sy_program`. */
101
+ syProgram: PublicKey;
102
+ /** `Vault.address_lookup_table`. */
103
+ addressLookupTable: PublicKey;
104
+ /** `Vault.yield_position`. */
105
+ yieldPosition: PublicKey;
106
+ /** SPL token program for PT/YT/SY mints (defaults to the classic token program). */
107
+ tokenProgram?: PublicKey;
108
+ }
109
+ interface ResolveExponentMergeContextParams {
110
+ connection: Connection;
111
+ /** Position owner / signer (the marginfi account authority). */
112
+ owner: PublicKey;
113
+ /** The maturity vault, or… */
114
+ vault?: PublicKey;
115
+ /** …the `MarketTwo` address (its `vault` will be read). One of `vault`/`market` is required. */
116
+ market?: PublicKey;
117
+ /** Token program for the PT/YT mints (Exponent's `merge` uses the classic Token program). */
118
+ ptYtTokenProgram?: PublicKey;
119
+ /** Token program for the SY mint (may be token-2022). Defaults to classic Token. */
120
+ syTokenProgram?: PublicKey;
121
+ }
122
+ /**
123
+ * Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
124
+ * accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
125
+ * redeemed SY amount from the vault's PT redemption rate.
126
+ */
127
+ interface ExponentMergeContext {
128
+ vaultAddress: PublicKey;
129
+ vault: ExponentVault;
130
+ mergeAccounts: ExponentMergeAccounts;
131
+ underlying: {
132
+ mint: PublicKey;
133
+ decimals: number;
134
+ tokenProgram: PublicKey;
135
+ };
136
+ /**
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`.
140
+ */
141
+ computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
142
+ }
143
+
144
+ export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentMergeContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentMergeContext as a, type ExponentMergeAccounts as b, type CrossbarSimulatePayload as c, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };