Skip to content

Commit e1c64d8

Browse files
committed
token-2022 interest-bearing: add pinocchio example
Ports the interest-bearing Token-2022 example to Pinocchio (the anchor example has no native sibling), matching the token-2022 pinocchio template (kit + litesvm, official @solana-program packages, real Rent::get()). The program hand-rolls three Token-2022 CPIs to create a mint with the InterestBearingConfig extension: it initializes the rate config to 0% before InitializeMint, then (mirroring the anchor example) updates it to 1% via UpdateRate, which the rate authority signs. The payer is the rate authority. Unlike a COption, the rate authority is an OptionalNonZeroPubkey (a bare 32-byte key, no tag byte), and the rate is a signed i16. Mint size is 222 bytes (a 52-byte InterestBearingConfig TLV value). The litesvm test decodes the mint with the official Token-2022 codec and asserts the rate authority and the current 1% rate.
1 parent 4f90945 commit e1c64d8

12 files changed

Lines changed: 3325 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ members = [
6969
"tokens/token-2022/transfer-fee/native/program",
7070
"tokens/token-2022/transfer-fee/pinocchio/program",
7171
"tokens/token-2022/multiple-extensions/native/program",
72+
"tokens/token-2022/interest-bearing/pinocchio/program",
7273
]
7374
resolver = "2"
7475

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# This script is for quick building & deploying of the program.
4+
# It also serves as a reference for the commands used for building & deploying Solana programs.
5+
# Run this bad boy with "bash cicd.sh" or "./cicd.sh"
6+
7+
cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so
8+
solana program deploy ./program/target/so/program.so
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"type": "module",
3+
"scripts": {
4+
"test": "mocha --import=tsx -t 1000000 ./tests/test.ts",
5+
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
6+
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
7+
"deploy": "solana program deploy ./program/target/so/program.so"
8+
},
9+
"dependencies": {
10+
"@solana-program/system": "^0.12.2",
11+
"@solana-program/token-2022": "^0.12.0",
12+
"@solana/kit": "^7.0.0",
13+
"@solana/sysvars": "^6.10.0",
14+
"litesvm": "^1.3.0"
15+
},
16+
"devDependencies": {
17+
"@types/chai": "^5.2.3",
18+
"@types/mocha": "^10.0.10",
19+
"@types/node": "^26.1.0",
20+
"chai": "^6.2.2",
21+
"mocha": "^11.7.5",
22+
"typescript": "^5.9.3",
23+
"tsx": "^4.19.2"
24+
}
25+
}

0 commit comments

Comments
 (0)