Open the app

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#

read.ts
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#

TypeScript
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);

A borrower commit also needs the price accounts, { solPrice, quotePrice, jitoPool? }, because the program checks collateral at commit.

Instructions#

BuilderSigned by
createAuctionInstructionAnyone
commitOrderInstructionOwner
revealOrderInstructionOwner
clearAuctionInstructionAnyone
claimLenderInstruction, claimBorrowerInstructionAnyone; assets go to the owner
expireBorrowerInstruction, refundUnrevealedInstructionAnyone
addCollateralInstruction, repayInstructionAnyone
liquidateInstructionThe buyer
finalizeAuctionInstructionAnyone
redeemNotesInstructionNote holder
sweepFeesInstructionAnyone; bonds go to the staking vault
stakeInstruction, requestUnstakeInstruction, withdrawUnstakedInstruction, claimRewardsInstructionStaker
updateVoterWeightRecordInstructionAnyone; 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.

CommandDoes
prepareWrites an order secret file offline
commit, revealSeals and reveals from a secret file
clear, finalizeCranks an auction
claim, expire, refund-unrevealedResolves an order
add-collateral, repayManages a loan
liquidateBuys collateral with --max-payment and --min-collateral-out bounds
redeemBurns notes after settlement
stake, unstake, withdraw-unstaked, claim-rewardsStakes TENOR and collects bond rewards
propose-series, vote, executeProposes a series, votes, and runs a passed proposal after its hold-up
sweep-feesSends a series' forfeited bonds to stakers
list, inspect, verify-prices, stakingReads accounts, checks price accounts and shows stake

Secret files are created exclusively, never overwritten, and their salts are never printed.