Skip to main content

Command Palette

Search for a command to run...

Task 6 Pinocchio AMM

Published
2 min readView as Markdown
C
酷愛計算機技術Ardently Love Computer Technology 長期關註反洗錢反欺詐Long-term Focus on Anti-Money Laundering and Anti-Fraud 精通支付結算的技術、系統、流程和製度Proficient in the Technology, System, Process and Institution of Payment and Settlement

参考代码仓库 https://github.com/dylean/solana-2026-task

克隆代码,进入项目文件夹

$ cd blueshift_native_amm

添加匹诺曹

# cargo add pinocchio pinocchio-system pinocchio-token pinocchio-associated-token-account
    Updating `rsproxy-sparse` index
      Adding pinocchio v0.10.1 to dependencies
             Features:
             + alloc
             - copy
             - cpi
      Adding pinocchio-system v0.5.0 to dependencies
      Adding pinocchio-token v0.5.0 to dependencies
      Adding pinocchio-associated-token-account v0.3.0 to dependencies
    Updating `rsproxy-sparse` index
     Locking 12 packages to latest compatible versions

添加恒定乘积曲线

# cargo add --git="https://github.com/deanmlittle/constant-product-curve" constant-product-curve
    Updating git repository `https://github.com/deanmlittle/constant-product-curve`
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 92 (delta 47), reused 72 (delta 27), pack-reused 0 (from 0)
展开对象中: 100% (92/92), 53.50 KiB | 182.00 KiB/s, 完成.
来自 https://github.com/deanmlittle/constant-product-curve
 * [新引用]          HEAD       -> origin/HEAD
      Adding constant-product-curve (git) to dependencies
    Updating git repository `https://github.com/deanmlittle/constant-product-curve`
     Locking 1 package to latest compatible version
      Adding constant-product-curve v0.1.0 (https://github.com/deanmlittle/constant-product-curve#2a723a0f)

查看 Cargo.toml 文件

$ cat Cargo.toml 
[package]
name = "blueshift_native_amm"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["lib", "cdylib"]

[dependencies]
pinocchio = "0.10.1"
pinocchio-system = "0.5.0"
pinocchio-token = "0.5.0"
pinocchio-associated-token-account = "0.3.0"

构建 .so 文件,未报错

# cargo build-sbf
    Updating git repository `https://github.com/deanmlittle/constant-product-curve`
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 92 (delta 47), reused 72 (delta 27), pack-reused 0 (from 0)
展开对象中: 100% (92/92), 53.50 KiB | 239.00 KiB/s, 完成.
来自 https://github.com/deanmlittle/constant-product-curve
 * [新引用]          2a723a0ff5ad522f657f80c053c2bb290da28b70 -> refs/commit/2a723a0ff5ad522f657f80c053c2bb290da28b70
   Compiling five8_core v1.0.0
   Compiling five8_const v1.0.0
...
   Compiling blueshift_native_amm v0.1.0
    Finished `release` profile [optimized] target(s) in 10.30s

目录结构

$ tree -L 3
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│   ├── instructions
│   │   ├── deposit.rs
│   │   ├── initialize.rs
│   │   ├── mod.rs
│   │   ├── swap.rs
│   │   └── withdraw.rs
│   ├── lib.rs
│   └── state.rs
└── target
    ├── CACHEDIR.TAG
    ├── deploy
    │   ├── blueshift_native_amm-keypair.json
    │   └── blueshift_native_amm.so
    ├── release
    │   ├── build
    │   ├── deps
    │   ├── examples
    │   └── incremental
    └── sbpf-solana-solana
        ├── CACHEDIR.TAG
        └── release

12 directories, 14 files

More from this blog

Penetration Test、Python、Weaponization

721 posts

微信 smartcat9999 反欺詐Anti-Fraud 反洗錢Anti-Money Laundering 反逃稅Anti-Tax Evasion 滲透測試Penetration Test 武器化Weaponization