@crypticdot/defituna-core 3.1.0
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/LICENSE +42 -0
- package/README.md +9 -0
- package/dist/browser/README.md +9 -0
- package/dist/browser/defituna_core_js_bindings.d.ts +34 -0
- package/dist/browser/defituna_core_js_bindings.js +4 -0
- package/dist/browser/defituna_core_js_bindings_bg.js +371 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +8 -0
- package/dist/browser/package.json +17 -0
- package/dist/nodejs/README.md +9 -0
- package/dist/nodejs/defituna_core_js_bindings.d.ts +34 -0
- package/dist/nodejs/defituna_core_js_bindings.js +366 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +8 -0
- package/dist/nodejs/package.json +11 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
DefiTuna SDK Source-Available License v1.0
|
|
2
|
+
Copyright (c) Cryptic Dot
|
|
3
|
+
|
|
4
|
+
This SDK is released under a source-available license. You are permitted to view and use the code under the terms below.
|
|
5
|
+
|
|
6
|
+
1. Grant of Rights
|
|
7
|
+
|
|
8
|
+
You are granted a limited, non-exclusive, non-transferable, non-sublicensable license to:
|
|
9
|
+
|
|
10
|
+
- View and read the source code for educational and integration purposes;
|
|
11
|
+
- Use the SDK **as-is**, without modification, for the sole purpose of building software that interacts with the DefiTuna protocol and services provided by Cryptic Dot;
|
|
12
|
+
- Use the SDK in production environments only if the SDK is used to interact directly with DefiTuna smart contracts, APIs, or infrastructure.
|
|
13
|
+
|
|
14
|
+
2. Restrictions
|
|
15
|
+
|
|
16
|
+
You may **not**:
|
|
17
|
+
|
|
18
|
+
- Modify, adapt, fork, or create derivative works of the SDK;
|
|
19
|
+
- Redistribute, republish, or sublicense the SDK or any portion thereof;
|
|
20
|
+
- Use the SDK for or in connection with any product, protocol, or service that is not built specifically to interact with DefiTuna;
|
|
21
|
+
- Use the SDK to develop or improve competing products, including AMMs, liquidity protocols, trading tools, or DeFi platforms;
|
|
22
|
+
- Use the SDK in any way that violates applicable law or harms the integrity of DefiTuna or Cryptic Dot.
|
|
23
|
+
|
|
24
|
+
3. Contributions
|
|
25
|
+
|
|
26
|
+
If you submit any pull request, patch, or contribution, you grant Cryptic Dot an irrevocable, worldwide, royalty-free license to use, modify, and distribute your contribution without obligation or attribution.
|
|
27
|
+
|
|
28
|
+
4. No Trademark Rights
|
|
29
|
+
|
|
30
|
+
This license does not grant any rights to use the names, logos, or trademarks of Cryptic Dot or DefiTuna.
|
|
31
|
+
|
|
32
|
+
5. Disclaimer
|
|
33
|
+
|
|
34
|
+
THE SDK IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. CRYPTIC DOT DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
35
|
+
|
|
36
|
+
6. Termination
|
|
37
|
+
|
|
38
|
+
This license is automatically terminated if you violate any of its terms. Upon termination, you must cease use of the SDK and delete all copies.
|
|
39
|
+
|
|
40
|
+
7. Governing Law
|
|
41
|
+
|
|
42
|
+
This license is governed by the laws of the Republic of Panama, without regard to its conflict of laws principles.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function _INVALID_ARGUMENTS(): string;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the liquidation price
|
|
6
|
+
*
|
|
7
|
+
* # Parameters
|
|
8
|
+
* - `position_token`: Token of the position
|
|
9
|
+
* - `amount`: Position total size (decimal)
|
|
10
|
+
* - `debt`: Position total debt (decimal)
|
|
11
|
+
* - `liquidation_threshold`: Liquidation threshold of the market (decimal)
|
|
12
|
+
*
|
|
13
|
+
* # Returns
|
|
14
|
+
* - `f64`: Decimal liquidation price
|
|
15
|
+
*/
|
|
16
|
+
export function getLiquidationPrice(position_token: PoolTokenFacade, amount: number, debt: number, liquidation_threshold: number): number;
|
|
17
|
+
export interface TunaSpotPositionFacade {
|
|
18
|
+
version: number;
|
|
19
|
+
marketMaker: MarketMakerFacade;
|
|
20
|
+
positionToken: PoolTokenFacade;
|
|
21
|
+
collateralToken: PoolTokenFacade;
|
|
22
|
+
flags: number;
|
|
23
|
+
amount: bigint;
|
|
24
|
+
loanShares: bigint;
|
|
25
|
+
loanFunds: bigint;
|
|
26
|
+
entrySqrtPrice: bigint;
|
|
27
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
28
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type MarketMakerFacade = "orca" | "fusion";
|
|
32
|
+
|
|
33
|
+
export type PoolTokenFacade = "a" | "b";
|
|
34
|
+
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let cachedUint8ArrayMemory0 = null;
|
|
8
|
+
|
|
9
|
+
function getUint8ArrayMemory0() {
|
|
10
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachedUint8ArrayMemory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
17
|
+
|
|
18
|
+
cachedTextDecoder.decode();
|
|
19
|
+
|
|
20
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
21
|
+
let numBytesDecoded = 0;
|
|
22
|
+
function decodeText(ptr, len) {
|
|
23
|
+
numBytesDecoded += len;
|
|
24
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
25
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
26
|
+
cachedTextDecoder.decode();
|
|
27
|
+
numBytesDecoded = len;
|
|
28
|
+
}
|
|
29
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getStringFromWasm0(ptr, len) {
|
|
33
|
+
ptr = ptr >>> 0;
|
|
34
|
+
return decodeText(ptr, len);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let heap = new Array(128).fill(undefined);
|
|
38
|
+
|
|
39
|
+
heap.push(undefined, null, true, false);
|
|
40
|
+
|
|
41
|
+
let heap_next = heap.length;
|
|
42
|
+
|
|
43
|
+
function addHeapObject(obj) {
|
|
44
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
45
|
+
const idx = heap_next;
|
|
46
|
+
heap_next = heap[idx];
|
|
47
|
+
|
|
48
|
+
heap[idx] = obj;
|
|
49
|
+
return idx;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getObject(idx) { return heap[idx]; }
|
|
53
|
+
|
|
54
|
+
let WASM_VECTOR_LEN = 0;
|
|
55
|
+
|
|
56
|
+
const cachedTextEncoder = new TextEncoder();
|
|
57
|
+
|
|
58
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
59
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
60
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
61
|
+
view.set(buf);
|
|
62
|
+
return {
|
|
63
|
+
read: arg.length,
|
|
64
|
+
written: buf.length
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
70
|
+
|
|
71
|
+
if (realloc === undefined) {
|
|
72
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
73
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
74
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
75
|
+
WASM_VECTOR_LEN = buf.length;
|
|
76
|
+
return ptr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let len = arg.length;
|
|
80
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
81
|
+
|
|
82
|
+
const mem = getUint8ArrayMemory0();
|
|
83
|
+
|
|
84
|
+
let offset = 0;
|
|
85
|
+
|
|
86
|
+
for (; offset < len; offset++) {
|
|
87
|
+
const code = arg.charCodeAt(offset);
|
|
88
|
+
if (code > 0x7F) break;
|
|
89
|
+
mem[ptr + offset] = code;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (offset !== len) {
|
|
93
|
+
if (offset !== 0) {
|
|
94
|
+
arg = arg.slice(offset);
|
|
95
|
+
}
|
|
96
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
97
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
98
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
99
|
+
|
|
100
|
+
offset += ret.written;
|
|
101
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
WASM_VECTOR_LEN = offset;
|
|
105
|
+
return ptr;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let cachedDataViewMemory0 = null;
|
|
109
|
+
|
|
110
|
+
function getDataViewMemory0() {
|
|
111
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
112
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
113
|
+
}
|
|
114
|
+
return cachedDataViewMemory0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isLikeNone(x) {
|
|
118
|
+
return x === undefined || x === null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function debugString(val) {
|
|
122
|
+
// primitive types
|
|
123
|
+
const type = typeof val;
|
|
124
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
125
|
+
return `${val}`;
|
|
126
|
+
}
|
|
127
|
+
if (type == 'string') {
|
|
128
|
+
return `"${val}"`;
|
|
129
|
+
}
|
|
130
|
+
if (type == 'symbol') {
|
|
131
|
+
const description = val.description;
|
|
132
|
+
if (description == null) {
|
|
133
|
+
return 'Symbol';
|
|
134
|
+
} else {
|
|
135
|
+
return `Symbol(${description})`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (type == 'function') {
|
|
139
|
+
const name = val.name;
|
|
140
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
141
|
+
return `Function(${name})`;
|
|
142
|
+
} else {
|
|
143
|
+
return 'Function';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// objects
|
|
147
|
+
if (Array.isArray(val)) {
|
|
148
|
+
const length = val.length;
|
|
149
|
+
let debug = '[';
|
|
150
|
+
if (length > 0) {
|
|
151
|
+
debug += debugString(val[0]);
|
|
152
|
+
}
|
|
153
|
+
for(let i = 1; i < length; i++) {
|
|
154
|
+
debug += ', ' + debugString(val[i]);
|
|
155
|
+
}
|
|
156
|
+
debug += ']';
|
|
157
|
+
return debug;
|
|
158
|
+
}
|
|
159
|
+
// Test for built-in
|
|
160
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
161
|
+
let className;
|
|
162
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
163
|
+
className = builtInMatches[1];
|
|
164
|
+
} else {
|
|
165
|
+
// Failed to match the standard '[object ClassName]'
|
|
166
|
+
return toString.call(val);
|
|
167
|
+
}
|
|
168
|
+
if (className == 'Object') {
|
|
169
|
+
// we're a user defined class or Object
|
|
170
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
171
|
+
// easier than looping through ownProperties of `val`.
|
|
172
|
+
try {
|
|
173
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
174
|
+
} catch (_) {
|
|
175
|
+
return 'Object';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// errors
|
|
179
|
+
if (val instanceof Error) {
|
|
180
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
181
|
+
}
|
|
182
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
183
|
+
return className;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
187
|
+
ptr = ptr >>> 0;
|
|
188
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function dropObject(idx) {
|
|
192
|
+
if (idx < 132) return;
|
|
193
|
+
heap[idx] = heap_next;
|
|
194
|
+
heap_next = idx;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function takeObject(idx) {
|
|
198
|
+
const ret = getObject(idx);
|
|
199
|
+
dropObject(idx);
|
|
200
|
+
return ret;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function _INVALID_ARGUMENTS() {
|
|
204
|
+
try {
|
|
205
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
206
|
+
wasm._INVALID_ARGUMENTS(retptr);
|
|
207
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
208
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
209
|
+
return getStringFromWasm0(r0, r1);
|
|
210
|
+
} finally {
|
|
211
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Returns the liquidation price
|
|
217
|
+
*
|
|
218
|
+
* # Parameters
|
|
219
|
+
* - `position_token`: Token of the position
|
|
220
|
+
* - `amount`: Position total size (decimal)
|
|
221
|
+
* - `debt`: Position total debt (decimal)
|
|
222
|
+
* - `liquidation_threshold`: Liquidation threshold of the market (decimal)
|
|
223
|
+
*
|
|
224
|
+
* # Returns
|
|
225
|
+
* - `f64`: Decimal liquidation price
|
|
226
|
+
*/
|
|
227
|
+
export function getLiquidationPrice(position_token, amount, debt, liquidation_threshold) {
|
|
228
|
+
try {
|
|
229
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
230
|
+
wasm.getLiquidationPrice(retptr, addHeapObject(position_token), amount, debt, liquidation_threshold);
|
|
231
|
+
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
232
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
233
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
234
|
+
if (r3) {
|
|
235
|
+
throw takeObject(r2);
|
|
236
|
+
}
|
|
237
|
+
return r0;
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function __wbg_Error_e83987f665cf5504(arg0, arg1) {
|
|
244
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
245
|
+
return addHeapObject(ret);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export function __wbg_String_eecc4a11987127d6(arg0, arg1) {
|
|
249
|
+
const ret = String(getObject(arg1));
|
|
250
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
251
|
+
const len1 = WASM_VECTOR_LEN;
|
|
252
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
253
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export function __wbg___wbindgen_boolean_get_6d5a1ee65bab5f68(arg0) {
|
|
257
|
+
const v = getObject(arg0);
|
|
258
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
259
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export function __wbg___wbindgen_debug_string_df47ffb5e35e6763(arg0, arg1) {
|
|
263
|
+
const ret = debugString(getObject(arg1));
|
|
264
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
265
|
+
const len1 = WASM_VECTOR_LEN;
|
|
266
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
267
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export function __wbg___wbindgen_is_object_c818261d21f283a4(arg0) {
|
|
271
|
+
const val = getObject(arg0);
|
|
272
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
273
|
+
return ret;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export function __wbg___wbindgen_is_string_fbb76cb2940daafd(arg0) {
|
|
277
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
278
|
+
return ret;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export function __wbg___wbindgen_jsval_loose_eq_b664b38a2f582147(arg0, arg1) {
|
|
282
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
283
|
+
return ret;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export function __wbg___wbindgen_number_get_a20bf9b85341449d(arg0, arg1) {
|
|
287
|
+
const obj = getObject(arg1);
|
|
288
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
289
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
290
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export function __wbg___wbindgen_string_get_e4f06c90489ad01b(arg0, arg1) {
|
|
294
|
+
const obj = getObject(arg1);
|
|
295
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
296
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
297
|
+
var len1 = WASM_VECTOR_LEN;
|
|
298
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
299
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export function __wbg___wbindgen_throw_b855445ff6a94295(arg0, arg1) {
|
|
303
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export function __wbg_entries_e171b586f8f6bdbf(arg0) {
|
|
307
|
+
const ret = Object.entries(getObject(arg0));
|
|
308
|
+
return addHeapObject(ret);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export function __wbg_get_7bed016f185add81(arg0, arg1) {
|
|
312
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
313
|
+
return addHeapObject(ret);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export function __wbg_instanceof_ArrayBuffer_70beb1189ca63b38(arg0) {
|
|
317
|
+
let result;
|
|
318
|
+
try {
|
|
319
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
320
|
+
} catch (_) {
|
|
321
|
+
result = false;
|
|
322
|
+
}
|
|
323
|
+
const ret = result;
|
|
324
|
+
return ret;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export function __wbg_instanceof_Uint8Array_20c8e73002f7af98(arg0) {
|
|
328
|
+
let result;
|
|
329
|
+
try {
|
|
330
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
331
|
+
} catch (_) {
|
|
332
|
+
result = false;
|
|
333
|
+
}
|
|
334
|
+
const ret = result;
|
|
335
|
+
return ret;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export function __wbg_length_69bca3cb64fc8748(arg0) {
|
|
339
|
+
const ret = getObject(arg0).length;
|
|
340
|
+
return ret;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export function __wbg_length_cdd215e10d9dd507(arg0) {
|
|
344
|
+
const ret = getObject(arg0).length;
|
|
345
|
+
return ret;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export function __wbg_new_5a79be3ab53b8aa5(arg0) {
|
|
349
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
350
|
+
return addHeapObject(ret);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export function __wbg_prototypesetcall_2a6620b6922694b2(arg0, arg1, arg2) {
|
|
354
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
358
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
359
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
360
|
+
return addHeapObject(ret);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
364
|
+
const ret = getObject(arg0);
|
|
365
|
+
return addHeapObject(ret);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
369
|
+
takeObject(arg0);
|
|
370
|
+
};
|
|
371
|
+
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
5
|
+
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
7
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
8
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "defituna-core_js_bindings",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"defituna_core_js_bindings_bg.wasm",
|
|
7
|
+
"defituna_core_js_bindings.js",
|
|
8
|
+
"defituna_core_js_bindings_bg.js",
|
|
9
|
+
"defituna_core_js_bindings.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "defituna_core_js_bindings.js",
|
|
12
|
+
"types": "defituna_core_js_bindings.d.ts",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"./defituna_core_js_bindings.js",
|
|
15
|
+
"./snippets/*"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function _INVALID_ARGUMENTS(): string;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the liquidation price
|
|
6
|
+
*
|
|
7
|
+
* # Parameters
|
|
8
|
+
* - `position_token`: Token of the position
|
|
9
|
+
* - `amount`: Position total size (decimal)
|
|
10
|
+
* - `debt`: Position total debt (decimal)
|
|
11
|
+
* - `liquidation_threshold`: Liquidation threshold of the market (decimal)
|
|
12
|
+
*
|
|
13
|
+
* # Returns
|
|
14
|
+
* - `f64`: Decimal liquidation price
|
|
15
|
+
*/
|
|
16
|
+
export function getLiquidationPrice(position_token: PoolTokenFacade, amount: number, debt: number, liquidation_threshold: number): number;
|
|
17
|
+
export interface TunaSpotPositionFacade {
|
|
18
|
+
version: number;
|
|
19
|
+
marketMaker: MarketMakerFacade;
|
|
20
|
+
positionToken: PoolTokenFacade;
|
|
21
|
+
collateralToken: PoolTokenFacade;
|
|
22
|
+
flags: number;
|
|
23
|
+
amount: bigint;
|
|
24
|
+
loanShares: bigint;
|
|
25
|
+
loanFunds: bigint;
|
|
26
|
+
entrySqrtPrice: bigint;
|
|
27
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
28
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type MarketMakerFacade = "orca" | "fusion";
|
|
32
|
+
|
|
33
|
+
export type PoolTokenFacade = "a" | "b";
|
|
34
|
+
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
let cachedUint8ArrayMemory0 = null;
|
|
6
|
+
|
|
7
|
+
function getUint8ArrayMemory0() {
|
|
8
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
9
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
10
|
+
}
|
|
11
|
+
return cachedUint8ArrayMemory0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
15
|
+
|
|
16
|
+
cachedTextDecoder.decode();
|
|
17
|
+
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getStringFromWasm0(ptr, len) {
|
|
23
|
+
ptr = ptr >>> 0;
|
|
24
|
+
return decodeText(ptr, len);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let heap = new Array(128).fill(undefined);
|
|
28
|
+
|
|
29
|
+
heap.push(undefined, null, true, false);
|
|
30
|
+
|
|
31
|
+
let heap_next = heap.length;
|
|
32
|
+
|
|
33
|
+
function addHeapObject(obj) {
|
|
34
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
35
|
+
const idx = heap_next;
|
|
36
|
+
heap_next = heap[idx];
|
|
37
|
+
|
|
38
|
+
heap[idx] = obj;
|
|
39
|
+
return idx;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getObject(idx) { return heap[idx]; }
|
|
43
|
+
|
|
44
|
+
let WASM_VECTOR_LEN = 0;
|
|
45
|
+
|
|
46
|
+
const cachedTextEncoder = new TextEncoder();
|
|
47
|
+
|
|
48
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
49
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
50
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
51
|
+
view.set(buf);
|
|
52
|
+
return {
|
|
53
|
+
read: arg.length,
|
|
54
|
+
written: buf.length
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
60
|
+
|
|
61
|
+
if (realloc === undefined) {
|
|
62
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
63
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
64
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
65
|
+
WASM_VECTOR_LEN = buf.length;
|
|
66
|
+
return ptr;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let len = arg.length;
|
|
70
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
71
|
+
|
|
72
|
+
const mem = getUint8ArrayMemory0();
|
|
73
|
+
|
|
74
|
+
let offset = 0;
|
|
75
|
+
|
|
76
|
+
for (; offset < len; offset++) {
|
|
77
|
+
const code = arg.charCodeAt(offset);
|
|
78
|
+
if (code > 0x7F) break;
|
|
79
|
+
mem[ptr + offset] = code;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (offset !== len) {
|
|
83
|
+
if (offset !== 0) {
|
|
84
|
+
arg = arg.slice(offset);
|
|
85
|
+
}
|
|
86
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
87
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
88
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
89
|
+
|
|
90
|
+
offset += ret.written;
|
|
91
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
WASM_VECTOR_LEN = offset;
|
|
95
|
+
return ptr;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let cachedDataViewMemory0 = null;
|
|
99
|
+
|
|
100
|
+
function getDataViewMemory0() {
|
|
101
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
102
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
103
|
+
}
|
|
104
|
+
return cachedDataViewMemory0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isLikeNone(x) {
|
|
108
|
+
return x === undefined || x === null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function debugString(val) {
|
|
112
|
+
// primitive types
|
|
113
|
+
const type = typeof val;
|
|
114
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
115
|
+
return `${val}`;
|
|
116
|
+
}
|
|
117
|
+
if (type == 'string') {
|
|
118
|
+
return `"${val}"`;
|
|
119
|
+
}
|
|
120
|
+
if (type == 'symbol') {
|
|
121
|
+
const description = val.description;
|
|
122
|
+
if (description == null) {
|
|
123
|
+
return 'Symbol';
|
|
124
|
+
} else {
|
|
125
|
+
return `Symbol(${description})`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (type == 'function') {
|
|
129
|
+
const name = val.name;
|
|
130
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
131
|
+
return `Function(${name})`;
|
|
132
|
+
} else {
|
|
133
|
+
return 'Function';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// objects
|
|
137
|
+
if (Array.isArray(val)) {
|
|
138
|
+
const length = val.length;
|
|
139
|
+
let debug = '[';
|
|
140
|
+
if (length > 0) {
|
|
141
|
+
debug += debugString(val[0]);
|
|
142
|
+
}
|
|
143
|
+
for(let i = 1; i < length; i++) {
|
|
144
|
+
debug += ', ' + debugString(val[i]);
|
|
145
|
+
}
|
|
146
|
+
debug += ']';
|
|
147
|
+
return debug;
|
|
148
|
+
}
|
|
149
|
+
// Test for built-in
|
|
150
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
151
|
+
let className;
|
|
152
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
153
|
+
className = builtInMatches[1];
|
|
154
|
+
} else {
|
|
155
|
+
// Failed to match the standard '[object ClassName]'
|
|
156
|
+
return toString.call(val);
|
|
157
|
+
}
|
|
158
|
+
if (className == 'Object') {
|
|
159
|
+
// we're a user defined class or Object
|
|
160
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
161
|
+
// easier than looping through ownProperties of `val`.
|
|
162
|
+
try {
|
|
163
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
164
|
+
} catch (_) {
|
|
165
|
+
return 'Object';
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// errors
|
|
169
|
+
if (val instanceof Error) {
|
|
170
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
171
|
+
}
|
|
172
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
173
|
+
return className;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
177
|
+
ptr = ptr >>> 0;
|
|
178
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function dropObject(idx) {
|
|
182
|
+
if (idx < 132) return;
|
|
183
|
+
heap[idx] = heap_next;
|
|
184
|
+
heap_next = idx;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function takeObject(idx) {
|
|
188
|
+
const ret = getObject(idx);
|
|
189
|
+
dropObject(idx);
|
|
190
|
+
return ret;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
exports._INVALID_ARGUMENTS = function() {
|
|
194
|
+
try {
|
|
195
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
196
|
+
wasm._INVALID_ARGUMENTS(retptr);
|
|
197
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
198
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
199
|
+
return getStringFromWasm0(r0, r1);
|
|
200
|
+
} finally {
|
|
201
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns the liquidation price
|
|
207
|
+
*
|
|
208
|
+
* # Parameters
|
|
209
|
+
* - `position_token`: Token of the position
|
|
210
|
+
* - `amount`: Position total size (decimal)
|
|
211
|
+
* - `debt`: Position total debt (decimal)
|
|
212
|
+
* - `liquidation_threshold`: Liquidation threshold of the market (decimal)
|
|
213
|
+
*
|
|
214
|
+
* # Returns
|
|
215
|
+
* - `f64`: Decimal liquidation price
|
|
216
|
+
*/
|
|
217
|
+
exports.getLiquidationPrice = function(position_token, amount, debt, liquidation_threshold) {
|
|
218
|
+
try {
|
|
219
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
220
|
+
wasm.getLiquidationPrice(retptr, addHeapObject(position_token), amount, debt, liquidation_threshold);
|
|
221
|
+
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
222
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
223
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
224
|
+
if (r3) {
|
|
225
|
+
throw takeObject(r2);
|
|
226
|
+
}
|
|
227
|
+
return r0;
|
|
228
|
+
} finally {
|
|
229
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
exports.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
|
|
234
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
235
|
+
return addHeapObject(ret);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
|
|
239
|
+
const ret = String(getObject(arg1));
|
|
240
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
241
|
+
const len1 = WASM_VECTOR_LEN;
|
|
242
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
243
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
exports.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
|
|
247
|
+
const v = getObject(arg0);
|
|
248
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
249
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
exports.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
|
|
253
|
+
const ret = debugString(getObject(arg1));
|
|
254
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
255
|
+
const len1 = WASM_VECTOR_LEN;
|
|
256
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
257
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
exports.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
|
|
261
|
+
const val = getObject(arg0);
|
|
262
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
263
|
+
return ret;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
exports.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
|
|
267
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
268
|
+
return ret;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
exports.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
|
|
272
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
273
|
+
return ret;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
exports.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
|
|
277
|
+
const obj = getObject(arg1);
|
|
278
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
279
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
280
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
exports.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
|
|
284
|
+
const obj = getObject(arg1);
|
|
285
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
286
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
287
|
+
var len1 = WASM_VECTOR_LEN;
|
|
288
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
289
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
293
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
exports.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
|
|
297
|
+
const ret = Object.entries(getObject(arg0));
|
|
298
|
+
return addHeapObject(ret);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
exports.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
|
|
302
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
303
|
+
return addHeapObject(ret);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
exports.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
|
|
307
|
+
let result;
|
|
308
|
+
try {
|
|
309
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
310
|
+
} catch (_) {
|
|
311
|
+
result = false;
|
|
312
|
+
}
|
|
313
|
+
const ret = result;
|
|
314
|
+
return ret;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
exports.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
|
|
318
|
+
let result;
|
|
319
|
+
try {
|
|
320
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
321
|
+
} catch (_) {
|
|
322
|
+
result = false;
|
|
323
|
+
}
|
|
324
|
+
const ret = result;
|
|
325
|
+
return ret;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
exports.__wbg_length_69bca3cb64fc8748 = function(arg0) {
|
|
329
|
+
const ret = getObject(arg0).length;
|
|
330
|
+
return ret;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
exports.__wbg_length_cdd215e10d9dd507 = function(arg0) {
|
|
334
|
+
const ret = getObject(arg0).length;
|
|
335
|
+
return ret;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
exports.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
|
|
339
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
340
|
+
return addHeapObject(ret);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
exports.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
|
|
344
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
348
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
349
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
350
|
+
return addHeapObject(ret);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
354
|
+
const ret = getObject(arg0);
|
|
355
|
+
return addHeapObject(ret);
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
359
|
+
takeObject(arg0);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const wasmPath = `${__dirname}/defituna_core_js_bindings_bg.wasm`;
|
|
363
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
364
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
365
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
366
|
+
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const _INVALID_ARGUMENTS: (a: number) => void;
|
|
5
|
+
export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
7
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
8
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "defituna-core_js_bindings",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"defituna_core_js_bindings_bg.wasm",
|
|
6
|
+
"defituna_core_js_bindings.js",
|
|
7
|
+
"defituna_core_js_bindings.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"main": "defituna_core_js_bindings.js",
|
|
10
|
+
"types": "defituna_core_js_bindings.d.ts"
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crypticdot/defituna-core",
|
|
3
|
+
"description": "DefiTuna core typescript package.",
|
|
4
|
+
"version": "3.1.0",
|
|
5
|
+
"main": "./dist/nodejs/defituna_core_js_bindings.js",
|
|
6
|
+
"types": "./dist/nodejs/defituna_core_js_bindings.d.ts",
|
|
7
|
+
"browser": "./dist/browser/defituna_core_js_bindings.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/browser/snippets/*",
|
|
14
|
+
"./dist/browser/defituna_core_js_bindings.js"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@crypticdot/eslint-config": "^1.0.0",
|
|
22
|
+
"@crypticdot/prettier-config": "^1.0.0",
|
|
23
|
+
"@crypticdot/typescript-config": "^1.0.0",
|
|
24
|
+
"typescript": "^5.8.3",
|
|
25
|
+
"wasm-pack": "^0.13.1",
|
|
26
|
+
"@crypticdot/defituna-rust-core": "3.1.0"
|
|
27
|
+
},
|
|
28
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"solana",
|
|
31
|
+
"crypto",
|
|
32
|
+
"defi",
|
|
33
|
+
"dex",
|
|
34
|
+
"amm"
|
|
35
|
+
],
|
|
36
|
+
"homepage": "https://defituna.com",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "wasm-pack build --release --out-dir ./dist/nodejs --target nodejs && wasm-pack build --release --out-dir ./dist/browser --target browser",
|
|
39
|
+
"deploy": "../../scripts/deploy-npm",
|
|
40
|
+
"clean": "cargo clean && rimraf dist"
|
|
41
|
+
}
|
|
42
|
+
}
|