@crypticdot/defituna-core 3.4.5 → 3.4.7
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 +203 -202
- package/dist/browser/defituna_core_js_bindings_bg.js +268 -256
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +30 -29
- package/dist/nodejs/defituna_core_js_bindings.d.ts +203 -202
- package/dist/nodejs/defituna_core_js_bindings.js +268 -256
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +30 -29
- package/package.json +2 -2
|
@@ -729,43 +729,226 @@ export function increaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps,
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
|
|
732
|
+
/**
|
|
733
|
+
* Get the first unoccupied position in a bundle
|
|
734
|
+
*
|
|
735
|
+
* # Arguments
|
|
736
|
+
* * `bundle` - The bundle to check
|
|
737
|
+
*
|
|
738
|
+
* # Returns
|
|
739
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
740
|
+
*/
|
|
741
|
+
export function firstUnoccupiedPositionInBundle(bitmap) {
|
|
742
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
743
|
+
const len0 = WASM_VECTOR_LEN;
|
|
744
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
745
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Check whether a position bundle is full
|
|
750
|
+
* A position bundle can contain 256 positions
|
|
751
|
+
*
|
|
752
|
+
* # Arguments
|
|
753
|
+
* * `bundle` - The bundle to check
|
|
754
|
+
*
|
|
755
|
+
* # Returns
|
|
756
|
+
* * `bool` - Whether the bundle is full
|
|
757
|
+
*/
|
|
758
|
+
export function isPositionBundleFull(bitmap) {
|
|
759
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
760
|
+
const len0 = WASM_VECTOR_LEN;
|
|
761
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
762
|
+
return ret !== 0;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Check whether a position bundle is empty
|
|
767
|
+
*
|
|
768
|
+
* # Arguments
|
|
769
|
+
* * `bundle` - The bundle to check
|
|
770
|
+
*
|
|
771
|
+
* # Returns
|
|
772
|
+
* * `bool` - Whether the bundle is empty
|
|
773
|
+
*/
|
|
774
|
+
export function isPositionBundleEmpty(bitmap) {
|
|
775
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
776
|
+
const len0 = WASM_VECTOR_LEN;
|
|
777
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
778
|
+
return ret !== 0;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Check if a position is in range.
|
|
783
|
+
* When a position is in range it is earning fees and rewards
|
|
784
|
+
*
|
|
785
|
+
* # Parameters
|
|
786
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
787
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
788
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
789
|
+
*
|
|
790
|
+
* # Returns
|
|
791
|
+
* - A boolean value indicating if the position is in range
|
|
792
|
+
*/
|
|
793
|
+
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
794
|
+
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
795
|
+
return ret !== 0;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Calculate the status of a position
|
|
800
|
+
* The status can be one of three values:
|
|
801
|
+
* - InRange: The position is in range
|
|
802
|
+
* - BelowRange: The position is below the range
|
|
803
|
+
* - AboveRange: The position is above the range
|
|
804
|
+
*
|
|
805
|
+
* # Parameters
|
|
806
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
807
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
808
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
809
|
+
*
|
|
810
|
+
* # Returns
|
|
811
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
812
|
+
*/
|
|
813
|
+
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
814
|
+
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
815
|
+
return takeObject(ret);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
820
|
+
*
|
|
821
|
+
* # Parameters
|
|
822
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
823
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
824
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
825
|
+
*
|
|
826
|
+
* # Returns
|
|
827
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
828
|
+
*/
|
|
829
|
+
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
830
|
+
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
831
|
+
return takeObject(ret);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Convert a price into a sqrt priceX64
|
|
836
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
837
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
838
|
+
*
|
|
839
|
+
* # Parameters
|
|
840
|
+
* * `price` - The price to convert
|
|
841
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
842
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
843
|
+
*
|
|
844
|
+
* # Returns
|
|
845
|
+
* * `u128` - The sqrt priceX64
|
|
846
|
+
*/
|
|
847
|
+
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
733
848
|
try {
|
|
734
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-
|
|
735
|
-
wasm.
|
|
849
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
850
|
+
wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
|
|
736
851
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
737
852
|
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
738
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
739
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
740
|
-
if (r5) {
|
|
741
|
-
throw takeObject(r4);
|
|
742
|
-
}
|
|
743
853
|
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
744
854
|
} finally {
|
|
745
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
855
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
746
856
|
}
|
|
747
857
|
}
|
|
748
858
|
|
|
749
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Convert a sqrt priceX64 into a tick index
|
|
861
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
862
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
863
|
+
*
|
|
864
|
+
* # Parameters
|
|
865
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
866
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
867
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
868
|
+
*
|
|
869
|
+
* # Returns
|
|
870
|
+
* * `f64` - The decimal price
|
|
871
|
+
*/
|
|
872
|
+
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
873
|
+
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
874
|
+
return ret;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Invert a price
|
|
879
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
880
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
881
|
+
*
|
|
882
|
+
* # Parameters
|
|
883
|
+
* * `price` - The price to invert
|
|
884
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
885
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
886
|
+
*
|
|
887
|
+
* # Returns
|
|
888
|
+
* * `f64` - The inverted price
|
|
889
|
+
*/
|
|
890
|
+
export function invertPrice(price, decimals_a, decimals_b) {
|
|
891
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
892
|
+
return ret;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Convert a tick index into a price
|
|
897
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
898
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
899
|
+
*
|
|
900
|
+
* # Parameters
|
|
901
|
+
* * `tick_index` - The tick index to convert
|
|
902
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
903
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
904
|
+
*
|
|
905
|
+
* # Returns
|
|
906
|
+
* * `f64` - The decimal price
|
|
907
|
+
*/
|
|
908
|
+
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
909
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
910
|
+
return ret;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Convert a price into a tick index
|
|
915
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
916
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
917
|
+
*
|
|
918
|
+
* # Parameters
|
|
919
|
+
* * `price` - The price to convert
|
|
920
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
921
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
922
|
+
*
|
|
923
|
+
* # Returns
|
|
924
|
+
* * `i32` - The tick index
|
|
925
|
+
*/
|
|
926
|
+
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
927
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
928
|
+
return ret;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
export function getLiquidityFromAmountA(amount_a, sqrt_price_lower, sqrt_price_upper) {
|
|
750
932
|
try {
|
|
751
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-
|
|
752
|
-
wasm.
|
|
933
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
934
|
+
wasm.getLiquidityFromAmountA(retptr, amount_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
753
935
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
754
|
-
var r2 = getDataViewMemory0().
|
|
755
|
-
var
|
|
756
|
-
|
|
757
|
-
|
|
936
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
937
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
938
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
939
|
+
if (r5) {
|
|
940
|
+
throw takeObject(r4);
|
|
758
941
|
}
|
|
759
|
-
return BigInt.asUintN(64, r0);
|
|
942
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
760
943
|
} finally {
|
|
761
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
944
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
762
945
|
}
|
|
763
946
|
}
|
|
764
947
|
|
|
765
|
-
export function
|
|
948
|
+
export function getLiquidityFromAmountB(amount_b, sqrt_price_lower, sqrt_price_upper) {
|
|
766
949
|
try {
|
|
767
950
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
768
|
-
wasm.
|
|
951
|
+
wasm.getLiquidityFromAmountB(retptr, amount_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
769
952
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
770
953
|
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
771
954
|
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
@@ -779,10 +962,26 @@ export function tryGetLiquidityFromB(token_delta_b, sqrt_price_lower, sqrt_price
|
|
|
779
962
|
}
|
|
780
963
|
}
|
|
781
964
|
|
|
782
|
-
export function
|
|
965
|
+
export function getAmountAFromLiquidity(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
966
|
+
try {
|
|
967
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
968
|
+
wasm.getAmountAFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
969
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
970
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
971
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
972
|
+
if (r3) {
|
|
973
|
+
throw takeObject(r2);
|
|
974
|
+
}
|
|
975
|
+
return BigInt.asUintN(64, r0);
|
|
976
|
+
} finally {
|
|
977
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
export function getAmountBFromLiquidity(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
783
982
|
try {
|
|
784
983
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
785
|
-
wasm.
|
|
984
|
+
wasm.getAmountBFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
786
985
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
787
986
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
788
987
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -795,10 +994,10 @@ export function tryGetTokenBFromLiquidity(liquidity_delta, sqrt_price_lower, sqr
|
|
|
795
994
|
}
|
|
796
995
|
}
|
|
797
996
|
|
|
798
|
-
export function
|
|
997
|
+
export function getAmountsFromLiquidity(liquidity, sqrt_price, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
799
998
|
try {
|
|
800
999
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
801
|
-
wasm.
|
|
1000
|
+
wasm.getAmountsFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price, sqrt_price >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
802
1001
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
803
1002
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
804
1003
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -811,10 +1010,10 @@ export function tryGetAmountsFromLiquidity(liquidity_delta, current_sqrt_price,
|
|
|
811
1010
|
}
|
|
812
1011
|
}
|
|
813
1012
|
|
|
814
|
-
export function
|
|
1013
|
+
export function getLiquidityFromAmounts(sqrt_price, sqrt_price_lower, sqrt_price_upper, amount_a, amount_b) {
|
|
815
1014
|
try {
|
|
816
1015
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
817
|
-
wasm.
|
|
1016
|
+
wasm.getLiquidityFromAmounts(retptr, sqrt_price, sqrt_price >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), amount_a, amount_b);
|
|
818
1017
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
819
1018
|
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
820
1019
|
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
@@ -828,41 +1027,6 @@ export function tryGetLiquidityFromAmounts(sqrt_price, sqrt_price_a_x64, sqrt_pr
|
|
|
828
1027
|
}
|
|
829
1028
|
}
|
|
830
1029
|
|
|
831
|
-
/**
|
|
832
|
-
* Calculate fees owed for a position
|
|
833
|
-
*
|
|
834
|
-
* # Paramters
|
|
835
|
-
* - `fusion_pool`: The fusion_pool state
|
|
836
|
-
* - `position`: The position state
|
|
837
|
-
* - `tick_lower`: The lower tick state
|
|
838
|
-
* - `tick_upper`: The upper tick state
|
|
839
|
-
* - `transfer_fee_a`: The transfer fee for token A
|
|
840
|
-
* - `transfer_fee_b`: The transfer fee for token B
|
|
841
|
-
*
|
|
842
|
-
* # Returns
|
|
843
|
-
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
844
|
-
*/
|
|
845
|
-
export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
|
|
846
|
-
try {
|
|
847
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
848
|
-
wasm.collectFeesQuote(retptr, addHeapObject(fusion_pool), addHeapObject(position), addHeapObject(tick_lower), addHeapObject(tick_upper), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
849
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
850
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
851
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
852
|
-
if (r2) {
|
|
853
|
-
throw takeObject(r1);
|
|
854
|
-
}
|
|
855
|
-
return takeObject(r0);
|
|
856
|
-
} finally {
|
|
857
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
export function limitOrderFee(fusion_pool) {
|
|
862
|
-
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
863
|
-
return ret;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
1030
|
/**
|
|
867
1031
|
* Calculate the amount A delta between two sqrt_prices
|
|
868
1032
|
*
|
|
@@ -1232,201 +1396,37 @@ export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount,
|
|
|
1232
1396
|
}
|
|
1233
1397
|
|
|
1234
1398
|
/**
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
* # Arguments
|
|
1238
|
-
* * `bundle` - The bundle to check
|
|
1239
|
-
*
|
|
1240
|
-
* # Returns
|
|
1241
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
1242
|
-
*/
|
|
1243
|
-
export function firstUnoccupiedPositionInBundle(bitmap) {
|
|
1244
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1245
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1246
|
-
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
1247
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* Check whether a position bundle is full
|
|
1252
|
-
* A position bundle can contain 256 positions
|
|
1253
|
-
*
|
|
1254
|
-
* # Arguments
|
|
1255
|
-
* * `bundle` - The bundle to check
|
|
1256
|
-
*
|
|
1257
|
-
* # Returns
|
|
1258
|
-
* * `bool` - Whether the bundle is full
|
|
1259
|
-
*/
|
|
1260
|
-
export function isPositionBundleFull(bitmap) {
|
|
1261
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1262
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1263
|
-
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
1264
|
-
return ret !== 0;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* Check whether a position bundle is empty
|
|
1269
|
-
*
|
|
1270
|
-
* # Arguments
|
|
1271
|
-
* * `bundle` - The bundle to check
|
|
1272
|
-
*
|
|
1273
|
-
* # Returns
|
|
1274
|
-
* * `bool` - Whether the bundle is empty
|
|
1275
|
-
*/
|
|
1276
|
-
export function isPositionBundleEmpty(bitmap) {
|
|
1277
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1278
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1279
|
-
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
1280
|
-
return ret !== 0;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* Check if a position is in range.
|
|
1285
|
-
* When a position is in range it is earning fees and rewards
|
|
1286
|
-
*
|
|
1287
|
-
* # Parameters
|
|
1288
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1289
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1290
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1291
|
-
*
|
|
1292
|
-
* # Returns
|
|
1293
|
-
* - A boolean value indicating if the position is in range
|
|
1294
|
-
*/
|
|
1295
|
-
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1296
|
-
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1297
|
-
return ret !== 0;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
/**
|
|
1301
|
-
* Calculate the status of a position
|
|
1302
|
-
* The status can be one of three values:
|
|
1303
|
-
* - InRange: The position is in range
|
|
1304
|
-
* - BelowRange: The position is below the range
|
|
1305
|
-
* - AboveRange: The position is above the range
|
|
1306
|
-
*
|
|
1307
|
-
* # Parameters
|
|
1308
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1309
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1310
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1311
|
-
*
|
|
1312
|
-
* # Returns
|
|
1313
|
-
* - A PositionStatus enum value indicating the status of the position
|
|
1314
|
-
*/
|
|
1315
|
-
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1316
|
-
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1317
|
-
return takeObject(ret);
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
/**
|
|
1321
|
-
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
1322
|
-
*
|
|
1323
|
-
* # Parameters
|
|
1324
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1325
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1326
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1327
|
-
*
|
|
1328
|
-
* # Returns
|
|
1329
|
-
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
1330
|
-
*/
|
|
1331
|
-
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1332
|
-
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1333
|
-
return takeObject(ret);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
/**
|
|
1337
|
-
* Convert a price into a sqrt priceX64
|
|
1338
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1339
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1399
|
+
* Calculate fees owed for a position
|
|
1340
1400
|
*
|
|
1341
|
-
* #
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1401
|
+
* # Paramters
|
|
1402
|
+
* - `fusion_pool`: The fusion_pool state
|
|
1403
|
+
* - `position`: The position state
|
|
1404
|
+
* - `tick_lower`: The lower tick state
|
|
1405
|
+
* - `tick_upper`: The upper tick state
|
|
1406
|
+
* - `transfer_fee_a`: The transfer fee for token A
|
|
1407
|
+
* - `transfer_fee_b`: The transfer fee for token B
|
|
1345
1408
|
*
|
|
1346
1409
|
* # Returns
|
|
1347
|
-
*
|
|
1410
|
+
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
1348
1411
|
*/
|
|
1349
|
-
export function
|
|
1412
|
+
export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
|
|
1350
1413
|
try {
|
|
1351
1414
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1352
|
-
wasm.
|
|
1353
|
-
var r0 = getDataViewMemory0().
|
|
1354
|
-
var
|
|
1355
|
-
|
|
1415
|
+
wasm.collectFeesQuote(retptr, addHeapObject(fusion_pool), addHeapObject(position), addHeapObject(tick_lower), addHeapObject(tick_upper), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1416
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1417
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1418
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1419
|
+
if (r2) {
|
|
1420
|
+
throw takeObject(r1);
|
|
1421
|
+
}
|
|
1422
|
+
return takeObject(r0);
|
|
1356
1423
|
} finally {
|
|
1357
1424
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1358
1425
|
}
|
|
1359
1426
|
}
|
|
1360
1427
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1364
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1365
|
-
*
|
|
1366
|
-
* # Parameters
|
|
1367
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1368
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1369
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1370
|
-
*
|
|
1371
|
-
* # Returns
|
|
1372
|
-
* * `f64` - The decimal price
|
|
1373
|
-
*/
|
|
1374
|
-
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1375
|
-
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
1376
|
-
return ret;
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
/**
|
|
1380
|
-
* Invert a price
|
|
1381
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1382
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1383
|
-
*
|
|
1384
|
-
* # Parameters
|
|
1385
|
-
* * `price` - The price to invert
|
|
1386
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1387
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1388
|
-
*
|
|
1389
|
-
* # Returns
|
|
1390
|
-
* * `f64` - The inverted price
|
|
1391
|
-
*/
|
|
1392
|
-
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1393
|
-
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1394
|
-
return ret;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* Convert a tick index into a price
|
|
1399
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1400
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1401
|
-
*
|
|
1402
|
-
* # Parameters
|
|
1403
|
-
* * `tick_index` - The tick index to convert
|
|
1404
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1405
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1406
|
-
*
|
|
1407
|
-
* # Returns
|
|
1408
|
-
* * `f64` - The decimal price
|
|
1409
|
-
*/
|
|
1410
|
-
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1411
|
-
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1412
|
-
return ret;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
/**
|
|
1416
|
-
* Convert a price into a tick index
|
|
1417
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1418
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1419
|
-
*
|
|
1420
|
-
* # Parameters
|
|
1421
|
-
* * `price` - The price to convert
|
|
1422
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1423
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1424
|
-
*
|
|
1425
|
-
* # Returns
|
|
1426
|
-
* * `i32` - The tick index
|
|
1427
|
-
*/
|
|
1428
|
-
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1429
|
-
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1428
|
+
export function limitOrderFee(fusion_pool) {
|
|
1429
|
+
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1430
1430
|
return ret;
|
|
1431
1431
|
}
|
|
1432
1432
|
|
|
@@ -1550,6 +1550,18 @@ export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION() {
|
|
|
1550
1550
|
}
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
|
+
export function _INVALID_RANGE_BOUNDS() {
|
|
1554
|
+
try {
|
|
1555
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1556
|
+
wasm._INVALID_RANGE_BOUNDS(retptr);
|
|
1557
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1558
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1559
|
+
return getStringFromWasm0(r0, r1);
|
|
1560
|
+
} finally {
|
|
1561
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1553
1565
|
export function _ZERO_TRADABLE_AMOUNT() {
|
|
1554
1566
|
try {
|
|
1555
1567
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1986,12 +1998,12 @@ export function solana_program_init() {
|
|
|
1986
1998
|
wasm.solana_program_init();
|
|
1987
1999
|
}
|
|
1988
2000
|
|
|
1989
|
-
function
|
|
1990
|
-
wasm.
|
|
2001
|
+
function __wasm_bindgen_func_elem_3153(arg0, arg1) {
|
|
2002
|
+
wasm.__wasm_bindgen_func_elem_3153(arg0, arg1);
|
|
1991
2003
|
}
|
|
1992
2004
|
|
|
1993
|
-
function
|
|
1994
|
-
wasm.
|
|
2005
|
+
function __wasm_bindgen_func_elem_3259(arg0, arg1, arg2) {
|
|
2006
|
+
wasm.__wasm_bindgen_func_elem_3259(arg0, arg1, addHeapObject(arg2));
|
|
1995
2007
|
}
|
|
1996
2008
|
|
|
1997
2009
|
function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
|
|
@@ -3414,15 +3426,9 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
|
3414
3426
|
return addHeapObject(ret);
|
|
3415
3427
|
};
|
|
3416
3428
|
|
|
3417
|
-
export function __wbindgen_cast_49dae81bf02b4884(arg0, arg1) {
|
|
3418
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 369, function: Function { arguments: [Externref], shim_idx: 380, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3419
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3261, __wasm_bindgen_func_elem_3288);
|
|
3420
|
-
return addHeapObject(ret);
|
|
3421
|
-
};
|
|
3422
|
-
|
|
3423
3429
|
export function __wbindgen_cast_7879599246031d81(arg0, arg1) {
|
|
3424
3430
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 343, function: Function { arguments: [], shim_idx: 344, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3425
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3431
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3149, __wasm_bindgen_func_elem_3153);
|
|
3426
3432
|
return addHeapObject(ret);
|
|
3427
3433
|
};
|
|
3428
3434
|
|
|
@@ -3438,6 +3444,12 @@ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
|
3438
3444
|
return addHeapObject(ret);
|
|
3439
3445
|
};
|
|
3440
3446
|
|
|
3447
|
+
export function __wbindgen_cast_e346b65485039441(arg0, arg1) {
|
|
3448
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [Externref], shim_idx: 366, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3449
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3232, __wasm_bindgen_func_elem_3259);
|
|
3450
|
+
return addHeapObject(ret);
|
|
3451
|
+
};
|
|
3452
|
+
|
|
3441
3453
|
export function __wbindgen_cast_e7b45dd881f38ce3(arg0, arg1) {
|
|
3442
3454
|
// Cast intrinsic for `U128 -> Externref`.
|
|
3443
3455
|
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|
|
Binary file
|