# @1inch/solana-fusion-sdk 中文文档

规范地址：https://npmcn.com/package/%401inch/solana-fusion-sdk/

版本：0\.2\.3
npm 元数据更新时间：2026-10-09T15:43:18.428Z
中文译文更新时间：2026-11-06T05:47:56.905Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%401inch/solana-fusion-sdk
原文对照：https://npmcn.com/package/%401inch/solana-fusion-sdk/?lang=original
项目主页：https://github.com/1inch/solana-fusion-sdk#readme
源码仓库：https://github.com/1inch/solana-fusion-sdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：792 kB，335 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22
- 运行依赖：8 个
- peer 依赖：axios ^1
- 首次发布：2025-04-29T17:13:17.016Z
- 最新版本发布：2026-09-16T06:56:22.986Z
- 近 30 天下载量：4670（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：16（近 12 个月 8 个）

## 中文简介

SDK用于对索拉纳的核聚变

## 安装

```sh
npm install @1inch/solana-fusion-sdk
```

也可以使用：`pnpm add @1inch/solana-fusion-sdk`、`yarn add @1inch/solana-fusion-sdk`、`bun add @1inch/solana-fusion-sdk`

## README

# 索拉纳组合SDK

## 安装

添加为 `package.json`

```json
{
  "dependencies": {
    "@1inch/solana-fusion-sdk": "@1inch/solana-fusion-sdk"
  }
}
```

## 文档

-   [组合顺序](https://npmcn.com/package/%401inch/solana-fusion-sdk/src/fusion-order/README.md)
-   [SDK 软件](https://npmcn.com/package/%401inch/solana-fusion-sdk/src/sdk/README.md)
-   [网络密钥 Api](https://npmcn.com/package/%401inch/solana-fusion-sdk/src/ws-api/README.md)

## 开始

### 用户

#### 创建和提交命令

```typescript
import { Address, FusionSwapContract, Sdk } from '@1inch/solana-fusion-sdk'
import { AxiosHttpProvider } from '@1inch/solana-fusion-sdk/axios'
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js' // v1

const authKey = '...'
const secretKey = Buffer.from('secret', 'base64') // replace to real secret key
const rpc = 'https://api.mainnet-beta.solana.com'

const connection = new Connection(rpc)
const maker = Keypair.fromSecretKey(secretKey)

const sdk = new Sdk(new AxiosHttpProvider(), { baseUrl: 'https://api.1inch.dev/fusion', authKey, version: 'v1.0' })

// quote and create order
// 1 SOL -> USDC
// when the quote carries partner fees the order embeds them automatically
const quote = await sdk.getQuote(
  Address.NATIVE, // SOL
  new Address('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), // USDC
  1_000_000_000n, // 1 SOL
  Address.fromPublicKey(maker.publicKey)
)
const order = quote.toOrder()

const contract = FusionSwapContract.default()

// create escrow instruction
const ix = contract.create(order, {
  maker: Address.fromPublicKey(maker.publicKey),
  srcTokenProgram: Address.TOKEN_PROGRAM_ID
})

// generate tx
// for an SPL destination prepend the idempotent fee-ata creates — those accounts must exist at fill time
const createOrderTx = new Transaction()

for (const instruction of [...quote.getFeeAtaCreateInstructions(), ix]) {
  createOrderTx.add({
    ...instruction,
    programId: new PublicKey(instruction.programId.toBuffer()),
    keys: instruction.accounts.map((a) => ({
      ...a,
      pubkey: new PublicKey(a.pubkey.toBuffer())
    }))
  })
}

createOrderTx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash
createOrderTx.sign(maker)

// broadcast tx
await connection.sendRawTransaction(createOrderTx.serialize())

while (true) {
  const status = await sdk.getOrderStatus(order.getOrderHashBase58())

  if (!status.isActive()) {
    console.log('order finished', status)
    break
  }

  await sleep(1000)
}

export function sleep(ms: number): Promise<void> {
  return new Promise((resolve) => setTimeout(resolve, ms))
}
```

当目的地是本地SOL时,直接向接收器钱包支付费用——这些钱包必须已经获得资金(免租金),否则填充会失败.

#### 取消订单

```typescript
import { Address, FusionSwapContract, Sdk } from '@1inch/solana-fusion-sdk'
import { AxiosHttpProvider } from '@1inch/solana-fusion-sdk/axios'
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js' // v1

const authKey = '...'
const secretKey = Buffer.from('secret', 'base64') // replace to real secret key
const rpc = 'https://api.mainnet-beta.solana.com'

const connection = new Connection(rpc)
const maker = Keypair.fromSecretKey(secretKey)

const sdk = new Sdk(new AxiosHttpProvider(), { baseUrl: 'https://api.1inch.dev/fusion', authKey, version: 'v1.0' })

const order = ... // see 'Create and submit order' section
const contract = FusionSwapContract.default()

// close escrow instruction
const ix = contract.cancelOwnOrder(order, {
  maker: Address.fromPublicKey(maker.publicKey),
  srcTokenProgram: Address.TOKEN_PROGRAM_ID
})

// generate tx
const cancelOrderTx = new Transaction().add({
  ...ix,
  programId: new PublicKey(ix.programId.toBuffer()),
  keys: ix.accounts.map((a) => ({
    ...a,
    pubkey: new PublicKey(a.pubkey.toBuffer())
  }))
})

cancelOrderTx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash
cancelOrderTx.sign(maker)

// broadcast tx
await connection.sendRawTransaction(createOrderTx.serialize())
```

### 为解析器

#### 填充顺序

```typescript
import { Address, FusionSwapContract, Sdk } from '@1inch/solana-fusion-sdk'
import { AxiosHttpProvider } from '@1inch/solana-fusion-sdk/axios'
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js' // v1

const authKey = '...'
const secretKey = Buffer.from('secret', 'base64') // replace to real secret key
const rpc = 'https://api.mainnet-beta.solana.com'

const connection = new Connection(rpc)
const resolver = Keypair.fromSecretKey(secretKey)

const sdk = new Sdk(new AxiosHttpProvider(), { baseUrl: 'https://api.1inch.dev/fusion', authKey, version: 'v1.0' })
const contract = FusionSwapContract.default()

const activeOrders = await sdk.getActiveOrders()
const orderToFill = activeOrders[0]

// fill order instruction
const ix = contract.fill(
  orderToFill.order,
  orderToFill.remainingMakerAmount, // fill for remaining amount
  accounts: {
      taker: Address.fromPublicKey(resolver.publicKey),
      maker: orderToFill.maker
      srcTokenProgram: Address.TOKEN_PROGRAM_ID,
      dstTokenProgram: Address.TOKEN_PROGRAM_ID,
  }
)

// generate tx
const fillTx = new Transaction().add({
  // at the moment of `ix` execution resolver must have enough source token, so it can be transferred to user
  ...ix,
  programId: new PublicKey(ix.programId.toBuffer()),
  keys: ix.accounts.map((a) => ({
    ...a,
    pubkey: new PublicKey(a.pubkey.toBuffer())
  }))
})

fillTx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash
fillTx.sign(resolver)

// broadcast tx
await connection.sendRawTransaction(createOrderTx.serialize())
```

#### 取消订单

取消过期的订单, 将支付解析器 `order.resolverCancellationConfig.maxCancellationPremium` 灯塔

```typescript
import { Address, FusionSwapContract, Sdk } from '@1inch/solana-fusion-sdk'
import { AxiosHttpProvider } from '@1inch/solana-fusion-sdk/axios'
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js' // v1

const authKey = '...'
const secretKey = Buffer.from('secret', 'base64') // replace to real secret key
const rpc = 'https://api.mainnet-beta.solana.com'

const connection = new Connection(rpc)
const maker = Keypair.fromSecretKey(secretKey)

const sdk = new Sdk(new AxiosHttpProvider(), { baseUrl: 'https://api.1inch.dev/fusion', authKey, version: 'v1.0' })

const cancellableOrders = await sdk.getOrdersCancellableByResolver()
const order = cancellableOrders[0]
const contract = FusionSwapContract.default()

// close escrow instruction
const ix = contract.cancelOrderByResolver(order.order, {
  maker: order.maker,
  resolver: Address.fromPublicKey(resolver.publicKey),
  srcTokenProgram: Address.TOKEN_PROGRAM_ID
})

// generate tx
const cancelOrderTx = new Transaction().add({
  ...ix,
  programId: new PublicKey(ix.programId.toBuffer()),
  keys: ix.accounts.map((a) => ({
    ...a,
    pubkey: new PublicKey(a.pubkey.toBuffer())
  }))
})

cancelOrderTx.recentBlockhash = (await connection.getRecentBlockhash()).blockhash
cancelOrderTx.sign(resolver)

// broadcast tx
await connection.sendRawTransaction(createOrderTx.serialize())
```

## 常见问题

### @1inch/solana-fusion-sdk 是什么？

SDK用于对索拉纳的核聚变

### 如何安装 @1inch/solana-fusion-sdk？

在项目目录运行 npm install @1inch/solana-fusion-sdk，或使用 pnpm add / yarn add / bun add。

### @1inch/solana-fusion-sdk 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @1inch/solana-fusion-sdk 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @1inch/solana-fusion-sdk 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @1inch/solana-fusion-sdk 可以商用吗？

@1inch/solana-fusion-sdk 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @1inch/solana-fusion-sdk 的下载量有多少？

根据 npm 官方下载统计，@1inch/solana-fusion-sdk 在 2026/10/05 – 2026/11/03 这 30 天内被下载 4,670 次，日均约 156 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @1inch/solana-fusion-sdk 还在维护吗？

最新版本 0\.2\.3 发布于 2026/09/16（1 个月前）；至今共发布 16 个版本，其中过去 12 个月发布了 8 个；首次发布于 2025/04/30。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

