@cetusprotocol/sui-clmm-sdk 1.0.0

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.
Files changed (64) hide show
  1. package/.turbo/turbo-build.log +11100 -0
  2. package/README.md +108 -0
  3. package/dist/index.d.mts +2251 -0
  4. package/dist/index.d.ts +2251 -0
  5. package/dist/index.js +13 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +13 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/docs/add_liquidity.md +145 -0
  10. package/docs/close_position.md +57 -0
  11. package/docs/collect_fees.md +37 -0
  12. package/docs/create_clmm_pool.md +228 -0
  13. package/docs/error_code.md +69 -0
  14. package/docs/get_clmm_pools.md +92 -0
  15. package/docs/get_positions.md +70 -0
  16. package/docs/get_reward.md +53 -0
  17. package/docs/get_ticks.md +39 -0
  18. package/docs/migrate_to_version_6.0.md +143 -0
  19. package/docs/open_position.md +224 -0
  20. package/docs/partner_swap.md +60 -0
  21. package/docs/pre_swap.md +136 -0
  22. package/docs/remove_liquidity.md +124 -0
  23. package/docs/swap.md +153 -0
  24. package/docs/utils.md +85 -0
  25. package/package.json +37 -0
  26. package/src/config/index.ts +2 -0
  27. package/src/config/mainnet.ts +41 -0
  28. package/src/config/testnet.ts +40 -0
  29. package/src/errors/errors.ts +93 -0
  30. package/src/errors/index.ts +1 -0
  31. package/src/index.ts +10 -0
  32. package/src/math/apr.ts +167 -0
  33. package/src/math/index.ts +1 -0
  34. package/src/modules/configModule.ts +540 -0
  35. package/src/modules/index.ts +5 -0
  36. package/src/modules/poolModule.ts +1066 -0
  37. package/src/modules/positionModule.ts +932 -0
  38. package/src/modules/rewarderModule.ts +430 -0
  39. package/src/modules/swapModule.ts +389 -0
  40. package/src/sdk.ts +131 -0
  41. package/src/types/clmm_type.ts +1002 -0
  42. package/src/types/clmmpool.ts +366 -0
  43. package/src/types/config_type.ts +241 -0
  44. package/src/types/index.ts +8 -0
  45. package/src/types/sui.ts +124 -0
  46. package/src/types/token_type.ts +189 -0
  47. package/src/utils/common.ts +426 -0
  48. package/src/utils/index.ts +3 -0
  49. package/src/utils/positionUtils.ts +434 -0
  50. package/src/utils/swapUtils.ts +499 -0
  51. package/tests/add_liquidity.test.ts +121 -0
  52. package/tests/add_liquidity_fix_token.test.ts +182 -0
  53. package/tests/apr.test.ts +71 -0
  54. package/tests/cetus_config.test.ts +26 -0
  55. package/tests/collect_fees.test.ts +11 -0
  56. package/tests/pool.test.ts +267 -0
  57. package/tests/position.test.ts +145 -0
  58. package/tests/remove_liquidity.test.ts +119 -0
  59. package/tests/rewarder.test.ts +60 -0
  60. package/tests/sdk_config.test.ts +49 -0
  61. package/tests/swap.test.ts +254 -0
  62. package/tests/tsconfig.json +26 -0
  63. package/tsconfig.json +5 -0
  64. package/tsup.config.ts +10 -0
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ <a name="readme-top"></a>
2
+
3
+ ![NPM](https://img.shields.io/npm/l/%40cetusprotocol%2Fcetus-sui-clmm-sdk?registry_uri=https%3A%2F%2Fregistry.npmjs.com&style=flat&logo=npm&logoColor=blue&label=%40cetusprotocol&labelColor=rgb&color=fedcba&cacheSeconds=3600&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40cetusprotocol%2Fcetus-sui-clmm-sdk)
4
+ ![npm](https://img.shields.io/npm/v/%40cetusprotocol%2Fcetus-sui-clmm-sdk?logo=npm&logoColor=rgb)
5
+ ![GitHub Repo stars](https://img.shields.io/github/stars/CetusProtocol/cetus-clmm-sui-sdk?logo=github)
6
+
7
+ <!-- PROJECT LOGO -->
8
+ <br />
9
+ <div align="center">
10
+ <a >
11
+ <img src="https://archive.cetus.zone/assets/image/logo.png" alt="Logo" width="100" height="100">
12
+ </a>
13
+
14
+ <h3 align="center">Cetus-CLMM-SUI-SDK</h3>
15
+
16
+ <p align="center">
17
+ Integrating Cetus-CLMM-SUI-SDK: A Comprehensive Guide, Please see details in document.
18
+ <br />
19
+ <a href="https://cetus-1.gitbook.io/cetus-developer-docs/developer/dev-overview"><strong>Explore the document »</strong></a>
20
+ <br />
21
+ <br />
22
+ </p>
23
+ </div>
24
+
25
+ ## Introduction
26
+
27
+ Cetus-CLMM-SUI-SDK is the official software development kit (SDK) specifically designed for seamless integration with Cetus-CLMM. It provides developers with the necessary tools and resources to easily connect and interact with Cetus-CLMM, enabling the development of robust and efficient applications.
28
+
29
+ ## Getting Started
30
+
31
+ To integrate our SDK into your local project, please follow the example steps provided below.
32
+ Please see details in document.
33
+
34
+ ### Prerequisites
35
+
36
+ ```sh
37
+ npm i @cetusprotocol/sui-clmm-sdk
38
+ ```
39
+
40
+ ## SDK Initialization
41
+
42
+ The SDK provides a convenient initialization method `src/config/initCetusSDK` for quick setup and configuration of the Cetus SDK.
43
+
44
+ ### Network Options
45
+
46
+ - `mainnet` (Production Network)
47
+ - `testnet` (Test Network)
48
+
49
+ ### Important Note
50
+
51
+ Before performing swaps or other asset-related operations, ensure:
52
+
53
+ - A wallet is properly configured
54
+ - The wallet has sufficient token balance for the intended operation
55
+
56
+ ```typescript
57
+ import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk'
58
+ ```
59
+
60
+ If you would like to use the mainnet network and the official Sui rpc url, you can do so as follows:
61
+
62
+ ```typescript
63
+ const sdk = CetusClmmSDK.createSDK()
64
+ ```
65
+
66
+ If you wish to set your own full node URL or network (You have the option to select either 'mainnet' or 'testnet' for the network), you can do so as follows:
67
+
68
+ ```typescript
69
+ const env = 'mainnet'
70
+ const full_rpc_url = 'YOUR_FULL_NODE_URL'
71
+ const wallet = 'YOUR_WALLET_ADDRESS'
72
+
73
+ const sdk = CetusClmmSDK.createSDK({ env })
74
+ ```
75
+
76
+ If you wish to set your own full node URL or SuiClient, you can do so as follows:
77
+
78
+ ```typescript
79
+ const sdk = CetusClmmSDK.createSDK({ env, sui_client })
80
+ //or
81
+ const sdk = CetusClmmSDK.createSDK({ env, full_rpc_url })
82
+ ```
83
+
84
+ **After linking your wallet, if you need use your wallet address to do something, you should set it by `CetusClmmSDK.setSenderAddress("YOUR_SUI_ADDRESS_HERE")`**
85
+
86
+ ```typescript
87
+ const wallet = 'YOUR_WALLET_ADDRESS'
88
+ sdk.setSenderAddress(wallet)
89
+ ```
90
+
91
+ Now, you can start using Cetus SDK.
92
+
93
+ ### Typescript Doc
94
+
95
+ You can view this typescript sdk in
96
+ <a href="https://cetus-1.gitbook.io/cetus-developer-docs/developer/dev-overview"><strong> Cetus Development Documents. </strong></a>
97
+ <br />
98
+
99
+ ## LICENSE
100
+
101
+ CETUS-SUI-SDK released under the Apache license. See the [LICENSE](./LICENSE) file for details.
102
+
103
+ ## More About Cetus
104
+
105
+ Use the following links to learn more about Cetus:
106
+ Learn more about working with Cetus in the [Cetus Documentation](https://cetus-1.gitbook.io/cetus-docs).
107
+
108
+ Join the Cetus community on [Cetus Discord](https://discord.com/channels/1009749448022315008/1009751382783447072).