@sanctumso/inf1 0.0.2-dev-1 → 0.0.2-dev-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.
Files changed (4) hide show
  1. package/index.d.ts +144 -122
  2. package/index.js +168 -151
  3. package/index_bg.wasm +0 -0
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,31 +1,41 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Returned accounts are deduped
4
+ * Returns the pubkeys of the accounts that need to be fetched to initialize
5
+ * a new {@link Inf} object
6
+ */
7
+ export function initPks(): Bs58Array[];
8
+ /**
9
+ * Initialize a new {@link Inf} object.
10
+ *
11
+ * The returned object must be updated for a mint pair before it is ready to
12
+ * quote and operate for trades involving that pair
5
13
  *
6
14
  * @throws
7
15
  */
8
- export function accountsToUpdateForRebalance(inf: Inf, arg1: PkPair): Bs58Array[];
16
+ export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
9
17
  /**
18
+ * Same as {@link init}, but instead of using accounts fetched from RPC,
19
+ * uses the accounts' js objects
20
+ *
10
21
  * @throws
11
22
  */
12
- export function updateForRebalance(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
23
+ export function initObj(pool: PoolStateV2, lst_state_list: LstState[], arg2: SplPoolAccounts): Inf;
24
+ export function cloneInf(src: Inf): Inf;
13
25
  /**
14
- * Add SPL LSTs auxiliary data to support new SPL LSTs that may have previously not been covered
26
+ * Returned accounts are deduped
27
+ *
28
+ * @throws
15
29
  */
16
- export function appendSplLsts(inf: Inf, arg1: SplPoolAccounts): void;
30
+ export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
17
31
  /**
18
- * Returns if the given SPL LST mints have their {@link SplPoolAccounts} present in the object.
19
- *
20
- * Returns a byte array where ret[i] corresponds to the result for `mints[i]`.
21
- * 0 - false, 1 - true.
22
- *
23
- * If false is returned, then the data needs to be added via {@link appendSplLsts}
24
- *
25
- * This fn returns a byte array instead of `boolean` array because wasm_bindgen's type
26
- * conversion doesnt work with bool arrays.
32
+ * @throws
27
33
  */
28
- export function hasSplData(inf: Inf, mints: Bs58Array[]): Uint8Array;
34
+ export function updateForTrade(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
35
+ /**
36
+ * @throws
37
+ */
38
+ export function rebalanceIxs(inf: Inf, arg1: RebalanceArgs): RebalanceIxs;
29
39
  /**
30
40
  * @throws if no valid PDA found
31
41
  */
@@ -44,19 +54,11 @@ export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
44
54
  * @throws
45
55
  */
46
56
  export function quoteTradeExactOut(inf: Inf, arg1: QuoteArgs): Quote;
47
- /**
48
- * @throws
49
- */
50
- export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
51
- /**
52
- * @throws
53
- */
54
- export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
55
57
  export function getPoolState(inf: Inf): PoolStateV2;
56
58
  /**
57
59
  * Sets the `PoolState` account data
58
60
  */
59
- export function setPoolState(inf: Inf, arg1: PoolStateV2): void;
61
+ export function setPoolState(inf: Inf, intf: PoolStateV2): void;
60
62
  /**
61
63
  * Returns serialized `PoolState` account data
62
64
  */
@@ -82,41 +84,59 @@ export function serLstStateList(inf: Inf): Uint8Array;
82
84
  */
83
85
  export function deserLstStateList(inf: Inf, lst_state_list_data: Uint8Array): void;
84
86
  /**
85
- * Returns the array of all possible {@link InfErr}s
87
+ * Returned accounts are deduped
88
+ *
89
+ * @throws
86
90
  */
87
- export function allInfErrs(): AllInfErrs;
88
- export function quoteRebalance(inf: Inf, arg1: RebalanceQuoteArgs): RebalanceQuote;
91
+ export function accountsToUpdateForRebalance(inf: Inf, arg1: PkPair): Bs58Array[];
89
92
  /**
90
- * Returns the pubkeys of the accounts that need to be fetched to initialize
91
- * a new {@link Inf} object
93
+ * @throws
92
94
  */
93
- export function initPks(): Bs58Array[];
95
+ export function updateForRebalance(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
94
96
  /**
95
- * Initialize a new {@link Inf} object.
97
+ * Add SPL LSTs auxiliary data to support new SPL LSTs that may have previously not been covered
98
+ */
99
+ export function appendSplLsts(inf: Inf, arg1: SplPoolAccounts): void;
100
+ /**
101
+ * Returns if the given SPL LST mints have their {@link SplPoolAccounts} present in the object.
96
102
  *
97
- * The returned object must be updated for a mint pair before it is ready to
98
- * quote and operate for trades involving that pair
103
+ * Returns a byte array where ret[i] corresponds to the result for `mints[i]`.
104
+ * 0 - false, 1 - true.
99
105
  *
100
- * @throws
106
+ * If false is returned, then the data needs to be added via {@link appendSplLsts}
107
+ *
108
+ * This fn returns a byte array instead of `boolean` array because wasm_bindgen's type
109
+ * conversion doesnt work with bool arrays.
101
110
  */
102
- export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
103
- export function cloneInf(src: Inf): Inf;
111
+ export function hasSplData(inf: Inf, mints: Bs58Array[]): Uint8Array;
104
112
  /**
105
- * Returned accounts are deduped
106
- *
107
- * @throws
113
+ * Returns the array of all possible {@link InfErr}s
108
114
  */
109
- export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
115
+ export function allInfErrs(): AllInfErrs;
116
+ export function quoteRebalance(inf: Inf, arg1: RebalanceQuoteArgs): RebalanceQuote;
110
117
  /**
111
118
  * @throws
112
119
  */
113
- export function updateForTrade(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
120
+ export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
114
121
  /**
115
122
  * @throws
116
123
  */
117
- export function rebalanceIxs(inf: Inf, arg1: RebalanceArgs): RebalanceIxs;
124
+ export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
118
125
  export type FoundPda = [B58PK, number];
119
126
 
127
+ export interface RebalanceArgs {
128
+ out: bigint;
129
+ minStartingOutLst: bigint;
130
+ maxStartingInpLst: bigint;
131
+ mints: PkPair;
132
+ withdrawTo: B58PK;
133
+ }
134
+
135
+ export interface RebalanceIxs {
136
+ start: Instruction;
137
+ end: Instruction;
138
+ }
139
+
120
140
  export type FeeMint = "inp" | "out";
121
141
 
122
142
  export interface QuoteArgs {
@@ -136,6 +156,13 @@ export interface Quote {
136
156
  * will leave the user\'s wallet.
137
157
  */
138
158
  inp: bigint;
159
+ /**
160
+ * SOL value of `inp` input tokens.
161
+ *
162
+ * SOL value of `out` output tokens
163
+ * = inp_sol_val - fee
164
+ */
165
+ inpSolVal: bigint;
139
166
  /**
140
167
  * Amount of output tokens returned by the pool to the user,
141
168
  * after fees. This is exactly the amount of tokens that
@@ -150,14 +177,56 @@ export interface Quote {
150
177
  mints: PkPair;
151
178
  }
152
179
 
153
- export interface TradeArgs {
154
- amt: bigint;
155
- limit: bigint;
156
- mints: PkPair;
157
- signer: B58PK;
158
- tokenAccs: PkPair;
180
+ export interface LstState {
181
+ isInputDisabled: number;
182
+ poolReservesBump: number;
183
+ protocolFeeAccumulatorBump: number;
184
+ solValue: bigint;
185
+ mint: B58PK;
186
+ solValueCalculator: B58PK;
187
+ }
188
+
189
+ export interface PoolStateV2 {
190
+ totalSolValue: bigint;
191
+ protocolFeeNanos: number;
192
+ version: number;
193
+ isDisabled: number;
194
+ isRebalancing: number;
195
+ admin: B58PK;
196
+ rebalanceAuthority: B58PK;
197
+ protocolFeeBeneficiary: B58PK;
198
+ pricingProgram: B58PK;
199
+ lpTokenMint: B58PK;
200
+ rpsAuthority: B58PK;
201
+ rps: bigint;
202
+ withheldLamports: bigint;
203
+ protocolFeeLamports: bigint;
204
+ lastReleaseSlot: bigint;
205
+ }
206
+
207
+ export interface Account {
208
+ data: Uint8Array;
209
+ owner: B58PK;
210
+ }
211
+
212
+ /**
213
+ * Map of `mint: stake pool account` for spl (all deploys) LSTs.
214
+ *
215
+ * This data is required to determine how to properly initialize the corresponding
216
+ * sol value calculator data since which stake pool account corresponds to which mint
217
+ * is not available onchain (yet)
218
+ */
219
+ export type SplPoolAccounts = Map<B58PK, B58PK>;
220
+
221
+ export type AccountMap = Map<B58PK, Account>;
222
+
223
+ export interface PkPair {
224
+ inp: B58PK;
225
+ out: B58PK;
159
226
  }
160
227
 
228
+ export type B58PK = Bs58Array;
229
+
161
230
 
162
231
  export type ERR_CODE_MSG_SEP = ":";
163
232
 
@@ -193,6 +262,13 @@ export interface RebalanceQuote {
193
262
  * Amount of output tokens that will leave the pool in StartRebalance
194
263
  */
195
264
  out: bigint;
265
+ /**
266
+ * SOL value of `out` output tokens.
267
+ *
268
+ * SOL value of `inp` input tokens
269
+ * should be the same, barring rounding
270
+ */
271
+ outSolVal: bigint;
196
272
  mints: PkPair;
197
273
  }
198
274
 
@@ -214,67 +290,12 @@ export interface Instruction {
214
290
  programAddress: B58PK;
215
291
  }
216
292
 
217
- export interface LstState {
218
- isInputDisabled: number;
219
- poolReservesBump: number;
220
- protocolFeeAccumulatorBump: number;
221
- solValue: bigint;
222
- mint: B58PK;
223
- solValueCalculator: B58PK;
224
- }
225
-
226
- export interface PoolStateV2 {
227
- totalSolValue: bigint;
228
- protocolFeeNanos: number;
229
- version: number;
230
- isDisabled: number;
231
- isRebalancing: number;
232
- admin: B58PK;
233
- rebalanceAuthority: B58PK;
234
- protocolFeeBeneficiary: B58PK;
235
- pricingProgram: B58PK;
236
- lpTokenMint: B58PK;
237
- rpsAuthority: B58PK;
238
- rps: bigint;
239
- withheldLamports: bigint;
240
- protocolFeeLamports: bigint;
241
- lastReleaseSlot: bigint;
242
- }
243
-
244
- export interface Account {
245
- data: Uint8Array;
246
- owner: B58PK;
247
- }
248
-
249
- /**
250
- * Map of `mint: stake pool account` for spl (all deploys) LSTs.
251
- *
252
- * This data is required to determine how to properly initialize the corresponding
253
- * sol value calculator data since which stake pool account corresponds to which mint
254
- * is not available onchain (yet)
255
- */
256
- export type SplPoolAccounts = Map<B58PK, B58PK>;
257
-
258
- export type AccountMap = Map<B58PK, Account>;
259
-
260
- export interface PkPair {
261
- inp: B58PK;
262
- out: B58PK;
263
- }
264
-
265
- export type B58PK = Bs58Array;
266
-
267
- export interface RebalanceArgs {
268
- out: bigint;
269
- minStartingOutLst: bigint;
270
- maxStartingInpLst: bigint;
293
+ export interface TradeArgs {
294
+ amt: bigint;
295
+ limit: bigint;
271
296
  mints: PkPair;
272
- withdrawTo: B58PK;
273
- }
274
-
275
- export interface RebalanceIxs {
276
- start: Instruction;
277
- end: Instruction;
297
+ signer: B58PK;
298
+ tokenAccs: PkPair;
278
299
  }
279
300
 
280
301
  export type Bs58Array = string
@@ -288,16 +309,18 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
288
309
 
289
310
  export interface InitOutput {
290
311
  readonly memory: WebAssembly.Memory;
291
- readonly accountsToUpdateForRebalance: (a: number, b: any) => [number, number, number, number];
292
- readonly updateForRebalance: (a: number, b: any, c: any) => [number, number];
293
- readonly appendSplLsts: (a: number, b: any) => void;
294
- readonly hasSplData: (a: number, b: number, c: number) => [number, number];
312
+ readonly __wbg_inf_free: (a: number, b: number) => void;
313
+ readonly initPks: () => [number, number];
314
+ readonly init: (a: any, b: any) => [number, number, number];
315
+ readonly initObj: (a: any, b: number, c: number, d: any) => [number, number, number];
316
+ readonly cloneInf: (a: number) => number;
317
+ readonly accountsToUpdateForTrade: (a: number, b: any) => [number, number, number, number];
318
+ readonly updateForTrade: (a: number, b: any, c: any) => [number, number];
319
+ readonly rebalanceIxs: (a: number, b: any) => [number, number, number];
295
320
  readonly findPoolReservesAta: (a: any) => [number, number, number];
296
321
  readonly findProtocolFeeAccumulatorAta: (a: any) => [number, number, number];
297
322
  readonly quoteTradeExactIn: (a: number, b: any) => [number, number, number];
298
323
  readonly quoteTradeExactOut: (a: number, b: any) => [number, number, number];
299
- readonly tradeExactInIx: (a: number, b: any) => [number, number, number];
300
- readonly tradeExactOutIx: (a: number, b: any) => [number, number, number];
301
324
  readonly getPoolState: (a: number) => any;
302
325
  readonly setPoolState: (a: number, b: any) => void;
303
326
  readonly serPoolState: (a: number) => [number, number];
@@ -306,23 +329,22 @@ export interface InitOutput {
306
329
  readonly setLstStateList: (a: number, b: number, c: number) => void;
307
330
  readonly serLstStateList: (a: number) => [number, number];
308
331
  readonly deserLstStateList: (a: number, b: number, c: number) => [number, number];
332
+ readonly accountsToUpdateForRebalance: (a: number, b: any) => [number, number, number, number];
333
+ readonly updateForRebalance: (a: number, b: any, c: any) => [number, number];
334
+ readonly appendSplLsts: (a: number, b: any) => void;
335
+ readonly hasSplData: (a: number, b: number, c: number) => [number, number];
309
336
  readonly allInfErrs: () => any;
310
337
  readonly quoteRebalance: (a: number, b: any) => [number, number, number];
311
- readonly __wbg_inf_free: (a: number, b: number) => void;
312
- readonly initPks: () => [number, number];
313
- readonly init: (a: any, b: any) => [number, number, number];
314
- readonly cloneInf: (a: number) => number;
315
- readonly accountsToUpdateForTrade: (a: number, b: any) => [number, number, number, number];
316
- readonly updateForTrade: (a: number, b: any, c: any) => [number, number];
317
- readonly rebalanceIxs: (a: number, b: any) => [number, number, number];
338
+ readonly tradeExactInIx: (a: number, b: any) => [number, number, number];
339
+ readonly tradeExactOutIx: (a: number, b: any) => [number, number, number];
318
340
  readonly __wbindgen_malloc: (a: number, b: number) => number;
319
341
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
320
342
  readonly __wbindgen_exn_store: (a: number) => void;
321
343
  readonly __externref_table_alloc: () => number;
322
344
  readonly __wbindgen_export_4: WebAssembly.Table;
323
- readonly __externref_table_dealloc: (a: number) => void;
324
345
  readonly __externref_drop_slice: (a: number, b: number) => void;
325
346
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
347
+ readonly __externref_table_dealloc: (a: number) => void;
326
348
  readonly __wbindgen_start: () => void;
327
349
  }
328
350