@graviton-inc/xeenon-tokens-program-idl
v0.0.10
Published
TypeScript IDL (Interface Definition Language) for the Xeenon Tokens Program on Solana.
Readme
@graviton-inc/xeenon-tokens-program-idl
TypeScript IDL (Interface Definition Language) for the Xeenon Tokens Program on Solana.
Overview
This package provides the complete IDL definition for the Xeenon Tokens Program, a Solana program that enables token trading, borrowing, staking, and rewards distribution. The IDL is available in both JSON format and TypeScript types for easy integration with Solana development tools.
Features
- Complete IDL Definition: Full interface definition for all program instructions, accounts, events, and types
- TypeScript Support: Strongly typed definitions for all program structures
- Solana Integration: Compatible with Anchor, Solana Web3.js, and other Solana development tools
- Rewards System: Support for creator and staker rewards distribution
- Trading Operations: Buy/sell operations with exact cash/token amounts
- Borrowing System: Collateralized borrowing with debt management
- Market Management: Market creation, configuration, and period management
Installation
npm install @graviton-inc/xeenon-tokens-program-idlor
yarn add @graviton-inc/xeenon-tokens-program-idlUsage
Basic Import
import { idl, Tokens } from '@graviton-inc/xeenon-tokens-program-idl';
// Use the IDL with Anchor
const program = new Program<Tokens>(idl, programId, provider);
// Use the TypeScript types
const marketAccount: Tokens['accounts'][0] = // ... your market accountProgram ID
The Xeenon Tokens Program ID is:
XEENqbVXt8y94cH7WMwYyQSuDgkvzZTzEzpsWLZu7JfKey Instructions
Market Operations
initXeenonPosition: Create a user position in a market, required to stake and borrow
Trading Operations
buyWithExactCashIn: Buy tokens with exact cash amountsellWithExactTokenIn: Sell tokens for exact cash amount
Staking & Borrowing
depositToken: Deposit tokens to stakewithdrawToken: Withdraw staked tokensborrow: Borrow against staked collateralrepay: Repay borrowed amount
Rewards
claimCreatorRewards: Claim rewards for market creatorsclaimStakerRewards: Claim rewards for stakersaccruePositionRewards: Accrue rewards for positions for previous period. Needs to be called before depositToken, withdrawToken, or claimStakerRewards for every period that has passed and the position has been active.
Account Types
Core Accounts
xeenonMarket: Main market account with trading and staking dataxeenonMarketGroup: Market group configurationxeenonPosition: User position in a marketxeenonMarketPeriod: Period-specific rewards of a market
Mayflower Integration
marketMeta: Market metadata and configurationmarketLinear: Linear market state and price curvepersonalPosition: User's personal position data
Event Types
The program emits various events for tracking operations:
marketCreatedEvent: Market creationdepositEvent: Token depositswithdrawEvent: Token withdrawalsborrowEvent: Borrowing operationsrepayEvent: Repayment operationsbuyWithExactCashInEvent: Buy operationssellWithExactTokenInEvent: Sell operationsclaimCreatorRewardsEvent: Creator reward claimsclaimStakerRewardsEvent: Staker reward claimsmarketPeriodClosedEvent: Period closurefloorRaisedEvent: Floor price updates
Error Codes
The program includes comprehensive error handling:
6000: Insufficient Staked Balance6001: Insufficient Global Staked Balance6002: Invalid Mint Percentage Options6003: Invalid Creator Rewards Share Percentage6004: Invalid Closing Period6005: Borrow Power Exceeded6006: Insufficient Debt to Repay6007: Cannot withdraw collateral with outstanding debt6008: Invalid Period Provided6009: Invalid Next Period Provided6010: Period is not closed6011: Position period does not match market period6012: No rewards to claim6013: Arithmetic overflow
Development
Building
yarn buildProject Structure
src/
├── index.ts # Main exports
├── tokens.ts # TypeScript type definitions
└── tokens.json # Raw IDL JSONTypeScript Configuration
The project uses TypeScript 5.5.4 with strict type checking. The build process generates both JavaScript and TypeScript declaration files.
Integration Examples
With Anchor Framework
import { Program, AnchorProvider } from '@coral-xyz/anchor';
import { idl, Tokens } from '@graviton-inc/xeenon-tokens-program-idl';
const provider = AnchorProvider.env();
const program = new Program<Tokens>(idl, programId, provider);
// Initialize a market
await program.methods
.initXeenonMarket({
name: "My Token",
symbol: "MTK",
uri: "https://example.com/metadata.json",
creatorRewardsSharePercentage: 10
})
.accounts({
payer: wallet.publicKey,
// ... other required accounts
})
.rpc();With Solana Web3.js
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
import { idl } from '@graviton-inc/xeenon-tokens-program-idl';
// Create instruction from IDL
const instruction = await program.methods
.depositToken(new BN(1000000))
.accounts({
payer: wallet.publicKey,
// ... other accounts
})
.instruction();
const transaction = new Transaction().add(instruction);License
MIT License.
Support
For questions and support, please create an issue in this repository.
