Cdpm agent sdk
npx -y skills add RandyPen/cdpm --skill cdpm-agent-sdkAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
TypeScript SDK guide for AI agents managing CDPM positions. Defines permission boundaries, operation workflows, automation strategies, and the Scallop and Kai SAV supply/redeem APIs agents share with owners and protocol bots. Use when building automated liquidity management agents.
SKILL.md
4.6 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
CDPM Agent SDK Guide
Overview
This guide is for AI agents authorized to manage CDPM positions on behalf of users. Agents have limited permissions and operate within specific boundaries.
Package Address: 0x573584cc4698e82fd85f2b54e64ad4cd901c42b768f7628ec167bf2d24aa2aa7 (only-dep-upgrades digest: F5kVa3YDSHoBvJvYJFH9y5dANCJScEdyZoxZLLy6qd15 — cdpm.move bytecode is locked; only dependency-version upgrades are allowed). Other shared object IDs live in reference/constants.md.
import { Transaction } from '@mysten/sui/transactions';
import { SuiGrpcClient } from '@mysten/sui/grpc';
Agent Permission Model
What Agents CAN Do
| Operation | Description |
|---|---|
| Add Liquidity | Add liquidity using PositionManager balance |
| Remove Liquidity | Remove liquidity and return to balance |
| Collect Fees | Collect fees from position (goes to fee bag) |
| Collect Rewards | Collect rewards (goes to fee bag) |
| Transfer Fee to Balance | Move fees from fee bag to balance |
Scallop scallop_supply | Park idle balance into Scallop |
Scallop scallop_redeem | Pull underlying back; yield fee deducted from interest portion |
Kai SAV kai_supply | Park idle balance into a Kai Vault<T, YT> |
Kai SAV kai_redeem | Pull underlying back via the strategy walk; same yield fee on interest |
What Agents CANNOT Do
| Operation | Reason |
|---|---|
| Withdraw Funds | Cannot move funds out of PositionManager |
| Close Position | Only owner can close |
| Authorize/Revoke Agents | Only owner can manage agents |
| Modify PositionManager | Cannot change configuration |
Permission Check
function canAgentOperate(
pm: PositionManager,
agentAddress: string
): boolean {
return pm.agents.includes(agentAddress);
}
// Example check
const { response: pm } = await client.getObject({ id: pmId, include: { content: true } });
const agents = pm?.content?.fields?.agents || [];
const isAuthorized = agents.includes(agentAddress);
Topics
Core Operations
- Agent Operations - Add/remove liquidity, collect fees, transfer fees
- Scallop Lending - Agent-driven
scallop_supply/scallop_redeem(onetx.moveCalleach); yield fee sharesfee_house.fee_ratewith Kai - Kai SAV Lending - Agent-driven
kai_supply/kai_redeem(onetx.moveCalleach); yield fee sharesfee_house.fee_ratewith Scallop - Automation Strategies - Auto-compounding, rebalancing, fee collection scheduler
Monitoring & Best Practices
- Event Monitoring - Subscribe to agent events
- Best Practices - Pre-operation checks, batch operations, gas optimization
- Security - Security checklist for agents
Reference
- Error Handling - Common agent errors and recovery strategies
- Constants - Package IDs and default thresholds
Calculations
For liquidity calculations, bin price math, position management, and fee calculations, use the cdpm-calculation skill with the Cetus DLMM SDK:
import { BinUtils, FeeUtils } from '@cetusprotocol/dlmm-sdk/utils'
// Agent-specific calculations
const qPrice = BinUtils.getQPriceFromId(binId, binStep)
const liquidity = BinUtils.getLiquidity(amountA, amountB, qPrice)
const binId = BinUtils.getBinIdFromPrice(price, binStep, true, decimalA, decimalB)
const positionCount = BinUtils.getPositionCount(lowerBinId, upperBinId)
const { amount_a, amount_b } = BinUtils.calculateOutByShare(bin, removeLiquidity)
// Agent strategy helper
function distributeLiquidity(totalA: string, totalB: string, bins: number[], binStep: number) {
return bins.map(binId => {
const qPrice = BinUtils.getQPriceFromId(binId, binStep)
const amountA = (BigInt(totalA) / BigInt(bins.length)).toString()
const amountB = (BigInt(totalB) / BigInt(bins.length)).toString()
return { binId, amountA, amountB, liquidity: BinUtils.getLiquidity(amountA, amountB, qPrice) }
})
}
See cdpm-calculation-skill for the full reference (formulas, redemption sizing, distribution math).
What ships with it: 8 files
49.9 KB alongside SKILL.md
reference/
- agent-operations.md6.1 KB
- automation-strategies.md6.6 KB
- best-practices.md7.9 KB
- constants.md1.6 KB
- error-handling.md4.2 KB
- event-monitoring.md3.5 KB
- kai-lending.md8.7 KB
- scallop-lending.md11.2 KB