@sanctumso/inf1 0.0.1-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.
- package/README.md +117 -0
- package/index.d.ts +124 -0
- package/index.js +632 -0
- package/index_bg.wasm +0 -0
- package/package.json +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# @sanctumso/inf1
|
|
2
|
+
|
|
3
|
+
Typescript + WASM SDK for Sanctum Infinity program V1.
|
|
4
|
+
|
|
5
|
+
## Example Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
createSolanaRpc,
|
|
10
|
+
getBase64Encoder,
|
|
11
|
+
type Address,
|
|
12
|
+
type IInstruction,
|
|
13
|
+
type Rpc,
|
|
14
|
+
type SolanaRpcApi,
|
|
15
|
+
} from "@solana/kit";
|
|
16
|
+
import {
|
|
17
|
+
accountsToUpdateForTrade,
|
|
18
|
+
initPks,
|
|
19
|
+
quoteTradeExactIn,
|
|
20
|
+
tradeExactInIx,
|
|
21
|
+
updateForTrade,
|
|
22
|
+
type AccountMap,
|
|
23
|
+
type SplPoolAccounts,
|
|
24
|
+
} from "@sanctumso/inf1";
|
|
25
|
+
|
|
26
|
+
const LAINESOL = "LAinEtNLgpmCP9Rvsf5Hn8W6EhNiKLZQti1xfWMLy6X";
|
|
27
|
+
const WSOL = "So11111111111111111111111111111111111111112";
|
|
28
|
+
const SPL_POOL_ACCOUNTS: SplPoolAccounts = {
|
|
29
|
+
[LAINESOL]: "2qyEeSAWKfU18AFthrF7JA8z8ZCi1yt76Tqs917vwQTV",
|
|
30
|
+
// ...populate rest of `spl lst mint: stake pool addr` data
|
|
31
|
+
// for every single spl lst mint in the INF pool (all 3 spl program deploys)
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// If out === INF mint, then below code will work the same,
|
|
35
|
+
// but the quote and instruction will be for AddLiquidity instead of SwapExactIn.
|
|
36
|
+
//
|
|
37
|
+
// If inp === INF mint, then below code will work the same,
|
|
38
|
+
// but the quote and instruction will be for RemoveLiquidity instead of SwapExactIn.
|
|
39
|
+
const SWAP_MINTS = { inp: LAINESOL, out: WSOL };
|
|
40
|
+
|
|
41
|
+
async function fetchAccountMap(
|
|
42
|
+
rpc: Rpc<SolanaRpcApi>,
|
|
43
|
+
accounts: string[]
|
|
44
|
+
): Promise<AccountMap> {
|
|
45
|
+
const map = new Map<string, Account>();
|
|
46
|
+
await Promise.all(
|
|
47
|
+
accounts.map(async (account) => {
|
|
48
|
+
const accountInfo = await rpc
|
|
49
|
+
.getAccountInfo(account as Address, {
|
|
50
|
+
encoding: "base64",
|
|
51
|
+
})
|
|
52
|
+
.send();
|
|
53
|
+
const acc = accountInfo.value!;
|
|
54
|
+
map.set(account, {
|
|
55
|
+
data: new Uint8Array(getBase64Encoder().encode(acc.data[0])),
|
|
56
|
+
owner: acc.owner,
|
|
57
|
+
});
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
return map;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
64
|
+
|
|
65
|
+
// init
|
|
66
|
+
const { poolState: poolStateAddr, lstStateList: lstStateListAddr } = initPks();
|
|
67
|
+
const initAccs = await fetchAccountMap(rpc, [poolStateAddr, lstStateListAddr]);
|
|
68
|
+
const inf = init(
|
|
69
|
+
{
|
|
70
|
+
poolState: initAccs.get(poolStateAddr)!,
|
|
71
|
+
lstStateList: initAccs.get(lstStateListAddr)!,
|
|
72
|
+
},
|
|
73
|
+
SPL_POOL_ACCOUNTS
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// update
|
|
77
|
+
const updateAccs = await fetchAccountMap(
|
|
78
|
+
rpc,
|
|
79
|
+
accountsToUpdateForTrade(inf, SWAP_MINTS)
|
|
80
|
+
);
|
|
81
|
+
updateForTrade(inf, SWAP_MINTS, updateAccs);
|
|
82
|
+
|
|
83
|
+
// quote
|
|
84
|
+
const amt = 1_000_000_000n;
|
|
85
|
+
const quote = quoteTradeExactIn(inf, {
|
|
86
|
+
amt,
|
|
87
|
+
mints: SWAP_MINTS,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// create transaction instruction
|
|
91
|
+
|
|
92
|
+
// user-provided pubkeys
|
|
93
|
+
const signer = ...;
|
|
94
|
+
const inpTokenAcc = ...;
|
|
95
|
+
const outTokenAcc = ...;
|
|
96
|
+
|
|
97
|
+
const ixUncasted = tradeExactInIx(inf, {
|
|
98
|
+
amt,
|
|
99
|
+
limit: quote.out,
|
|
100
|
+
mints: SWAP_MINTS,
|
|
101
|
+
signer,
|
|
102
|
+
tokenAccs: {
|
|
103
|
+
inp: inpTokenAcc,
|
|
104
|
+
out: outTokenAcc,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
// return type is compatible with kit,
|
|
108
|
+
// but needs to be casted explicitly
|
|
109
|
+
const ix = ixUncasted as unknown as IInstruction;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Build
|
|
113
|
+
|
|
114
|
+
### Prerequisites
|
|
115
|
+
|
|
116
|
+
- [`wasm-pack`](https://rustwasm.github.io/wasm-pack/)
|
|
117
|
+
- `make` (optional, you can just run the `wasm-pack` commands manually)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function tradeExactInIx(inf: Inf, arg1: TradeArgs): Instruction;
|
|
4
|
+
export function tradeExactOutIx(inf: Inf, arg1: TradeArgs): Instruction;
|
|
5
|
+
export function findPoolReservesAta(arg0: Bs58Array): FoundPda;
|
|
6
|
+
export function findProtocolFeeAccumulatorAta(arg0: Bs58Array): FoundPda;
|
|
7
|
+
export function initPks(): InitPks;
|
|
8
|
+
export function init(arg0: InitAccounts, arg1: SplPoolAccounts): Inf;
|
|
9
|
+
/**
|
|
10
|
+
* Update SPL LSTs auxiliary data to support new SPL LSTs that may have previously not been covered
|
|
11
|
+
*/
|
|
12
|
+
export function updateSplLsts(inf: Inf, arg1: SplPoolAccounts): void;
|
|
13
|
+
export function quoteTradeExactIn(inf: Inf, arg1: QuoteArgs): Quote;
|
|
14
|
+
export function quoteTradeExactOut(arg0: Inf, arg1: QuoteArgs): Quote;
|
|
15
|
+
export function accountsToUpdateForTrade(inf: Inf, arg1: PkPair): Bs58Array[];
|
|
16
|
+
export function updateForTrade(inf: Inf, arg1: PkPair, arg2: AccountMap): void;
|
|
17
|
+
export interface TradeArgs {
|
|
18
|
+
amt: bigint;
|
|
19
|
+
limit: bigint;
|
|
20
|
+
mints: PkPair;
|
|
21
|
+
signer: B58PK;
|
|
22
|
+
tokenAccs: PkPair;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AccountMeta {
|
|
26
|
+
address: B58PK;
|
|
27
|
+
/**
|
|
28
|
+
* Represents the role of an account in a transaction:
|
|
29
|
+
* - Readonly: 0
|
|
30
|
+
* - Writable: 1
|
|
31
|
+
* - ReadonlySigner: 2
|
|
32
|
+
* - WritableSigner: 3
|
|
33
|
+
*/
|
|
34
|
+
role: 0 | 1 | 2 | 3;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Instruction {
|
|
38
|
+
data: Uint8Array;
|
|
39
|
+
accounts: AccountMeta[];
|
|
40
|
+
programAddress: B58PK;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type FoundPda = [B58PK, number];
|
|
44
|
+
|
|
45
|
+
export interface Account {
|
|
46
|
+
data: Uint8Array;
|
|
47
|
+
owner: B58PK;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Map of `mint: stake pool account` for spl (all deploys) LSTs.
|
|
52
|
+
*
|
|
53
|
+
* This data is required to determine how to properly initialize the corresponding
|
|
54
|
+
* sol value calculator data since which stake pool account corresponds to which mint
|
|
55
|
+
* is not available onchain (yet)
|
|
56
|
+
*/
|
|
57
|
+
export type SplPoolAccounts = Map<B58PK, B58PK>;
|
|
58
|
+
|
|
59
|
+
export type AccountMap = Map<B58PK, Account>;
|
|
60
|
+
|
|
61
|
+
export type B58PK = Bs58Array;
|
|
62
|
+
|
|
63
|
+
export interface Pair<T> {
|
|
64
|
+
inp: T;
|
|
65
|
+
out: T;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type PkPair = Pair<B58PK>;
|
|
69
|
+
|
|
70
|
+
export interface Init<T> {
|
|
71
|
+
poolState: T;
|
|
72
|
+
lstStateList: T;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type InitPks = Init<B58PK>;
|
|
76
|
+
|
|
77
|
+
export type InitAccounts = Init<Account>;
|
|
78
|
+
|
|
79
|
+
export type FeeMint = "inp" | "out";
|
|
80
|
+
|
|
81
|
+
export interface QuoteArgs {
|
|
82
|
+
amt: bigint;
|
|
83
|
+
mints: PkPair;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface Quote {
|
|
87
|
+
/**
|
|
88
|
+
* Amount of input tokens given by the user to the pool,
|
|
89
|
+
* after fees. This is exactly the amount of tokens that
|
|
90
|
+
* will leave the user\'s wallet.
|
|
91
|
+
*/
|
|
92
|
+
inp: bigint;
|
|
93
|
+
/**
|
|
94
|
+
* Amount of output tokens returned by the pool to the user,
|
|
95
|
+
* after fees. This is exactly the amount of tokens that
|
|
96
|
+
* will enter the user\'s wallet.
|
|
97
|
+
*/
|
|
98
|
+
out: bigint;
|
|
99
|
+
/**
|
|
100
|
+
* The amount of fee accrued to pool LPs,
|
|
101
|
+
* accumulated in the pool reserves.
|
|
102
|
+
*
|
|
103
|
+
* Which mint it is denoted in (whether inp_mint or out_mint)
|
|
104
|
+
* depends on value of `self.fee_mint`
|
|
105
|
+
*/
|
|
106
|
+
lpFee: bigint;
|
|
107
|
+
/**
|
|
108
|
+
* The amount of fee accrued to the protocol,
|
|
109
|
+
* to be transferred to the protocol fee accumulator account.
|
|
110
|
+
*
|
|
111
|
+
* Which mint it is denoted in (whether inp_mint or out_mint)
|
|
112
|
+
* depends on value of `self.fee_mint`
|
|
113
|
+
*/
|
|
114
|
+
protocolFee: bigint;
|
|
115
|
+
feeMint: FeeMint;
|
|
116
|
+
mints: PkPair;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type Bs58Array = string
|
|
120
|
+
|
|
121
|
+
export class Inf {
|
|
122
|
+
private constructor();
|
|
123
|
+
free(): void;
|
|
124
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
let wasm;
|
|
5
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
6
|
+
|
|
7
|
+
let WASM_VECTOR_LEN = 0;
|
|
8
|
+
|
|
9
|
+
let cachedUint8ArrayMemory0 = null;
|
|
10
|
+
|
|
11
|
+
function getUint8ArrayMemory0() {
|
|
12
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
+
}
|
|
15
|
+
return cachedUint8ArrayMemory0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
19
|
+
|
|
20
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
21
|
+
? function (arg, view) {
|
|
22
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
23
|
+
}
|
|
24
|
+
: function (arg, view) {
|
|
25
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
26
|
+
view.set(buf);
|
|
27
|
+
return {
|
|
28
|
+
read: arg.length,
|
|
29
|
+
written: buf.length
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
34
|
+
|
|
35
|
+
if (realloc === undefined) {
|
|
36
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
37
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
38
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
39
|
+
WASM_VECTOR_LEN = buf.length;
|
|
40
|
+
return ptr;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let len = arg.length;
|
|
44
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
45
|
+
|
|
46
|
+
const mem = getUint8ArrayMemory0();
|
|
47
|
+
|
|
48
|
+
let offset = 0;
|
|
49
|
+
|
|
50
|
+
for (; offset < len; offset++) {
|
|
51
|
+
const code = arg.charCodeAt(offset);
|
|
52
|
+
if (code > 0x7F) break;
|
|
53
|
+
mem[ptr + offset] = code;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (offset !== len) {
|
|
57
|
+
if (offset !== 0) {
|
|
58
|
+
arg = arg.slice(offset);
|
|
59
|
+
}
|
|
60
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
61
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
62
|
+
const ret = encodeString(arg, view);
|
|
63
|
+
|
|
64
|
+
offset += ret.written;
|
|
65
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
WASM_VECTOR_LEN = offset;
|
|
69
|
+
return ptr;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let cachedDataViewMemory0 = null;
|
|
73
|
+
|
|
74
|
+
function getDataViewMemory0() {
|
|
75
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
76
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
77
|
+
}
|
|
78
|
+
return cachedDataViewMemory0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function addToExternrefTable0(obj) {
|
|
82
|
+
const idx = wasm.__externref_table_alloc();
|
|
83
|
+
wasm.__wbindgen_export_4.set(idx, obj);
|
|
84
|
+
return idx;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleError(f, args) {
|
|
88
|
+
try {
|
|
89
|
+
return f.apply(this, args);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
const idx = addToExternrefTable0(e);
|
|
92
|
+
wasm.__wbindgen_exn_store(idx);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isLikeNone(x) {
|
|
97
|
+
return x === undefined || x === null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function debugString(val) {
|
|
101
|
+
// primitive types
|
|
102
|
+
const type = typeof val;
|
|
103
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
104
|
+
return `${val}`;
|
|
105
|
+
}
|
|
106
|
+
if (type == 'string') {
|
|
107
|
+
return `"${val}"`;
|
|
108
|
+
}
|
|
109
|
+
if (type == 'symbol') {
|
|
110
|
+
const description = val.description;
|
|
111
|
+
if (description == null) {
|
|
112
|
+
return 'Symbol';
|
|
113
|
+
} else {
|
|
114
|
+
return `Symbol(${description})`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (type == 'function') {
|
|
118
|
+
const name = val.name;
|
|
119
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
120
|
+
return `Function(${name})`;
|
|
121
|
+
} else {
|
|
122
|
+
return 'Function';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// objects
|
|
126
|
+
if (Array.isArray(val)) {
|
|
127
|
+
const length = val.length;
|
|
128
|
+
let debug = '[';
|
|
129
|
+
if (length > 0) {
|
|
130
|
+
debug += debugString(val[0]);
|
|
131
|
+
}
|
|
132
|
+
for(let i = 1; i < length; i++) {
|
|
133
|
+
debug += ', ' + debugString(val[i]);
|
|
134
|
+
}
|
|
135
|
+
debug += ']';
|
|
136
|
+
return debug;
|
|
137
|
+
}
|
|
138
|
+
// Test for built-in
|
|
139
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
140
|
+
let className;
|
|
141
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
142
|
+
className = builtInMatches[1];
|
|
143
|
+
} else {
|
|
144
|
+
// Failed to match the standard '[object ClassName]'
|
|
145
|
+
return toString.call(val);
|
|
146
|
+
}
|
|
147
|
+
if (className == 'Object') {
|
|
148
|
+
// we're a user defined class or Object
|
|
149
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
150
|
+
// easier than looping through ownProperties of `val`.
|
|
151
|
+
try {
|
|
152
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
153
|
+
} catch (_) {
|
|
154
|
+
return 'Object';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// errors
|
|
158
|
+
if (val instanceof Error) {
|
|
159
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
160
|
+
}
|
|
161
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
162
|
+
return className;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
166
|
+
|
|
167
|
+
cachedTextDecoder.decode();
|
|
168
|
+
|
|
169
|
+
function getStringFromWasm0(ptr, len) {
|
|
170
|
+
ptr = ptr >>> 0;
|
|
171
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function _assertClass(instance, klass) {
|
|
175
|
+
if (!(instance instanceof klass)) {
|
|
176
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function takeFromExternrefTable0(idx) {
|
|
181
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
182
|
+
wasm.__externref_table_dealloc(idx);
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @param {Inf} inf
|
|
187
|
+
* @param {TradeArgs} arg1
|
|
188
|
+
* @returns {Instruction}
|
|
189
|
+
*/
|
|
190
|
+
module.exports.tradeExactInIx = function(inf, arg1) {
|
|
191
|
+
_assertClass(inf, Inf);
|
|
192
|
+
const ret = wasm.tradeExactInIx(inf.__wbg_ptr, arg1);
|
|
193
|
+
if (ret[2]) {
|
|
194
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
195
|
+
}
|
|
196
|
+
return takeFromExternrefTable0(ret[0]);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {Inf} inf
|
|
201
|
+
* @param {TradeArgs} arg1
|
|
202
|
+
* @returns {Instruction}
|
|
203
|
+
*/
|
|
204
|
+
module.exports.tradeExactOutIx = function(inf, arg1) {
|
|
205
|
+
_assertClass(inf, Inf);
|
|
206
|
+
const ret = wasm.tradeExactOutIx(inf.__wbg_ptr, arg1);
|
|
207
|
+
if (ret[2]) {
|
|
208
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
209
|
+
}
|
|
210
|
+
return takeFromExternrefTable0(ret[0]);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @param {Bs58Array} arg0
|
|
215
|
+
* @returns {FoundPda}
|
|
216
|
+
*/
|
|
217
|
+
module.exports.findPoolReservesAta = function(arg0) {
|
|
218
|
+
const ret = wasm.findPoolReservesAta(arg0);
|
|
219
|
+
if (ret[2]) {
|
|
220
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
221
|
+
}
|
|
222
|
+
return takeFromExternrefTable0(ret[0]);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @param {Bs58Array} arg0
|
|
227
|
+
* @returns {FoundPda}
|
|
228
|
+
*/
|
|
229
|
+
module.exports.findProtocolFeeAccumulatorAta = function(arg0) {
|
|
230
|
+
const ret = wasm.findProtocolFeeAccumulatorAta(arg0);
|
|
231
|
+
if (ret[2]) {
|
|
232
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
233
|
+
}
|
|
234
|
+
return takeFromExternrefTable0(ret[0]);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @returns {InitPks}
|
|
239
|
+
*/
|
|
240
|
+
module.exports.initPks = function() {
|
|
241
|
+
const ret = wasm.initPks();
|
|
242
|
+
return ret;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @param {InitAccounts} arg0
|
|
247
|
+
* @param {SplPoolAccounts} arg1
|
|
248
|
+
* @returns {Inf}
|
|
249
|
+
*/
|
|
250
|
+
module.exports.init = function(arg0, arg1) {
|
|
251
|
+
const ret = wasm.init(arg0, arg1);
|
|
252
|
+
if (ret[2]) {
|
|
253
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
254
|
+
}
|
|
255
|
+
return Inf.__wrap(ret[0]);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Update SPL LSTs auxiliary data to support new SPL LSTs that may have previously not been covered
|
|
260
|
+
* @param {Inf} inf
|
|
261
|
+
* @param {SplPoolAccounts} arg1
|
|
262
|
+
*/
|
|
263
|
+
module.exports.updateSplLsts = function(inf, arg1) {
|
|
264
|
+
_assertClass(inf, Inf);
|
|
265
|
+
wasm.updateSplLsts(inf.__wbg_ptr, arg1);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @param {Inf} inf
|
|
270
|
+
* @param {QuoteArgs} arg1
|
|
271
|
+
* @returns {Quote}
|
|
272
|
+
*/
|
|
273
|
+
module.exports.quoteTradeExactIn = function(inf, arg1) {
|
|
274
|
+
_assertClass(inf, Inf);
|
|
275
|
+
const ret = wasm.quoteTradeExactIn(inf.__wbg_ptr, arg1);
|
|
276
|
+
if (ret[2]) {
|
|
277
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
278
|
+
}
|
|
279
|
+
return takeFromExternrefTable0(ret[0]);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @param {Inf} arg0
|
|
284
|
+
* @param {QuoteArgs} arg1
|
|
285
|
+
* @returns {Quote}
|
|
286
|
+
*/
|
|
287
|
+
module.exports.quoteTradeExactOut = function(arg0, arg1) {
|
|
288
|
+
_assertClass(arg0, Inf);
|
|
289
|
+
const ret = wasm.quoteTradeExactOut(arg0.__wbg_ptr, arg1);
|
|
290
|
+
if (ret[2]) {
|
|
291
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
292
|
+
}
|
|
293
|
+
return takeFromExternrefTable0(ret[0]);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
297
|
+
ptr = ptr >>> 0;
|
|
298
|
+
const mem = getDataViewMemory0();
|
|
299
|
+
const result = [];
|
|
300
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
301
|
+
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
302
|
+
}
|
|
303
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @param {Inf} inf
|
|
308
|
+
* @param {PkPair} arg1
|
|
309
|
+
* @returns {Bs58Array[]}
|
|
310
|
+
*/
|
|
311
|
+
module.exports.accountsToUpdateForTrade = function(inf, arg1) {
|
|
312
|
+
_assertClass(inf, Inf);
|
|
313
|
+
const ret = wasm.accountsToUpdateForTrade(inf.__wbg_ptr, arg1);
|
|
314
|
+
if (ret[3]) {
|
|
315
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
316
|
+
}
|
|
317
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
318
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
319
|
+
return v1;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @param {Inf} inf
|
|
324
|
+
* @param {PkPair} arg1
|
|
325
|
+
* @param {AccountMap} arg2
|
|
326
|
+
*/
|
|
327
|
+
module.exports.updateForTrade = function(inf, arg1, arg2) {
|
|
328
|
+
_assertClass(inf, Inf);
|
|
329
|
+
const ret = wasm.updateForTrade(inf.__wbg_ptr, arg1, arg2);
|
|
330
|
+
if (ret[1]) {
|
|
331
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const InfFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
336
|
+
? { register: () => {}, unregister: () => {} }
|
|
337
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_inf_free(ptr >>> 0, 1));
|
|
338
|
+
|
|
339
|
+
class Inf {
|
|
340
|
+
|
|
341
|
+
static __wrap(ptr) {
|
|
342
|
+
ptr = ptr >>> 0;
|
|
343
|
+
const obj = Object.create(Inf.prototype);
|
|
344
|
+
obj.__wbg_ptr = ptr;
|
|
345
|
+
InfFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
346
|
+
return obj;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
__destroy_into_raw() {
|
|
350
|
+
const ptr = this.__wbg_ptr;
|
|
351
|
+
this.__wbg_ptr = 0;
|
|
352
|
+
InfFinalization.unregister(this);
|
|
353
|
+
return ptr;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
free() {
|
|
357
|
+
const ptr = this.__destroy_into_raw();
|
|
358
|
+
wasm.__wbg_inf_free(ptr, 0);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
module.exports.Inf = Inf;
|
|
362
|
+
|
|
363
|
+
module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
364
|
+
const ret = String(arg1);
|
|
365
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
|
+
const len1 = WASM_VECTOR_LEN;
|
|
367
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
368
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
372
|
+
const ret = arg0.buffer;
|
|
373
|
+
return ret;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
377
|
+
const ret = arg0.call(arg1);
|
|
378
|
+
return ret;
|
|
379
|
+
}, arguments) };
|
|
380
|
+
|
|
381
|
+
module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
|
|
382
|
+
const ret = arg0.done;
|
|
383
|
+
return ret;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
module.exports.__wbg_entries_3265d4158b33e5dc = function(arg0) {
|
|
387
|
+
const ret = Object.entries(arg0);
|
|
388
|
+
return ret;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
module.exports.__wbg_from_2a5d3e218e67aa85 = function(arg0) {
|
|
392
|
+
const ret = Array.from(arg0);
|
|
393
|
+
return ret;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
|
|
397
|
+
const ret = Reflect.get(arg0, arg1);
|
|
398
|
+
return ret;
|
|
399
|
+
}, arguments) };
|
|
400
|
+
|
|
401
|
+
module.exports.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
402
|
+
const ret = arg0[arg1 >>> 0];
|
|
403
|
+
return ret;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
407
|
+
const ret = arg0[arg1];
|
|
408
|
+
return ret;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
module.exports.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
|
|
412
|
+
let result;
|
|
413
|
+
try {
|
|
414
|
+
result = arg0 instanceof ArrayBuffer;
|
|
415
|
+
} catch (_) {
|
|
416
|
+
result = false;
|
|
417
|
+
}
|
|
418
|
+
const ret = result;
|
|
419
|
+
return ret;
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
|
|
423
|
+
let result;
|
|
424
|
+
try {
|
|
425
|
+
result = arg0 instanceof Uint8Array;
|
|
426
|
+
} catch (_) {
|
|
427
|
+
result = false;
|
|
428
|
+
}
|
|
429
|
+
const ret = result;
|
|
430
|
+
return ret;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
module.exports.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
434
|
+
const ret = Array.isArray(arg0);
|
|
435
|
+
return ret;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
439
|
+
const ret = Number.isSafeInteger(arg0);
|
|
440
|
+
return ret;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
444
|
+
const ret = Symbol.iterator;
|
|
445
|
+
return ret;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
449
|
+
const ret = arg0.length;
|
|
450
|
+
return ret;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
454
|
+
const ret = arg0.length;
|
|
455
|
+
return ret;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
module.exports.__wbg_new_405e22f390576ce2 = function() {
|
|
459
|
+
const ret = new Object();
|
|
460
|
+
return ret;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
module.exports.__wbg_new_78feb108b6472713 = function() {
|
|
464
|
+
const ret = new Array();
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
469
|
+
const ret = new Uint8Array(arg0);
|
|
470
|
+
return ret;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
474
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
475
|
+
return ret;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
479
|
+
const ret = arg0.next;
|
|
480
|
+
return ret;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
484
|
+
const ret = arg0.next();
|
|
485
|
+
return ret;
|
|
486
|
+
}, arguments) };
|
|
487
|
+
|
|
488
|
+
module.exports.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
489
|
+
arg0[arg1 >>> 0] = arg2;
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
493
|
+
arg0[arg1] = arg2;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
497
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
501
|
+
const ret = arg0.value;
|
|
502
|
+
return ret;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
module.exports.__wbindgen_as_number = function(arg0) {
|
|
506
|
+
const ret = +arg0;
|
|
507
|
+
return ret;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
511
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
512
|
+
return ret;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
516
|
+
const v = arg1;
|
|
517
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
518
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
519
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
523
|
+
const v = arg0;
|
|
524
|
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
525
|
+
return ret;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
529
|
+
const ret = debugString(arg1);
|
|
530
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
531
|
+
const len1 = WASM_VECTOR_LEN;
|
|
532
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
533
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
537
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
538
|
+
return ret;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
542
|
+
const ret = arg0 in arg1;
|
|
543
|
+
return ret;
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
module.exports.__wbindgen_init_externref_table = function() {
|
|
547
|
+
const table = wasm.__wbindgen_export_4;
|
|
548
|
+
const offset = table.grow(4);
|
|
549
|
+
table.set(0, undefined);
|
|
550
|
+
table.set(offset + 0, undefined);
|
|
551
|
+
table.set(offset + 1, null);
|
|
552
|
+
table.set(offset + 2, true);
|
|
553
|
+
table.set(offset + 3, false);
|
|
554
|
+
;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
558
|
+
const ret = typeof(arg0) === 'bigint';
|
|
559
|
+
return ret;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
module.exports.__wbindgen_is_function = function(arg0) {
|
|
563
|
+
const ret = typeof(arg0) === 'function';
|
|
564
|
+
return ret;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
module.exports.__wbindgen_is_object = function(arg0) {
|
|
568
|
+
const val = arg0;
|
|
569
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
570
|
+
return ret;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
574
|
+
const ret = arg0 === undefined;
|
|
575
|
+
return ret;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
|
|
579
|
+
const ret = arg0 === arg1;
|
|
580
|
+
return ret;
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
584
|
+
const ret = arg0 == arg1;
|
|
585
|
+
return ret;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
module.exports.__wbindgen_memory = function() {
|
|
589
|
+
const ret = wasm.memory;
|
|
590
|
+
return ret;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
module.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
594
|
+
const obj = arg1;
|
|
595
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
596
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
597
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
module.exports.__wbindgen_number_new = function(arg0) {
|
|
601
|
+
const ret = arg0;
|
|
602
|
+
return ret;
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
606
|
+
const obj = arg1;
|
|
607
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
608
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
609
|
+
var len1 = WASM_VECTOR_LEN;
|
|
610
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
611
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
615
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
616
|
+
return ret;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
620
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
const path = require('path').join(__dirname, 'index_bg.wasm');
|
|
624
|
+
const bytes = require('fs').readFileSync(path);
|
|
625
|
+
|
|
626
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
627
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
628
|
+
wasm = wasmInstance.exports;
|
|
629
|
+
module.exports.__wasm = wasm;
|
|
630
|
+
|
|
631
|
+
wasm.__wbindgen_start();
|
|
632
|
+
|
package/index_bg.wasm
ADDED
|
Binary file
|