npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cetusprotocol/vaults-sdk

v0.0.5

Published

SDK for vaults

Downloads

396

Readme

Vaults Docs

Vaults is a system specifically designed to automatically manage user liquidity. It encompasses the timely reinvestment of fees and rewards, as well as rebalancing when necessary.

Vaults possesses the Farms WrappedPositionNFT. When a user deposits tokens into Vaults, those tokens are utilized to provide liquidity within the positions held by Vaults.

As tokens are added to the respective positions, LP (Liquidity Provider) tokens are minted and allocated to users.

These LP tokens serve as a representation of the individual's share of liquidity within Vaults.

Vault SDK - TS

Github Link: https://github.com/CetusProtocol/cetus-vaults-sdk

NPM Link: @cetusprotocol/vaults-sdk

1. Find all vaults by owner address.

const owner = '0x...'
const vaultsResult = await sdk.Vaults.getOwnerVaultsBalance(owner)

// result
[
    {
        vault_id: '0x5732b81e659bd2db47a5b55755743dde15be99490a39717abc80d62ec812bcb6',
        clmm_pool_id: '0x6c545e78638c8c1db7a48b282bb8ca79da107993fcb185f75cedc1f5adb2f535',
        owner: '0x...',
        lp_token_type: '0xb490d6fa9ead588a9d72da07a02914da42f6b5b1339b8118a90011a42b67a44f::lp_token::LP_TOKEN',
        lp_token_balance: '739242144247',
        liquidity: '799210772591',
        tick_lower_index: 100,
        tick_upper_index: 394,
        amount_a: '5514867803',
        amount_b: '6197505499',
        coin_type_a: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT',
        coin_type_b: '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
    },
    {
        vault_id: '0xff4cc0af0ad9d50d4a3264dfaafd534437d8b66c8ebe9f92b4c39d898d6870a3',
        clmm_pool_id: '0xa528b26eae41bcfca488a9feaa3dca614b2a1d9b9b5c78c256918ced051d4c50',
        owner: '0x...',
        lp_token_type: '0x0c8a5fcbe32b9fc88fe1d758d33dd32586143998f68656f43f3a6ced95ea4dc3::lp_token::LP_TOKEN',
        lp_token_balance: '0',
        liquidity: '0',
        tick_lower_index: 100,
        tick_upper_index: 394,
        amount_a: '0',
        amount_b: '0',
        coin_type_a: '0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI',
        coin_type_b: '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
    },
    {
        vault_id: '0xde97452e63505df696440f86f0b805263d8659b77b8c316739106009d514c270',
        clmm_pool_id: '0x871d8a227114f375170f149f7e9d45be822dd003eba225e83c05ac80828596bc',
        owner: '0x...',
        lp_token_type: '0x828b452d2aa239d48e4120c24f4a59f451b8cd8ac76706129f4ac3bd78ac8809::lp_token::LP_TOKEN',
        lp_token_balance: '892508867879',
        liquidity: '563072189415',
        tick_lower_index: 200,
        tick_upper_index: 488,
        amount_a: '3439040327',
        amount_b: '4659999185',
        coin_type_a: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI',
        coin_type_b: '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'
    }
]

2. Get vault by vault id

const vault = await sdk.Vaults.getVault(vaultId)

3. Get vault asset

const ftAsset = await sdk.getOwnerCoinBalances(sdk.senderAddress, vault?.lp_token_type)

4. Deposit

Deposit Liquidity into vaults,User deposit coinA and coinB into vaults, and the associated LP Token will mint to user.

const params: DepositParams = {
    vault_id: vaultId,
    fix_amount_a: false,
    input_amount: '1000000000',
    slippage: 0.01,
    side: InputType.Both,
}
const paylod = await sdk.Vaults.deposit(params)
const txResult = await sdk.fullClient.devInspectTransactionBlock({
    transactionBlock: paylod,
    sender: sdk.senderAddress,
})

5. Withdraw

const result = await sdk.Vaults.calculateWithdrawAmount({
    vault_id: vaultId,
    fix_amount_a: true,
    input_amount: '1000000000',
    slippage: 0.01,
    is_ft_input: false,
    side: InputType.Both,
    max_ft_amount: '',
})

const paylod = await sdk.Vaults.withdraw({
    vault_id: vaultId,
    slippage: 0.01,
    ft_amount: result.burn_ft_amount,
})
const txResult = await sdk.fullClient.sendTransaction(sendKeypair, paylod)