@sanctumso/inf1 0.0.1-dev-8 → 0.0.2-dev-1

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