@dipcoinlab/perp-ts-library
v0.0.22
Published
Perpetual exchange library housing helper methods, classes to interact with Dipcoin protocol deployed on Sui
Downloads
488
Readme
perp-ts-library
perp-ts-library is a TypeScript library for interacting with DipCoin perpetual contract smart contracts on-chain, providing complete functionality for interacting with the Dipcoin protocol.
🚀 Features
- Complete Protocol Integration: Full support for all DipCoin perpetual trading operations
- Type Safety: Built with TypeScript for enhanced developer experience
- Modular Design: Clean separation of concerns with dedicated modules
- Comprehensive Documentation: Detailed guides and examples for all use cases
- Auto Split Coin: Automatic coin splitting functionality for seamless deposits
🛠 Core Components
TransactionBuilder
Class to transactions with the DipCoin protocol.
New Auto Split Features:
bank_depositWithAutoSplitTx()- Automatic coin splitting for depositsbank_batchDepositWithAutoSplitTx()- Batch deposits with auto splitting- No need for external signer or manual splitCoin operations
OrderSigner
Handles order signing and verification for secure trading operations.
Market Operations
- Order placement and management
- Position tracking and management
- Liquidation handling
- Funding rate operations
💡 Auto Split Coin Feature
The library now includes automatic coin splitting functionality that eliminates the need for manual splitCoin operations:
Traditional Method (Before)
// 1. Manual split coin operation
const splitTx = await splitCoin(client, signer, coinType, amount);
const coinId = TransactionParse.getCreatedObjectIDs(splitTx)[0];
// 2. Deposit with split coin
const depositTx = await txBuilder.bank_depositTx({
coinID: coinId,
amount: amount,
accountAddress: userAddress
});Auto Split Method (Now)
// Single step - automatic coin splitting and deposit
const depositTx = await txBuilder.bank_depositWithAutoSplitTx({
amount: amount,
accountAddress: userAddress
});Benefits
- Simplified API: No need for external signer in deposit operations
- Reduced Complexity: Single transaction instead of multiple steps
- Better UX: Streamlined deposit process for end users
- Batch Support: Automatic splitting for batch deposits
🧪 Development and Examples
Prerequisites
- Node.js (v16 or higher)
- Yarn package manager
- Access to DipCoin protocol contracts
Installation
yarn installBuilding the Project
yarn buildDocumentation and Examples
Frontend and backend users can refer to the following documentation and examples:
- Examples - Complete usage examples
- Auto Split Deposit Example - New automatic coin splitting feature
- Onboarding and 1CT - Getting started guide
- Deposit and Withdrawal - Account management
- Signature Mechanism - Security and signing
- TypeScript SDK - SDK reference
📖 Generating API Reference
This project uses JSDoc format for comments and automatically generates documentation using TypeDoc.
npx typedoc src/The generated documentation will be saved in the docs/api/ directory.
