跳到正文
cccskills
免费在 GitHub 公开

starknet-defi

Execute token swaps, recurring purchases, and STRK staking on Starknet. Use avnu to obtain swap quotes, check prices and rewards, and pay transaction fees in a supported token through its paymaster service.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Execute DeFi operations on Starknet including token swaps via avnu aggregator, DCA recurring buys, STRK staking, and lending/borrowing. Supports gasless transactions.

实测评分 未实测

查看安装方法

适用场景

  • Swap tokens on Starknet
  • Set up recurring STRK purchases
  • Check staking rewards and restake them
  • Pay swap fees in USDC

包含的文件(3)

  • SKILL.md9.2 KB
  • agents/openai.yaml312 B
  • LICENSE1.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

  1. Install the AVNU + starknet.js dependencies and point the skill at a funded Starknet account.
  2. 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: DcaOrderStatus.OPEN,  // Use enum, not string
});

// Cancel an order
await executeCancelDca({
  provider: account,
  orderAddress: orders[0].orderAddress,
});

STRK Staking

Stake STRK

import { executeStake, getAvnuStakingInfo } from "@avnu/avnu-sdk";

// Get pool info
const stakingInfo = await getAvnuStakingInfo();
// stakingInfo.pools[0] = { address, apy, tvl, token, minStake }

const result = await executeStake({
  provider: account,
  poolAddress: stakingInfo.pools[0].address,
  amount: parseUnits("100", 18), // 100 STRK
});

Get User Staking Info

import { getUserStakingInfo } from "@avnu/avnu-sdk";

const userInfo = await getUserStakingInfo(TOKENS.STRK, account.address);
console.log("Staked:", userInfo.amount);
console.log("Unclaimed rewards:", userInfo.unclaimedRewards);

Claim Rewards

import { executeClaimRewards } from "@avnu/avnu-sdk";

// Claim and restake (compound)
await executeClaimRewards({
  provider: account,
  poolAddress: poolAddress,
  restake: true,
});

Unstake

import { executeInitiateUnstake, executeUnstake } from "@avnu/avnu-sdk";

// Step 1: Initiate (starts cooldown -- 21 days for STRK)
await executeInitiateUnstake({
  provider: account,
  poolAddress: poolAddress,
  amount: parseUnits("50", 18),
});

// Step 2: Complete unstake (after cooldown period)
await executeUnstake({
  provider: account,
  poolAddress: poolAddress,
});

Market Data

Token Prices

import { getPrices, fetchTokens, fetchVerifiedTokenBySymbol } from "@avnu/avnu-sdk";

// Get token by symbol
const strk = await fetchVerifiedTokenBySymbol("STRK");

// Get prices for multiple tokens
const prices = await getPrices([ethAddress, strkAddress, usdcAddress]);
// prices = { "0x049d...": 3200.50, "0x047...": 1.23, ... }

// Browse tokens with pagination
const tokens = await fetchTokens({ page: 0, size: 20, tags: ["verified"] });

Protocol Reference

ProtocolOperationsNotes
avnuSwap aggregation, DCA, gaslessBest-price routing across all DEXs
EkuboAMM, concentrated liquidityHighest TVL on Starknet
JediSwapAMM, classic poolsV2 with concentrated liquidity
zkLendLending, borrowingVariable and stable rates
NostraLending, borrowingMulti-asset pools

Configuration

VariablePurposeDefault
STARKNET_RPC_URLStarknet JSON-RPC endpointRequired
STARKNET_ACCOUNT_ADDRESSAgent's account addressRequired
STARKNET_PRIVATE_KEYAgent's signing keyRequired
AVNU_BASE_URLavnu API base URLhttps://starknet.api.avnu.fi
AVNU_PAYMASTER_URLavnu paymaster URLhttps://starknet.paymaster.avnu.fi
AVNU_API_KEYOptional avnu integrator keyNone

avnu URL Reference

NetworkAPI URLPaymaster URL
Mainnethttps://starknet.api.avnu.fihttps://starknet.paymaster.avnu.fi
Sepoliahttps://sepolia.api.avnu.fihttps://sepolia.paymaster.avnu.fi

Error Handling

async function safeSwap(account, quote, slippage = 0.01) {
  try {
    return await executeSwap({
      provider: account,
      quote,
      slippage,
      executeApprove: true,
    });
  } catch (error) {
    if (error.message?.includes("INSUFFICIENT_BALANCE")) {
      throw new Error("Not enough tokens for swap");
    }
    if (error.message?.includes("SLIPPAGE") || error.message?.includes("Insufficient tokens received")) {
      // Retry with higher slippage
      return await executeSwap({
        provider: account,
        quote,
        slippage: slippage * 2,
        executeApprove: true,
      });
    }
    if (error.message?.includes("QUOTE_EXPIRED")) {
      throw new Error("Quote expired. Please retry the operation.");
    }
    if (error.message?.includes("INSUFFICIENT_LIQUIDITY")) {
      throw new Error("Insufficient liquidity. Try a smaller amount.");
    }
    throw error;
  }
}

References

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Build chat, image generation, and speech transcription features on 0G Compute Network, a distributed GPU marketplace. This skill guides SDK integration, model fine-tuning, response processing for billing, and account funding through code patterns and CLI commands.

中文简介正在准备中。当前显示英语简介。

  • Integrating chat and image generation into an application
  • Preparing model fine-tuning jobs
  • Checking balances and funding provider accounts
internet-court/internet-court-skill69872026年8月20日 更新

Build servers and clients for A2A, an open protocol that lets AI agents communicate across frameworks. Publish agent capabilities, exchange tasks and results, stream progress, and add notifications for workflows involving multiple agents.

中文简介正在准备中。当前显示英语简介。

  • Connect agents built with different frameworks
  • Publish agent capabilities through an Agent Card
  • Build a research, writing, and review workflow
internet-court/internet-court-skill69872026年8月20日 更新

Give an AI agent a wallet with administrator-defined transaction limits. The skill covers encrypted key storage, balance checks, and sending funds through code-enforced rules for destinations, amounts, transaction frequency, and emergency shutdown.

中文简介正在准备中。当前显示英语简介。

  • Give an agent a wallet with transaction limits
  • Restrict transfers to approved chains and addresses
  • Check balances and active rules before sending
internet-court/internet-court-skill69872026年8月20日 更新

Manage a crypto wallet with the awal CLI, including sign-in, balance checks, transfers, swaps, and funding. Also find and pay for APIs through x402, a payment protocol, set up paid endpoints, and query blockchain data on Base.

中文简介正在准备中。当前显示英语简介。

  • Check wallet balances across supported networks
  • Send tokens to an address or ENS name
  • Swap tokens or add wallet funds
internet-court/internet-court-skill69872026年8月20日 更新

Write TypeScript, Rust, or Python code for Alkahest escrow contracts, which hold assets until conditions are met. Covers creating escrows, submitting fulfillment, collecting payments, and building custom contracts that decide whether requirements have been satisfied.

中文简介正在准备中。当前显示英语简介。

  • Integrate Alkahest escrow into an application
  • Build a bot that creates escrows and submits fulfillment
  • Implement payment collection and fulfillment monitoring
internet-court/internet-court-skill69872026年8月20日 更新

Use the Alkahest CLI to manage escrow, where assets are held until agreed conditions are met. It covers buyer deposits, seller fulfillment and collection, third-party decisions, token swaps, and reclaiming expired, unfulfilled deposits.

中文简介正在准备中。当前显示英语简介。

  • Creating escrow with release conditions
  • Submitting work and collecting escrowed assets
  • Approving or rejecting fulfillment as an oracle
internet-court/internet-court-skill69872026年8月20日 更新

查看 internet-court 的全部技能

报告此技能的问题