@sanctumso/inf1 0.0.1-dev-9 → 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 +184 -141
  2. package/index.js +239 -150
  3. package/index_bg.wasm +0 -0
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,18 +1,27 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function getPoolState(inf: Inf): PoolState;
4
3
  /**
5
- * Returns serialized `PoolState` account data
4
+ * Returns the pubkeys of the accounts that need to be fetched to initialize
5
+ * a new {@link Inf} object
6
6
  */
7
- export function serPoolState(inf: Inf): Uint8Array;
7
+ export function initPks(): Bs58Array[];
8
8
  /**
9
- * @throws if stored lst state list account data is invalid
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
13
+ *
14
+ * @throws
10
15
  */
11
- export function getLstStateList(inf: Inf): LstState[];
16
+ export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
12
17
  /**
13
- * Returns serialized `LstStateList` account data
18
+ * Same as {@link init}, but instead of using accounts fetched from RPC,
19
+ * uses the accounts' js objects
20
+ *
21
+ * @throws
14
22
  */
15
- export function serLstStateList(inf: Inf): Uint8Array;
23
+ export function initObj(pool: PoolStateV2, lst_state_list: LstState[], arg2: SplPoolAccounts): Inf;
24
+ export function cloneInf(src: Inf): Inf;
16
25
  /**
17
26
  * Returned accounts are deduped
18
27
  *
@@ -23,6 +32,57 @@ export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
23
32
  * @throws
24
33
  */
25
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;
39
+ /**
40
+ * @throws if no valid PDA found
41
+ */
42
+ export function findPoolReservesAta(arg0: Bs58Array): FoundPda;
43
+ /**
44
+ * @deprecated Protocol fee accumulator token accounts are no longer used in v2
45
+ *
46
+ * @throws if no valid PDA found
47
+ */
48
+ export function findProtocolFeeAccumulatorAta(arg0: Bs58Array): FoundPda;
49
+ /**
50
+ * @throws
51
+ */
52
+ export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
53
+ /**
54
+ * @throws
55
+ */
56
+ export function quoteTradeExactOut(inf: Inf, arg1: QuoteArgs): Quote;
57
+ export function getPoolState(inf: Inf): PoolStateV2;
58
+ /**
59
+ * Sets the `PoolState` account data
60
+ */
61
+ export function setPoolState(inf: Inf, intf: PoolStateV2): void;
62
+ /**
63
+ * Returns serialized `PoolState` account data
64
+ */
65
+ export function serPoolState(inf: Inf): Uint8Array;
66
+ /**
67
+ * @throws if `pool_state_data` is invalid
68
+ */
69
+ export function deserPoolState(inf: Inf, pool_state_data: Uint8Array): void;
70
+ /**
71
+ * @throws if stored lst state list account data is invalid
72
+ */
73
+ export function getLstStateList(inf: Inf): LstState[];
74
+ /**
75
+ * Sets the `LstStateList` account data
76
+ */
77
+ export function setLstStateList(inf: Inf, lst_state_list: LstState[]): void;
78
+ /**
79
+ * Returns serialized `LstStateList` account data
80
+ */
81
+ export function serLstStateList(inf: Inf): Uint8Array;
82
+ /**
83
+ * @throws if `lst_state_list_data` is invalid
84
+ */
85
+ export function deserLstStateList(inf: Inf, lst_state_list_data: Uint8Array): void;
26
86
  /**
27
87
  * Returned accounts are deduped
28
88
  *
@@ -54,22 +114,6 @@ export function hasSplData(inf: Inf, mints: Bs58Array[]): Uint8Array;
54
114
  */
55
115
  export function allInfErrs(): AllInfErrs;
56
116
  export function quoteRebalance(inf: Inf, arg1: RebalanceQuoteArgs): RebalanceQuote;
57
- /**
58
- * @throws
59
- */
60
- export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
61
- /**
62
- * @throws
63
- */
64
- export function quoteTradeExactOut(inf: Inf, arg1: QuoteArgs): Quote;
65
- /**
66
- * @throws if no valid PDA found
67
- */
68
- export function findPoolReservesAta(arg0: Bs58Array): FoundPda;
69
- /**
70
- * @throws if no valid PDA found
71
- */
72
- export function findProtocolFeeAccumulatorAta(arg0: Bs58Array): FoundPda;
73
117
  /**
74
118
  * @throws
75
119
  */
@@ -78,87 +122,33 @@ export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
78
122
  * @throws
79
123
  */
80
124
  export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
81
- /**
82
- * @throws
83
- */
84
- export function rebalanceIxs(inf: Inf, arg1: RebalanceArgs): RebalanceIxs;
85
- /**
86
- * Returns the pubkeys of the accounts that need to be fetched to initialize
87
- * a new {@link Inf} object
88
- */
89
- export function initPks(): Bs58Array[];
90
- /**
91
- * Initialize a new {@link Inf} object.
92
- *
93
- * The returned object must be updated for a mint pair before it is ready to
94
- * quote and operate for trades involving that pair
95
- *
96
- * @throws
97
- */
98
- export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
99
-
100
- export type ERR_CODE_MSG_SEP = ":";
101
-
102
- /**
103
- * All {@link Error} objects thrown by the SDK have messages of this format
104
- */
105
- export type InfErrMsg = `${InfErr}${ERR_CODE_MSG_SEP}${string}`;
106
-
107
-
108
- /**
109
- * All {@link Error} objects thrown by SDK functions will start with
110
- * `{InfErr}:`, so that the `InfErr` error code can be
111
- * extracted by splitting on the first colon `:`
112
- */
113
- export type InfErr = "AccDeserErr" | "InternalErr" | "MissingAccErr" | "MissingSplDataErr" | "MissingSvcDataErr" | "NoValidPdaErr" | "PoolErr" | "UnknownPpErr" | "UnknownSvcErr" | "UnsupportedMintErr" | "SizeTooSmallErr" | "SizeTooLargeErr";
114
-
115
- export type AllInfErrs = InfErr[];
116
-
117
- export interface RebalanceQuoteArgs {
118
- /**
119
- * Amount of output tokens that will leave the pool in StartRebalance
120
- */
121
- out: bigint;
122
- mints: PkPair;
123
- }
125
+ export type FoundPda = [B58PK, number];
124
126
 
125
- export interface RebalanceQuote {
126
- /**
127
- * Amount of input tokens that needs to enter the pool by EndRebalance
128
- */
129
- inp: bigint;
130
- /**
131
- * Amount of output tokens that will leave the pool in StartRebalance
132
- */
127
+ export interface RebalanceArgs {
133
128
  out: bigint;
129
+ minStartingOutLst: bigint;
130
+ maxStartingInpLst: bigint;
134
131
  mints: PkPair;
132
+ withdrawTo: B58PK;
135
133
  }
136
134
 
137
- export interface AccountMeta {
138
- address: B58PK;
139
- /**
140
- * Represents the role of an account in a transaction:
141
- * - Readonly: 0
142
- * - Writable: 1
143
- * - ReadonlySigner: 2
144
- * - WritableSigner: 3
145
- */
146
- role: 0 | 1 | 2 | 3;
147
- }
148
-
149
- export interface Instruction {
150
- data: Uint8Array;
151
- accounts: AccountMeta[];
152
- programAddress: B58PK;
135
+ export interface RebalanceIxs {
136
+ start: Instruction;
137
+ end: Instruction;
153
138
  }
154
139
 
155
140
  export type FeeMint = "inp" | "out";
156
141
 
157
142
  export interface QuoteArgs {
143
+ slotLookahead: bigint;
158
144
  amt: bigint;
159
145
  mints: PkPair;
160
146
  }
161
147
 
148
+ /**
149
+ * Basically same as [`inf1_std::quote::Quote`] but with fields converted
150
+ * to wasm compat
151
+ */
162
152
  export interface Quote {
163
153
  /**
164
154
  * Amount of input tokens given by the user to the pool,
@@ -166,6 +156,13 @@ export interface Quote {
166
156
  * will leave the user\'s wallet.
167
157
  */
168
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;
169
166
  /**
170
167
  * Amount of output tokens returned by the pool to the user,
171
168
  * after fees. This is exactly the amount of tokens that
@@ -173,46 +170,13 @@ export interface Quote {
173
170
  */
174
171
  out: bigint;
175
172
  /**
176
- * The amount of fee accrued to pool LPs,
177
- * accumulated in the pool reserves.
178
- *
179
- * Which mint it is denoted in (whether inp_mint or out_mint)
180
- * depends on value of `self.fee_mint`
173
+ * The amount of fee accrued to the pool,
174
+ * in terms of sol value (lamports)
181
175
  */
182
- lpFee: bigint;
183
- /**
184
- * The amount of fee accrued to the protocol,
185
- * to be transferred to the protocol fee accumulator account.
186
- *
187
- * Which mint it is denoted in (whether inp_mint or out_mint)
188
- * depends on value of `self.fee_mint`
189
- */
190
- protocolFee: bigint;
191
- feeMint: FeeMint;
176
+ fee: bigint;
192
177
  mints: PkPair;
193
178
  }
194
179
 
195
- export interface TradeArgs {
196
- amt: bigint;
197
- limit: bigint;
198
- mints: PkPair;
199
- signer: B58PK;
200
- tokenAccs: PkPair;
201
- }
202
-
203
- export interface RebalanceArgs {
204
- out: bigint;
205
- minStartingOutLst: bigint;
206
- maxStartingInpLst: bigint;
207
- mints: PkPair;
208
- withdrawTo: B58PK;
209
- }
210
-
211
- export interface RebalanceIxs {
212
- start: Instruction;
213
- end: Instruction;
214
- }
215
-
216
180
  export interface LstState {
217
181
  isInputDisabled: number;
218
182
  poolReservesBump: number;
@@ -222,10 +186,9 @@ export interface LstState {
222
186
  solValueCalculator: B58PK;
223
187
  }
224
188
 
225
- export interface PoolState {
189
+ export interface PoolStateV2 {
226
190
  totalSolValue: bigint;
227
- tradingProtocolFeeBps: number;
228
- lpProtocolFeeBps: number;
191
+ protocolFeeNanos: number;
229
192
  version: number;
230
193
  isDisabled: number;
231
194
  isRebalancing: number;
@@ -234,6 +197,11 @@ export interface PoolState {
234
197
  protocolFeeBeneficiary: B58PK;
235
198
  pricingProgram: B58PK;
236
199
  lpTokenMint: B58PK;
200
+ rpsAuthority: B58PK;
201
+ rps: bigint;
202
+ withheldLamports: bigint;
203
+ protocolFeeLamports: bigint;
204
+ lastReleaseSlot: bigint;
237
205
  }
238
206
 
239
207
  export interface Account {
@@ -259,7 +227,76 @@ export interface PkPair {
259
227
 
260
228
  export type B58PK = Bs58Array;
261
229
 
262
- export type FoundPda = [B58PK, number];
230
+
231
+ export type ERR_CODE_MSG_SEP = ":";
232
+
233
+ /**
234
+ * All {@link Error} objects thrown by the SDK have messages of this format
235
+ */
236
+ export type InfErrMsg = `${InfErr}${ERR_CODE_MSG_SEP}${string}`;
237
+
238
+
239
+ /**
240
+ * All {@link Error} objects thrown by SDK functions will start with
241
+ * `{InfErr}:`, so that the `InfErr` error code can be
242
+ * extracted by splitting on the first colon `:`
243
+ */
244
+ export type InfErr = "AccDeserErr" | "InternalErr" | "MissingAccErr" | "MissingSplDataErr" | "MissingSvcDataErr" | "NoValidPdaErr" | "PoolErr" | "UnknownPpErr" | "UnknownSvcErr" | "UnsupportedMintErr" | "SizeTooSmallErr" | "SizeTooLargeErr";
245
+
246
+ export type AllInfErrs = InfErr[];
247
+
248
+ export interface RebalanceQuoteArgs {
249
+ /**
250
+ * Amount of output tokens that will leave the pool in StartRebalance
251
+ */
252
+ out: bigint;
253
+ mints: PkPair;
254
+ }
255
+
256
+ export interface RebalanceQuote {
257
+ /**
258
+ * Amount of input tokens that needs to enter the pool by EndRebalance
259
+ */
260
+ inp: bigint;
261
+ /**
262
+ * Amount of output tokens that will leave the pool in StartRebalance
263
+ */
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;
272
+ mints: PkPair;
273
+ }
274
+
275
+ export interface AccountMeta {
276
+ address: B58PK;
277
+ /**
278
+ * Represents the role of an account in a transaction:
279
+ * - Readonly: 0
280
+ * - Writable: 1
281
+ * - ReadonlySigner: 2
282
+ * - WritableSigner: 3
283
+ */
284
+ role: 0 | 1 | 2 | 3;
285
+ }
286
+
287
+ export interface Instruction {
288
+ data: Uint8Array;
289
+ accounts: AccountMeta[];
290
+ programAddress: B58PK;
291
+ }
292
+
293
+ export interface TradeArgs {
294
+ amt: bigint;
295
+ limit: bigint;
296
+ mints: PkPair;
297
+ signer: B58PK;
298
+ tokenAccs: PkPair;
299
+ }
263
300
 
264
301
  export type Bs58Array = string
265
302
 
@@ -272,36 +309,42 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
272
309
 
273
310
  export interface InitOutput {
274
311
  readonly memory: WebAssembly.Memory;
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];
320
+ readonly findPoolReservesAta: (a: any) => [number, number, number];
321
+ readonly findProtocolFeeAccumulatorAta: (a: any) => [number, number, number];
322
+ readonly quoteTradeExactIn: (a: number, b: any) => [number, number, number];
323
+ readonly quoteTradeExactOut: (a: number, b: any) => [number, number, number];
275
324
  readonly getPoolState: (a: number) => any;
325
+ readonly setPoolState: (a: number, b: any) => void;
276
326
  readonly serPoolState: (a: number) => [number, number];
327
+ readonly deserPoolState: (a: number, b: number, c: number) => [number, number];
277
328
  readonly getLstStateList: (a: number) => [number, number, number, number];
329
+ readonly setLstStateList: (a: number, b: number, c: number) => void;
278
330
  readonly serLstStateList: (a: number) => [number, number];
279
- readonly accountsToUpdateForTrade: (a: number, b: any) => [number, number, number, number];
280
- readonly updateForTrade: (a: number, b: any, c: any) => [number, number];
331
+ readonly deserLstStateList: (a: number, b: number, c: number) => [number, number];
281
332
  readonly accountsToUpdateForRebalance: (a: number, b: any) => [number, number, number, number];
282
333
  readonly updateForRebalance: (a: number, b: any, c: any) => [number, number];
283
334
  readonly appendSplLsts: (a: number, b: any) => void;
284
335
  readonly hasSplData: (a: number, b: number, c: number) => [number, number];
285
- readonly __wbg_inf_free: (a: number, b: number) => void;
286
336
  readonly allInfErrs: () => any;
287
337
  readonly quoteRebalance: (a: number, b: any) => [number, number, number];
288
- readonly quoteTradeExactIn: (a: number, b: any) => [number, number, number];
289
- readonly quoteTradeExactOut: (a: number, b: any) => [number, number, number];
290
- readonly findPoolReservesAta: (a: any) => [number, number, number];
291
- readonly findProtocolFeeAccumulatorAta: (a: any) => [number, number, number];
292
338
  readonly tradeExactInIx: (a: number, b: any) => [number, number, number];
293
339
  readonly tradeExactOutIx: (a: number, b: any) => [number, number, number];
294
- readonly rebalanceIxs: (a: number, b: any) => [number, number, number];
295
- readonly initPks: () => [number, number];
296
- readonly init: (a: any, b: any) => [number, number, number];
297
340
  readonly __wbindgen_malloc: (a: number, b: number) => number;
298
341
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
299
342
  readonly __wbindgen_exn_store: (a: number) => void;
300
343
  readonly __externref_table_alloc: () => number;
301
344
  readonly __wbindgen_export_4: WebAssembly.Table;
345
+ readonly __externref_drop_slice: (a: number, b: number) => void;
302
346
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
303
347
  readonly __externref_table_dealloc: (a: number) => void;
304
- readonly __externref_drop_slice: (a: number, b: number) => void;
305
348
  readonly __wbindgen_start: () => void;
306
349
  }
307
350