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