@magmaprotocol/magma-clmm-sdk 0.5.44 → 0.5.47
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/index.d.ts +207 -206
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -804,7 +804,7 @@ type CalculateRatesResult = {
|
|
|
804
804
|
/**
|
|
805
805
|
* Represents parameters for a swap operation.
|
|
806
806
|
*/
|
|
807
|
-
type SwapParams
|
|
807
|
+
type SwapParams = {
|
|
808
808
|
/**
|
|
809
809
|
* The identifier of the pool.
|
|
810
810
|
*/
|
|
@@ -1632,6 +1632,199 @@ type GetRewardByPosition = {
|
|
|
1632
1632
|
coinTypeB: string;
|
|
1633
1633
|
};
|
|
1634
1634
|
|
|
1635
|
+
type FetchPairParams = {
|
|
1636
|
+
pair: string;
|
|
1637
|
+
coinTypeA: string;
|
|
1638
|
+
coinTypeB: string;
|
|
1639
|
+
};
|
|
1640
|
+
type CreatePairParams = {
|
|
1641
|
+
bin_step: number;
|
|
1642
|
+
base_fee: number;
|
|
1643
|
+
coinTypeA: string;
|
|
1644
|
+
coinTypeB: string;
|
|
1645
|
+
coinADecimal: number;
|
|
1646
|
+
coinBDecimal: number;
|
|
1647
|
+
priceTokenBPerTokenA: string;
|
|
1648
|
+
};
|
|
1649
|
+
type MintPercentParams = {
|
|
1650
|
+
pair: string;
|
|
1651
|
+
coinTypeA: string;
|
|
1652
|
+
coinTypeB: string;
|
|
1653
|
+
amountATotal: number;
|
|
1654
|
+
amountBTotal: number;
|
|
1655
|
+
storageIds: number[];
|
|
1656
|
+
binsAPercent: number[];
|
|
1657
|
+
binsBPercent: number[];
|
|
1658
|
+
to: string;
|
|
1659
|
+
};
|
|
1660
|
+
type MintAmountParams = {
|
|
1661
|
+
pair: string;
|
|
1662
|
+
coinTypeA: string;
|
|
1663
|
+
coinTypeB: string;
|
|
1664
|
+
amountATotal: number;
|
|
1665
|
+
amountBTotal: number;
|
|
1666
|
+
storageIds: number[];
|
|
1667
|
+
amountsA: number[];
|
|
1668
|
+
amountsB: number[];
|
|
1669
|
+
to: string;
|
|
1670
|
+
};
|
|
1671
|
+
type DLMMSwapParams = {
|
|
1672
|
+
pair: string;
|
|
1673
|
+
coinTypeA: string;
|
|
1674
|
+
coinTypeB: string;
|
|
1675
|
+
amountIn: number;
|
|
1676
|
+
minAmountOut: number;
|
|
1677
|
+
swapForY: boolean;
|
|
1678
|
+
to: string;
|
|
1679
|
+
};
|
|
1680
|
+
type FetchBinsParams = {
|
|
1681
|
+
pair: string;
|
|
1682
|
+
coinTypeA: string;
|
|
1683
|
+
coinTypeB: string;
|
|
1684
|
+
offset: number;
|
|
1685
|
+
limit: number;
|
|
1686
|
+
};
|
|
1687
|
+
type GetPositionLiquidityParams = {
|
|
1688
|
+
pair: string;
|
|
1689
|
+
positionId: string;
|
|
1690
|
+
coinTypeA: string;
|
|
1691
|
+
coinTypeB: string;
|
|
1692
|
+
};
|
|
1693
|
+
type GetPairLiquidityParams = {
|
|
1694
|
+
pair: string;
|
|
1695
|
+
coinTypeA: string;
|
|
1696
|
+
coinTypeB: string;
|
|
1697
|
+
};
|
|
1698
|
+
type EventPairParams = {
|
|
1699
|
+
base_factor: number;
|
|
1700
|
+
filter_period: number;
|
|
1701
|
+
decay_period: number;
|
|
1702
|
+
reduction_factor: number;
|
|
1703
|
+
variable_fee_control: number;
|
|
1704
|
+
protocol_share: number;
|
|
1705
|
+
max_volatility_accumulator: number;
|
|
1706
|
+
volatility_accumulator: number;
|
|
1707
|
+
volatility_reference: number;
|
|
1708
|
+
index_reference: number;
|
|
1709
|
+
time_of_last_update: number | string;
|
|
1710
|
+
oracle_index: number;
|
|
1711
|
+
active_index: number;
|
|
1712
|
+
};
|
|
1713
|
+
type EventBin = {
|
|
1714
|
+
storage_id: number | string;
|
|
1715
|
+
price_q128: number | string;
|
|
1716
|
+
reserve_x: number | string;
|
|
1717
|
+
reserve_y: number | string;
|
|
1718
|
+
staked_liquidity: number | string;
|
|
1719
|
+
staked_lp_amount: number | string;
|
|
1720
|
+
fee_x: number | string;
|
|
1721
|
+
fee_y: number | string;
|
|
1722
|
+
fee_growth_x: number | string;
|
|
1723
|
+
fee_growth_y: number | string;
|
|
1724
|
+
rewarder_growth: number[] | string[];
|
|
1725
|
+
distribution_growth: number | string;
|
|
1726
|
+
distribution_last_updated: number | string;
|
|
1727
|
+
};
|
|
1728
|
+
type EventPositionLiquidity = {
|
|
1729
|
+
shares: number | string;
|
|
1730
|
+
liquidity: number | string;
|
|
1731
|
+
x_equivalent: number | string;
|
|
1732
|
+
y_equivalent: number | string;
|
|
1733
|
+
bin_ids: number[] | string[];
|
|
1734
|
+
bin_x_eq: number[] | string[];
|
|
1735
|
+
bin_y_eq: number[] | string[];
|
|
1736
|
+
bin_liquidity: number[] | string[];
|
|
1737
|
+
};
|
|
1738
|
+
type EventPairLiquidity = {
|
|
1739
|
+
shares: number | string;
|
|
1740
|
+
liquidity: number | string;
|
|
1741
|
+
x: number | string;
|
|
1742
|
+
y: number | string;
|
|
1743
|
+
bin_ids: number[] | string[];
|
|
1744
|
+
bin_x: number[] | string[];
|
|
1745
|
+
bin_y: number[] | string[];
|
|
1746
|
+
};
|
|
1747
|
+
type DlmmPoolInfo = {
|
|
1748
|
+
pool_id: string;
|
|
1749
|
+
bin_step: number;
|
|
1750
|
+
coin_a: string;
|
|
1751
|
+
coin_b: string;
|
|
1752
|
+
base_factor: number;
|
|
1753
|
+
base_fee: number;
|
|
1754
|
+
active_index: number;
|
|
1755
|
+
};
|
|
1756
|
+
type DlmmAddLiquidityParams = {
|
|
1757
|
+
pool_id: string;
|
|
1758
|
+
coin_a: string;
|
|
1759
|
+
coin_b: string;
|
|
1760
|
+
position_id: string;
|
|
1761
|
+
amounts_a: number[];
|
|
1762
|
+
amounts_b: number[];
|
|
1763
|
+
receiver: string;
|
|
1764
|
+
rewards_token: string[];
|
|
1765
|
+
};
|
|
1766
|
+
type DlmmBurnPositionParams = {
|
|
1767
|
+
pool_id: string;
|
|
1768
|
+
position_id: string;
|
|
1769
|
+
coin_a: string;
|
|
1770
|
+
coin_b: string;
|
|
1771
|
+
rewards_token: string[];
|
|
1772
|
+
};
|
|
1773
|
+
type DlmmShrinkPosition = {
|
|
1774
|
+
pool_id: string;
|
|
1775
|
+
position_id: string;
|
|
1776
|
+
coin_a: string;
|
|
1777
|
+
coin_b: string;
|
|
1778
|
+
delta_percentage: number;
|
|
1779
|
+
rewards_token: string[];
|
|
1780
|
+
};
|
|
1781
|
+
type DlmmCollectRewardParams = {
|
|
1782
|
+
pool_id: string;
|
|
1783
|
+
coin_a: string;
|
|
1784
|
+
coin_b: string;
|
|
1785
|
+
position_id: string;
|
|
1786
|
+
rewards_token: string[];
|
|
1787
|
+
};
|
|
1788
|
+
type DlmmCollectFeeParams = {
|
|
1789
|
+
pool_id: string;
|
|
1790
|
+
coin_a: string;
|
|
1791
|
+
coin_b: string;
|
|
1792
|
+
position_id: string;
|
|
1793
|
+
};
|
|
1794
|
+
type DlmmRewardsParams = {
|
|
1795
|
+
pool_id: string;
|
|
1796
|
+
position_id: string;
|
|
1797
|
+
coin_a: string;
|
|
1798
|
+
coin_b: string;
|
|
1799
|
+
rewards_token: string[];
|
|
1800
|
+
};
|
|
1801
|
+
type DlmmEventEarnedFees = {
|
|
1802
|
+
position_id: string;
|
|
1803
|
+
x: string;
|
|
1804
|
+
y: string;
|
|
1805
|
+
fee_x: number;
|
|
1806
|
+
fee_y: number;
|
|
1807
|
+
};
|
|
1808
|
+
type DlmmEventEarnedRewards = {
|
|
1809
|
+
position_id: string;
|
|
1810
|
+
reward: string[];
|
|
1811
|
+
amount: number[];
|
|
1812
|
+
};
|
|
1813
|
+
type GetPairRewarderParams = {
|
|
1814
|
+
pool_id: string;
|
|
1815
|
+
coin_a: string;
|
|
1816
|
+
coin_b: string;
|
|
1817
|
+
};
|
|
1818
|
+
type DlmmEventPairRewardTypes = {
|
|
1819
|
+
pair_id: string;
|
|
1820
|
+
tokens: string[];
|
|
1821
|
+
};
|
|
1822
|
+
type BinDisplay = {
|
|
1823
|
+
binId: number;
|
|
1824
|
+
amountX: BN;
|
|
1825
|
+
amountY: BN;
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1635
1828
|
type BigNumber = Decimal.Value | number | string;
|
|
1636
1829
|
|
|
1637
1830
|
interface IModule {
|
|
@@ -2212,11 +2405,7 @@ declare function autoFillXByStrategy(activeId: number, binStep: number, amountY:
|
|
|
2212
2405
|
* @param clock The clock info. Get from DLMM instance.
|
|
2213
2406
|
* @returns The distribution of liquidity.
|
|
2214
2407
|
*/
|
|
2215
|
-
declare function toAmountsBothSideByStrategy(activeId: number, binStep: number, minBinId: number, maxBinId: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, strategyType: StrategyType):
|
|
2216
|
-
binId: number;
|
|
2217
|
-
amountX: BN;
|
|
2218
|
-
amountY: BN;
|
|
2219
|
-
}[];
|
|
2408
|
+
declare function toAmountsBothSideByStrategy(activeId: number, binStep: number, minBinId: number, maxBinId: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, strategyType: StrategyType): BinDisplay[];
|
|
2220
2409
|
|
|
2221
2410
|
declare function getPriceOfBinByBinId(binId: number, binStep: number): Decimal;
|
|
2222
2411
|
declare function autoFillYByWeight(activeId: number, binStep: number, amountX: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, distributions: {
|
|
@@ -3122,7 +3311,7 @@ declare class SwapModule implements IModule {
|
|
|
3122
3311
|
* If this parameter is not passed, gas estimation is not performed
|
|
3123
3312
|
* @returns
|
|
3124
3313
|
*/
|
|
3125
|
-
createSwapTransactionPayload(params: SwapParams
|
|
3314
|
+
createSwapTransactionPayload(params: SwapParams, gasEstimateArg?: {
|
|
3126
3315
|
byAmountIn: boolean;
|
|
3127
3316
|
slippage: Percentage;
|
|
3128
3317
|
decimalsA: number;
|
|
@@ -3137,7 +3326,7 @@ declare class SwapModule implements IModule {
|
|
|
3137
3326
|
* If this parameter is not passed, gas estimation is not performed
|
|
3138
3327
|
* @returns tx and coin ABs
|
|
3139
3328
|
*/
|
|
3140
|
-
createSwapTransactionWithoutTransferCoinsPayload(params: SwapParams
|
|
3329
|
+
createSwapTransactionWithoutTransferCoinsPayload(params: SwapParams, gasEstimateArg?: {
|
|
3141
3330
|
byAmountIn: boolean;
|
|
3142
3331
|
slippage: Percentage;
|
|
3143
3332
|
decimalsA: number;
|
|
@@ -3500,193 +3689,6 @@ declare class GaugeModule implements IModule {
|
|
|
3500
3689
|
getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
|
|
3501
3690
|
}
|
|
3502
3691
|
|
|
3503
|
-
type FetchPairParams = {
|
|
3504
|
-
pair: string;
|
|
3505
|
-
coinTypeA: string;
|
|
3506
|
-
coinTypeB: string;
|
|
3507
|
-
};
|
|
3508
|
-
type CreatePairParams = {
|
|
3509
|
-
bin_step: number;
|
|
3510
|
-
coinTypeA: string;
|
|
3511
|
-
coinTypeB: string;
|
|
3512
|
-
coinADecimal: number;
|
|
3513
|
-
coinBDecimal: number;
|
|
3514
|
-
priceTokenBPerTokenA: string;
|
|
3515
|
-
};
|
|
3516
|
-
type MintPercentParams = {
|
|
3517
|
-
pair: string;
|
|
3518
|
-
coinTypeA: string;
|
|
3519
|
-
coinTypeB: string;
|
|
3520
|
-
amountATotal: number;
|
|
3521
|
-
amountBTotal: number;
|
|
3522
|
-
storageIds: number[];
|
|
3523
|
-
binsAPercent: number[];
|
|
3524
|
-
binsBPercent: number[];
|
|
3525
|
-
to: string;
|
|
3526
|
-
};
|
|
3527
|
-
type MintAmountParams = {
|
|
3528
|
-
pair: string;
|
|
3529
|
-
coinTypeA: string;
|
|
3530
|
-
coinTypeB: string;
|
|
3531
|
-
amountATotal: number;
|
|
3532
|
-
amountBTotal: number;
|
|
3533
|
-
storageIds: number[];
|
|
3534
|
-
amountsA: number[];
|
|
3535
|
-
amountsB: number[];
|
|
3536
|
-
to: string;
|
|
3537
|
-
};
|
|
3538
|
-
type SwapParams = {
|
|
3539
|
-
pair: string;
|
|
3540
|
-
coinTypeA: string;
|
|
3541
|
-
coinTypeB: string;
|
|
3542
|
-
amountIn: number;
|
|
3543
|
-
minAmountOut: number;
|
|
3544
|
-
swapForY: boolean;
|
|
3545
|
-
to: string;
|
|
3546
|
-
};
|
|
3547
|
-
type FetchBinsParams = {
|
|
3548
|
-
pair: string;
|
|
3549
|
-
coinTypeA: string;
|
|
3550
|
-
coinTypeB: string;
|
|
3551
|
-
offset: number;
|
|
3552
|
-
limit: number;
|
|
3553
|
-
};
|
|
3554
|
-
type GetPositionLiquidityParams = {
|
|
3555
|
-
pair: string;
|
|
3556
|
-
positionId: string;
|
|
3557
|
-
coinTypeA: string;
|
|
3558
|
-
coinTypeB: string;
|
|
3559
|
-
};
|
|
3560
|
-
type GetPairLiquidityParams = {
|
|
3561
|
-
pair: string;
|
|
3562
|
-
coinTypeA: string;
|
|
3563
|
-
coinTypeB: string;
|
|
3564
|
-
};
|
|
3565
|
-
type EventPairParams = {
|
|
3566
|
-
base_factor: number;
|
|
3567
|
-
filter_period: number;
|
|
3568
|
-
decay_period: number;
|
|
3569
|
-
reduction_factor: number;
|
|
3570
|
-
variable_fee_control: number;
|
|
3571
|
-
protocol_share: number;
|
|
3572
|
-
max_volatility_accumulator: number;
|
|
3573
|
-
volatility_accumulator: number;
|
|
3574
|
-
volatility_reference: number;
|
|
3575
|
-
index_reference: number;
|
|
3576
|
-
time_of_last_update: number | string;
|
|
3577
|
-
oracle_index: number;
|
|
3578
|
-
active_index: number;
|
|
3579
|
-
};
|
|
3580
|
-
type EventBin = {
|
|
3581
|
-
storage_id: number | string;
|
|
3582
|
-
price_q128: number | string;
|
|
3583
|
-
reserve_x: number | string;
|
|
3584
|
-
reserve_y: number | string;
|
|
3585
|
-
staked_liquidity: number | string;
|
|
3586
|
-
staked_lp_amount: number | string;
|
|
3587
|
-
fee_x: number | string;
|
|
3588
|
-
fee_y: number | string;
|
|
3589
|
-
fee_growth_x: number | string;
|
|
3590
|
-
fee_growth_y: number | string;
|
|
3591
|
-
rewarder_growth: number[] | string[];
|
|
3592
|
-
distribution_growth: number | string;
|
|
3593
|
-
distribution_last_updated: number | string;
|
|
3594
|
-
};
|
|
3595
|
-
type EventPositionLiquidity = {
|
|
3596
|
-
shares: number | string;
|
|
3597
|
-
liquidity: number | string;
|
|
3598
|
-
x_equivalent: number | string;
|
|
3599
|
-
y_equivalent: number | string;
|
|
3600
|
-
bin_ids: number[] | string[];
|
|
3601
|
-
bin_x_eq: number[] | string[];
|
|
3602
|
-
bin_y_eq: number[] | string[];
|
|
3603
|
-
bin_liquidity: number[] | string[];
|
|
3604
|
-
};
|
|
3605
|
-
type EventPairLiquidity = {
|
|
3606
|
-
shares: number | string;
|
|
3607
|
-
liquidity: number | string;
|
|
3608
|
-
x: number | string;
|
|
3609
|
-
y: number | string;
|
|
3610
|
-
bin_ids: number[] | string[];
|
|
3611
|
-
bin_x: number[] | string[];
|
|
3612
|
-
bin_y: number[] | string[];
|
|
3613
|
-
};
|
|
3614
|
-
type DlmmPoolInfo = {
|
|
3615
|
-
pool_id: string;
|
|
3616
|
-
bin_step: number;
|
|
3617
|
-
coin_a: string;
|
|
3618
|
-
coin_b: string;
|
|
3619
|
-
base_factor: number;
|
|
3620
|
-
base_fee: number;
|
|
3621
|
-
active_index: number;
|
|
3622
|
-
};
|
|
3623
|
-
type DlmmAddLiquidityParams = {
|
|
3624
|
-
pool_id: string;
|
|
3625
|
-
coin_a: string;
|
|
3626
|
-
coin_b: string;
|
|
3627
|
-
position_id: string;
|
|
3628
|
-
amounts_a: number[];
|
|
3629
|
-
amounts_b: number[];
|
|
3630
|
-
receiver: string;
|
|
3631
|
-
rewards_token: string[];
|
|
3632
|
-
};
|
|
3633
|
-
type DlmmBurnPositionParams = {
|
|
3634
|
-
pool_id: string;
|
|
3635
|
-
position_id: string;
|
|
3636
|
-
coin_a: string;
|
|
3637
|
-
coin_b: string;
|
|
3638
|
-
rewards_token: string[];
|
|
3639
|
-
};
|
|
3640
|
-
type DlmmShrinkPosition = {
|
|
3641
|
-
pool_id: string;
|
|
3642
|
-
position_id: string;
|
|
3643
|
-
coin_a: string;
|
|
3644
|
-
coin_b: string;
|
|
3645
|
-
delta_percentage: number;
|
|
3646
|
-
rewards_token: string[];
|
|
3647
|
-
};
|
|
3648
|
-
type DlmmCollectRewardParams = {
|
|
3649
|
-
pool_id: string;
|
|
3650
|
-
coin_a: string;
|
|
3651
|
-
coin_b: string;
|
|
3652
|
-
position_id: string;
|
|
3653
|
-
rewards_token: string[];
|
|
3654
|
-
};
|
|
3655
|
-
type DlmmCollectFeeParams = {
|
|
3656
|
-
pool_id: string;
|
|
3657
|
-
coin_a: string;
|
|
3658
|
-
coin_b: string;
|
|
3659
|
-
position_id: string;
|
|
3660
|
-
};
|
|
3661
|
-
type DlmmRewardsParams = {
|
|
3662
|
-
pool_id: string;
|
|
3663
|
-
position_id: string;
|
|
3664
|
-
coin_a: string;
|
|
3665
|
-
coin_b: string;
|
|
3666
|
-
rewards_token: string[];
|
|
3667
|
-
};
|
|
3668
|
-
type DlmmEventEarnedFees = {
|
|
3669
|
-
position_id: string;
|
|
3670
|
-
x: string;
|
|
3671
|
-
y: string;
|
|
3672
|
-
fee_x: number;
|
|
3673
|
-
fee_y: number;
|
|
3674
|
-
};
|
|
3675
|
-
type DlmmEventEarnedRewards = {
|
|
3676
|
-
position_id: string;
|
|
3677
|
-
reward: string[];
|
|
3678
|
-
amount: number[];
|
|
3679
|
-
};
|
|
3680
|
-
type GetPairRewarderParams = {
|
|
3681
|
-
pool_id: string;
|
|
3682
|
-
coin_a: string;
|
|
3683
|
-
coin_b: string;
|
|
3684
|
-
};
|
|
3685
|
-
type DlmmEventPairRewardTypes = {
|
|
3686
|
-
pair_id: string;
|
|
3687
|
-
tokens: string[];
|
|
3688
|
-
};
|
|
3689
|
-
|
|
3690
3692
|
declare class DlmmModule implements IModule {
|
|
3691
3693
|
protected _sdk: MagmaClmmSDK;
|
|
3692
3694
|
constructor(sdk: MagmaClmmSDK);
|
|
@@ -3695,7 +3697,6 @@ declare class DlmmModule implements IModule {
|
|
|
3695
3697
|
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3696
3698
|
price_to_storage_id(price: string, bin_step: number, tokenADecimal: number, tokenBDecimal: number): number;
|
|
3697
3699
|
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
3698
|
-
createAddLiquidityPayload(): Promise<Transaction>;
|
|
3699
3700
|
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3700
3701
|
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3701
3702
|
addLiquidity(params: DlmmAddLiquidityParams): Promise<Transaction>;
|
|
@@ -3705,7 +3706,7 @@ declare class DlmmModule implements IModule {
|
|
|
3705
3706
|
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3706
3707
|
collectReward(params: DlmmCollectRewardParams): Promise<Transaction>;
|
|
3707
3708
|
collectFees(params: DlmmCollectFeeParams): Promise<Transaction>;
|
|
3708
|
-
swap(params:
|
|
3709
|
+
swap(params: DLMMSwapParams): Promise<Transaction>;
|
|
3709
3710
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3710
3711
|
getPositionLiquidity(params: GetPositionLiquidityParams): Promise<EventPositionLiquidity>;
|
|
3711
3712
|
getPairLiquidity(params: GetPairLiquidityParams): Promise<EventPairLiquidity>;
|
|
@@ -4182,7 +4183,7 @@ declare class TransactionUtil {
|
|
|
4182
4183
|
* @param curSqrtPrice
|
|
4183
4184
|
* @returns
|
|
4184
4185
|
*/
|
|
4185
|
-
static buildSwapTransactionForGas(sdk: MagmaClmmSDK, params: SwapParams
|
|
4186
|
+
static buildSwapTransactionForGas(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
4186
4187
|
byAmountIn: boolean;
|
|
4187
4188
|
slippage: Percentage;
|
|
4188
4189
|
decimalsA: number;
|
|
@@ -4196,7 +4197,7 @@ declare class TransactionUtil {
|
|
|
4196
4197
|
* @param packageId
|
|
4197
4198
|
* @returns
|
|
4198
4199
|
*/
|
|
4199
|
-
static buildSwapTransaction(sdk: MagmaClmmSDK, params: SwapParams
|
|
4200
|
+
static buildSwapTransaction(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
4200
4201
|
static buildCreateLockTransaction(sdk: MagmaClmmSDK, params: CreateLockParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
4201
4202
|
static buildCreateTransactionArgs(tx: Transaction, params: CreateLockParams, sdkOptions: SdkOptions, lockCoinInput: BuildCoinResult): Transaction;
|
|
4202
4203
|
static buildIncreaseLockAmountTransaction(sdk: MagmaClmmSDK, params: IncreaseLockAmountParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
@@ -4220,7 +4221,7 @@ declare class TransactionUtil {
|
|
|
4220
4221
|
* @param packageId
|
|
4221
4222
|
* @returns
|
|
4222
4223
|
*/
|
|
4223
|
-
static buildSwapTransactionArgs(tx: Transaction, params: SwapParams
|
|
4224
|
+
static buildSwapTransactionArgs(tx: Transaction, params: SwapParams, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): Transaction;
|
|
4224
4225
|
/**
|
|
4225
4226
|
* build add liquidity transaction with out transfer coins
|
|
4226
4227
|
* @param params
|
|
@@ -4228,7 +4229,7 @@ declare class TransactionUtil {
|
|
|
4228
4229
|
* @param curSqrtPrice
|
|
4229
4230
|
* @returns
|
|
4230
4231
|
*/
|
|
4231
|
-
static buildSwapTransactionWithoutTransferCoinsForGas(sdk: MagmaClmmSDK, params: SwapParams
|
|
4232
|
+
static buildSwapTransactionWithoutTransferCoinsForGas(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
4232
4233
|
byAmountIn: boolean;
|
|
4233
4234
|
slippage: Percentage;
|
|
4234
4235
|
decimalsA: number;
|
|
@@ -4245,7 +4246,7 @@ declare class TransactionUtil {
|
|
|
4245
4246
|
* @param packageId
|
|
4246
4247
|
* @returns
|
|
4247
4248
|
*/
|
|
4248
|
-
static buildSwapTransactionWithoutTransferCoins(sdk: MagmaClmmSDK, params: SwapParams
|
|
4249
|
+
static buildSwapTransactionWithoutTransferCoins(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[]): {
|
|
4249
4250
|
tx: Transaction;
|
|
4250
4251
|
coinABs: TransactionObjectArgument[];
|
|
4251
4252
|
};
|
|
@@ -4255,18 +4256,18 @@ declare class TransactionUtil {
|
|
|
4255
4256
|
* @param packageId
|
|
4256
4257
|
* @returns
|
|
4257
4258
|
*/
|
|
4258
|
-
static buildSwapTransactionWithoutTransferCoinArgs(sdk: MagmaClmmSDK, tx: Transaction, params: SwapParams
|
|
4259
|
+
static buildSwapTransactionWithoutTransferCoinArgs(sdk: MagmaClmmSDK, tx: Transaction, params: SwapParams, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): {
|
|
4259
4260
|
tx: Transaction;
|
|
4260
4261
|
txRes: TransactionObjectArgument[];
|
|
4261
4262
|
};
|
|
4262
|
-
static fixSwapParams(sdk: MagmaClmmSDK, params: SwapParams
|
|
4263
|
+
static fixSwapParams(sdk: MagmaClmmSDK, params: SwapParams, gasEstimateArg: {
|
|
4263
4264
|
byAmountIn: boolean;
|
|
4264
4265
|
slippage: Percentage;
|
|
4265
4266
|
decimalsA: number;
|
|
4266
4267
|
decimalsB: number;
|
|
4267
4268
|
swapTicks: Array<TickData>;
|
|
4268
4269
|
currentPool: Pool;
|
|
4269
|
-
}): Promise<SwapParams
|
|
4270
|
+
}): Promise<SwapParams>;
|
|
4270
4271
|
static syncBuildCoinInputForAmount(sdk: MagmaClmmSDK, tx: Transaction, amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): Promise<TransactionObjectArgument | undefined>;
|
|
4271
4272
|
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
4272
4273
|
private static buildVectorCoin;
|
|
@@ -4446,4 +4447,4 @@ interface InitMagmaSDKOptions {
|
|
|
4446
4447
|
*/
|
|
4447
4448
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4448
4449
|
|
|
4449
|
-
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, BinLiquidity, BinMath, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmConfig, DlmmScript, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityAndCoinYResult, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_NO_LIQUIDITY, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, StrategyType, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams
|
|
4450
|
+
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, BinDisplay, BinLiquidity, BinMath, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePairParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DLMMSwapParams, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmAddLiquidityParams, DlmmBurnPositionParams, DlmmCollectFeeParams, DlmmCollectRewardParams, DlmmConfig, DlmmEventEarnedFees, DlmmEventEarnedRewards, DlmmEventPairRewardTypes, DlmmPoolInfo, DlmmRewardsParams, DlmmScript, DlmmShrinkPosition, EpochEmission, EventBin, EventPairLiquidity, EventPairParams, EventPositionLiquidity, FEE_RATE_DENOMINATOR, FaucetCoin, FetchBinsParams, FetchPairParams, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetPairLiquidityParams, GetPairRewarderParams, GetPositionLiquidityParams, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityAndCoinYResult, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, MintAmountParams, MintPercentParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_NO_LIQUIDITY, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, StrategyType, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, WithdrawPosition, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getCoinXYForLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityAndCoinYByCoinX, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getPriceOfBinByBinId, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16, withLiquiditySlippage };
|
package/dist/index.js
CHANGED
|
@@ -1821,7 +1821,7 @@ var import_decimal6 = __toESM(require("decimal.js"));
|
|
|
1821
1821
|
var import_calc_dlmm = require("@magmaprotocol/calc_dlmm");
|
|
1822
1822
|
function getPriceOfBinByBinId(binId, binStep) {
|
|
1823
1823
|
const twoDec = new import_decimal6.default(2);
|
|
1824
|
-
const price = new import_decimal6.default((0, import_calc_dlmm.
|
|
1824
|
+
const price = new import_decimal6.default((0, import_calc_dlmm.get_price_x128_from_real_id)(binId, binStep));
|
|
1825
1825
|
return price.div(twoDec.pow(128));
|
|
1826
1826
|
}
|
|
1827
1827
|
function autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
@@ -2813,7 +2813,7 @@ var import_calc_dlmm2 = require("@magmaprotocol/calc_dlmm");
|
|
|
2813
2813
|
var BinMath = class {
|
|
2814
2814
|
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2815
2815
|
const twoDec = new import_decimal9.default(2);
|
|
2816
|
-
const price = new import_decimal9.default((0, import_calc_dlmm2.
|
|
2816
|
+
const price = new import_decimal9.default((0, import_calc_dlmm2.get_price_x128_from_real_id)(binId, binStep));
|
|
2817
2817
|
return price.div(twoDec.pow(128)).mul(import_decimal9.default.pow(10, decimalsA - decimalsB));
|
|
2818
2818
|
}
|
|
2819
2819
|
};
|
|
@@ -10795,7 +10795,7 @@ var DlmmModule = class {
|
|
|
10795
10795
|
const tenDec = new import_decimal13.default(10);
|
|
10796
10796
|
const twoDec = new import_decimal13.default(2);
|
|
10797
10797
|
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10798
|
-
const active_id = (0, import_calc_dlmm3.
|
|
10798
|
+
const active_id = (0, import_calc_dlmm3.get_real_id_from_price_x128)(price_x128.toFixed(0).toString(), bin_step);
|
|
10799
10799
|
return (0, import_calc_dlmm3.get_storage_id_from_real_id)(active_id);
|
|
10800
10800
|
}
|
|
10801
10801
|
// NOTE: x, y should be sorted
|
|
@@ -10807,7 +10807,13 @@ var DlmmModule = class {
|
|
|
10807
10807
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10808
10808
|
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10809
10809
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10810
|
-
const args = [
|
|
10810
|
+
const args = [
|
|
10811
|
+
tx.object(dlmmConfig.factory),
|
|
10812
|
+
tx.object(global_config_id),
|
|
10813
|
+
tx.pure.u64(params.base_fee),
|
|
10814
|
+
tx.pure.u16(params.bin_step),
|
|
10815
|
+
tx.pure.u32(storage_id)
|
|
10816
|
+
];
|
|
10811
10817
|
tx.moveCall({
|
|
10812
10818
|
target: `${integrate.published_at}::${DlmmScript}::create_pair`,
|
|
10813
10819
|
typeArguments,
|
|
@@ -10815,10 +10821,6 @@ var DlmmModule = class {
|
|
|
10815
10821
|
});
|
|
10816
10822
|
return tx;
|
|
10817
10823
|
}
|
|
10818
|
-
async createAddLiquidityPayload() {
|
|
10819
|
-
const tx = new import_transactions12.Transaction();
|
|
10820
|
-
return tx;
|
|
10821
|
-
}
|
|
10822
10824
|
// Create a position by percent
|
|
10823
10825
|
async mintPercent(params) {
|
|
10824
10826
|
const tx = new import_transactions12.Transaction();
|