The sukuk library

packages/sukuk builds every instruction Tsamara sends.

@tsamara/sukuk is a TypeScript package of pure instruction builders on @solana/web3.js and @solana/spl-token. It signs nothing and sends nothing: the caller decides who signs.

A series

SeriesTerms describes a series: name, symbol, akad, maturity, currency, expectedProfitRateBps, paymentsPerYear, unitValue, restrictedJurisdictions, maxHolding, tangibleAssetsBps and tangibilityAsOf. DEMO_SERIES is the one the demo uses.

FunctionUse
issueSeriesIxsCreate the mint with its extensions and publish the terms as metadata
publishTermsIxsWrite or update the metadata fields
initializeComplianceIxCreate the series config for the transfer hook
isEligibleWhether a country may hold the series
isTradableAtAgreedPriceWhether tangible assets are at least 51%

Investors

FunctionUse
approveInvestorIxsRegister the investor and thaw their token account; throws early for a restricted country
registerInvestorIxOnly the investor record
revokeInvestorIxFreeze the account

Settlement

FunctionUse
subscribeIxsPayment to the issuer and minting to the investor, for one transaction
transferIxA transfer with the hook's extra accounts resolved
tradeIxsPayment one way and units the other, between two investors, for one transaction
payIxA payment-token transfer

The payment token is a PaymentToken: mint, decimals and token program. Any token on either token program works.

Distributions

FunctionUse
periodicDistributionWhat a holding earns in one period, rounded down
distributionBatchesPayments grouped eight to a transaction, each batch with its memo
distributionMemotsamara:distribution:<symbol>:<period>:<batch>

Recovery

forcedTransferIxs moves units using the permanent delegate. It refuses to build the transfer without a reason and an orderedBy, and adds a memo carrying both.

Example

import { DEMO_SERIES, subscribeIxs } from '@tsamara/sukuk';

const ixs = subscribeIxs({
  sukukMint,
  payment,              // { mint, decimals, programId }
  issuer: issuer.publicKey,
  investor: wallet,
  units: 10n,
  terms: DEMO_SERIES
});
// One transaction, signed by the investor and the issuer.

On this page