@crypticdot/defituna-core 3.2.7 → 3.3.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.
@@ -1,12 +1,63 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const _INVALID_ARGUMENTS: (a: number) => void;
5
- export const getIncreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
6
- export const getDecreaseSpotPositionQuote: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
4
+ export const getIncreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
5
+ export const getDecreaseSpotPositionQuote: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: bigint, h: bigint, i: number, j: number, k: number, l: number, m: number, n: number) => number;
7
6
  export const getLiquidationPrice: (a: number, b: number, c: number, d: number, e: number) => void;
8
7
  export const getTradableAmount: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number) => void;
9
8
  export const calculateTunaProtocolFee: (a: number, b: number, c: bigint, d: bigint, e: number, f: number) => number;
9
+ export const _INVALID_ARGUMENTS: (a: number) => void;
10
+ export const _TICK_ARRAYS_NOT_PROVIDED: (a: number) => void;
11
+ export const _JUPITER_QUOTE_REQUEST_ERROR: (a: number) => void;
12
+ export const _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR: (a: number) => void;
13
+ export const __wbg_transaction_free: (a: number, b: number) => void;
14
+ export const transaction_constructor: (a: number, b: number) => number;
15
+ export const transaction_message: (a: number) => number;
16
+ export const transaction_messageData: (a: number, b: number) => void;
17
+ export const transaction_verify: (a: number, b: number) => void;
18
+ export const transaction_partialSign: (a: number, b: number, c: number) => void;
19
+ export const transaction_isSigned: (a: number) => number;
20
+ export const transaction_toBytes: (a: number, b: number) => void;
21
+ export const transaction_fromBytes: (a: number, b: number, c: number) => void;
22
+ export const __wbg_keypair_free: (a: number, b: number) => void;
23
+ export const keypair_constructor: () => number;
24
+ export const keypair_toBytes: (a: number, b: number) => void;
25
+ export const keypair_fromBytes: (a: number, b: number, c: number) => void;
26
+ export const keypair_pubkey: (a: number) => number;
27
+ export const solana_program_init: () => void;
28
+ export const __wbg_message_free: (a: number, b: number) => void;
29
+ export const __wbg_get_message_recent_blockhash: (a: number) => number;
30
+ export const __wbg_set_message_recent_blockhash: (a: number, b: number) => void;
31
+ export const systeminstruction_createAccount: (a: number, b: number, c: bigint, d: bigint, e: number) => number;
32
+ export const systeminstruction_createAccountWithSeed: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: bigint, h: number) => number;
33
+ export const systeminstruction_assign: (a: number, b: number) => number;
34
+ export const systeminstruction_assignWithSeed: (a: number, b: number, c: number, d: number, e: number) => number;
35
+ export const systeminstruction_transfer: (a: number, b: number, c: bigint) => number;
36
+ export const systeminstruction_transferWithSeed: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => number;
37
+ export const systeminstruction_allocate: (a: number, b: bigint) => number;
38
+ export const systeminstruction_allocateWithSeed: (a: number, b: number, c: number, d: number, e: bigint, f: number) => number;
39
+ export const systeminstruction_createNonceAccount: (a: number, b: number, c: number, d: bigint) => number;
40
+ export const systeminstruction_advanceNonceAccount: (a: number, b: number) => number;
41
+ export const systeminstruction_withdrawNonceAccount: (a: number, b: number, c: number, d: bigint) => number;
42
+ export const systeminstruction_authorizeNonceAccount: (a: number, b: number, c: number) => number;
43
+ export const __wbg_instruction_free: (a: number, b: number) => void;
44
+ export const __wbg_instructions_free: (a: number, b: number) => void;
45
+ export const instructions_constructor: () => number;
46
+ export const instructions_push: (a: number, b: number) => void;
47
+ export const __wbg_pubkey_free: (a: number, b: number) => void;
48
+ export const pubkey_constructor: (a: number, b: number) => void;
49
+ export const pubkey_toString: (a: number, b: number) => void;
50
+ export const pubkey_isOnCurve: (a: number) => number;
51
+ export const pubkey_equals: (a: number, b: number) => number;
52
+ export const pubkey_toBytes: (a: number, b: number) => void;
53
+ export const pubkey_createWithSeed: (a: number, b: number, c: number, d: number, e: number) => void;
54
+ export const pubkey_createProgramAddress: (a: number, b: number, c: number, d: number) => void;
55
+ export const pubkey_findProgramAddress: (a: number, b: number, c: number, d: number) => void;
56
+ export const __wbg_hash_free: (a: number, b: number) => void;
57
+ export const hash_constructor: (a: number, b: number) => void;
58
+ export const hash_toString: (a: number, b: number) => void;
59
+ export const hash_equals: (a: number, b: number) => number;
60
+ export const hash_toBytes: (a: number, b: number) => void;
10
61
  export const decreaseLiquidityQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
11
62
  export const decreaseLiquidityQuoteA: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number) => void;
12
63
  export const decreaseLiquidityQuoteB: (a: number, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number) => void;
@@ -86,7 +137,13 @@ export const limitOrderQuoteByInputToken: (a: number, b: bigint, c: number, d: n
86
137
  export const limitOrderQuoteByOutputToken: (a: number, b: bigint, c: number, d: number, e: number) => void;
87
138
  export const limitOrderRewardByOutputToken: (a: number, b: bigint, c: number, d: number) => void;
88
139
  export const decreaseLimitOrderQuote: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number) => void;
140
+ export const __wasm_bindgen_func_elem_3304: (a: number, b: number, c: number) => void;
141
+ export const __wasm_bindgen_func_elem_3323: (a: number, b: number) => void;
142
+ export const __wasm_bindgen_func_elem_3120: (a: number, b: number) => void;
143
+ export const __wasm_bindgen_func_elem_3116: (a: number, b: number) => void;
144
+ export const __wasm_bindgen_func_elem_480: (a: number, b: number, c: number, d: number) => void;
89
145
  export const __wbindgen_export: (a: number, b: number) => number;
90
146
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
91
147
  export const __wbindgen_export3: (a: number) => void;
148
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
92
149
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
@@ -631,7 +631,6 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
631
631
  * The exact input or output amount for the swap transaction.
632
632
  */
633
633
  export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
634
- export function _INVALID_ARGUMENTS(): string;
635
634
  /**
636
635
  * Spot position increase quote
637
636
  *
@@ -643,13 +642,15 @@ export function _INVALID_ARGUMENTS(): string;
643
642
  * - `slippage_tolerance_bps`: An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
644
643
  * - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
645
644
  * - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
645
+ * - `mint_a`: Token A mint address
646
+ * - `mint_b`: Token B mint address
646
647
  * - `fusion_pool`: Fusion pool.
647
- * - `tick_arrays`: Five tick arrays around the current pool price.
648
+ * - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
648
649
  *
649
650
  * # Returns
650
651
  * - `IncreaseSpotPositionQuoteResult`: quote result
651
652
  */
652
- export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token: number, position_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): IncreaseSpotPositionQuoteResult;
653
+ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral_token: number, position_token: number, leverage: number, slippage_tolerance_bps: number | null | undefined, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, mint_a: Pubkey, mint_b: Pubkey, fusion_pool: FusionPoolFacade, tick_arrays?: TickArrayFacade[] | null): Promise<any>;
653
654
  /**
654
655
  * Spot position decrease quote
655
656
  *
@@ -665,12 +666,12 @@ export function getIncreaseSpotPositionQuote(increase_amount: bigint, collateral
665
666
  * - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
666
667
  * - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
667
668
  * - `fusion_pool`: Fusion pool.
668
- * - `tick_arrays`: Five tick arrays around the current pool price.
669
+ * - `tick_arrays`: Optional five tick arrays around the current pool price. If not provided, the quote will be calculated using the Jupiter Aggregator.
669
670
  *
670
671
  * # Returns
671
672
  * - `DecreaseSpotPositionQuoteResult`: quote result
672
673
  */
673
- export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, reduce_only: boolean, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): DecreaseSpotPositionQuoteResult;
674
+ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral_token: number, leverage: number, reduce_only: boolean, slippage_tolerance_bps: number | null | undefined, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, mint_a: Pubkey, mint_b: Pubkey, fusion_pool: FusionPoolFacade, tick_arrays?: TickArrayFacade[] | null): Promise<any>;
674
675
  /**
675
676
  * Returns the liquidation price
676
677
  *
@@ -704,8 +705,21 @@ export function getLiquidationPrice(position_token: number, amount: number, debt
704
705
  * # Returns
705
706
  * - `u64`: the maximum tradable amount
706
707
  */
707
- export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, new_position_token: number, reduce_only: boolean, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[]): bigint;
708
+ export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, new_position_token: number, reduce_only: boolean, position_token: number, position_amount: bigint, position_debt: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, tick_arrays?: TickArrayFacade[] | null): bigint;
708
709
  export function calculateTunaProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
710
+ export function _INVALID_ARGUMENTS(): string;
711
+ export function _TICK_ARRAYS_NOT_PROVIDED(): string;
712
+ export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
713
+ export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
714
+ /**
715
+ * Initialize Javascript logging and panic handler
716
+ */
717
+ export function solana_program_init(): void;
718
+ export interface CollectFeesQuote {
719
+ feeOwedA: bigint;
720
+ feeOwedB: bigint;
721
+ }
722
+
709
723
  export interface TickArrayFacade {
710
724
  startTickIndex: number;
711
725
  ticks: TickFacade[];
@@ -779,11 +793,6 @@ export interface DecreaseLiquidityQuote {
779
793
  tokenMinB: bigint;
780
794
  }
781
795
 
782
- export interface CollectFeesQuote {
783
- feeOwedA: bigint;
784
- feeOwedB: bigint;
785
- }
786
-
787
796
  export interface TokenPair {
788
797
  a: bigint;
789
798
  b: bigint;
@@ -839,28 +848,206 @@ export interface TunaSpotPositionFacade {
839
848
  upperLimitOrderSqrtPrice: bigint;
840
849
  }
841
850
 
842
- export interface DecreaseSpotPositionQuoteResult {
843
- decreasePercent: number;
844
- collateralToken: number;
845
- positionToken: number;
851
+ export interface SwapInstruction {
852
+ data: number[];
853
+ accounts: AccountMeta[];
854
+ addressLookupTableAddresses: Pubkey[];
855
+ }
856
+
857
+ export interface IncreaseSpotPositionQuoteResult {
846
858
  collateral: bigint;
847
859
  borrow: bigint;
848
- decreaseAcceptableSwapAmount: bigint;
849
- increaseMinSwapOutputAmount: bigint;
850
860
  estimatedAmount: bigint;
861
+ swapInputAmount: bigint;
862
+ minSwapOutputAmount: bigint;
851
863
  protocolFeeA: bigint;
852
864
  protocolFeeB: bigint;
853
865
  priceImpact: number;
866
+ jupiterSwapIx: SwapInstruction | undefined;
854
867
  }
855
868
 
856
- export interface IncreaseSpotPositionQuoteResult {
869
+ export interface DecreaseSpotPositionQuoteResult {
870
+ decreasePercent: number;
871
+ collateralToken: number;
872
+ positionToken: number;
857
873
  collateral: bigint;
858
874
  borrow: bigint;
875
+ decreaseAcceptableSwapAmount: bigint;
876
+ increaseMinSwapOutputAmount: bigint;
859
877
  estimatedAmount: bigint;
860
- swapInputAmount: bigint;
861
- minSwapOutputAmount: bigint;
862
878
  protocolFeeA: bigint;
863
879
  protocolFeeB: bigint;
864
880
  priceImpact: number;
881
+ jupiterSwapIx: SwapInstruction | undefined;
865
882
  }
866
883
 
884
+ /**
885
+ * A hash; the 32-byte output of a hashing algorithm.
886
+ *
887
+ * This struct is used most often in `solana-sdk` and related crates to contain
888
+ * a [SHA-256] hash, but may instead contain a [blake3] hash.
889
+ *
890
+ * [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
891
+ * [blake3]: https://github.com/BLAKE3-team/BLAKE3
892
+ */
893
+ export class Hash {
894
+ free(): void;
895
+ [Symbol.dispose](): void;
896
+ /**
897
+ * Create a new Hash object
898
+ *
899
+ * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]`
900
+ */
901
+ constructor(value: any);
902
+ /**
903
+ * Return the base58 string representation of the hash
904
+ */
905
+ toString(): string;
906
+ /**
907
+ * Checks if two `Hash`s are equal
908
+ */
909
+ equals(other: Hash): boolean;
910
+ /**
911
+ * Return the `Uint8Array` representation of the hash
912
+ */
913
+ toBytes(): Uint8Array;
914
+ }
915
+ /**
916
+ * wasm-bindgen version of the Instruction struct.
917
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
918
+ * is fixed. This must not diverge from the regular non-wasm Instruction struct.
919
+ */
920
+ export class Instruction {
921
+ private constructor();
922
+ free(): void;
923
+ [Symbol.dispose](): void;
924
+ }
925
+ export class Instructions {
926
+ free(): void;
927
+ [Symbol.dispose](): void;
928
+ constructor();
929
+ push(instruction: Instruction): void;
930
+ }
931
+ /**
932
+ * A vanilla Ed25519 key pair
933
+ */
934
+ export class Keypair {
935
+ free(): void;
936
+ [Symbol.dispose](): void;
937
+ /**
938
+ * Create a new `Keypair `
939
+ */
940
+ constructor();
941
+ /**
942
+ * Convert a `Keypair` to a `Uint8Array`
943
+ */
944
+ toBytes(): Uint8Array;
945
+ /**
946
+ * Recover a `Keypair` from a `Uint8Array`
947
+ */
948
+ static fromBytes(bytes: Uint8Array): Keypair;
949
+ /**
950
+ * Return the `Pubkey` for this `Keypair`
951
+ */
952
+ pubkey(): Pubkey;
953
+ }
954
+ /**
955
+ * wasm-bindgen version of the Message struct.
956
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
957
+ * is fixed. This must not diverge from the regular non-wasm Message struct.
958
+ */
959
+ export class Message {
960
+ private constructor();
961
+ free(): void;
962
+ [Symbol.dispose](): void;
963
+ /**
964
+ * The id of a recent ledger entry.
965
+ */
966
+ recent_blockhash: Hash;
967
+ }
968
+ /**
969
+ * The address of a [Solana account][acc].
970
+ *
971
+ * Some account addresses are [ed25519] public keys, with corresponding secret
972
+ * keys that are managed off-chain. Often, though, account addresses do not
973
+ * have corresponding secret keys &mdash; as with [_program derived
974
+ * addresses_][pdas] &mdash; or the secret key is not relevant to the operation
975
+ * of a program, and may have even been disposed of. As running Solana programs
976
+ * can not safely create or manage secret keys, the full [`Keypair`] is not
977
+ * defined in `solana-program` but in `solana-sdk`.
978
+ *
979
+ * [acc]: https://solana.com/docs/core/accounts
980
+ * [ed25519]: https://ed25519.cr.yp.to/
981
+ * [pdas]: https://solana.com/docs/core/cpi#program-derived-addresses
982
+ * [`Keypair`]: https://docs.rs/solana-sdk/latest/solana_sdk/signer/keypair/struct.Keypair.html
983
+ */
984
+ export class Pubkey {
985
+ free(): void;
986
+ [Symbol.dispose](): void;
987
+ /**
988
+ * Create a new Pubkey object
989
+ *
990
+ * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]`
991
+ */
992
+ constructor(value: any);
993
+ /**
994
+ * Return the base58 string representation of the public key
995
+ */
996
+ toString(): string;
997
+ /**
998
+ * Check if a `Pubkey` is on the ed25519 curve.
999
+ */
1000
+ isOnCurve(): boolean;
1001
+ /**
1002
+ * Checks if two `Pubkey`s are equal
1003
+ */
1004
+ equals(other: Pubkey): boolean;
1005
+ /**
1006
+ * Return the `Uint8Array` representation of the public key
1007
+ */
1008
+ toBytes(): Uint8Array;
1009
+ /**
1010
+ * Derive a Pubkey from another Pubkey, string seed, and a program id
1011
+ */
1012
+ static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey;
1013
+ /**
1014
+ * Derive a program address from seeds and a program id
1015
+ */
1016
+ static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey;
1017
+ /**
1018
+ * Find a valid program address
1019
+ *
1020
+ * Returns:
1021
+ * * `[PubKey, number]` - the program address and bump seed
1022
+ */
1023
+ static findProgramAddress(seeds: any[], program_id: Pubkey): any;
1024
+ }
1025
+ /**
1026
+ * wasm-bindgen version of the Transaction struct.
1027
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
1028
+ * is fixed. This must not diverge from the regular non-wasm Transaction struct.
1029
+ */
1030
+ export class Transaction {
1031
+ free(): void;
1032
+ [Symbol.dispose](): void;
1033
+ /**
1034
+ * Create a new `Transaction`
1035
+ */
1036
+ constructor(instructions: Instructions, payer?: Pubkey | null);
1037
+ /**
1038
+ * Return a message containing all data that should be signed.
1039
+ */
1040
+ message(): Message;
1041
+ /**
1042
+ * Return the serialized message data to sign.
1043
+ */
1044
+ messageData(): Uint8Array;
1045
+ /**
1046
+ * Verify the transaction
1047
+ */
1048
+ verify(): void;
1049
+ partialSign(keypair: Keypair, recent_blockhash: Hash): void;
1050
+ isSigned(): boolean;
1051
+ toBytes(): Uint8Array;
1052
+ static fromBytes(bytes: Uint8Array): Transaction;
1053
+ }