@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.
- package/dist/browser/defituna_core_js_bindings.d.ts +214 -41
- package/dist/browser/defituna_core_js_bindings_bg.js +1337 -62
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +60 -4
- package/dist/nodejs/defituna_core_js_bindings.d.ts +214 -41
- package/dist/nodejs/defituna_core_js_bindings.js +1353 -62
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +60 -4
- package/package.json +2 -2
|
@@ -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`:
|
|
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
|
|
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`:
|
|
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,
|
|
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
|
-
* - `
|
|
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,
|
|
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
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
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
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
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 — as with [_program derived
|
|
960
|
+
* addresses_][pdas] — 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
|
-
|