@sanctumso/inf1 0.0.1-dev-3 → 0.0.1-dev-5

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.
package/index.d.ts CHANGED
@@ -1,13 +1,44 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Returned accounts are deduped
5
+ *
4
6
  * @throws
5
7
  */
6
- export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
8
+ export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
7
9
  /**
8
10
  * @throws
9
11
  */
10
- export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
12
+ export function updateForTrade(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
13
+ /**
14
+ * Returns the array of all possible {@link InfErr}s
15
+ */
16
+ export function allInfErrs(): AllInfErrs;
17
+ export function quoteRebalance(inf: Inf, arg1: RebalanceQuoteArgs): RebalanceQuote;
18
+ /**
19
+ * Returned accounts are deduped
20
+ *
21
+ * @throws
22
+ */
23
+ export function accountsToUpdateForRebalance(inf: Inf, arg1: PkPair): Bs58Array[];
24
+ /**
25
+ * @throws
26
+ */
27
+ export function updateForRebalance(inf: Inf, arg1: PkPair, account_map: AccountMap): void;
28
+ /**
29
+ * Returns the pubkeys of the accounts that need ot be fetched to initialize
30
+ * a new {@link Inf} object
31
+ */
32
+ export function initPks(): Bs58Array[];
33
+ /**
34
+ * Initialize a new {@link Inf} object.
35
+ *
36
+ * The returned object must be updated for a mint pair before it is ready to
37
+ * quote and operate for trades involving that pair
38
+ *
39
+ * @throws
40
+ */
41
+ export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
11
42
  /**
12
43
  * Add SPL LSTs auxiliary data to support new SPL LSTs that may have previously not been covered
13
44
  */
@@ -25,57 +56,126 @@ export function appendSplLsts(inf: Inf, arg1: SplPoolAccounts): void;
25
56
  */
26
57
  export function hasSplData(inf: Inf, mints: Bs58Array[]): Uint8Array;
27
58
  /**
28
- * Returned accounts are deduped
29
- *
30
59
  * @throws
31
60
  */
32
- export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
61
+ export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
33
62
  /**
34
63
  * @throws
35
64
  */
36
- export function updateForTrade(inf: Inf, arg1: PkPair, arg2: AccountMap): void;
65
+ export function quoteTradeExactOut(inf: Inf, arg1: QuoteArgs): Quote;
37
66
  /**
38
- * @throws
67
+ * @throws if no valid PDA found
39
68
  */
40
- export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
69
+ export function findPoolReservesAta(arg0: Bs58Array): FoundPda;
70
+ /**
71
+ * @throws if no valid PDA found
72
+ */
73
+ export function findProtocolFeeAccumulatorAta(arg0: Bs58Array): FoundPda;
41
74
  /**
42
75
  * @throws
43
76
  */
44
- export function quoteTradeExactOut(inf: Inf, arg1: QuoteArgs): Quote;
77
+ export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
45
78
  /**
46
- * Returns the array of all possible {@link InfErr}s
79
+ * @throws
47
80
  */
48
- export function allInfErrs(): AllInfErrs;
81
+ export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
49
82
  /**
50
- * @throws if not valid PDA found
83
+ * @throws
51
84
  */
52
- export function findPoolReservesAta(arg0: Bs58Array): FoundPda;
85
+ export function rebalanceIxs(inf: Inf, arg1: RebalanceArgs): RebalanceIxs;
86
+ export interface Account {
87
+ data: Uint8Array;
88
+ owner: B58PK;
89
+ }
90
+
53
91
  /**
54
- * @throws if not valid PDA found
92
+ * Map of `mint: stake pool account` for spl (all deploys) LSTs.
93
+ *
94
+ * This data is required to determine how to properly initialize the corresponding
95
+ * sol value calculator data since which stake pool account corresponds to which mint
96
+ * is not available onchain (yet)
55
97
  */
56
- export function findProtocolFeeAccumulatorAta(arg0: Bs58Array): FoundPda;
98
+ export type SplPoolAccounts = Map<B58PK, B58PK>;
99
+
100
+ export type AccountMap = Map<B58PK, Account>;
101
+
102
+ export interface PkPair {
103
+ inp: B58PK;
104
+ out: B58PK;
105
+ }
106
+
107
+ export type B58PK = Bs58Array;
108
+
109
+
110
+ export type ERR_CODE_MSG_SEP = ":";
111
+
57
112
  /**
58
- * Returns the pubkeys of the accounts that need ot be fetched to initialize
59
- * a new {@link Inf} object
113
+ * All {@link Error} objects thrown by the SDK have messages of this format
60
114
  */
61
- export function initPks(): Bs58Array[];
115
+ export type InfErrMsg = `${InfErr}${ERR_CODE_MSG_SEP}${string}`;
116
+
117
+
62
118
  /**
63
- * Initialize a new {@link Inf} object.
64
- *
65
- * The returned object must be updated for a mint pair before it is ready to
66
- * quote and operate for trades involving that pair
67
- *
68
- * @throws
119
+ * All {@link Error} objects thrown by SDK functions will start with
120
+ * `{InfErr}:`, so that the `InfErr` error code can be
121
+ * extracted by splitting on the first colon `:`
69
122
  */
70
- export function init(arg0: AccountMap, arg1: SplPoolAccounts): Inf;
71
- export interface TradeArgs {
72
- amt: bigint;
73
- limit: bigint;
123
+ export type InfErr = "AccDeserErr" | "InternalErr" | "MissingAccErr" | "MissingSplDataErr" | "MissingSvcDataErr" | "NoValidPdaErr" | "PoolErr" | "UnknownPpErr" | "UnknownSvcErr" | "UnsupportedMintErr" | "SizeTooSmallErr" | "SizeTooLargeErr";
124
+
125
+ export type AllInfErrs = [
126
+ "AccDeserErr",
127
+ "InternalErr",
128
+ "MissingAccErr",
129
+ "MissingSplDataErr",
130
+ "MissingSvcDataErr",
131
+ "NoValidPdaErr",
132
+ "PoolErr",
133
+ "UnknownSvcErr",
134
+ "UnsupportedMintErr",
135
+ "SizeTooSmallErr",
136
+ "SizeTooLargeErr",
137
+ ];
138
+
139
+ export interface RebalanceQuoteArgs {
140
+ /**
141
+ * Amount of output tokens that will leave the pool in StartRebalance
142
+ */
143
+ out: bigint;
74
144
  mints: PkPair;
75
- signer: B58PK;
76
- tokenAccs: PkPair;
77
145
  }
78
146
 
147
+ export interface RebalanceQuote {
148
+ /**
149
+ * Amount of input tokens that needs to enter the pool by EndRebalance
150
+ */
151
+ inp: bigint;
152
+ /**
153
+ * Amount of output tokens that will leave the pool in StartRebalance
154
+ */
155
+ out: bigint;
156
+ mints: PkPair;
157
+ }
158
+
159
+ export interface AccountMeta {
160
+ address: B58PK;
161
+ /**
162
+ * Represents the role of an account in a transaction:
163
+ * - Readonly: 0
164
+ * - Writable: 1
165
+ * - ReadonlySigner: 2
166
+ * - WritableSigner: 3
167
+ */
168
+ role: 0 | 1 | 2 | 3;
169
+ }
170
+
171
+ export interface Instruction {
172
+ data: Uint8Array;
173
+ accounts: AccountMeta[];
174
+ programAddress: B58PK;
175
+ }
176
+
177
+ export type FoundPda = [B58PK, number];
178
+
79
179
  export type FeeMint = "inp" | "out";
80
180
 
81
181
  export interface QuoteArgs {
@@ -116,58 +216,25 @@ export interface Quote {
116
216
  mints: PkPair;
117
217
  }
118
218
 
119
- export interface Pair<T> {
120
- inp: T;
121
- out: T;
122
- }
123
-
124
- export type PkPair = Pair<B58PK>;
125
-
126
- export interface Account {
127
- data: Uint8Array;
128
- owner: B58PK;
219
+ export interface TradeArgs {
220
+ amt: bigint;
221
+ limit: bigint;
222
+ mints: PkPair;
223
+ signer: B58PK;
224
+ tokenAccs: PkPair;
129
225
  }
130
226
 
131
- /**
132
- * Map of `mint: stake pool account` for spl (all deploys) LSTs.
133
- *
134
- * This data is required to determine how to properly initialize the corresponding
135
- * sol value calculator data since which stake pool account corresponds to which mint
136
- * is not available onchain (yet)
137
- */
138
- export type SplPoolAccounts = Map<B58PK, B58PK>;
139
-
140
- export type AccountMap = Map<B58PK, Account>;
141
-
142
- export type B58PK = Bs58Array;
143
-
144
- /**
145
- * All {@link Error} objects thrown by SDK functions will start with
146
- * `{InfErr}:`, so that the `InfErr` error code can be
147
- * extracted by splitting on the first colon `:`
148
- */
149
- export type InfErr = "AccDeserErr" | "InternalErr" | "MissingAccErr" | "MissingSplDataErr" | "MissingSvcDataErr" | "NoValidPdaErr" | "PoolErr" | "UnknownSvcErr" | "UnsupportedMintErr" | "UserErr";
150
-
151
- export type AllInfErrs = InfErr[];
152
-
153
- export type FoundPda = [B58PK, number];
154
-
155
- export interface AccountMeta {
156
- address: B58PK;
157
- /**
158
- * Represents the role of an account in a transaction:
159
- * - Readonly: 0
160
- * - Writable: 1
161
- * - ReadonlySigner: 2
162
- * - WritableSigner: 3
163
- */
164
- role: 0 | 1 | 2 | 3;
227
+ export interface RebalanceArgs {
228
+ out: bigint;
229
+ minStartingOutLst: bigint;
230
+ maxStartingInpLst: bigint;
231
+ mints: PkPair;
232
+ withdrawTo: B58PK;
165
233
  }
166
234
 
167
- export interface Instruction {
168
- data: Uint8Array;
169
- accounts: AccountMeta[];
170
- programAddress: B58PK;
235
+ export interface RebalanceIxs {
236
+ start: Instruction;
237
+ end: Instruction;
171
238
  }
172
239
 
173
240
  export type Bs58Array = string
@@ -181,28 +248,32 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
181
248
 
182
249
  export interface InitOutput {
183
250
  readonly memory: WebAssembly.Memory;
184
- readonly tradeExactInIx: (a: number, b: any) => [number, number, number];
185
- readonly tradeExactOutIx: (a: number, b: any) => [number, number, number];
186
- readonly appendSplLsts: (a: number, b: any) => void;
187
- readonly hasSplData: (a: number, b: number, c: number) => [number, number];
188
251
  readonly accountsToUpdateForTrade: (a: number, b: any) => [number, number, number, number];
189
252
  readonly updateForTrade: (a: number, b: any, c: any) => [number, number];
253
+ readonly allInfErrs: () => any;
254
+ readonly quoteRebalance: (a: number, b: any) => [number, number, number];
255
+ readonly accountsToUpdateForRebalance: (a: number, b: any) => [number, number, number, number];
256
+ readonly updateForRebalance: (a: number, b: any, c: any) => [number, number];
257
+ readonly initPks: () => [number, number];
258
+ readonly init: (a: any, b: any) => [number, number, number];
259
+ readonly appendSplLsts: (a: number, b: any) => void;
260
+ readonly hasSplData: (a: number, b: number, c: number) => [number, number];
261
+ readonly __wbg_inf_free: (a: number, b: number) => void;
190
262
  readonly quoteTradeExactIn: (a: number, b: any) => [number, number, number];
191
263
  readonly quoteTradeExactOut: (a: number, b: any) => [number, number, number];
192
- readonly __wbg_inf_free: (a: number, b: number) => void;
193
- readonly allInfErrs: () => any;
194
264
  readonly findPoolReservesAta: (a: any) => [number, number, number];
195
265
  readonly findProtocolFeeAccumulatorAta: (a: any) => [number, number, number];
196
- readonly initPks: () => [number, number];
197
- readonly init: (a: any, b: any) => [number, number, number];
266
+ readonly tradeExactInIx: (a: number, b: any) => [number, number, number];
267
+ readonly tradeExactOutIx: (a: number, b: any) => [number, number, number];
268
+ readonly rebalanceIxs: (a: number, b: any) => [number, number, number];
198
269
  readonly __wbindgen_malloc: (a: number, b: number) => number;
199
270
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
200
271
  readonly __wbindgen_exn_store: (a: number) => void;
201
272
  readonly __externref_table_alloc: () => number;
202
273
  readonly __wbindgen_export_4: WebAssembly.Table;
203
274
  readonly __externref_table_dealloc: (a: number) => void;
204
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
205
275
  readonly __externref_drop_slice: (a: number, b: number) => void;
276
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
206
277
  readonly __wbindgen_start: () => void;
207
278
  }
208
279