TypeScript SDK for Powfi on Alephium. This package provides high-level modules for CPMM, CLMM, staking, and token operations, and re-exports generated contract artifacts/deployments.
Powfientrypoint for network/provider/signer configurationpowfi.cpmmfor constant-product liquidity poolspowfi.clmmfor concentrated-liquidity poolspowfi.stakingfor xALPH staking flowspowfi.tokenfor token metadata helpers- Re-exported contract types and deployment loaders from
clmm,cpmm, andstaking
For SDK consumers:
npm install @alephium/powfi-sdkFor development:
bun installimport { Powfi, CpmmModule } from '@alephium/powfi-sdk'
const powfi = Powfi.load({ networkId: 'testnet' })
const poolState = await powfi.cpmm.getPoolState(tokenAId, tokenBId)
const quote = CpmmModule.computeSwapAmount({
state: poolState,
tokenInId: tokenAId,
tokenOutId: tokenBId,
amountIn: 1_000_000n,
slippageBps: 50n
})CLMM simulation example:
const simulation = await powfi.clmm.simulateSwap({
configIndex: 0n,
token0,
token1,
zeroForOne: true,
amount: 1_000_000n
})For write operations (swap, add/remove liquidity, staking), pass a signer when loading the SDK:
const powfi = Powfi.load({ networkId: 'testnet', signer })The SDK is organized around a central Powfi class that initializes all modules:
const powfi = Powfi.load({ networkId: 'mainnet', signer })
powfi.cpmm // CpmmModule — constant-product AMM operations
powfi.clmm // ClmmModule — concentrated liquidity operations
powfi.staking // StakingModule — xALPH staking lifecycle
powfi.token // TokenModule — token metadata from token listEach module extends ModuleBase, which provides access to the parent Powfi instance (node provider, signer, network config) and structured logging.
Dependency flow (no circular dependencies):
index.ts → Powfi → CpmmModule, ClmmModule, StakingModule, TokenModule
│ │ │
└────────────┴──────────────┘
│
common/ (math, numeric, error, utils)
bun run build
bun run test
bun run typecheck
bun run lint
bun run format:checkIntegration tests expect a local Alephium devnet at 127.0.0.1:22973:
docker compose -f docker/docker-compose.yml up -dclmm/, cpmm/ and staking/ hold the generated contract bindings (artifacts/) and deployment metadata (deployments/) for the Powfi contracts. They are committed here and bundled into the published SDK.
After the contracts change, maintainers with access to the contracts repository refresh them from its compiled packages:
CONTRACTS_DIR=<path-to-contracts-repo>/packages bun run copy-artifacts