avnu-labs/avnu-skill
Overview
This skill integrates the avnu SDK to add Starknet-native DeFi features: best-price token swaps, DCA recurring buys, native staking, gasless/paymaster-backed transactions, and market data. It exposes patterns for backend scripts and frontend wallet flows, helping teams build trading, DEX aggregation, and automation features quickly. The SDK is TypeScript-first and designed for Starknet accounts and paymaster workflows.
How this skill works
The SDK queries multiple on-chain liquidity sources to compute optimized swap quotes and routes, then returns executable call sets or optionally executes transactions via a connected Starknet account. It supports building and estimating calls for paymaster gas payment modes (user-paid token fees or sponsored gas), creating and managing periodic DCA orders, staking flows (stake/unstake/claim), and fetching token lists and price data. Typical usage alternates between getQuote/quoteToCalls/executeSwap and high-level helpers for DCA and staking.
When to use it
- Building a Starknet DEX aggregator or swap widget that needs best-price routing.
- Adding DCA recurring buys to let users dollar-cost-average into positions.
- Implementing gasless or sponsored transactions using paymaster flows.
- Adding native staking UX for STRK and supported pools.
- Integrating real-time token lists and price feeds for market interfaces.
Best practices
- Use a server-side account or protected API routes for any flow requiring secrets or paymaster API keys; never expose backend keys client-side.
- Always refresh quotes immediately before final execution; quotes expire quickly (≈30s) and price impact can change.
- Estimate paymaster fees when using token-paid gas to avoid paymaster rejections and to set accurate max fee values.
- Set slippage thresholds by token liquidity: stablecoins 0.1–0.5%, majors 0.5–1%, low-liquidity up to 3%.
- Build calls with quoteToCalls for custom execution, auditing, or bundling with other on-chain actions.
Example use cases
- A frontend swap widget that shows top 3 optimized quotes and executes the best route with wallet approval.
- Backend service that builds sponsored (gasfree) transactions and exposes signed payloads to clients for frictionless UX.
- Automated trading bot that creates and monitors DCA orders and cancels or adjusts orders programmatically.
- Staking dashboard that displays pool APY, user positions, and enables stake/claim/unstake flows.
- Payment-fee support where users pay gas in USDC using the paymaster RPC with preflight fee estimation.
FAQ
Yes. The SDK requires a Starknet account for executing transactions. Use a direct account for backend scripts or a wallet-connected account (Argent, Braavos) for frontend flows.
When should I use paymaster vs sponsored gas?
Use paymaster token-paid (gasless) when users should pay fees in ERC-20 tokens. Use sponsored (gasfree) when the dApp will pay gas for zero-friction UX; the latter requires a backend-held API key and careful server-side handling.