starknet-defi
What it does
This skill guides DeFi actions on the Starknet blockchain, such as swapping tokens and setting up recurring buys. It is for developers and agent builders who want their agent to trade or earn yield on Starknet.
When to use it
- ✓When you want an agent to swap one token for another on Starknet at the best available route.
- ✓When you need a recurring buy, staking, or a lending and borrowing flow on Starknet.
- ✓When you want gasless transactions through a paymaster for an agent workflow.
Skill link
https://github.com/internet-court/internet-court-skill/blob/main/vendored/starknet/starknet-defi/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you swap 50 USDC for ETH on Starknet at the best available price and show me the quote first?”
5 new skills a week. 1 minute to read.
How it works
The agent installs the avnu and starknet.js libraries, connects to a funded Starknet account, and asks the avnu aggregator for quotes. It then executes the chosen swap or DeFi action on that account.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Starknet DeFi Skill
Execute DeFi operations on Starknet using avnu aggregator and native protocols.
When to Use
- Swaps, DCA orders, staking, and lending or borrowing flows on Starknet.
- Agent workflows that need AVNU routing, paymaster support, or protocol-specific DeFi execution.
When NOT to Use
- Plain wallet management without DeFi intent.
- Cairo contract authoring, deployment operations, or security auditing.
Quick Start
- Install the AVNU + starknet.js dependencies and point the skill at a funded Starknet account.
- Use skills catalog when the flow expands into wallet setup, deployment, or auditing.
Prerequisites
npm install starknet@^8.9.1 @avnu/avnu-sdk@^4.0.1
Token Swaps (avnu SDK v4)
Get Quote and Execute Swap
import { getQuotes, executeSwap, type QuoteRequest } from "@avnu/avnu-sdk";
import { Account, RpcProvider, ETransactionVersion } from "starknet";
const provider = new RpcProvider({ nodeUrl: process.env.STARKNET_RPC_URL });
// starknet.js v8: Account uses options object
const account = new Account({
provider,
address,
signer: privateKey,
transactionVersion: ETransactionVersion.V3,
});
// Resolve token addresses via avnu SDK (or use MCP server's TokenService)
import { fetchVerifiedTokenBySymbol } from '@avnu/avnu-sdk';
const eth = await fetchVerifiedTokenBySymbol('ETH');
const strk = await fetchVerifiedTokenBySymbol('STRK');
// SDK v4: getQuotes takes QuoteRequest object directly
const quoteParams: QuoteRequest = {
sellTokenAddress: eth.address,
buyTokenAddress: strk.address,
sellAmount: BigInt(10 ** 17), // 0.1 ETH
takerAddress: account.address,
};
const quotes = await getQuotes(quoteParams);
const bestQuote = quotes[0];
// SDK v4: executeSwap takes single object param
const result = await executeSwap({
provider: account,
quote: bestQuote,
slippage: 0.01, // 1%
executeApprove: true,
});
console.log("Tx:", result.transactionHash);
Quote Response Fields (SDK v4)
interface Quote {
quoteId: string;
sellTokenAddress: string;
buyTokenAddress: string;
sellAmount: bigint;
buyAmount: bigint;
sellAmountInUsd: number;
buyAmountInUsd: number;
priceImpact: number; // In basis points (15 = 0.15%)
gasFeesInUsd: number;
routes: Array<{
name: string; // e.g., "Ekubo", "JediSwap"
percent: number; // e.g., 0.8 = 80%
}>;
fee: {
avnuFees: bigint;
integratorFees: bigint;
};
}
Build Swap Calls (for multicall composition)
import { quoteToCalls } from "@avnu/avnu-sdk";
const calls = await quoteToCalls({
quote: bestQuote,
takerAddress: account.address,
slippage: 0.01,
includeApprove: true,
});
// `calls` can be combined with other calls in account.execute([...calls, ...otherCalls])
Gasless Swap (Pay Gas in Token) - SDK v4 + PaymasterRpc
import { getQuotes, executeSwap } from "@avnu/avnu-sdk";
import { PaymasterRpc } from "starknet";
const quotes = await getQuotes(quoteParams);
const bestQuote = quotes[0];
// SDK v4: Use PaymasterRpc from starknet.js
// Mainnet: https://starknet.paymaster.avnu.fi
// Sepolia: https://sepolia.paymaster.avnu.fi
const paymaster = new PaymasterRpc({
nodeUrl: process.env.AVNU_PAYMASTER_URL || "https://starknet.paymaster.avnu.fi",
});
const result = await executeSwap({
provider: account,
quote: bestQuote,
slippage: 0.01,
executeApprove: true,
paymaster: {
active: true,
provider: paymaster,
params: {
feeMode: {
mode: "default",
gasToken: "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8", // USDC
},
},
},
});
DCA (Dollar Cost Averaging)
Create DCA Order
import { executeCreateDca } from "@avnu/avnu-sdk";
import moment from "moment";
const dcaOrder = {
sellTokenAddress: usdcAddress,
buyTokenAddress: strkAddress,
totalAmount: parseUnits("100", 6), // Total 100 USDC
numberOfOrders: 10, // Split into 10 orders
frequency: moment.duration(1, "day"), // moment.Duration object, not string
startAt: Math.floor(Date.now() / 1000),
};
const result = await executeCreateDca({
provider: account,
order: dcaOrder,
});
Check and Cancel DCA
import { getDcaOrders, executeCancelDca, DcaOrderStatus } from "@avnu/avnu-sdk";
const orders = await getDcaOrders({
traderAddress: account.address,
status: D
FAQ
Does it help with Cairo contract writing?
No. Cairo contract authoring, deployment, and security audits are outside this skill.
Can transactions be gasless?
Yes. The skill mentions paymaster support for gasless transactions.
Does it need an account first?
Yes. It needs a funded Starknet account, which the agent connects to.
Details
Original description by the author
Execute DeFi operations on Starknet including token swaps via avnu aggregator, DCA recurring buys, STRK staking, and lending/borrowing. Supports gasless transactions.
Popularity
- GitHub stars
- 7.0k
- Ranking position
- #13685
- License
- —
- Updated
- 10/26/2026
Comments
- …
More skills from this repository
internet-court
7.0kHelps your agent pay, hire, or deal safely with another AI agent or paid service, and points it to the right specialized guide.
genlayer-erc7710-connector
7.0kHelps your agent connect an AI review result to a permission system, so a bad review can limit or cancel an agent's permissions.
genlayer-intelligent-contracts
7.0kHelps your agent define the rules, evidence and outputs of an AI judge that checks whether another agent followed its mandate.
x402-erc7710
7.0kHelps your agent pay for web services one request at a time, and set up ongoing spending that stays within a permission budget.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.