Reference
SDK and CLI
A TypeScript SDK that builds every Tenor instruction without an Anchor client, and a CLI on top of it for scripts and keepers.
@tenor/sdk is the TypeScript client the app itself runs on. It encodes instructions natively, derives every account, decodes accounts with exact size and owner checks, and uses bigint for all amounts. It also installs the tenor command line.
Read an auction#
import { createConnection, TenorClient } from "@tenor/sdk";
const connection = createConnection(process.env.TENOR_RPC_URL!);
const client = new TenorClient(connection);
const { value: auction } = await client.fetchAuction(auctionAddress);
console.log(auction.cleared, auction.clearingTick, auction.matched);fetchSeries, fetchAuction and fetchOrder return { address, slot, value } after checking the owning program, the account size and the derived address.
Seal and reveal#
import {
commitOrderInstruction, revealOrderInstruction, orderCommitment,
orderAddress, generateSalt, LENDER,
} from "@tenor/sdk";
const salt = generateSalt(); // keep this: it is the only way to reveal
const size = 100_000_000_000n; // 100,000 USDC in atoms
const rateTick = 25; // 6.25%
const commitment = orderCommitment({ side: LENDER, rateTick, size, salt, owner, auction });
const commit = commitOrderInstruction(owner, series, auction, {
nonce: 0n, side: LENDER, maxSize: size, collateralAmount: 0n, collateralIndex: 0, commitment,
});
// During the reveal window:
const order = orderAddress(auction, owner, 0n);
const reveal = revealOrderInstruction(owner, series, auction, order, rateTick, size, salt);# Prepare offline; sizes are raw units (USDC 6 decimals)
tenor prepare --owner OWNER --auction AUCTION --side lender --rate-tick 25 --size 100000000000 --nonce 0 --secret lend.secret.json
tenor commit --secret lend.secret.json --keypair wallet.json --rpc URL --genesis HASH
# During the reveal window
tenor reveal --secret lend.secret.json --keypair wallet.json --rpc URL --genesis HASHA borrower commit also needs the price accounts, { solPrice, quotePrice, jitoPool? }, because the program checks collateral at commit.
Instructions#
| Builder | Signed by |
|---|---|
createAuctionInstruction | Anyone |
commitOrderInstruction | Owner |
revealOrderInstruction | Owner |
clearAuctionInstruction | Anyone |
claimLenderInstruction, claimBorrowerInstruction | Anyone; assets go to the owner |
expireBorrowerInstruction, refundUnrevealedInstruction | Anyone |
addCollateralInstruction, repayInstruction | Anyone |
liquidateInstruction | The buyer |
finalizeAuctionInstruction | Anyone |
redeemNotesInstruction | Note holder |
sweepFeesInstruction | Anyone; bonds go to the staking vault |
stakeInstruction, requestUnstakeInstruction, withdrawUnstakedInstruction, claimRewardsInstruction | Staker |
updateVoterWeightRecordInstruction | Anyone; send it in the same transaction as the vote |
@tenor/sdk/governance builds the SPL Governance side: proposeInstructions, voteInstructions, finalizeVoteInstructions and executeInstructions, each refreshing the voter's weight from active stake where a vote counts.
Claims, expiry and refunds pay into the owner's token accounts. Wrap them with prepareResolveOrderInstructions, and repayment or liquidation with prepareSettlementInstructions, to create any missing accounts in the same transaction.
CLI#
Every command that sends a transaction requires a keypair file and the network's genesis hash, and stops if the RPC reports a different network. On Solana mainnet the genesis hash is 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d.
| Command | Does |
|---|---|
prepare | Writes an order secret file offline |
commit, reveal | Seals and reveals from a secret file |
clear, finalize | Cranks an auction |
claim, expire, refund-unrevealed | Resolves an order |
add-collateral, repay | Manages a loan |
liquidate | Buys collateral with --max-payment and --min-collateral-out bounds |
redeem | Burns notes after settlement |
stake, unstake, withdraw-unstaked, claim-rewards | Stakes TENOR and collects bond rewards |
propose-series, vote, execute | Proposes a series, votes, and runs a passed proposal after its hold-up |
sweep-fees | Sends a series' forfeited bonds to stakers |
list, inspect, verify-prices, staking | Reads accounts, checks price accounts and shows stake |
Secret files are created exclusively, never overwritten, and their salts are never printed.