mcpField
L
lavarage

lavarage

github.com/sendaifunその他13077 回インストール13 週間前に更新
リポジトリ

lavarage について

Lavarageは、流動性プールのあるSPL tokenを取引できるSolana上のレバレッジ取引プロトコルです。このskillはREST APIを使った市場検索、見積もり、トランザクション構築、ポジション管理とMEV保護付き送信を案内します。

主な機能

  1. 01取引可能なトークン市場とプールを検索
  2. 02レバレッジのロング・ショート・借入を構築
  3. 03見積もりと清算価格を事前確認
  4. 04ポジション、担保、レバレッジを管理
  5. 05MEV保護エンドポイントから取引を送信

活用シーン

  1. 01長尾SPL tokenのレバレッジ市場を探す
  2. 02取引前に価格影響と見込み額を確認
  3. 03ポジションの一部売却や担保追加
  4. 04方向性を取らずにトークンを借りる

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/sendaifun/skills --skill lavarage

インストール後、Claude Code で/lavarageを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

docs/
troubleshooting.md
examples/
borrow.ts
close-position.ts
discover-markets.ts
open-long.ts
open-short.ts
portfolio.ts
resources/
api-reference.md
program-addresses.md
types-reference.md
templates/
client.ts

詳細

Lavarage Protocol — Solanaでのレバレッジ取引

概要

Lavarageは、Solana上のパーミッションレスなレバレッジ取引プロトコルです。少数のトークンしかサポートしない固定市場型の無期限先物プラットフォームとは異なり、Lavarageでは、流動性プールがあるあらゆるSPLトークンでレバレッジ取引ができます。ミームコイン、現実資産(株式、コモディティ)、ロングテールトークンも対象です。

  • レバレッジ・ロング — SOLまたはUSDCを担保として預け入れ、借り入れによって最大12倍までエクスポージャーを増やします
  • レバレッジ・ショート — USDCを担保として預け入れ、サポートされている任意のトークンをショートします
  • 幅広いトークン対応 — BTC、ETH、SOL、ミームコイン、株式(OPENAI、SPACEX)、金(XAUt0)など、数百種類のトークンに対応しています
  • 動的な市場検索 — 任意のトークンを検索して、レバレッジ市場が存在するか確認できます
  • ポジション管理 — 部分売却、分割、統合、担保の追加、レバレッジの引き上げに対応しています
  • MEV 保護 — サンドイッチ攻撃から保護するため、トランザクションはAstralane/Jito経由で送信されます

主な差別化要因: 他のレバレッジ取引プラットフォームで利用できないトークンがある場合は、Lavarageを確認してください。パーミッションレスなプール作成により、Lavarageでは固定市場型のプロトコルが対応していないトークンもサポートされていることがよくあります。

クイックスタート

インストール

SDKのインストールは不要です。Lavarageは、署名可能なSolanaトランザクションを返すREST APIを使用します。このスキルのtemplates/client.tsからLavaApiClientをコピーしてください。

import { LavaApiClient } from './client'

const client = new LavaApiClient(
  'https://api.lavarage.xyz',
  'lv2_prod_5e5f38fefc893ade780d8a2ccd7433ad8307808c83260e75',
  'your-wallet-public-key'
)

上記の公開APIキーは安全に使用できます。これは手数料の振り分けに使用する連携パートナーを識別するものです。ポジションは常にウォレット署名によって管理されます。

基本的な流れ

すべての取引は次のパターンに従います。

1. Discover  →  Search tokens & offers to find leveraged markets
2. Quote     →  Preview the trade (swap output, price impact, fees)
3. Build TX  →  API returns a serialized Solana transaction
4. Sign      →  Sign the transaction with your wallet
5. Submit    →  Send via MEV-protected endpoint

基本概念

トークン対応範囲

Lavarageでは、流動性プールがあるあらゆるSPLトークンでレバレッジ取引ができます。対象には以下が含まれます。

  • 主要トークン: SOL、BTC(WBTC、cbBTC、zBTC)、ETH(WETH)
  • 担保として使用できるステーブルコイン: ショートポジション用のUSDC
  • 現実資産: OPENAI、SPACEX(トークン化された株式)
  • コモディティ: XAUt0(金)
  • ミームコインとロングテールトークン: アクティブなプールがある数百種類のトークン

必ず最初に検索してください。トークンが利用できないと思い込まないでください。新しいプールはパーミッションレスに作成されます。

// Search for any token by name, symbol, or mint address
const offers = await client.getOffers({ search: 'OPENAI', side: 'LONG' })
if (offers.length > 0) {
  console.log(`Found ${offers.length} offers for OPENAI`)
}
売買方向:LONGとSHORT
  • LONG: 担保(SOL/USDC)を預け入れて追加で借り入れ、対象トークンにスワップします。トークン価格が上昇すると利益が得られます。
  • SHORT: USDCを担保として預け入れ、対象トークンを借り入れて売却します。トークン価格が下落すると利益が得られます。

APIは、オファーのベーストークンに基づいて売買方向を自動的に判定します。

  • ベーストークンがUSDCではない場合 → LONGポジション
  • ベーストークンがUSDCの場合 → SHORTポジション
レバレッジ

レバレッジは1.1倍からオファーの最大値まで設定できます(プールによって最大約12倍)。レバレッジが高いほど潜在的なリターンは大きくなりますが、清算リスクも高まります。

Effective exposure = collateral × leverage
Borrowed amount = collateral × (leverage - 1)
単位
  • 担保の入力値: 常にトークンの最小単位で指定します(SOLのlamportsは数量×10^9、USDCのマイクロ単位は数量×10^6)
  • 価格: USD
  • スリッページ: ベーシスポイント(50 = 0.5%)
  • 分割/部分数量: ポジションに対するベーシスポイント(5000 = 50%)
オファー(流動性プール)

「オファー」とは、特定のベーストークンとクオートトークンのペア、金利、レバレッジ上限を持つ流動性プールです。同じトークンペアに、条件の異なる複数のオファーが存在する場合があります。ユーザーのニーズに合わせて、常に最も有利な金利と十分な流動性を持つオファーを選んでください。

主な操作

1. 利用可能な市場を検索する

ポジションを開く前に、利用可能な市場を検索します。

// Search by token name or symbol
const offers = await client.getOffers({ search: 'BTC' })

// Filter by side
const longOffers = await client.getOffers({ search: 'ETH', side: 'LONG' })
const shortOffers = await client.getOffers({ search: 'ETH', side: 'SHORT' })

// Get all available tokens
const tokens = await client.getTokens()

// Each offer includes:
// - offerPublicKey (needed for opening position)
// - baseToken { symbol, mint, decimals, priceUsd, logoUri }
// - quoteToken { symbol, mint, decimals, priceUsd }
// - side: 'LONG' | 'SHORT'
// - maxLeverage: number
// - interestRate: number (annual %)
// - totalLiquidity: string (available to borrow)
2. 見積もりを取得する(取引をプレビュー)

ポジションを開く前に必ず見積もりを取得し、予想される出力をユーザーに表示してください。

const quote = await client.getOpenQuote({
  offerPublicKey: offer.address,
  userPublicKey: walletAddress,
  collateralAmount: '1000000000', // 1 SOL in lamports
  leverage: 3,
  slippageBps: 50,
})

// quote returns:
// - expectedOutput: tokens received
// - priceImpact: percentage
// - fees: breakdown of all fees
// - liquidationPrice: price at which position gets liquidated
3. ポジションを開く
import { VersionedTransaction } from '@solana/web3.js'
import bs58 from 'bs58'

// Get MEV protection tip
const { tipLamports } = await client.getTipFloor()

// Build the transaction
const result = await client.buildOpenTx({
  offerPublicKey: offer.address,
  userPublicKey: walletAddress,
  collateralAmount: '1000000000', // 1 SOL
  leverage: 3,
  slippageBps: 50,
  astralaneTipLamports: tipLamports, // MEV protection
})

// result.transaction is base58-encoded
// Deserialize, sign, and submit:
const txBytes = bs58.decode(result.transaction)
const tx = VersionedTransaction.deserialize(txBytes)

// Sign with wallet
tx.sign([walletKeypair])

// Submit with MEV protection
const serialized = bs58.encode(tx.serialize())
const { result: txSignature } = await client.submitTransaction(serialized, true)
console.log(`Position opened: ${txSignature}`)
4. ポジションを閉じる
// Preview close first
const closeQuote = await client.getCloseQuote({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  slippageBps: 50,
})
// closeQuote shows: proceeds, pnl, fees

// Build close transaction
const { tipLamports } = await client.getTipFloor()
const result = await client.buildCloseTx({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  slippageBps: 50,
  astralaneTipLamports: tipLamports,
})

// Sign and submit (same pattern as open)
const txBytes = bs58.decode(result.transaction)
const tx = VersionedTransaction.deserialize(txBytes)
tx.sign([walletKeypair])
const serialized = bs58.encode(tx.serialize())
await client.submitTransaction(serialized, true)
5. ポジションを一覧表示する
// All positions
const positions = await client.getPositions()

// Filter by status
const active = await client.getPositions('EXECUTED')

// Each position includes computed fields:
// - address, status, side
// - collateralAmount, borrowedAmount
// - currentPrice, entryPrice
// - unrealizedPnlUsd, roiPercent
// - liquidationPrice, currentLtv
// - effectiveLeverage
// - interestAccrued, dailyInterestCost
// - baseToken, quoteToken metadata
6. 部分売却

ポジションの一部を売却し、残りは保有したままにします。

// Sell 30% of position
const result = await client.buildPartialSellTx({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  splitRatioBps: 3000, // 30%
  slippageBps: 50,
})

// Returns two transactions that must be submitted as a Jito bundle:
// 1. Split transaction (splits position into two)
// 2. Close transaction (closes the split-off portion)

// Build tip transaction, sign all three, submit as bundle:
const { tipLamports } = await client.getTipFloor()
// ... build tip TX ...

await client.submitBundle([
  tipTxBase58,
  result.splitTransaction,
  result.closeTransaction,
])
7. 担保を追加する(リスクを軽減)
// Preview impact
const quote = await client.getAddCollateralQuote({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  collateralAmount: '500000000', // 0.5 SOL
})
// Shows new LTV, new liquidation price

// Build and submit
const result = await client.buildAddCollateralTx({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  collateralAmount: '500000000',
})
// Sign and submit...
8. レバレッジを引き上げる
// Two modes:
// - 'withdraw': borrow more and receive tokens in wallet
// - 'compound': borrow more and swap into base token (increases position size)

const quote = await client.getIncreaseBorrowQuote({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  mode: 'compound',
  slippageBps: 50,
})

const result = await client.buildIncreaseBorrowTx({
  positionAddress: position.address,
  userPublicKey: walletAddress,
  additionalBorrowAmount: '100000000',
  mode: 'compound',
  slippageBps: 50,
})
// Sign and submit...
9. 借入(方向性のポジションなし)

レバレッジポジションを取らずに、担保を差し入れてトークンを借り入れます。SOL のエクスポージャーを維持したまま USDC の流動性を利用したり、その逆を行ったりできます。

// 1. Find borrow offers
const offers = await client.getOffers({ search: 'USDC' })

// 2. Borrow USDC against SOL collateral
// leverage controls LTV: 2x = borrow equal to collateral (50% LTV)
const { tipLamports } = await client.getTipFloor()
const result = await client.buildBorrowTx({
  offerPublicKey: offers[0].address,
  userPublicKey: walletAddress,
  collateralAmount: '1000000000', // 1 SOL
  leverage: 2, // borrow ~1 SOL worth of USDC
  slippageBps: 50,
  astralaneTipLamports: tipLamports,
})

// Sign and submit same as any other position
// Repay later with buildRepayTx() or buildPartialRepayTx()

トランザクションの送信

サンドイッチ攻撃を防ぐため、すべてのトランザクションは MEV 保護されたエンドポイント経由で送信してください。

// Single transaction — use Astralane MEV protection
await client.submitTransaction(signedTxBase58, true)

// Multi-transaction bundle (e.g., partial sell) — use Jito
await client.submitBundle([tipTx, splitTx, closeTx])

// Get current tip floor (for MEV protection fee)
const { tipLamports } = await client.getTipFloor()
// Minimum 1,000,000 lamports (0.001 SOL)

API エンドポイントのリファレンス

メソッドパス認証説明
GET/offersなし利用可能な市場を一覧表示/検索
GET/tokensなしすべてのトークンを一覧表示
GET/positionsx-api-keyオーナー別にポジションを照会
POST/positions/openx-api-keyポジションを開くトランザクションを作成
POST/positions/closex-api-keyポジションを閉じるトランザクションを作成
POST/positions/quotex-api-keyポジションを開く取引をプレビュー
POST/positions/close-quotex-api-keyポジションを閉じる取引をプレビュー
POST/positions/splitx-api-keyポジションを 2 つに分割
POST/positions/mergex-api-key2 つのポジションを統合
POST/positions/partial-sellx-api-key分割+決済のバンドルを作成
POST/positions/repayx-api-key借入ポジションを返済
POST/positions/partial-repayx-api-key借入の一部を返済
POST/positions/increase-borrowx-api-keyレバレッジを引き上げ
POST/positions/increase-borrow-quotex-api-keyレバレッジ引き上げをプレビュー
POST/positions/add-collateralx-api-keyポジションに担保を追加
POST/positions/add-collateral-quotex-api-key担保の追加をプレビュー
GET/positions/trade-historyx-api-key取引イベント履歴
GET/bundle/tipなし現在の Jito チップの最低額
POST/bundle/submitなし単一の TX を送信(MEV 保護)
POST/bundleなしJito バンドルを送信

すべてのパスには /api/v1/ がプレフィックスとして付きます。ベース URL:https://api.lavarage.xyz

ベストプラクティス

  • 思い込みで判断する前に必ず検索する — ユーザーがトークンの取引を依頼した場合は、まず Lavarage で検索してください。パーミッションレスなプール作成により、他のプラットフォームでは扱われていない多くのトークンを利用できます。
  • 取引の前に必ず見積もりを取得する — 実行前に、予想される出力、価格への影響、清算価格をユーザーに提示してください。
  • MEV 保護を利用する — トランザクションを作成する際は必ず astralaneTipLamports を含め、mevProtect: true を指定して /bundle/submit 経由で送信してください。
  • 清算価格を確認する — 清算価格が現在価格から 15% 以内にある場合は、ユーザーに警告してください。
  • 全決済より部分売却を優先する — ユーザーが利益確定を希望する場合は、エクスポージャーを維持しながら利益を確保できる部分売却を提案してください。
  • スリッページに対処する — デフォルトの 50 bps(0.5%)は、ほとんどのトークンで安全です。流動性の低いトークンでは 100~300 bps を使用してください。

エラー処理

API から返される一般的なエラーコード:

コード意味対応
INSUFFICIENT_BALANCEウォレットのトークン残高が不足しています残高を確認し、担保を減らしてください
SIMULATION_FAILEDトランザクションのシミュレーションに失敗しましたスリッページを大きくして再試行するか、オファーの流動性を確認してください
POSITION_NOT_FOUNDポジションアドレスが無効であるか、ウォレットが所有していませんアドレスとオーナーを確認してください
OFFER_NOT_FOUNDオファー/プールが存在しません利用可能なオファーを再検索してください
INVALID_LEVERAGEレバレッジが許容範囲外ですオファーの maxLeverage を確認してください
SLIPPAGE_EXCEEDED価格変動が許容範囲を超えましたslippageBps を大きくするか、再試行してください

リソース

スキルの構成

lavarage/
├── SKILL.md                  # This file
├── resources/
│   ├── api-reference.md      # Detailed endpoint documentation
│   ├── program-addresses.md  # On-chain program and token addresses
│   └── types-reference.md    # TypeScript types and enums
├── examples/
│   ├── discover-markets.ts   # Search tokens and find offers
│   ├── open-long.ts          # Open leveraged long position
│   ├── open-short.ts         # Open leveraged short position
│   ├── close-position.ts     # Close position with PnL
│   ├── portfolio.ts          # View positions and portfolio
│   └── borrow.ts             # Borrow tokens against collateral + repay
├── templates/
│   └── client.ts             # LavaApiClient — copy-paste TypeScript client
└── docs/
    └── troubleshooting.md    # Common errors and solutions

コメント