@exponent-labs/exponent-sdk 0.0.3

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/addressLookupTableUtil.d.ts +12 -0
  3. package/build/addressLookupTableUtil.js +32 -0
  4. package/build/addressLookupTableUtil.js.map +1 -0
  5. package/build/environment.d.ts +10 -0
  6. package/build/environment.js +13 -0
  7. package/build/environment.js.map +1 -0
  8. package/build/events.d.ts +339 -0
  9. package/build/events.js +231 -0
  10. package/build/events.js.map +1 -0
  11. package/build/flavors.d.ts +24 -0
  12. package/build/flavors.js +713 -0
  13. package/build/flavors.js.map +1 -0
  14. package/build/index.d.ts +11 -0
  15. package/build/index.js +45 -0
  16. package/build/index.js.map +1 -0
  17. package/build/lpPosition.d.ts +35 -0
  18. package/build/lpPosition.js +103 -0
  19. package/build/lpPosition.js.map +1 -0
  20. package/build/market.d.ts +567 -0
  21. package/build/market.js +1445 -0
  22. package/build/market.js.map +1 -0
  23. package/build/syPosition.d.ts +6 -0
  24. package/build/syPosition.js +115 -0
  25. package/build/syPosition.js.map +1 -0
  26. package/build/tokenUtil.d.ts +3 -0
  27. package/build/tokenUtil.js +23 -0
  28. package/build/tokenUtil.js.map +1 -0
  29. package/build/utils/altUtil.d.ts +8 -0
  30. package/build/utils/altUtil.js +35 -0
  31. package/build/utils/altUtil.js.map +1 -0
  32. package/build/utils/binSolver.d.ts +1 -0
  33. package/build/utils/binSolver.js +45 -0
  34. package/build/utils/binSolver.js.map +1 -0
  35. package/build/utils/binSolver.test.d.ts +1 -0
  36. package/build/utils/binSolver.test.js +15 -0
  37. package/build/utils/binSolver.test.js.map +1 -0
  38. package/build/utils/index.d.ts +6 -0
  39. package/build/utils/index.js +31 -0
  40. package/build/utils/index.js.map +1 -0
  41. package/build/utils/ix.d.ts +6 -0
  42. package/build/utils/ix.js +3 -0
  43. package/build/utils/ix.js.map +1 -0
  44. package/build/vault.d.ts +289 -0
  45. package/build/vault.js +615 -0
  46. package/build/vault.js.map +1 -0
  47. package/build/ytPosition.d.ts +86 -0
  48. package/build/ytPosition.js +231 -0
  49. package/build/ytPosition.js.map +1 -0
  50. package/jest.config.js +5 -0
  51. package/package.json +42 -0
  52. package/src/addressLookupTableUtil.ts +34 -0
  53. package/src/environment.ts +19 -0
  54. package/src/events.ts +595 -0
  55. package/src/flavors.ts +773 -0
  56. package/src/index.ts +11 -0
  57. package/src/lpPosition.ts +129 -0
  58. package/src/market.ts +2338 -0
  59. package/src/syPosition.ts +151 -0
  60. package/src/tokenUtil.ts +20 -0
  61. package/src/utils/altUtil.ts +47 -0
  62. package/src/utils/binSolver.test.ts +15 -0
  63. package/src/utils/binSolver.ts +44 -0
  64. package/src/utils/index.ts +32 -0
  65. package/src/utils/ix.ts +7 -0
  66. package/src/vault.ts +999 -0
  67. package/src/ytPosition.ts +313 -0
  68. package/tsconfig.json +38 -0
@@ -0,0 +1,289 @@
1
+ /// <reference types="bn.js" />
2
+ import { BN, web3 } from "@coral-xyz/anchor";
3
+ import { ClaimAmount } from "@exponent-labs/exponent-ix";
4
+ import { Environment } from "./environment";
5
+ import { InstructionAccounts } from "./utils";
6
+ import { ExponentPDA } from "@exponent-labs/exponent-pda";
7
+ import { VaultEmission, VaultJson, VaultState, AnchorizedPNum, CpiAccountsRaw } from "@exponent-labs/exponent-types";
8
+ export type CollectTreasuryEmissionKind = {
9
+ yieldPosition: {};
10
+ } | {
11
+ treasuryEmission: {};
12
+ };
13
+ export type CollectTreasuryInterestKind = {
14
+ yieldPosition: {};
15
+ } | {
16
+ treasuryInterest: {};
17
+ };
18
+ /** Emission info for SY program */
19
+ interface SyEmission {
20
+ /** Token account that holds emission tokens */
21
+ escrowAccountAddress: web3.PublicKey;
22
+ /** Mint for the emission token */
23
+ mint: web3.PublicKey;
24
+ /** Token program ID for the emission token */
25
+ tokenProgramAddress: web3.PublicKey;
26
+ /** How many emissions have been claimed by SY holders */
27
+ totalClaimed: BN;
28
+ /** How many emissions have been earned by the SY robot over its lifetime */
29
+ lastSeenTotalAccruedEmissions: BN;
30
+ /** Global index for sharing out rewards to SY holders */
31
+ index: AnchorizedPNum;
32
+ }
33
+ export declare class Vault {
34
+ state: VaultState;
35
+ selfAddress: web3.PublicKey;
36
+ env: Environment;
37
+ connection: web3.Connection;
38
+ private coreProgram;
39
+ constructor(state: VaultState, selfAddress: web3.PublicKey, env: Environment, connection: web3.Connection);
40
+ static loadFromJson(v: VaultJson, address: web3.PublicKey, env: Environment, connection: web3.Connection): Vault;
41
+ static load(env: Environment, connection: web3.Connection, address: web3.PublicKey): Promise<Vault>;
42
+ reload(conn?: web3.Connection): Promise<Vault>;
43
+ toJson(): VaultJson;
44
+ get pda(): ExponentPDA;
45
+ get syBalance(): bigint;
46
+ get mintSy(): web3.PublicKey;
47
+ getAdminStatePda(): web3.PublicKey;
48
+ get mintPt(): web3.PublicKey;
49
+ get mintYt(): web3.PublicKey;
50
+ get flavor(): import("@exponent-labs/exponent-types").Flavor;
51
+ get cpiAccounts(): CpiAccountsRaw;
52
+ get authority(): web3.PublicKey;
53
+ get escrowSy(): web3.PublicKey;
54
+ get addressLookupTable(): web3.PublicKey;
55
+ get eventAuthority(): web3.PublicKey;
56
+ /** Emission metadata from SY program */
57
+ get syEmissions(): SyEmission[];
58
+ /** Emissions from the vault */
59
+ get vaultEmissions(): VaultEmission[];
60
+ /** Get the escrow token account addresses for the emissions, in order */
61
+ get vaultEmissionTokenAccounts(): web3.PublicKey[];
62
+ get currentSyExchangeRate(): number;
63
+ get escrowYt(): web3.PublicKey;
64
+ /** UNIX Timestamp (seconds) at which the vault expires */
65
+ get expirationTimestamp(): number;
66
+ /** Date at which the vault expires */
67
+ get expirationDate(): Date;
68
+ /** Collect an emission earned with a YT position */
69
+ ixCollectEmission({ owner, emissionIndex, amount, emissionDst, }: {
70
+ owner: web3.PublicKey;
71
+ emissionIndex: number;
72
+ amount: ClaimAmount;
73
+ emissionDst?: web3.PublicKey;
74
+ }): Promise<web3.TransactionInstruction>;
75
+ /** Strip SY into PT & YT */
76
+ ixStrip({ syIn, depositor, ptDst, ytDst, sySrc, }: {
77
+ syIn: bigint;
78
+ depositor: web3.PublicKey;
79
+ ptDst?: web3.PublicKey;
80
+ ytDst?: web3.PublicKey;
81
+ sySrc?: web3.PublicKey;
82
+ }): Promise<web3.TransactionInstruction>;
83
+ ixStripFromBase({ owner, amountBase, baseSrc, sySrc, ptDst, ytDst, }: {
84
+ owner: web3.PublicKey;
85
+ amountBase: bigint;
86
+ baseSrc?: web3.PublicKey;
87
+ sySrc?: web3.PublicKey;
88
+ ptDst?: web3.PublicKey;
89
+ ytDst?: web3.PublicKey;
90
+ }): Promise<web3.TransactionInstruction>;
91
+ ixMergeToBase({ owner, amountPy, ptSrc, ytSrc, syDst, baseDst, }: {
92
+ owner: web3.PublicKey;
93
+ amountPy: bigint;
94
+ ptSrc?: web3.PublicKey;
95
+ ytSrc?: web3.PublicKey;
96
+ syDst?: web3.PublicKey;
97
+ baseDst?: web3.PublicKey;
98
+ }): Promise<web3.TransactionInstruction>;
99
+ /** Merge PT & YT into SY */
100
+ ixMerge({ pyIn, depositor, ptSrc, ytSrc, syDst, }: {
101
+ pyIn: bigint;
102
+ depositor: web3.PublicKey;
103
+ ptSrc?: web3.PublicKey;
104
+ ytSrc?: web3.PublicKey;
105
+ syDst?: web3.PublicKey;
106
+ }): Promise<web3.TransactionInstruction>;
107
+ /** Initialize the yield position for a vault */
108
+ ixInitializeYieldPosition({ owner }: {
109
+ owner: web3.PublicKey;
110
+ }): Promise<web3.TransactionInstruction>;
111
+ /** Collect interest (as SY) from a yield position */
112
+ ixCollectInterest({ owner, amount, syDst }: {
113
+ owner: web3.PublicKey;
114
+ amount: ClaimAmount;
115
+ syDst?: web3.PublicKey;
116
+ }): Promise<web3.TransactionInstruction>;
117
+ /** Administrative action to configure a vault */
118
+ /** Administrative action to configure a vault */
119
+ ixConfigureVault({ signer, action, }: {
120
+ signer: web3.PublicKey;
121
+ action: AdminAction;
122
+ }): Promise<web3.TransactionInstruction>;
123
+ collectEmissionAccounts({ emissionIndex, owner, emissionDst, }: {
124
+ emissionIndex: number;
125
+ owner: web3.PublicKey;
126
+ emissionDst?: web3.PublicKey;
127
+ }): InstructionAccounts<CollectEmissionAccounts>;
128
+ stripAccounts({ depositor, ptDst, ytDst, sySrc, }: {
129
+ depositor: web3.PublicKey;
130
+ ptDst?: web3.PublicKey;
131
+ ytDst?: web3.PublicKey;
132
+ sySrc?: web3.PublicKey;
133
+ }): InstructionAccounts<StripAccounts>;
134
+ ixCollectTreasuryInterest({ signer, syDst, amount, kind, }: {
135
+ signer: web3.PublicKey;
136
+ syDst: web3.PublicKey;
137
+ amount: ClaimAmount;
138
+ kind: CollectTreasuryInterestKind;
139
+ }): Promise<web3.TransactionInstruction>;
140
+ ixCollectTreasuryEmission({ index, amount, emissionDst, signer, kind, }: {
141
+ index: number;
142
+ amount: ClaimAmount;
143
+ emissionDst: web3.PublicKey;
144
+ signer: web3.PublicKey;
145
+ kind: CollectTreasuryEmissionKind;
146
+ }): Promise<web3.TransactionInstruction>;
147
+ ixAddStandaloneEmission({ signer, emissionMint, emissionTokenProgram, treasuryTokenAccountEmission, treasuryFeeBps, altAddresses, cpiAccounts, }: {
148
+ signer: web3.PublicKey;
149
+ emissionMint: web3.PublicKey;
150
+ emissionTokenProgram?: web3.PublicKey;
151
+ treasuryTokenAccountEmission: web3.PublicKey;
152
+ treasuryFeeBps: number;
153
+ altAddresses: web3.PublicKey[];
154
+ cpiAccounts: CpiAccountsRaw;
155
+ }): Promise<{
156
+ extendAddressLookupTableExtensionAccounts: web3.PublicKey[];
157
+ ix: web3.TransactionInstruction;
158
+ }>;
159
+ collectInterestAccounts({ owner, syDst, }: {
160
+ owner: web3.PublicKey;
161
+ syDst?: web3.PublicKey;
162
+ }): InstructionAccounts<CollectInterestAccounts>;
163
+ /** Construct accounts for Merge instruction */
164
+ mergeAccounts({ owner, ptSrc, ytSrc, syDst, }: {
165
+ owner: web3.PublicKey;
166
+ ptSrc?: web3.PublicKey;
167
+ ytSrc?: web3.PublicKey;
168
+ syDst?: web3.PublicKey;
169
+ }): InstructionAccounts<MergeAccounts>;
170
+ initializeYieldPositionAccounts({ owner, }: {
171
+ owner: web3.PublicKey;
172
+ }): InstructionAccounts<InitializeYieldPositionAccounts>;
173
+ /** Construct accounts for Merge instruction */
174
+ configureVaultAccounts({ signer }: {
175
+ signer: web3.PublicKey;
176
+ }): InstructionAccounts<ConfigureVaultAccounts>;
177
+ }
178
+ export interface CollectInterestAccounts {
179
+ vault: web3.PublicKey;
180
+ owner: web3.PublicKey;
181
+ authority: web3.PublicKey;
182
+ escrowSy: web3.PublicKey;
183
+ tokenSyDst: web3.PublicKey;
184
+ tokenProgram: web3.PublicKey;
185
+ yieldPosition: web3.PublicKey;
186
+ addressLookupTable: web3.PublicKey;
187
+ syProgram: web3.PublicKey;
188
+ treasurySyTokenAccount: web3.PublicKey;
189
+ eventAuthority: web3.PublicKey;
190
+ program: web3.PublicKey;
191
+ }
192
+ export interface CollectEmissionAccounts {
193
+ owner: web3.PublicKey;
194
+ vault: web3.PublicKey;
195
+ position: web3.PublicKey;
196
+ syProgram: web3.PublicKey;
197
+ addressLookupTable: web3.PublicKey;
198
+ authority: web3.PublicKey;
199
+ emissionEscrow: web3.PublicKey;
200
+ emissionDst: web3.PublicKey;
201
+ treasuryEmissionTokenAccount: web3.PublicKey;
202
+ tokenProgram: web3.PublicKey;
203
+ eventAuthority: web3.PublicKey;
204
+ program: web3.PublicKey;
205
+ }
206
+ /** Accounts used by Merge */
207
+ export interface MergeAccounts {
208
+ owner: web3.PublicKey;
209
+ authority: web3.PublicKey;
210
+ vault: web3.PublicKey;
211
+ escrowSy: web3.PublicKey;
212
+ ytSrc: web3.PublicKey;
213
+ ptSrc: web3.PublicKey;
214
+ syDst: web3.PublicKey;
215
+ mintPt: web3.PublicKey;
216
+ mintYt: web3.PublicKey;
217
+ addressLookupTable: web3.PublicKey;
218
+ syProgram: web3.PublicKey;
219
+ tokenProgram: web3.PublicKey;
220
+ yieldPosition: web3.PublicKey;
221
+ eventAuthority: web3.PublicKey;
222
+ program: web3.PublicKey;
223
+ }
224
+ /** Accounts used by Strip */
225
+ export interface StripAccounts {
226
+ depositor: web3.PublicKey;
227
+ authority: web3.PublicKey;
228
+ vault: web3.PublicKey;
229
+ sySrc: web3.PublicKey;
230
+ escrowSy: web3.PublicKey;
231
+ ytDst: web3.PublicKey;
232
+ ptDst: web3.PublicKey;
233
+ mintYt: web3.PublicKey;
234
+ mintPt: web3.PublicKey;
235
+ tokenProgram: web3.PublicKey;
236
+ addressLookupTable: web3.PublicKey;
237
+ syProgram: web3.PublicKey;
238
+ yieldPosition: web3.PublicKey;
239
+ eventAuthority: web3.PublicKey;
240
+ program: web3.PublicKey;
241
+ }
242
+ /** Accounts used by Initialize Yield Position */
243
+ export interface InitializeYieldPositionAccounts {
244
+ owner: web3.PublicKey;
245
+ vault: web3.PublicKey;
246
+ yieldPosition: web3.PublicKey;
247
+ systemProgram: web3.PublicKey;
248
+ eventAuthority: web3.PublicKey;
249
+ program: web3.PublicKey;
250
+ }
251
+ /** Accounts used by Configure Vault */
252
+ export interface ConfigureVaultAccounts {
253
+ vault: web3.PublicKey;
254
+ signer: web3.PublicKey;
255
+ adminState: web3.PublicKey;
256
+ systemProgram: web3.PublicKey;
257
+ }
258
+ export type AdminAction = {
259
+ setVaultStatus: [number];
260
+ } | {
261
+ changeVaultBpsFee: [number];
262
+ } | {
263
+ changeVaultTreasuryTokenAccount: [web3.PublicKey];
264
+ } | {
265
+ changeEmissionTreasuryTokenAccount: {
266
+ emissionIndex: number;
267
+ newTokenAccount: web3.PublicKey;
268
+ };
269
+ } | {
270
+ changeMinOperationSize: {
271
+ isStrip: boolean;
272
+ newSize: BN;
273
+ };
274
+ } | {
275
+ changeEmissionBpsFee: {
276
+ emissionIndex: number;
277
+ newFeeBps: number;
278
+ };
279
+ } | {
280
+ changeClaimLimits: {
281
+ maxClaimAmountPerWindow: BN;
282
+ claimWindowDurationSeconds: number;
283
+ };
284
+ } | {
285
+ changeMaxPySupply: {
286
+ newMaxPySupply: BN;
287
+ };
288
+ };
289
+ export {};