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