
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@cetusprotocol/dca-sdk
Advanced tools
DCA (Dollar-Cost Averaging) is an efficient and low-risk investment strategy, particularly suitable for markets with high volatility. By using the DCA SDK, developers can easily integrate this strategy into their applications, helping users achieve long-term, stable investment growth. Through automation and regular investments, the DCA SDK helps users reduce the impact of short-term market fluctuations, leading to better investment outcomes.
To start using the Dca SDK, you first need to install it in your TypeScript project:
npm link: https://www.npmjs.com/package/@cetusprotocol/dca-sdk
npm install @cetusprotocol/dca-sdk
Import the SDK into the TypeScript file where you intend to use it:
import { CetusDcaSDK } from '@cetusprotocol/dca-sdk'
Initialize the SDK with the required configuration parameters. This typically includes setting up the network and API keys, if needed.
If you would like to use the mainnet network and the official Sui rpc url, you can do so as follows:
const sdk = CetusDcaSDK.createSDK()
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:
const env = 'mainnet'
const full_rpc_url = 'YOUR_FULL_NODE_URL'
const wallet = 'YOUR_WALLET_ADDRESS'
const sdk = CetusDcaSDK.createSDK({ env })
If you wish to set your own full node URL or SuiClient, you can do so as follows:
const sdk = CetusDcaSDK.createSDK({ env, sui_client })
// or
const sdk = CetusDcaSDK.createSDK({ env, full_rpc_url })
After linking your wallet, you need to set it by sdk.setSenderAddress.
const wallet = 'YOUR_WALLET_ADDRESS'
sdk.setSenderAddress(wallet)
const in_coin_type = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
const out_coin_type = '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC'
const cycle_count = 4
const in_coin_amount = '40000000000'
const cycle_count_amount = new Decimal(in_coin_amount).div(Math.pow(10, 9)).div(cycle_count)
const min_price = 0.83854
const max_price = 2.172898
const per_cycle_max_out_amount = d(cycle_count_amount).div(d(min_price)).mul(Math.pow(10, 6)).toFixed(0).toString()
const per_cycle_min_out_amount = d(cycle_count_amount).div(d(max_price)).mul(Math.pow(10, 6)).toFixed(0).toString()
const payload = await sdk.Dca.dcaOpenOrderPayload({
in_coin_type,
out_coin_type,
in_coin_amount,
cycle_frequency: 600,
cycle_count,
per_cycle_min_out_amount,
per_cycle_max_out_amount,
per_cycle_in_amount_limit: '9744545',
fee_rate: 0,
timestamp: 1723719298,
signature: '004f1929446176bc982043113c7be68d3bf2bdf9bb7f19bcf8cbc4e9d3db8172902a4a60a08405b0acbc5d367b54714...',
})
const send_key_pair = 'THE_KEY_PAIR_GENERATED_BY_YOUR_PRIVATE_KEY'
const result = await sdk.FullClient.sendTransaction(send_key_pair, payload)
const order_id = '0xfba94aa36e93ccc7d84a...'
const dca_order = await sdk.Dca.getDcaOrders(order_id)
const in_coin_type = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
const out_coin_type = '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC'
const order_id = '0xa60c763185a84b87380a0a1e7e677...'
const withdraw_payload = await sdk.Dca.withdrawPayload({
in_coin_type,
out_coin_type,
order_id,
})
const result = await sdk.FullClient.sendTransaction(send_key_pair, withdraw_payload)
const order_id = '0xfc519e9cccf90f4dfdf3008e529...'
const in_coin_type = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
const out_coin_type = '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdc::USDC'
const dca_close_order_payload = await sdk.Dca.dcaCloseOrderPayload([
{
order_id,
in_coin_type,
out_coin_type,
},
])
const result = await sdk.FullClient.sendTransaction(send_key_pair, dca_close_order_payload)
const order_id = '0x45b567654b09d291f3c99566922b7...'
const list = await sdk.Dca.getDcaOrdersMakeDeal(order_id)
whitelist_mode = 0 , Disable whitelist mode. whitelist_mode = 1 , Enable whitelist mode for in_coin only. whitelist_mode = 2 , Enable whitelist mode for out_coin only. whitelist_mode = 3 , Enable whitelist mode for both in_coin and out_coin.
const whitelist_mode = 3
const whiteList = await sdk.Dca.getDcaCoinWhiteList(whitelist_mode)
Use the following links to learn more about Cetus:
Learn more about working with Cetus in the Cetus Documentation.
Join the Cetus community on Cetus Discord.
MIT
FAQs
SDK for cetus dca
We found that @cetusprotocol/dca-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.