diff --git a/.changeset/cute-steaks-dig.md b/.changeset/cute-steaks-dig.md new file mode 100644 index 00000000..91a2196c --- /dev/null +++ b/.changeset/cute-steaks-dig.md @@ -0,0 +1,5 @@ +--- +"@macalinao/codama-renderers-markdown": patch +--- + +Modify error code output format diff --git a/.changeset/every-trees-sip.md b/.changeset/every-trees-sip.md new file mode 100644 index 00000000..57d72625 --- /dev/null +++ b/.changeset/every-trees-sip.md @@ -0,0 +1,14 @@ +--- +"@macalinao/codama-instruction-accounts-dedupe-visitor": patch +"@macalinao/codama-nodes-from-anchor-x": patch +"@macalinao/codama-renderers-markdown": patch +"@macalinao/codama-renderers-js-esm": patch +"@macalinao/codama-rename-visitor": patch +"@macalinao/clients-kamino-lending": patch +"@macalinao/clients-token-metadata": patch +"@macalinao/clients-quarry": patch +"@macalinao/coda": patch +"coda-docs": patch +--- + +Update documentation diff --git a/.changeset/green-oranges-grab.md b/.changeset/green-oranges-grab.md new file mode 100644 index 00000000..00eef3d0 --- /dev/null +++ b/.changeset/green-oranges-grab.md @@ -0,0 +1,5 @@ +--- +"@macalinao/codama-instruction-accounts-dedupe-visitor": patch +--- + +Only apply deduping if necessary diff --git a/.changeset/sharp-mugs-design.md b/.changeset/sharp-mugs-design.md new file mode 100644 index 00000000..efcbda37 --- /dev/null +++ b/.changeset/sharp-mugs-design.md @@ -0,0 +1,6 @@ +--- +"@macalinao/codama-renderers-markdown": minor +"@macalinao/codama-rename-visitor": minor +--- + +Refactor packages diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a9c5d7c..628c66f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: run: bun install --frozen-lockfile - name: Build all packages - run: bun run build + run: bun run build:ci - name: Run linting run: bun run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b41b120..64ea23b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: run: bun install --frozen-lockfile - name: Build packages - run: bun run build + run: bun run build:ci - name: Setup NPM authentication run: | diff --git a/CLAUDE.md b/CLAUDE.md index 3d887450..e2952160 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -189,6 +189,7 @@ export default defineConfig({ - Arrays use shorthand syntax: `string[]` not `Array` - **Use double quotes for strings** (not single quotes) - ES modules with `.js` extensions for imports +- **File naming**: Use kebab-case for all TypeScript files (e.g., `root-node-from-anchor.ts`, `create-codama-from-idls.ts`) ### After Making Code Changes **Always run these commands to ensure code quality:** diff --git a/apps/docs/content/docs/examples.mdx b/apps/docs/content/docs/examples.mdx index d786ec01..ef7b529f 100644 --- a/apps/docs/content/docs/examples.mdx +++ b/apps/docs/content/docs/examples.mdx @@ -39,40 +39,39 @@ The Quarry client demonstrates Coda's **multi-program** capabilities: Ideal for protocol developers managing multiple interconnected programs or anyone building comprehensive DeFi integrations. -## Add Your Example +### Kamino Lending Client -Using Coda in your project? We'd love to showcase it! +[![npm version](https://img.shields.io/npm/v/@macalinao/clients-kamino-lending.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/clients-kamino-lending.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) -**[Submit a Pull Request →](https://github.com/macalinao/coda/pulls)** to add your project to this documentation. +[View on GitHub →](https://github.com/macalinao/coda/tree/master/clients/kamino-lending) -### How to Add Your Example +The Kamino Lending client demonstrates Coda's ability to handle **complex IDLs with overlapping account names**: -1. Fork the [Coda repository](https://github.com/macalinao/coda) -2. Edit this file at `apps/docs/content/docs/examples.mdx` -3. Add your project following this format: +- **Overlapping account names** - Handles instructions with duplicate account names across nested structures +- **Automatic flattening** - Intelligently flattens nested account groups to avoid naming conflicts +- **Complex DeFi protocol** - Full lending protocol with deposit, withdraw, and liquidation operations +- **Production-scale IDL** - Processes large IDL with numerous instructions and account types -```mdx -### Your Project Name +This example is particularly useful for developers working with: -[View on GitHub →](https://github.com/yourname/yourproject) +- Complex DeFi protocols with nested account structures +- IDLs that have evolved over time with naming inconsistencies +- Programs requiring sophisticated account management patterns +- Large-scale production protocols with intricate instruction sets -Brief description of what makes your implementation unique: +The Kamino Lending client showcases how Coda's automatic account flattening feature (via `codama-instruction-accounts-dedupe-visitor`) resolves naming conflicts that would otherwise cause compilation errors in generated TypeScript code. -- **Key feature 1** - Description -- **Key feature 2** - Description -- **Key feature 3** - Description +## Add Your Example -What developers can learn from your example. -``` +Using Coda in your project? We'd love to showcase it! + +**[Submit a Pull Request →](https://github.com/macalinao/coda/pulls)** to add your project to this documentation. -4. Submit your PR with a clear description +### How to Add Your Example -We welcome examples that demonstrate: -- Novel configuration approaches -- Integration patterns -- Complex visitor usage -- Multi-program setups -- Custom code generation workflows -- Production deployment strategies +1. Fork the [Coda repository](https://github.com/macalinao/coda) +2. Edit this file at `apps/docs/content/docs/examples.mdx` +3. Submit your PR with a clear description -Help the Solana developer community by sharing your Coda implementation! \ No newline at end of file +Help the Solana developer community by sharing your Coda implementation! diff --git a/apps/docs/content/docs/meta.json b/apps/docs/content/docs/meta.json index aef33b44..81969ebe 100644 --- a/apps/docs/content/docs/meta.json +++ b/apps/docs/content/docs/meta.json @@ -11,6 +11,8 @@ "generating-clients", "generating-docs", "examples", + "---Packages---", + "packages", "---Reference---", "api" ] diff --git a/apps/docs/content/docs/packages/coda.mdx b/apps/docs/content/docs/packages/coda.mdx new file mode 100644 index 00000000..62fa9f15 --- /dev/null +++ b/apps/docs/content/docs/packages/coda.mdx @@ -0,0 +1,333 @@ +--- +title: "@macalinao/coda" +description: The main CLI tool for automated client generation from Solana IDLs +--- + +The core Coda package provides a zero-config CLI that transforms Anchor IDLs into modern TypeScript clients with full type safety and ES modules support. + +## Installation + +```bash +bun add -D @macalinao/coda +``` + +Or with npm: +```bash +npm install -D @macalinao/coda +``` + +## Features + +- 🚀 **Zero configuration** - Works out of the box with sensible defaults +- 🔧 **Fully customizable** - Extend and transform generated code with visitors +- 📦 **ES modules native** - Modern JavaScript with proper `.js` extensions +- 🎯 **Type-safe** - Full TypeScript support with precise types +- 🔄 **Anchor compatible** - Works with any Anchor IDL +- 🏗️ **Extensible** - Add custom visitors to transform the Codama tree +- ⚡ **Fast** - Optimized code generation pipeline + +## CLI Commands + +### Generate Command + +Generate TypeScript clients from an Anchor IDL: + +```bash +coda generate [options] + +Options: + -i, --idl Path to Anchor IDL file (default: "./idls/*.json") + -o, --output Output directory (default: "./src/generated") + -c, --config Path to config file (default: "./coda.config.mjs") +``` + +### Init Command + +Initialize a new configuration file: + +```bash +coda init [options] + +Options: + -c, --config Path for config file (default: "./coda.config.mjs") +``` + +## Configuration + +### Zero-Config (Default) + +Coda works without any configuration by looking for IDLs in `./idls/*.json`: + +```bash +# Just place your IDL files in the idls/ directory +coda generate +``` + +### Configuration File + +Create a `coda.config.mjs` to customize generation: + +```javascript +import { defineConfig } from "@macalinao/coda"; +import { addPdasVisitor } from "codama"; + +export default defineConfig({ + // Custom paths (optional) + idlPath: "./idls/my_program.json", + outputDir: "./src/clients/my_program", + + // Add visitors to customize generation + visitors: [ + // Add custom PDAs + addPdasVisitor({ + myAccount: [ + { + name: "authority", + seeds: [ + { kind: "constant", value: "authority" }, + { kind: "variable", name: "user", type: publicKeyTypeNode() } + ] + } + ] + }) + ] +}); +``` + +### Multiple IDLs + +Handle multiple programs with glob patterns: + +```javascript +export default defineConfig({ + // Use glob pattern to match all IDLs + idlPath: "./idls/*.json", + outputDir: "./src/generated", +}); +``` + +Or specify an array of paths: + +```javascript +export default defineConfig({ + idlPath: [ + "./idls/program1.json", + "./idls/program2.json", + ], + outputDir: "./src/generated", +}); +``` + +### Dynamic Configuration + +Use a function to conditionally apply visitors: + +```javascript +export default defineConfig({ + visitors: ({ idl }) => { + const visitors = []; + + // Conditionally add visitors based on IDL content + if (idl.name === "my_program") { + visitors.push(myCustomVisitor()); + } + + return visitors; + } +}); +``` + +## Generated Code Structure + +Coda generates a comprehensive client with the following structure: + +``` +src/generated/ +├── accounts/ # Account decoders and fetchers +├── instructions/ # Instruction builders +├── types/ # TypeScript type definitions +├── pdas/ # PDA helper functions +├── errors/ # Typed error codes +├── programs/ # Program ID constants +└── index.ts # Main exports +``` + +### Instructions + +Fully typed instruction builders with proper serialization: + +```typescript +export function createTransferInstruction( + input: TransferInstructionInput +): Instruction; + +export function getTransferInstructionDataEncoder(): Encoder; +``` + +### Accounts + +Account decoders with type safety: + +```typescript +export function decodeTokenAccount( + encodedAccount: EncodedAccount +): TokenAccount; + +export async function fetchTokenAccount( + rpc: Rpc, + address: Address +): Promise; +``` + +### Types + +All types from your IDL with proper TypeScript definitions: + +```typescript +export type TokenAccount = { + mint: Address; + owner: Address; + amount: bigint; + // ... other fields +}; +``` + +### PDAs + +Helper functions for program-derived addresses: + +```typescript +export async function findAuthorityPda( + seeds: { + user: Address; + } +): Promise<[Address, number]>; +``` + +### Errors + +Typed error enums for better error handling: + +```typescript +export enum MyProgramError { + InvalidAmount = 0x1770, + Unauthorized = 0x1771, + // ... +} +``` + +## API Reference + +### defineConfig + +Creates a configuration object for Coda: + +```typescript +function defineConfig(config: CodaConfig): CodaConfig; + +interface CodaConfig { + idlPath?: string | string[]; + outputDir?: string; + visitors?: Visitor[] | ((context: VisitorContext) => Visitor[]); +} +``` + +### VisitorContext + +Context passed to dynamic visitor functions: + +```typescript +interface VisitorContext { + idl: Idl; // The parsed Anchor IDL + idlPath: string; // Path to the IDL file + outputDir: string; // Output directory path +} +``` + +## Integration Examples + +### With Package.json Scripts + +```json +{ + "scripts": { + "codegen": "coda generate", + "codegen:watch": "coda generate --watch" + } +} +``` + +### With Turborepo + +```json +// turbo.json +{ + "tasks": { + "codegen": { + "outputs": ["./src/generated/**"], + "cache": false + } + } +} +``` + +### With GitHub Actions + +```yaml +- name: Generate clients + run: | + bun install + bun run codegen +``` + +## Advanced Features + +### Custom Visitors + +Extend generated code with Codama visitors: + +```javascript +import { updateInstructionsVisitor } from "codama"; + +const customVisitor = updateInstructionsVisitor({ + transfer: { + defaults: { + amount: 0n + } + } +}); + +export default defineConfig({ + visitors: [customVisitor] +}); +``` + +### Flattening Nested Accounts + +Use the dedupe visitor to flatten nested account structures: + +```javascript +import { instructionAccountsDedupeVisitor } from "@macalinao/codama-instruction-accounts-dedupe-visitor"; + +export default defineConfig({ + visitors: [ + instructionAccountsDedupeVisitor() + ] +}); +``` + +### Custom Renderers + +Use alternative renderers for different output formats: + +```javascript +import { renderJavaScriptEsmVisitor } from "@macalinao/codama-renderers-js-esm"; + +export default defineConfig({ + visitors: ({ idl }) => { + const codama = createFromIdls([idl]); + codama.accept(renderJavaScriptEsmVisitor("./src/generated")); + return []; + } +}); +``` \ No newline at end of file diff --git a/apps/docs/content/docs/packages/codama-instruction-accounts-dedupe-visitor.mdx b/apps/docs/content/docs/packages/codama-instruction-accounts-dedupe-visitor.mdx new file mode 100644 index 00000000..c505defe --- /dev/null +++ b/apps/docs/content/docs/packages/codama-instruction-accounts-dedupe-visitor.mdx @@ -0,0 +1,226 @@ +--- +title: "@macalinao/codama-instruction-accounts-dedupe-visitor" +description: Codama visitor for deduplicating and flattening instruction accounts from Anchor IDL +--- + +This package provides a Codama visitor that flattens nested account structures from Anchor IDLs while preserving relationships through naming conventions. + +## Installation + +```bash +bun add -D @macalinao/codama-instruction-accounts-dedupe-visitor +``` + +Or with npm: +```bash +npm install -D @macalinao/codama-instruction-accounts-dedupe-visitor +``` + +## Why Use This Package? + +Anchor IDL supports nested account structures where accounts can be grouped together. When converting these to Codama nodes, the nested structure needs to be flattened while preserving the relationship. This visitor: + +1. **Flattens Nested Accounts**: Converts nested account groups into flat structures +2. **Preserves Relationships**: Uses underscore-separated naming to maintain parent-child relationships +3. **Updates PDA Seeds**: Properly adjusts PDA seed references when accounts are flattened +4. **Maintains Type Safety**: Ensures all account references remain valid after flattening + +This addresses an [active issue in Codama](https://github.com/codama-idl/codama/issues/754) regarding nested account handling. + +## Usage + +### Basic Usage + +```typescript +import { instructionAccountsDedupeVisitor } from "@macalinao/codama-instruction-accounts-dedupe-visitor"; +import { rootNodeFromAnchor } from "@codama/nodes-from-anchor"; +import { visit } from "codama"; + +// Your Anchor IDL +const idl = /* your anchor IDL */; + +// Create the root node from Anchor IDL +const root = rootNodeFromAnchor(idl); + +// Apply the dedupe visitor +const visitor = instructionAccountsDedupeVisitor(idl); +const deduplicatedRoot = visit(root, visitor); +``` + +### With Coda Configuration + +Use it in your `coda.config.mjs`: + +```javascript +import { defineConfig } from "@macalinao/coda"; +import { instructionAccountsDedupeVisitor } from "@macalinao/codama-instruction-accounts-dedupe-visitor"; + +export default defineConfig({ + idlPath: "./idls/my_program.json", + outputDir: "./src/generated", + visitors: [ + instructionAccountsDedupeVisitor() + ] +}); +``` + +## How It Works + +The visitor transforms nested account structures through a multi-step process: + +1. **Traversing Account Groups**: Recursively processes nested account groups +2. **Prefixing Names**: Joins parent and child names with underscores +3. **Adjusting PDA Seeds**: Updates seed paths to match the flattened structure +4. **Preserving All Metadata**: Maintains all account properties and constraints + +### Example Transformation + +#### Before (Nested Structure) + +```typescript +{ + name: "mintAccounts", + accounts: [ + { + name: "mint", + isMut: false, + isSigner: false + }, + { + name: "metadata", + isMut: true, + isSigner: false + } + ] +} +``` + +#### After (Flattened Structure) + +```typescript +[ + { + name: "mintAccounts_mint", + isMut: false, + isSigner: false + }, + { + name: "mintAccounts_metadata", + isMut: true, + isSigner: false + } +] +``` + +### PDA Seed Updates + +When flattening accounts, PDA seeds are also updated to reflect the new structure: + +#### Before +```typescript +{ + seeds: [ + { + kind: "account", + path: "mintAccounts.mint" + } + ] +} +``` + +#### After +```typescript +{ + seeds: [ + { + kind: "account", + path: "mintAccounts_mint" + } + ] +} +``` + +## API Reference + +### instructionAccountsDedupeVisitor + +Creates a visitor that flattens nested instruction accounts: + +```typescript +function instructionAccountsDedupeVisitor(idl?: Idl): Visitor; +``` + +**Parameters:** +- `idl` (optional): The Anchor IDL to use for context during transformation + +**Returns:** +- A Codama visitor that can be applied to transform the AST + +## Use Cases + +### Complex Nested Structures + +Particularly useful for programs with deeply nested account structures: + +```typescript +// Handles multi-level nesting +{ + name: "tokenAccounts", + accounts: [ + { + name: "source", + accounts: [ + { name: "mint" }, + { name: "authority" } + ] + }, + { + name: "destination", + accounts: [ + { name: "mint" }, + { name: "authority" } + ] + } + ] +} + +// Becomes: +[ + { name: "tokenAccounts_source_mint" }, + { name: "tokenAccounts_source_authority" }, + { name: "tokenAccounts_destination_mint" }, + { name: "tokenAccounts_destination_authority" } +] +``` + +### Maintaining Compatibility + +The flattened structure maintains compatibility with the original Anchor program while providing a cleaner interface for client generation. + +## Best Practices + +1. **Apply Early**: Use this visitor early in your visitor chain to ensure other visitors work with the flattened structure +2. **Consistent Naming**: The underscore separator is consistent and predictable +3. **PDA References**: Always verify PDA seed references are correctly updated after flattening + +## Troubleshooting + +### Accounts Not Flattening + +Ensure you're passing the correct IDL and that it contains nested account structures: + +```typescript +// Check if your IDL has nested structures +const hasNested = idl.instructions.some(ix => + ix.accounts.some(acc => acc.accounts && acc.accounts.length > 0) +); +``` + +### PDA Seeds Not Updating + +The visitor automatically updates PDA seeds. If seeds aren't updating correctly, ensure they reference accounts using the dot notation (e.g., `parent.child`). + +## Related Packages + +- [@macalinao/coda](./coda) - Main CLI for client generation +- [@macalinao/codama-renderers-js-esm](./codama-renderers-js-esm) - ESM renderer for generated code \ No newline at end of file diff --git a/apps/docs/content/docs/packages/codama-rename-visitor.mdx b/apps/docs/content/docs/packages/codama-rename-visitor.mdx new file mode 100644 index 00000000..19228e8f --- /dev/null +++ b/apps/docs/content/docs/packages/codama-rename-visitor.mdx @@ -0,0 +1,299 @@ +--- +title: "@macalinao/codama-rename-visitor" +description: Codama visitor for renaming instructions, events, and types within Solana programs +--- + +This package provides flexible visitors for renaming instructions, events, and defined types in your Codama AST. It's particularly useful when you want to change naming conventions without modifying the original IDL. + +## Installation + +```bash +bun add -D @macalinao/codama-rename-visitor +``` + +Or with npm: +```bash +npm install -D @macalinao/codama-rename-visitor +``` + +## Why Use This Package? + +When working with Solana programs, you might need to: + +- **Avoid naming conflicts** between multiple programs +- **Follow consistent naming conventions** across your codebase +- **Add context** to generic instruction names +- **Maintain backward compatibility** while improving naming + +This visitor allows you to rename elements at the AST level, ensuring all references are updated correctly throughout the generated code. + +## Usage + +### Program-Specific Renaming (Recommended) + +The most powerful way to use this visitor is to specify renames for specific programs: + +```typescript +import { renameVisitor } from "@macalinao/codama-rename-visitor"; +import { visit } from "codama"; + +// Rename elements in specific programs +const visitor = renameVisitor({ + quarryMine: { + instructions: { + claimRewards: "claimRewardsMine" + } + }, + token: { + instructions: { + transfer: "transferTokens", + mint: "mintNft" + }, + events: { + tokenMinted: "nftMinted" + } + } +}); + +const updatedRoot = visit(root, visitor); +``` + +### With Coda Configuration + +Use it in your `coda.config.mjs`: + +```javascript +import { defineConfig } from "@macalinao/coda"; +import { renameVisitor } from "@macalinao/codama-rename-visitor"; + +export default defineConfig({ + idlPath: "./idls/*.json", + outputDir: "./src/generated", + visitors: [ + renameVisitor({ + quarryMine: { + instructions: { + // Avoid conflicts with quarryMergeMine + claimRewards: "claimRewardsMine", + claimRewardsV2: "claimRewardsMineV2" + } + }, + quarryMergeMine: { + instructions: { + // Give these distinct names + claimRewards: "claimRewardsMergeMine" + } + } + }) + ] +}); +``` + +### Renaming Specific Element Types + +For simpler use cases, you can rename just instructions or events across all programs: + +#### Rename Instructions Only + +```typescript +import { renameInstructionsVisitor } from "@macalinao/codama-rename-visitor"; + +const visitor = renameInstructionsVisitor({ + oldInstructionName: "newInstructionName", + transfer: "transferTokens", + mint: "mintNft" +}); + +const updatedRoot = visit(root, visitor); +``` + +#### Rename Events Only + +```typescript +import { renameEventsVisitor } from "@macalinao/codama-rename-visitor"; + +const visitor = renameEventsVisitor({ + oldEventName: "newEventName", + tokenMinted: "nftMinted", + transferComplete: "transferFinished" +}); + +const updatedRoot = visit(root, visitor); +``` + +### Legacy Single-Program Format + +For backward compatibility, you can use the legacy format for renaming in a single program: + +```typescript +import { renameVisitor } from "@macalinao/codama-rename-visitor"; + +// Legacy format: applies to the current program +const visitor = renameVisitor({ + instructions: { + transfer: "transferTokens", + mint: "mintNft" + }, + events: { + tokenMinted: "nftMinted", + transferComplete: "transferFinished" + }, + definedTypes: { + TokenMetadata: "NftMetadata" + } +}); +``` + +## API Reference + +### renameVisitor + +The main visitor for comprehensive renaming: + +```typescript +function renameVisitor( + config: RenameConfig | LegacyRenameConfig +): Visitor; + +// Program-specific renaming (recommended) +interface RenameConfig { + [programName: string]: ProgramRenameOptions; +} + +interface ProgramRenameOptions { + instructions?: Record; + events?: Record; + definedTypes?: Record; +} + +// Legacy single-program format +interface LegacyRenameConfig { + instructions?: Record; + events?: Record; + definedTypes?: Record; +} +``` + +### renameInstructionsVisitor + +Visitor for renaming only instructions: + +```typescript +function renameInstructionsVisitor( + mapping: Record +): Visitor; +``` + +**Parameters:** +- `mapping`: Object mapping old instruction names to new names + +### renameEventsVisitor + +Visitor for renaming only events (defined types): + +```typescript +function renameEventsVisitor( + mapping: Record +): Visitor; +``` + +**Parameters:** +- `mapping`: Object mapping old event names to new names + +## Use Cases + +### Avoiding Naming Conflicts + +When working with multiple related programs: + +```typescript +renameVisitor({ + // Quarry Mine program + quarryMine: { + instructions: { + createMiner: "createQuarryMiner", + stake: "stakeInQuarry" + } + }, + // Quarry Merge Mine program + quarryMergeMine: { + instructions: { + createMiner: "createMergeMiner", + stake: "stakeInMergePool" + } + } +}) +``` + +### Adding Context + +Make generic names more specific: + +```typescript +renameVisitor({ + token: { + instructions: { + transfer: "transferToken", + burn: "burnToken" + } + }, + nft: { + instructions: { + transfer: "transferNft", + burn: "burnNft" + } + } +}) +``` + +### Consistent Naming Conventions + +Enforce naming patterns across your codebase: + +```typescript +renameVisitor({ + myProgram: { + instructions: { + // Convert to camelCase + create_account: "createAccount", + update_metadata: "updateMetadata", + delete_record: "deleteRecord" + }, + events: { + // Add "Event" suffix + accountCreated: "accountCreatedEvent", + metadataUpdated: "metadataUpdatedEvent" + } + } +}) +``` + +## Best Practices + +1. **Use Program-Specific Renaming**: Always prefer the program-specific format to avoid unintended renames +2. **Document Renames**: Comment why certain renames are necessary +3. **Be Consistent**: Apply similar naming patterns across related programs +4. **Test Generated Code**: Verify that renamed elements work correctly in your client code + +## Troubleshooting + +### Renames Not Applied + +Ensure the visitor is added to your configuration and that names match exactly: + +```javascript +// Check that program names match your IDL +console.log(idl.metadata.name); // Should match keys in renameVisitor config +``` + +### Type Errors After Renaming + +Make sure all references are updated. The visitor handles most cases, but verify: +- Instruction builders use new names +- Event types use new names +- PDA derivations reference correct instruction names + +## Related Packages + +- [@macalinao/coda](./coda) - Main CLI for client generation +- [@macalinao/codama-instruction-accounts-dedupe-visitor](./codama-instruction-accounts-dedupe-visitor) - Flatten nested accounts \ No newline at end of file diff --git a/apps/docs/content/docs/packages/codama-renderers-js-esm.mdx b/apps/docs/content/docs/packages/codama-renderers-js-esm.mdx new file mode 100644 index 00000000..7c4c5a50 --- /dev/null +++ b/apps/docs/content/docs/packages/codama-renderers-js-esm.mdx @@ -0,0 +1,265 @@ +--- +title: "@macalinao/codama-renderers-js-esm" +description: ESM-native TypeScript renderer for Codama JavaScript code generation +--- + +This package extends Codama's JavaScript renderer to produce fully ESM-compatible TypeScript/JavaScript code with proper module resolution and improved type safety. + +## Installation + +```bash +bun add -D @macalinao/codama-renderers-js-esm +``` + +Or with npm: +```bash +npm install -D @macalinao/codama-renderers-js-esm +``` + +## Why Use This Package? + +While `@codama/renderers-js` generates excellent TypeScript code, it produces CommonJS-style imports that may not work correctly in pure ESM environments. This package addresses: + +1. **ESM Module Resolution**: Adds `.js` extensions to all relative imports +2. **TypeScript ESM Compatibility**: Works correctly with `"type": "module"` +3. **Production-Ready Code**: Removes Node.js-specific environment checks +4. **Type Safety Improvements**: Enhanced type assertions and null checks + +## Usage + +### Basic Usage + +Use this visitor in place of the standard Codama JavaScript renderer: + +```typescript +import { renderESMTypeScriptVisitor } from "@macalinao/codama-renderers-js-esm"; +import { rootNode, visit } from "codama"; + +// Your Codama root node (typically from parsing an IDL) +const root = rootNode(/* ... */); + +// Generate ESM-compatible TypeScript code +const visitor = renderESMTypeScriptVisitor("./src/generated"); +visit(root, visitor); +``` + +### With Coda Configuration + +This renderer is used by default in Coda, but you can explicitly configure it: + +```javascript +import { defineConfig } from "@macalinao/coda"; +import { renderESMTypeScriptVisitor } from "@macalinao/codama-renderers-js-esm"; + +export default defineConfig({ + idlPath: "./idls/my_program.json", + outputDir: "./src/generated", + visitors: ({ idl }) => { + // Custom rendering configuration + const visitor = renderESMTypeScriptVisitor("./src/generated", { + // Custom options if needed + }); + return [visitor]; + } +}); +``` + +## Key Features + +### 1. Automatic Import Extensions + +All relative imports automatically get `.js` extensions: + +#### Before (Standard Renderer) +```typescript +import { Address } from "@solana/web3.js"; +import { SomeType } from "./types"; +import { decodeAccount } from "./accounts"; +export * from "./instructions"; +``` + +#### After (ESM Renderer) +```typescript +import { Address } from "@solana/web3.js"; +import { SomeType } from "./types/index.js"; +import { decodeAccount } from "./accounts/index.js"; +export * from "./instructions/index.js"; +``` + +### 2. Directory Import Resolution + +Bare directory imports are converted to explicit index imports: + +```typescript +// Before +import { something } from "./utils"; + +// After +import { something } from "./utils/index.js"; +``` + +### 3. Strict Null Checks + +Loose equality checks are replaced with strict checks: + +```typescript +// Before +if (value == null) { /* ... */ } + +// After +if (value === null || value === undefined) { /* ... */ } +``` + +### 4. Universal JavaScript Compatibility + +Removes Node.js-specific code for broader runtime support: + +```typescript +// Removed: Node.js-specific environment checks +// Works in: Browser, Deno, Bun, Node.js, etc. +``` + +## Comparison with Standard Renderer + +| Feature | @codama/renderers-js | @macalinao/codama-renderers-js-esm | +|---------|----------------------|-------------------------------------| +| Module Format | CommonJS-compatible | Pure ESM | +| Import Extensions | No extensions | `.js` extensions | +| TypeScript Config | Standard | ESM-native | +| Runtime Checks | Node.js-specific | Universal | +| Null Checks | Loose (`==`) | Strict (`===`) | +| Tree Shaking | Good | Excellent | + +## Configuration + +### TypeScript Configuration + +Ensure your `tsconfig.json` is configured for ESM: + +```json +{ + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "target": "ES2022", + "allowImportingTsExtensions": false, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + } +} +``` + +### Package.json Configuration + +Your package.json should specify ESM: + +```json +{ + "type": "module", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + } +} +``` + +## API Reference + +### renderESMTypeScriptVisitor + +Creates a visitor that renders ESM-compatible TypeScript: + +```typescript +function renderESMTypeScriptVisitor( + outputDir: string, + options?: RenderOptions +): Visitor; + +interface RenderOptions { + // Inherits all options from @codama/renderers-js + // Additional ESM-specific options may be added +} +``` + +**Parameters:** +- `outputDir`: Directory where files will be generated +- `options`: Optional configuration for the renderer + +## How It Works + +The package applies a series of transformations: + +### 1. Custom Dependency Map + +Provides ESM-specific import paths: + +```typescript +{ + errors: "../errors/index.js", + generatedAccounts: "../accounts/index.js", + generatedInstructions: "../instructions/index.js", + generatedTypes: "../types/index.js", + generatedPdas: "../pdas/index.js", + hooked: "../../hooked/index.js", + shared: "../shared/index.js" +} +``` + +### 2. Import Path Transformations + +- Adds `.js` to imports without extensions +- Converts directory imports to `index.js` +- Preserves external package imports + +### 3. Code Quality Improvements + +- Replaces loose equality with strict equality +- Improves type assertions +- Removes runtime-specific checks + +## Best Practices + +1. **Use with ESM Projects**: This renderer is designed for ESM-first projects +2. **Configure TypeScript Properly**: Ensure your tsconfig supports ESM +3. **Test in Target Environment**: Verify generated code works in your runtime +4. **Combine with Other Visitors**: Works well with other Codama visitors + +## Troubleshooting + +### Import Errors + +If you see "Cannot find module" errors: + +1. Verify all imports have `.js` extensions +2. Check that `"type": "module"` is in package.json +3. Ensure TypeScript module resolution is correct + +### Type Resolution Issues + +For TypeScript type resolution: + +```json +// tsconfig.json +{ + "compilerOptions": { + "moduleResolution": "bundler", + // or "node16" / "nodenext" for Node.js + } +} +``` + +### Build Tool Compatibility + +Works with modern build tools: +- **Vite**: Full support out of the box +- **esbuild**: Works with ESM configuration +- **Rollup**: Native ESM support +- **Webpack 5**: Configure for ESM output + +## Related Packages + +- [@macalinao/coda](./coda) - Main CLI using this renderer by default +- [@codama/renderers-js](https://github.com/codama-idl/codama) - Original JavaScript renderer +- [@macalinao/codama-renderers-markdown](./codama-renderers-markdown) - Markdown documentation renderer \ No newline at end of file diff --git a/apps/docs/content/docs/packages/codama-renderers-markdown.mdx b/apps/docs/content/docs/packages/codama-renderers-markdown.mdx new file mode 100644 index 00000000..f4286526 --- /dev/null +++ b/apps/docs/content/docs/packages/codama-renderers-markdown.mdx @@ -0,0 +1,431 @@ +--- +title: "@macalinao/codama-renderers-markdown" +description: Codama visitor that renders comprehensive markdown documentation from Solana program IDLs +--- + +This package generates beautiful, comprehensive markdown documentation from your Solana program IDLs using the Codama AST. + +## Why Use This Package? + +Documentation is critical for Solana program adoption, but manually maintaining API docs is time-consuming and error-prone. This package solves these problems by: + +- **Eliminating Documentation Drift**: Your docs always match your deployed program since they're generated from the same IDL +- **Providing Complete Coverage**: Every instruction, account, type, and error is automatically documented +- **Saving Development Time**: No more manually writing and updating API documentation +- **Ensuring Consistency**: All programs in your project follow the same documentation format +- **Enabling Better Developer Experience**: Well-documented programs get more adoption + +## Live Examples + +See real documentation generated by this package: + +### [Quarry Protocol Documentation](https://coda-docs.vercel.app/docs/api/clients/quarry) + +The Quarry staking protocol documentation showcases the comprehensive output: +- **[60+ Instructions](https://coda-docs.vercel.app/docs/api/clients/quarry/instructions)** - Every instruction with full parameter documentation +- **[Account Structures](https://coda-docs.vercel.app/docs/api/clients/quarry/accounts)** - All accounts with field descriptions and sizes +- **[PDA Derivations](https://coda-docs.vercel.app/docs/api/clients/quarry/pdas)** - Program-derived addresses with seed definitions +- **[Custom Types](https://coda-docs.vercel.app/docs/api/clients/quarry/types)** - All custom types and enums +- **[Error Codes](https://coda-docs.vercel.app/docs/api/clients/quarry/errors)** - Every error with code and message + +### [Token Metadata Documentation](https://coda-docs.vercel.app/docs/api/clients/token-metadata) + +Metaplex Token Metadata program documentation demonstrating complex type handling. + +All this documentation is generated automatically with zero manual editing required! + +## Installation + +```bash +bun add -D @macalinao/codama-renderers-markdown +``` + +Or with npm: +```bash +npm install -D @macalinao/codama-renderers-markdown +``` + +## Quick Start with Coda CLI + +The easiest way to use this package is through the [Coda CLI](https://coda.ianm.com), which includes built-in documentation generation: + +```bash +# Install Coda CLI +bun add -D @macalinao/coda + +# Generate both TypeScript client and markdown docs +coda generate --docs + +# Or just generate documentation +coda docs +``` + +Learn more about Coda at [coda.ianm.com](https://coda.ianm.com). + +## Usage + +### Basic Usage + +Generate markdown documentation from your IDL: + +```typescript +import { renderMarkdownVisitor } from "@macalinao/codama-renderers-markdown"; +import { rootNodeFromAnchor } from "@codama/nodes-from-anchor"; +import { visit } from "codama"; +import fs from "fs"; + +// Load your IDL +const idl = JSON.parse(fs.readFileSync("path/to/idl.json", "utf-8")); + +// Create Codama root node +const root = rootNodeFromAnchor(idl); + +// Generate markdown documentation +visit(root, renderMarkdownVisitor("./docs")); +``` + +### With Coda Configuration + +Use it alongside TypeScript generation: + +```javascript +import { defineConfig } from "@macalinao/coda"; +import { renderMarkdownVisitor } from "@macalinao/codama-renderers-markdown"; + +export default defineConfig({ + idlPath: "./idls/my_program.json", + outputDir: "./src/generated", + visitors: [ + // Generate both TypeScript and documentation + renderMarkdownVisitor("./docs/api") + ] +}); +``` + +### With Custom Options + +Configure the output format: + +```typescript +const visitor = renderMarkdownVisitor("./docs", { + // Format program addresses (e.g., link to explorer) + formatAddress: (address) => + `[${address}](https://explorer.solana.com/address/${address})`, + + // Control table of contents generation + renderTableOfContents: true, +}); +``` + +## Generated Documentation Structure + +The renderer creates a comprehensive markdown file with the following sections: + +### 1. Program Overview + +```markdown +# Program Name + +Program description from IDL metadata + +**Program ID:** `11111111111111111111111111111111` +``` + +### 2. Table of Contents + +Automatically generated with links to all sections: + +```markdown +## Table of Contents + +- [Accounts](#accounts) + - [TokenAccount](#tokenaccount) + - [Metadata](#metadata) +- [Instructions](#instructions) + - [Transfer](#transfer) + - [Mint](#mint) +- [PDAs](#pdas) + - [Authority](#authority) +- [Types](#types) +- [Errors](#errors) +``` + +### 3. Accounts Section + +Detailed documentation for each account: + +```markdown +## Accounts + +### TokenAccount + +Token account storing balance and owner information + +| Field | Type | Description | +|-------|------|-------------| +| mint | `PublicKey` | Token mint address | +| owner | `PublicKey` | Account owner | +| amount | `u64` | Token balance | + +**Size:** 165 bytes +**Discriminator:** `[1, 2, 3, 4, 5, 6, 7, 8]` +``` + +### 4. Instructions Section + +Complete instruction documentation: + +```markdown +## Instructions + +### Transfer + +Transfer tokens between accounts + +#### Accounts + +| Name | Type | Description | +|------|------|-------------| +| source | `mut` | Source token account | +| destination | `mut` | Destination token account | +| authority | `signer` | Transfer authority | + +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| amount | `u64` | Amount to transfer | +``` + +### 5. PDAs Section + +Program-derived address documentation: + +```markdown +## PDAs + +### Authority + +Derives the program authority address + +**Seeds:** +- `"authority"` (constant) +- `user` (PublicKey) +- `mint` (PublicKey) +``` + +### 6. Types Section + +Custom type definitions: + +```markdown +## Types + +### TokenMetadata + +```typescript +type TokenMetadata = { + name: string; + symbol: string; + uri: string; + decimals: u8; +} +``` + +### 7. Errors Section + +Program error codes: + +```markdown +## Errors + +| Code | Name | Message | +|------|------|---------| +| 6000 | InvalidAmount | The provided amount is invalid | +| 6001 | Unauthorized | Unauthorized access attempt | +``` + +## API Reference + +### renderMarkdownVisitor + +Creates a visitor that renders markdown documentation: + +```typescript +function renderMarkdownVisitor( + outputDir: string, + options?: MarkdownOptions +): Visitor; + +interface MarkdownOptions { + // Format addresses in the output + formatAddress?: (address: string) => string; + + // Whether to render table of contents (default: true) + renderTableOfContents?: boolean; +} +``` + +**Parameters:** +- `outputDir`: Directory where markdown files will be generated +- `options`: Optional configuration for formatting + +## Features + +### Comprehensive Coverage + +Documents all aspects of your program: +- ✅ Accounts with all fields and metadata +- ✅ Instructions with accounts and arguments +- ✅ PDAs with seed definitions +- ✅ Custom types and enums +- ✅ Error codes and messages +- ✅ Program metadata and IDs + +### Formatted Output + +- **Tables** for structured data +- **Code blocks** for type definitions +- **Links** between related sections +- **Descriptions** from IDL documentation +- **Size calculations** for accounts +- **Discriminators** for account identification + +### TypeScript-Style Types + +Types are rendered in familiar TypeScript syntax: + +```typescript +type TransferArgs = { + amount: bigint; + memo?: string; +} +``` + +## Use Cases + +### Documentation Sites + +Generate API documentation for your documentation site: + +```bash +# Generate docs +coda generate-docs + +# Use with MkDocs, Docusaurus, etc. +cp ./docs/api.md ./website/docs/ +``` + +### GitHub README + +Include generated documentation in your repository: + +```javascript +// In your build script +visit(root, renderMarkdownVisitor("./")); +// Creates README.md with full API docs +``` + +### Multiple Programs + +Document multiple programs in one project: + +```javascript +// For each program +programs.forEach(program => { + const root = rootNodeFromAnchor(program.idl); + visit(root, renderMarkdownVisitor( + `./docs/${program.name}` + )); +}); +``` + +## Best Practices + +1. **Keep IDL Descriptions Updated**: Add descriptions to your Anchor program for better docs +2. **Use Semantic Names**: Clear naming improves generated documentation +3. **Version Your Docs**: Generate docs for each program version +4. **Link to Examples**: Add links to usage examples in your custom sections + +## Example Output + +Here's a snippet of generated documentation: + +```markdown +# Token Program + +A standard SPL token program implementation + +**Program ID:** `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` + +## Instructions + +### Transfer + +Transfers tokens from one account to another + +#### Accounts + +| Name | Type | Description | +|------|------|-------------| +| source | `mut` | Source token account | +| destination | `mut` | Destination token account | +| authority | `signer` | Account owner or delegate | + +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| amount | `u64` | Number of tokens to transfer | + +--- +``` + +## Integration with Coda + +This renderer integrates seamlessly with Coda's `generate-docs` command: + +```bash +# Generate both TypeScript client and markdown docs +coda generate --docs + +# Or just generate documentation +coda generate-docs +``` + +## Troubleshooting + +### Missing Descriptions + +If descriptions are missing, add them to your Anchor program: + +```rust +/// Token account storing user balances +#[account] +pub struct TokenAccount { + /// Token mint address + pub mint: Pubkey, + /// Account owner + pub owner: Pubkey, +} +``` + +### Large Output Files + +For very large programs, consider splitting documentation: + +```typescript +// Split by component type +visit(root, renderMarkdownVisitor("./docs/accounts", { + components: ["accounts"] +})); +visit(root, renderMarkdownVisitor("./docs/instructions", { + components: ["instructions"] +})); +``` + +## Related Packages + +- [@macalinao/coda](./coda) - Main CLI for client generation +- [@macalinao/codama-renderers-js-esm](./codama-renderers-js-esm) - TypeScript client renderer +- [@codama/nodes-from-anchor](https://github.com/codama-idl/codama) - Parse Anchor IDLs \ No newline at end of file diff --git a/apps/docs/content/docs/packages/index.mdx b/apps/docs/content/docs/packages/index.mdx new file mode 100644 index 00000000..018a0558 --- /dev/null +++ b/apps/docs/content/docs/packages/index.mdx @@ -0,0 +1,60 @@ +--- +title: Packages +description: Core packages that power Coda's client generation capabilities +--- + +Coda is built as a modular system of packages that work together to generate high-quality TypeScript clients from Solana IDLs. Each package serves a specific purpose in the generation pipeline. + +## Core Packages + +### [@macalinao/coda](/docs/packages/coda) +The main CLI tool for generating TypeScript clients from Anchor IDLs. Provides zero-config defaults and extensible configuration. + +### [@macalinao/codama-instruction-accounts-dedupe-visitor](/docs/packages/codama-instruction-accounts-dedupe-visitor) +Flattens nested account structures from Anchor IDLs while preserving relationships through naming conventions. + +### [@macalinao/codama-rename-visitor](/docs/packages/codama-rename-visitor) +Provides utilities for renaming nodes in the Codama AST, useful for customizing generated code naming. + +### [@macalinao/codama-renderers-js-esm](/docs/packages/codama-renderers-js-esm) +ESM-native TypeScript renderer that generates modern JavaScript modules with proper `.js` extensions. + +### [@macalinao/codama-renderers-markdown](/docs/packages/codama-renderers-markdown) +Generates comprehensive Markdown documentation from Codama AST nodes, perfect for API documentation. + +## Package Architecture + +Each package in the Coda ecosystem follows a consistent structure: + +- **TypeScript-first**: All packages are written in TypeScript with full type safety +- **ES Modules**: Uses modern JavaScript modules with `"type": "module"` +- **Simple builds**: Direct `tsc` compilation without complex bundling +- **Consistent scripts**: Standardized `build`, `test`, `lint` commands + +## Installation + +Each package can be installed individually based on your needs: + +```bash +# Install the main CLI +bun add -D @macalinao/coda + +# Install specific visitors +bun add -D @macalinao/codama-instruction-accounts-dedupe-visitor +bun add -D @macalinao/codama-renderers-js-esm +``` + +## Contributing + +All packages follow the same development workflow: + +```bash +# Build the package +bun run build + +# Run tests +bun test + +# Fix linting issues +bun run lint:fix +``` \ No newline at end of file diff --git a/apps/docs/content/docs/packages/meta.json b/apps/docs/content/docs/packages/meta.json new file mode 100644 index 00000000..d595801b --- /dev/null +++ b/apps/docs/content/docs/packages/meta.json @@ -0,0 +1,14 @@ +{ + "title": "Packages", + "pages": [ + "index", + "---Core Package---", + "coda", + "---Visitors---", + "codama-instruction-accounts-dedupe-visitor", + "codama-rename-visitor", + "---Renderers---", + "codama-renderers-js-esm", + "codama-renderers-markdown" + ] +} diff --git a/apps/docs/package.json b/apps/docs/package.json index c20643c4..0b299bf5 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -1,5 +1,6 @@ { "name": "coda-docs", + "description": "Documentation site for Coda", "version": "0.0.2", "private": true, "license": "Apache-2.0", @@ -10,23 +11,23 @@ "postinstall": "fumadocs-mdx" }, "dependencies": { + "fumadocs-core": "15.7.0", + "fumadocs-mdx": "11.8.0", + "fumadocs-ui": "15.7.0", "next": "15.5.0", "react": "^19.1.1", - "react-dom": "^19.1.1", - "fumadocs-ui": "15.7.0", - "fumadocs-core": "15.7.0", - "fumadocs-mdx": "11.8.0" + "react-dom": "^19.1.1" }, "devDependencies": { + "@tailwindcss/postcss": "^4.1.12", + "@types/mdx": "^2.0.13", "@types/node": "24.3.0", - "@types/react": "^19.1.10", + "@types/react": "^19.1.11", "@types/react-dom": "^19.1.7", - "typescript": "^5.9.2", - "@types/mdx": "^2.0.13", - "@tailwindcss/postcss": "^4.1.12", - "tailwindcss": "^4.1.12", + "eslint": "^8.57.1", + "eslint-config-next": "15.5.0", "postcss": "^8.5.6", - "eslint": "^8", - "eslint-config-next": "15.5.0" + "tailwindcss": "^4.1.12", + "typescript": "^5.9.2" } } diff --git a/bun.lock b/bun.lock index 523273ff..78ef8c28 100644 --- a/bun.lock +++ b/bun.lock @@ -2,14 +2,11 @@ "lockfileVersion": 1, "workspaces": { "": { - "name": "@macalinao/grill-monorepo", - "dependencies": { - "dnum": "^2.15.0", - }, + "name": "@macalinao/coda-monorepo", "devDependencies": { "@biomejs/biome": "^2.2.0", "@changesets/cli": "^2.29.6", - "eslint": "^9.33.0", + "eslint": "^9.34.0", "glob": "^11.0.3", "husky": "^9.1.7", "lint-staged": "^16.1.5", @@ -33,15 +30,30 @@ "@tailwindcss/postcss": "^4.1.12", "@types/mdx": "^2.0.13", "@types/node": "24.3.0", - "@types/react": "^19.1.10", + "@types/react": "^19.1.11", "@types/react-dom": "^19.1.7", - "eslint": "^8", + "eslint": "^8.57.1", "eslint-config-next": "15.5.0", "postcss": "^8.5.6", "tailwindcss": "^4.1.12", "typescript": "^5.9.2", }, }, + "clients/kamino-lending": { + "name": "@macalinao/clients-kamino-lending", + "version": "0.0.1", + "devDependencies": { + "@macalinao/coda": "workspace:*", + "@macalinao/eslint-config": "catalog:", + "@macalinao/tsconfig": "catalog:", + "@solana/kit": "*", + "eslint": "catalog:", + "typescript": "catalog:", + }, + "peerDependencies": { + "@solana/kit": "*", + }, + }, "clients/quarry": { "name": "@macalinao/clients-quarry", "version": "0.1.2", @@ -51,7 +63,6 @@ "@macalinao/eslint-config": "catalog:", "@macalinao/tsconfig": "catalog:", "@solana/kit": "*", - "codama": "*", "eslint": "catalog:", "typescript": "catalog:", }, @@ -67,7 +78,6 @@ "@macalinao/eslint-config": "catalog:", "@macalinao/tsconfig": "catalog:", "@solana/kit": "*", - "codama": "*", "eslint": "catalog:", "typescript": "catalog:", }, @@ -82,10 +92,12 @@ "coda": "./dist/bin/cli.js", }, "dependencies": { - "@codama/nodes-from-anchor": "*", + "@codama/nodes-from-anchor": "catalog:", + "@macalinao/codama-nodes-from-anchor-x": "workspace:*", + "@macalinao/codama-rename-visitor": "workspace:*", "@macalinao/codama-renderers-js-esm": "workspace:*", "@macalinao/codama-renderers-markdown": "workspace:*", - "codama": "*", + "codama": "catalog:", "commander": "^14.0.0", "glob": "^11.0.3", }, @@ -102,8 +114,8 @@ "name": "@macalinao/codama-instruction-accounts-dedupe-visitor", "version": "0.2.1", "dependencies": { - "@codama/nodes-from-anchor": "*", - "codama": "*", + "@codama/nodes-from-anchor": "catalog:", + "codama": "catalog:", }, "devDependencies": { "@macalinao/eslint-config": "catalog:", @@ -112,11 +124,25 @@ "typescript": "catalog:", }, }, + "packages/codama-nodes-from-anchor-x": { + "name": "@macalinao/codama-nodes-from-anchor-x", + "version": "0.0.1", + "dependencies": { + "@codama/nodes": "catalog:", + "@codama/nodes-from-anchor": "catalog:", + "@macalinao/codama-instruction-accounts-dedupe-visitor": "^0.2.1", + "codama": "catalog:", + }, + "devDependencies": { + "@types/bun": "latest", + "typescript": "^5.9.2", + }, + }, "packages/codama-rename-visitor": { "name": "@macalinao/codama-rename-visitor", "version": "0.1.1", "dependencies": { - "codama": "*", + "codama": "catalog:", }, "devDependencies": { "@macalinao/eslint-config": "catalog:", @@ -129,9 +155,9 @@ "name": "@macalinao/codama-renderers-js-esm", "version": "0.2.1", "dependencies": { - "@codama/renderers-core": "*", - "@codama/renderers-js": "*", - "codama": "*", + "@codama/renderers-core": "catalog:", + "@codama/renderers-js": "catalog:", + "codama": "catalog:", }, "devDependencies": { "@macalinao/eslint-config": "catalog:", @@ -144,18 +170,18 @@ "name": "@macalinao/codama-renderers-markdown", "version": "0.1.1", "dependencies": { - "@codama/errors": "^1.0.2", - "@codama/nodes": "^1.0.2", - "@codama/renderers-core": "^1.0.2", - "@codama/visitors-core": "^1.0.2", - "codama": "^1.0.2", - "prettier": "^3.0.0", + "@codama/errors": "catalog:", + "@codama/nodes": "catalog:", + "@codama/renderers-core": "catalog:", + "@codama/visitors-core": "catalog:", + "codama": "catalog:", + "prettier": "^3.6.2", }, "devDependencies": { - "@macalinao/eslint-config": "^5.0.1", - "@macalinao/tsconfig": "^3.2.3", - "@types/bun": "^1.1.0", - "typescript": "^5.5.4", + "@macalinao/eslint-config": "catalog:", + "@macalinao/tsconfig": "catalog:", + "@types/bun": "catalog:", + "typescript": "catalog:", }, }, }, @@ -164,6 +190,15 @@ "react-dom": "^19.1.1", }, "catalog": { + "@codama/errors": "^1.1.3", + "@codama/node-types": "^1.1.3", + "@codama/nodes": "^1.3.3", + "@codama/nodes-from-anchor": "^1.2.5", + "@codama/renderers-core": "^1.0.19", + "@codama/renderers-js": "^1.3.4", + "@codama/validators": "^1.1.3", + "@codama/visitors": "^1.1.3", + "@codama/visitors-core": "^1.3.3", "@macalinao/eslint-config": "^5", "@macalinao/tsconfig": "^3.2.3", "@solana/kit": "^2.3.0", @@ -173,6 +208,7 @@ "@types/bun": "^1.2.20", "@types/react": "^19.1.10", "@types/react-dom": "^19.1.7", + "codama": "^1.3.3", "eslint": "^9.33.0", "gill": "^0.10.3", "gill-react": "^0.5.0", @@ -238,23 +274,25 @@ "@changesets/write": ["@changesets/write@0.4.0", "", { "dependencies": { "@changesets/types": "^6.1.0", "fs-extra": "^7.0.1", "human-id": "^4.1.1", "prettier": "^2.7.1" } }, "sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q=="], - "@codama/errors": ["@codama/errors@1.3.1", "", { "dependencies": { "@codama/node-types": "1.3.1", "chalk": "^5.4.1", "commander": "^14.0.0" }, "bin": { "errors": "bin/cli.cjs" } }, "sha512-tsQ83+8RRV7lXcRuSqRZJCjEM0gsVGo4PXAKL9dokUJzSTMMPQU4y87ExUps5KjeXQf6MkfOzYnGKqGf4FtU4g=="], + "@codama/cli": ["@codama/cli@1.3.1", "", { "dependencies": { "@codama/nodes": "1.3.3", "@codama/visitors": "1.3.3", "@codama/visitors-core": "1.3.3", "commander": "^14.0.0", "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "bin": { "codama": "bin/cli.cjs" } }, "sha512-3m84aErp6W0cFIArYh9Ymzp2QFFHL+zFx/QS8R8piBjkA/WbSTdslZnierBBqgXkoSM6uIqvm008DSvo3gj1LA=="], - "@codama/node-types": ["@codama/node-types@1.3.1", "", {}, "sha512-tpZwqOnCNXs1aLj95+ZjQW3K96LkiekqsYFTmuJxgspWoR3Ro+NDQEoxD3j5364hIYt0VfjcZlAcFD6y95GaQA=="], + "@codama/errors": ["@codama/errors@1.3.3", "", { "dependencies": { "@codama/node-types": "1.3.3", "chalk": "^5.5.0", "commander": "^14.0.0" }, "bin": { "errors": "bin/cli.cjs" } }, "sha512-iyo5qEW/rgNTTtcZnGqahcnUtMHRRTlTzeTZo6SLpuNistbEn2itOssnklNZVClhXR/4Td0riHwGedP3AjwgJA=="], - "@codama/nodes": ["@codama/nodes@1.3.1", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/node-types": "1.3.1" } }, "sha512-ipmZFoX8Q7+2tKLOrTwcZ4R9eurhDyPU/oZ8I+2jNAuFEEW5mUewdNdeCt8xcq+vduovAd2BuvC3eJp2WbohCQ=="], + "@codama/node-types": ["@codama/node-types@1.3.3", "", {}, "sha512-41GdFy/OPRemXTAmptDSi/wDXHPimy40mx9v0z2EdIMNYEyKAYZDcvr2jzSei8meeCV9j4PgKF5snwBQK7HaSg=="], - "@codama/nodes-from-anchor": ["@codama/nodes-from-anchor@1.2.3", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/visitors": "1.3.1", "@noble/hashes": "^1.8.0", "@solana/codecs": "^2.3.0" } }, "sha512-0ALDfHPGqYZLk86LBZ3LVR3dHiJm0h1VsqLHlM7wF/Gikt4z4bKR/vld/3larAt80HFNxptLB0zDGy513jhY8Q=="], + "@codama/nodes": ["@codama/nodes@1.3.3", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/node-types": "1.3.3" } }, "sha512-CgxGfH6ndcZpvf+RfVwSyIOyq8cNejbqY9TRr4SqVMIEbE1Wpqx+GPrEGRKtwHgB8KqsWCz7Pve8BCGhsPkr2g=="], - "@codama/renderers-core": ["@codama/renderers-core@1.0.17", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/visitors-core": "1.3.1" } }, "sha512-pH0tyCrkhmmc84V5kAfXAiaTn+FPPW8nM530cZWneWr2q12frgmCtmIwrGcRKyqDPnS/dJ05P+y/TOZMit+Ldg=="], + "@codama/nodes-from-anchor": ["@codama/nodes-from-anchor@1.2.5", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/visitors": "1.3.3", "@noble/hashes": "^1.8.0", "@solana/codecs": "^2.3.0" } }, "sha512-d13zrDEMtFKYFwFAshcFegXskns82E3n5wjmyvxk3gJcXVOVVX8nAyFIe1nOAVzffbN73cwPrpv57SzOFwRz1A=="], - "@codama/renderers-js": ["@codama/renderers-js@1.3.2", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/renderers-core": "1.0.17", "@codama/visitors-core": "1.3.1", "@solana/codecs-strings": "^2.3.0", "nunjucks": "^3.2.4", "prettier": "^3.6.2" } }, "sha512-LDYurCw+rWVMlRiZSClQFYdV52TmEMjMBsP3HBUID4I0WQcZhQYzlnQEQbasnlBSHuVOLvjGEMztC7g2yioZIg=="], + "@codama/renderers-core": ["@codama/renderers-core@1.0.19", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/visitors-core": "1.3.3" } }, "sha512-ARvgw8ObOMiIbeahcKBpWKl2N4lYaywDOAsbYDjr/zV8jpPll39TVidgQt0lP4JjdGz7xZTBCmQmtxW5hqr9pA=="], - "@codama/validators": ["@codama/validators@1.3.1", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/visitors-core": "1.3.1" } }, "sha512-xgPz3dzUirrS+qkxQpFHm+g4WhUW8ff7wfgjzZEVnaMrc8qKhOPgFO8b0WwPVZSytUMTdhqIpa+zLNZg8vvzNw=="], + "@codama/renderers-js": ["@codama/renderers-js@1.3.4", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/renderers-core": "1.0.19", "@codama/visitors-core": "1.3.3", "@solana/codecs-strings": "^2.3.0", "nunjucks": "^3.2.4", "prettier": "^3.6.2" } }, "sha512-srcHHCc7l2FXTlUEoPOolw0bmxBkdyqpzOGtBNc7eeF9sOCE3mlR84qXzxoqCKx4T26wl+QHihI0wby0bMlfrA=="], - "@codama/visitors": ["@codama/visitors@1.3.1", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/visitors-core": "1.3.1" } }, "sha512-C6JZB9HrsPw7ZFogU+b8S7yRqznHpDuskyCY3103ZLknNs0SadOrry22ITQrS3Q3TETGGu3LOk8nu86CuLYl/Q=="], + "@codama/validators": ["@codama/validators@1.3.3", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/visitors-core": "1.3.3" } }, "sha512-dj3vlwMlxU57l6cRLxb76ZwlrEGv+dq7llDtH0aqc1z3OW5SOryREUuzeqL7T/2hY8FiY+pxjH4CQx+A08hULQ=="], - "@codama/visitors-core": ["@codama/visitors-core@1.3.1", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "json-stable-stringify": "^1.3.0" } }, "sha512-dlwzywaJEKO22QC/E3LpfVqNbSkTBXzFVR6pSGhWan/MNn//UR5+jyp3bFIKr+KPFDq+czilgFvFvllq5XFAXw=="], + "@codama/visitors": ["@codama/visitors@1.3.3", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/visitors-core": "1.3.3" } }, "sha512-ReZoo0kItffkhpvl9qRjy3HV1nZXv/k8p4wZ10NveUTDtRghk72YkY0kpK2lt/p+2SlWrhQ9IkO4Q+EQoqABrA=="], + + "@codama/visitors-core": ["@codama/visitors-core@1.3.3", "", { "dependencies": { "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "json-stable-stringify": "^1.3.0" } }, "sha512-Kuz2we5iDhq0Y9bPwEjEGGSueBPJkLxoDkJ+Z3NuHlqo/k2aHvDNl9NaoOOUPwNzPVbntfpJW9Ga3pP9oc/PQQ=="], "@emnapi/core": ["@emnapi/core@1.4.5", "", { "dependencies": { "@emnapi/wasi-threads": "1.0.4", "tslib": "^2.4.0" } }, "sha512-XsLw1dEOpkSX/WucdqUhPWP7hDxSvZiY+fsUC14h+FtQ2Ifni4znbBt8punRX+Uj2JG/uDb8nEHVKvrVlvdZ5Q=="], @@ -326,7 +364,7 @@ "@eslint/eslintrc": ["@eslint/eslintrc@3.3.1", "", { "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^10.0.1", "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" } }, "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ=="], - "@eslint/js": ["@eslint/js@9.33.0", "", {}, "sha512-5K1/mKhWaMfreBGJTwval43JJmkip0RmM+3+IuqupeSKNC/Th2Kc7ucaq5ovTSra/OOKB9c58CGSz3QMVbWt0A=="], + "@eslint/js": ["@eslint/js@9.34.0", "", {}, "sha512-EoyvqQnBNsV1CWaEJ559rxXL4c8V92gxirbawSmVUOWXlsRxxQXl6LmCpdUblgxgSkDIqKnhzba2SjRTI/A5Rw=="], "@eslint/object-schema": ["@eslint/object-schema@2.1.6", "", {}, "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA=="], @@ -334,9 +372,9 @@ "@floating-ui/core": ["@floating-ui/core@1.7.3", "", { "dependencies": { "@floating-ui/utils": "^0.2.10" } }, "sha512-sGnvb5dmrJaKEZ+LDIpguvdX3bDlEllmv4/ClQ9awcmCZrlx5jQyyMWFM5kBI+EyNOCDDiKk8il0zeuX3Zlg/w=="], - "@floating-ui/dom": ["@floating-ui/dom@1.7.3", "", { "dependencies": { "@floating-ui/core": "^1.7.3", "@floating-ui/utils": "^0.2.10" } }, "sha512-uZA413QEpNuhtb3/iIKoYMSK07keHPYeXF02Zhd6e213j+d1NamLix/mCLxBUDW/Gx52sPH2m+chlUsyaBs/Ag=="], + "@floating-ui/dom": ["@floating-ui/dom@1.7.4", "", { "dependencies": { "@floating-ui/core": "^1.7.3", "@floating-ui/utils": "^0.2.10" } }, "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA=="], - "@floating-ui/react-dom": ["@floating-ui/react-dom@2.1.5", "", { "dependencies": { "@floating-ui/dom": "^1.7.3" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-HDO/1/1oH9fjj4eLgegrlH3dklZpHtUYYFiVwMUwfGvk9jWDRWqkklA2/NFScknrcNSspbV868WjXORvreDX+Q=="], + "@floating-ui/react-dom": ["@floating-ui/react-dom@2.1.6", "", { "dependencies": { "@floating-ui/dom": "^1.7.4" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-4JX6rEatQEvlmgU80wZyq9RT96HZJa88q8hp0pBd+LrczeDI4o6uA2M+uvxngVHo4Ihr8uibXxH6+70zhAFrVw=="], "@floating-ui/utils": ["@floating-ui/utils@0.2.10", "", {}, "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ=="], @@ -418,6 +456,8 @@ "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.30", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q=="], + "@macalinao/clients-kamino-lending": ["@macalinao/clients-kamino-lending@workspace:clients/kamino-lending"], + "@macalinao/clients-quarry": ["@macalinao/clients-quarry@workspace:clients/quarry"], "@macalinao/clients-token-metadata": ["@macalinao/clients-token-metadata@workspace:clients/token-metadata"], @@ -426,6 +466,8 @@ "@macalinao/codama-instruction-accounts-dedupe-visitor": ["@macalinao/codama-instruction-accounts-dedupe-visitor@workspace:packages/codama-instruction-accounts-dedupe-visitor"], + "@macalinao/codama-nodes-from-anchor-x": ["@macalinao/codama-nodes-from-anchor-x@workspace:packages/codama-nodes-from-anchor-x"], + "@macalinao/codama-rename-visitor": ["@macalinao/codama-rename-visitor@workspace:packages/codama-rename-visitor"], "@macalinao/codama-renderers-js-esm": ["@macalinao/codama-renderers-js-esm@workspace:packages/codama-renderers-js-esm"], @@ -546,46 +588,6 @@ "@radix-ui/rect": ["@radix-ui/rect@1.1.1", "", {}, "sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw=="], - "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.46.3", "", { "os": "android", "cpu": "arm" }, "sha512-UmTdvXnLlqQNOCJnyksjPs1G4GqXNGW1LrzCe8+8QoaLhhDeTXYBgJ3k6x61WIhlHX2U+VzEJ55TtIjR/HTySA=="], - - "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.46.3", "", { "os": "android", "cpu": "arm64" }, "sha512-8NoxqLpXm7VyeI0ocidh335D6OKT0UJ6fHdnIxf3+6oOerZZc+O7r+UhvROji6OspyPm+rrIdb1gTXtVIqn+Sg=="], - - "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.46.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-csnNavqZVs1+7/hUKtgjMECsNG2cdB8F7XBHP6FfQjqhjF8rzMzb3SLyy/1BG7YSfQ+bG75Ph7DyedbUqwq1rA=="], - - "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.46.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-r2MXNjbuYabSIX5yQqnT8SGSQ26XQc8fmp6UhlYJd95PZJkQD1u82fWP7HqvGUf33IsOC6qsiV+vcuD4SDP6iw=="], - - "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.46.3", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-uluObTmgPJDuJh9xqxyr7MV61Imq+0IvVsAlWyvxAaBSNzCcmZlhfYcRhCdMaCsy46ccZa7vtDDripgs9Jkqsw=="], - - "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.46.3", "", { "os": "freebsd", "cpu": "x64" }, "sha512-AVJXEq9RVHQnejdbFvh1eWEoobohUYN3nqJIPI4mNTMpsyYN01VvcAClxflyk2HIxvLpRcRggpX1m9hkXkpC/A=="], - - "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.46.3", "", { "os": "linux", "cpu": "arm" }, "sha512-byyflM+huiwHlKi7VHLAYTKr67X199+V+mt1iRgJenAI594vcmGGddWlu6eHujmcdl6TqSNnvqaXJqZdnEWRGA=="], - - "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.46.3", "", { "os": "linux", "cpu": "arm" }, "sha512-aLm3NMIjr4Y9LklrH5cu7yybBqoVCdr4Nvnm8WB7PKCn34fMCGypVNpGK0JQWdPAzR/FnoEoFtlRqZbBBLhVoQ=="], - - "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.46.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-VtilE6eznJRDIoFOzaagQodUksTEfLIsvXymS+UdJiSXrPW7Ai+WG4uapAc3F7Hgs791TwdGh4xyOzbuzIZrnw=="], - - "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.46.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-dG3JuS6+cRAL0GQ925Vppafi0qwZnkHdPeuZIxIPXqkCLP02l7ka+OCyBoDEv8S+nKHxfjvjW4OZ7hTdHkx8/w=="], - - "@rollup/rollup-linux-loongarch64-gnu": ["@rollup/rollup-linux-loongarch64-gnu@4.46.3", "", { "os": "linux", "cpu": "none" }, "sha512-iU8DxnxEKJptf8Vcx4XvAUdpkZfaz0KWfRrnIRrOndL0SvzEte+MTM7nDH4A2Now4FvTZ01yFAgj6TX/mZl8hQ=="], - - "@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.46.3", "", { "os": "linux", "cpu": "ppc64" }, "sha512-VrQZp9tkk0yozJoQvQcqlWiqaPnLM6uY1qPYXvukKePb0fqaiQtOdMJSxNFUZFsGw5oA5vvVokjHrx8a9Qsz2A=="], - - "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.46.3", "", { "os": "linux", "cpu": "none" }, "sha512-uf2eucWSUb+M7b0poZ/08LsbcRgaDYL8NCGjUeFMwCWFwOuFcZ8D9ayPl25P3pl+D2FH45EbHdfyUesQ2Lt9wA=="], - - "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.46.3", "", { "os": "linux", "cpu": "none" }, "sha512-7tnUcDvN8DHm/9ra+/nF7lLzYHDeODKKKrh6JmZejbh1FnCNZS8zMkZY5J4sEipy2OW1d1Ncc4gNHUd0DLqkSg=="], - - "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.46.3", "", { "os": "linux", "cpu": "s390x" }, "sha512-MUpAOallJim8CsJK+4Lc9tQzlfPbHxWDrGXZm2z6biaadNpvh3a5ewcdat478W+tXDoUiHwErX/dOql7ETcLqg=="], - - "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.46.3", "", { "os": "linux", "cpu": "x64" }, "sha512-F42IgZI4JicE2vM2PWCe0N5mR5vR0gIdORPqhGQ32/u1S1v3kLtbZ0C/mi9FFk7C5T0PgdeyWEPajPjaUpyoKg=="], - - "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.46.3", "", { "os": "linux", "cpu": "x64" }, "sha512-oLc+JrwwvbimJUInzx56Q3ujL3Kkhxehg7O1gWAYzm8hImCd5ld1F2Gry5YDjR21MNb5WCKhC9hXgU7rRlyegQ=="], - - "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.46.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-lOrQ+BVRstruD1fkWg9yjmumhowR0oLAAzavB7yFSaGltY8klttmZtCLvOXCmGE9mLIn8IBV/IFrQOWz5xbFPg=="], - - "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.46.3", "", { "os": "win32", "cpu": "ia32" }, "sha512-vvrVKPRS4GduGR7VMH8EylCBqsDcw6U+/0nPDuIjXQRbHJc6xOBj+frx8ksfZAh6+Fptw5wHrN7etlMmQnPQVg=="], - - "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.46.3", "", { "os": "win32", "cpu": "x64" }, "sha512-fi3cPxCnu3ZeM3EwKZPgXbWoGzm2XHgB/WShKI81uj8wG0+laobmqy5wbgEwzstlbLu4MyO8C19FyhhWseYKNQ=="], - "@rtsao/scc": ["@rtsao/scc@1.1.0", "", {}, "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g=="], "@rushstack/eslint-patch": ["@rushstack/eslint-patch@1.12.0", "", {}, "sha512-5EwMtOqvJMMa3HbmxLlF74e+3/HhwBTMcvt3nqVJgGCozO6hzIPOBlwm8mGVNR9SN2IJpxSnlxczyDjcn7qIyw=="], @@ -738,31 +740,31 @@ "@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], - "@types/react": ["@types/react@19.1.10", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-EhBeSYX0Y6ye8pNebpKrwFJq7BoQ8J5SO6NlvNwwHjSj6adXJViPQrKlsyPw7hLBLvckEMO1yxeGdR82YBBlDg=="], + "@types/react": ["@types/react@19.1.11", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-lr3jdBw/BGj49Eps7EvqlUaoeA0xpj3pc0RoJkHpYaCHkVK7i28dKyImLQb3JVlqs3aYSXf7qYuWOW/fgZnTXQ=="], "@types/react-dom": ["@types/react-dom@19.1.7", "", { "peerDependencies": { "@types/react": "^19.0.0" } }, "sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw=="], "@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="], - "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.39.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.39.1", "@typescript-eslint/type-utils": "8.39.1", "@typescript-eslint/utils": "8.39.1", "@typescript-eslint/visitor-keys": "8.39.1", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.39.1", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-yYegZ5n3Yr6eOcqgj2nJH8cH/ZZgF+l0YIdKILSDjYFRjgYQMgv/lRjV5Z7Up04b9VYUondt8EPMqg7kTWgJ2g=="], + "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.40.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.40.0", "@typescript-eslint/type-utils": "8.40.0", "@typescript-eslint/utils": "8.40.0", "@typescript-eslint/visitor-keys": "8.40.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.40.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-w/EboPlBwnmOBtRbiOvzjD+wdiZdgFeo17lkltrtn7X37vagKKWJABvyfsJXTlHe6XBzugmYgd4A4nW+k8Mixw=="], - "@typescript-eslint/parser": ["@typescript-eslint/parser@8.39.1", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.39.1", "@typescript-eslint/types": "8.39.1", "@typescript-eslint/typescript-estree": "8.39.1", "@typescript-eslint/visitor-keys": "8.39.1", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-pUXGCuHnnKw6PyYq93lLRiZm3vjuslIy7tus1lIQTYVK9bL8XBgJnCWm8a0KcTtHC84Yya1Q6rtll+duSMj0dg=="], + "@typescript-eslint/parser": ["@typescript-eslint/parser@8.40.0", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.40.0", "@typescript-eslint/types": "8.40.0", "@typescript-eslint/typescript-estree": "8.40.0", "@typescript-eslint/visitor-keys": "8.40.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-jCNyAuXx8dr5KJMkecGmZ8KI61KBUhkCob+SD+C+I5+Y1FWI2Y3QmY4/cxMCC5WAsZqoEtEETVhUiUMIGCf6Bw=="], - "@typescript-eslint/project-service": ["@typescript-eslint/project-service@8.39.1", "", { "dependencies": { "@typescript-eslint/tsconfig-utils": "^8.39.1", "@typescript-eslint/types": "^8.39.1", "debug": "^4.3.4" }, "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-8fZxek3ONTwBu9ptw5nCKqZOSkXshZB7uAxuFF0J/wTMkKydjXCzqqga7MlFMpHi9DoG4BadhmTkITBcg8Aybw=="], + "@typescript-eslint/project-service": ["@typescript-eslint/project-service@8.40.0", "", { "dependencies": { "@typescript-eslint/tsconfig-utils": "^8.40.0", "@typescript-eslint/types": "^8.40.0", "debug": "^4.3.4" }, "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-/A89vz7Wf5DEXsGVvcGdYKbVM9F7DyFXj52lNYUDS1L9yJfqjW/fIp5PgMuEJL/KeqVTe2QSbXAGUZljDUpArw=="], - "@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.39.1", "", { "dependencies": { "@typescript-eslint/types": "8.39.1", "@typescript-eslint/visitor-keys": "8.39.1" } }, "sha512-RkBKGBrjgskFGWuyUGz/EtD8AF/GW49S21J8dvMzpJitOF1slLEbbHnNEtAHtnDAnx8qDEdRrULRnWVx27wGBw=="], + "@typescript-eslint/scope-manager": ["@typescript-eslint/scope-manager@8.40.0", "", { "dependencies": { "@typescript-eslint/types": "8.40.0", "@typescript-eslint/visitor-keys": "8.40.0" } }, "sha512-y9ObStCcdCiZKzwqsE8CcpyuVMwRouJbbSrNuThDpv16dFAj429IkM6LNb1dZ2m7hK5fHyzNcErZf7CEeKXR4w=="], - "@typescript-eslint/tsconfig-utils": ["@typescript-eslint/tsconfig-utils@8.39.1", "", { "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-ePUPGVtTMR8XMU2Hee8kD0Pu4NDE1CN9Q1sxGSGd/mbOtGZDM7pnhXNJnzW63zk/q+Z54zVzj44HtwXln5CvHA=="], + "@typescript-eslint/tsconfig-utils": ["@typescript-eslint/tsconfig-utils@8.40.0", "", { "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-jtMytmUaG9d/9kqSl/W3E3xaWESo4hFDxAIHGVW/WKKtQhesnRIJSAJO6XckluuJ6KDB5woD1EiqknriCtAmcw=="], - "@typescript-eslint/type-utils": ["@typescript-eslint/type-utils@8.39.1", "", { "dependencies": { "@typescript-eslint/types": "8.39.1", "@typescript-eslint/typescript-estree": "8.39.1", "@typescript-eslint/utils": "8.39.1", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-gu9/ahyatyAdQbKeHnhT4R+y3YLtqqHyvkfDxaBYk97EcbfChSJXyaJnIL3ygUv7OuZatePHmQvuH5ru0lnVeA=="], + "@typescript-eslint/type-utils": ["@typescript-eslint/type-utils@8.40.0", "", { "dependencies": { "@typescript-eslint/types": "8.40.0", "@typescript-eslint/typescript-estree": "8.40.0", "@typescript-eslint/utils": "8.40.0", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-eE60cK4KzAc6ZrzlJnflXdrMqOBaugeukWICO2rB0KNvwdIMaEaYiywwHMzA1qFpTxrLhN9Lp4E/00EgWcD3Ow=="], - "@typescript-eslint/types": ["@typescript-eslint/types@8.39.1", "", {}, "sha512-7sPDKQQp+S11laqTrhHqeAbsCfMkwJMrV7oTDvtDds4mEofJYir414bYKUEb8YPUm9QL3U+8f6L6YExSoAGdQw=="], + "@typescript-eslint/types": ["@typescript-eslint/types@8.40.0", "", {}, "sha512-ETdbFlgbAmXHyFPwqUIYrfc12ArvpBhEVgGAxVYSwli26dn8Ko+lIo4Su9vI9ykTZdJn+vJprs/0eZU0YMAEQg=="], - "@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.39.1", "", { "dependencies": { "@typescript-eslint/project-service": "8.39.1", "@typescript-eslint/tsconfig-utils": "8.39.1", "@typescript-eslint/types": "8.39.1", "@typescript-eslint/visitor-keys": "8.39.1", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-EKkpcPuIux48dddVDXyQBlKdeTPMmALqBUbEk38McWv0qVEZwOpVJBi7ugK5qVNgeuYjGNQxrrnoM/5+TI/BPw=="], + "@typescript-eslint/typescript-estree": ["@typescript-eslint/typescript-estree@8.40.0", "", { "dependencies": { "@typescript-eslint/project-service": "8.40.0", "@typescript-eslint/tsconfig-utils": "8.40.0", "@typescript-eslint/types": "8.40.0", "@typescript-eslint/visitor-keys": "8.40.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", "minimatch": "^9.0.4", "semver": "^7.6.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "typescript": ">=4.8.4 <6.0.0" } }, "sha512-k1z9+GJReVVOkc1WfVKs1vBrR5MIKKbdAjDTPvIK3L8De6KbFfPFt6BKpdkdk7rZS2GtC/m6yI5MYX+UsuvVYQ=="], - "@typescript-eslint/utils": ["@typescript-eslint/utils@8.39.1", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.7.0", "@typescript-eslint/scope-manager": "8.39.1", "@typescript-eslint/types": "8.39.1", "@typescript-eslint/typescript-estree": "8.39.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-VF5tZ2XnUSTuiqZFXCZfZs1cgkdd3O/sSYmdo2EpSyDlC86UM/8YytTmKnehOW3TGAlivqTDT6bS87B/GQ/jyg=="], + "@typescript-eslint/utils": ["@typescript-eslint/utils@8.40.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.7.0", "@typescript-eslint/scope-manager": "8.40.0", "@typescript-eslint/types": "8.40.0", "@typescript-eslint/typescript-estree": "8.40.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-Cgzi2MXSZyAUOY+BFwGs17s7ad/7L+gKt6Y8rAVVWS+7o6wrjeFN4nVfTpbE25MNcxyJ+iYUXflbs2xR9h4UBg=="], - "@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.39.1", "", { "dependencies": { "@typescript-eslint/types": "8.39.1", "eslint-visitor-keys": "^4.2.1" } }, "sha512-W8FQi6kEh2e8zVhQ0eeRnxdvIoOkAp/CPAahcNio6nO9dsIwb9b34z90KOlheoyuVf6LSOEdjlkxSkapNEc+4A=="], + "@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.40.0", "", { "dependencies": { "@typescript-eslint/types": "8.40.0", "eslint-visitor-keys": "^4.2.1" } }, "sha512-8CZ47QwalyRjsypfwnbI3hKy5gJDPmrkLjkgMxhi0+DZZ2QNx2naS6/hWoVYUHU7LU2zleF68V9miaVZvhFfTA=="], "@ungap/structured-clone": ["@ungap/structured-clone@1.3.0", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="], @@ -878,7 +880,7 @@ "callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="], - "caniuse-lite": ["caniuse-lite@1.0.30001735", "", {}, "sha512-EV/laoX7Wq2J9TQlyIXRxTJqIw4sxfXS4OYgudGxBYRuTv0q7AM6yMEpU/Vo1I94thg9U6EZ2NfZx9GJq83u7w=="], + "caniuse-lite": ["caniuse-lite@1.0.30001737", "", {}, "sha512-BiloLiXtQNrY5UyF0+1nSJLXUENuhka2pzy2Fx5pGxqavdrxSCW4U6Pn/PoG3Efspi2frRbHpBV2XsrPE6EDlw=="], "ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="], @@ -912,7 +914,7 @@ "coda-docs": ["coda-docs@workspace:apps/docs"], - "codama": ["codama@1.3.1", "", { "dependencies": { "@codama/errors": "1.3.1", "@codama/nodes": "1.3.1", "@codama/validators": "1.3.1", "@codama/visitors": "1.3.1" } }, "sha512-ItaKBdCaAO0S9rYkI27Wkm3T614YP+ks4qmvVk+CN5bbj1q+Jr2itPYOLYjEbRIBxTiHvZrWgiGUage72QEq8Q=="], + "codama": ["codama@1.3.3", "", { "dependencies": { "@codama/cli": "1.3.1", "@codama/errors": "1.3.3", "@codama/nodes": "1.3.3", "@codama/validators": "1.3.3", "@codama/visitors": "1.3.3" }, "bin": { "codama": "bin/cli.cjs" } }, "sha512-eCOflah25uWKHGyjvW2FPydRAwhDw4ZAjBuBFF9AVJIE3xknR+pcRMLdlxO5LO3ixlxkHKHdESXJY/aVXmzZtw=="], "collapse-white-space": ["collapse-white-space@2.1.0", "", {}, "sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw=="], @@ -972,8 +974,6 @@ "dir-glob": ["dir-glob@3.0.1", "", { "dependencies": { "path-type": "^4.0.0" } }, "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA=="], - "dnum": ["dnum@2.15.0", "", { "dependencies": { "from-exponential": "^1.1.1" } }, "sha512-7wyYHrTq32laVKSQSuWsUysCY8kMjFjfgbZmcVECROyeT3yvwF9oaSDFWL1s1s8nAfhhERC04LdtFVbmx8xRWQ=="], - "doctrine": ["doctrine@3.0.0", "", { "dependencies": { "esutils": "^2.0.2" } }, "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w=="], "dotenv": ["dotenv@16.0.3", "", {}, "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="], @@ -1014,7 +1014,7 @@ "escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="], - "eslint": ["eslint@9.33.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.0", "@eslint/config-helpers": "^0.3.1", "@eslint/core": "^0.15.2", "@eslint/eslintrc": "^3.3.1", "@eslint/js": "9.33.0", "@eslint/plugin-kit": "^0.3.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.4.0", "eslint-visitor-keys": "^4.2.1", "espree": "^10.4.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-TS9bTNIryDzStCpJN93aC5VRSW3uTx9sClUn4B87pwiCaJh220otoI0X8mJKr+VcPtniMdN8GKjlwgWGUv5ZKA=="], + "eslint": ["eslint@9.34.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.0", "@eslint/config-helpers": "^0.3.1", "@eslint/core": "^0.15.2", "@eslint/eslintrc": "^3.3.1", "@eslint/js": "9.34.0", "@eslint/plugin-kit": "^0.3.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.4.0", "eslint-visitor-keys": "^4.2.1", "espree": "^10.4.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-RNCHRX5EwdrESy3Jc9o8ie8Bog+PeYvvSR8sDGoZxNFTvZ4dlxUB3WzQ3bQMztFrSRODGrLLj8g6OFuGY/aiQg=="], "eslint-config-next": ["eslint-config-next@15.5.0", "", { "dependencies": { "@next/eslint-plugin-next": "15.5.0", "@rushstack/eslint-patch": "^1.10.3", "@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "eslint-import-resolver-node": "^0.3.6", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jsx-a11y": "^6.10.0", "eslint-plugin-react": "^7.37.0", "eslint-plugin-react-hooks": "^5.0.0" }, "peerDependencies": { "eslint": "^7.23.0 || ^8.0.0 || ^9.0.0", "typescript": ">=3.3.1" }, "optionalPeers": ["typescript"] }, "sha512-Yl4hlOdBqstAuHnlBfx2RimBzWQwysM2SJNu5EzYVa2qS2ItPs7lgxL0sJJDudEx5ZZHfWPZ/6U8+FtDFWs7/w=="], @@ -1046,7 +1046,7 @@ "eslint-plugin-turbo": ["eslint-plugin-turbo@2.5.6", "", { "dependencies": { "dotenv": "16.0.3" }, "peerDependencies": { "eslint": ">6.6.0", "turbo": ">2.0.0" } }, "sha512-KUDE23aP2JV8zbfZ4TeM1HpAXzMM/AYG/bJam7P4AalUxas8Pd/lS/6R3p4uX91qJcH1LwL4h0ED48nDe8KorQ=="], - "eslint-plugin-unused-imports": ["eslint-plugin-unused-imports@4.1.4", "", { "peerDependencies": { "@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0", "eslint": "^9.0.0 || ^8.0.0" }, "optionalPeers": ["@typescript-eslint/eslint-plugin"] }, "sha512-YptD6IzQjDardkl0POxnnRBhU1OEePMV0nd6siHaRBbd+lyh6NAhFEobiznKU7kTsSsDeSD62Pe7kAM1b7dAZQ=="], + "eslint-plugin-unused-imports": ["eslint-plugin-unused-imports@4.2.0", "", { "peerDependencies": { "@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0", "eslint": "^9.0.0 || ^8.0.0" }, "optionalPeers": ["@typescript-eslint/eslint-plugin"] }, "sha512-hLbJ2/wnjKq4kGA9AUaExVFIbNzyxYdVo49QZmKCnhk5pc9wcYRbfgLHvWJ8tnsdcseGhoUAddm9gn/lt+d74w=="], "eslint-scope": ["eslint-scope@8.4.0", "", { "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg=="], @@ -1116,14 +1116,10 @@ "foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="], - "from-exponential": ["from-exponential@1.1.1", "", {}, "sha512-VBE7f5OVnYwdgB3LHa+Qo29h8qVpxhVO9Trlc+AWm+/XNAgks1tAwMFHb33mjeiof77GglsJzeYF7OqXrROP/A=="], - "fs-extra": ["fs-extra@7.0.1", "", { "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw=="], "fs.realpath": ["fs.realpath@1.0.0", "", {}, "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="], - "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], - "fumadocs-core": ["fumadocs-core@15.7.0", "", { "dependencies": { "@formatjs/intl-localematcher": "^0.6.1", "@orama/orama": "^3.1.11", "@shikijs/rehype": "^3.11.0", "@shikijs/transformers": "^3.11.0", "github-slugger": "^2.0.0", "hast-util-to-estree": "^3.1.3", "hast-util-to-jsx-runtime": "^2.3.6", "image-size": "^2.0.2", "negotiator": "^1.0.0", "npm-to-yarn": "^3.0.1", "react-remove-scroll": "^2.7.1", "remark": "^15.0.0", "remark-gfm": "^4.0.1", "remark-rehype": "^11.1.2", "scroll-into-view-if-needed": "^3.1.0", "shiki": "^3.11.0", "unist-util-visit": "^5.0.0" }, "peerDependencies": { "@mixedbread/sdk": "^0.19.0", "@oramacloud/client": "1.x.x || 2.x.x", "@types/react": "*", "algoliasearch": "5.x.x", "next": "14.x.x || 15.x.x", "react": "18.x.x || 19.x.x", "react-dom": "18.x.x || 19.x.x", "react-router": "7.x.x" }, "optionalPeers": ["@mixedbread/sdk", "@oramacloud/client", "@types/react", "algoliasearch", "next", "react", "react-dom", "react-router"] }, "sha512-KBRzqbk4pkrGgIeX8uVoJaBsvBu6qr7m9Hz52774jIZcEGDY1Rr6Rqqdi40cQhEYIkXKaGDyUsiLmWxHrGviwQ=="], "fumadocs-mdx": ["fumadocs-mdx@11.8.0", "", { "dependencies": { "@mdx-js/mdx": "^3.1.0", "@standard-schema/spec": "^1.0.0", "chokidar": "^4.0.3", "esbuild": "^0.25.9", "estree-util-value-to-estree": "^3.4.0", "js-yaml": "^4.1.0", "lru-cache": "^11.1.0", "picocolors": "^1.1.1", "tinyexec": "^1.0.1", "tinyglobby": "^0.2.14", "unist-util-visit": "^5.0.0", "zod": "^4.0.17" }, "peerDependencies": { "@fumadocs/mdx-remote": "^1.4.0", "fumadocs-core": "^14.0.0 || ^15.0.0", "next": "^15.3.0", "react": "*", "vite": "6.x.x || 7.x.x" }, "optionalPeers": ["@fumadocs/mdx-remote", "next", "react", "vite"], "bin": { "fumadocs-mdx": "bin.js" } }, "sha512-svbJBgkvLHG3GX2tG+TxiMPDnvE2QDHCIT2wgcYf+flWoDIMgh8ZWTvv4r5/BpU+svYeEd6sKFq3sEjlgDM4ag=="], @@ -1318,6 +1314,8 @@ "keyv": ["keyv@4.5.4", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="], + "kleur": ["kleur@3.0.3", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="], + "language-subtag-registry": ["language-subtag-registry@0.3.23", "", {}, "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ=="], "language-tags": ["language-tags@1.0.9", "", { "dependencies": { "language-subtag-registry": "^0.3.20" } }, "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA=="], @@ -1350,7 +1348,7 @@ "lint-staged": ["lint-staged@16.1.5", "", { "dependencies": { "chalk": "^5.5.0", "commander": "^14.0.0", "debug": "^4.4.1", "lilconfig": "^3.1.3", "listr2": "^9.0.1", "micromatch": "^4.0.8", "nano-spawn": "^1.0.2", "pidtree": "^0.6.0", "string-argv": "^0.3.2", "yaml": "^2.8.1" }, "bin": { "lint-staged": "bin/lint-staged.js" } }, "sha512-uAeQQwByI6dfV7wpt/gVqg+jAPaSp8WwOA8kKC/dv1qw14oGpnpAisY65ibGHUGDUv0rYaZ8CAJZ/1U8hUvC2A=="], - "listr2": ["listr2@9.0.1", "", { "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", "log-update": "^6.1.0", "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" } }, "sha512-SL0JY3DaxylDuo/MecFeiC+7pedM0zia33zl0vcjgwcq1q1FWWF1To9EIauPbl8GbMCU0R2e0uJ8bZunhYKD2g=="], + "listr2": ["listr2@9.0.2", "", { "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", "log-update": "^6.1.0", "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" } }, "sha512-VVd7cS6W+vLJu2wmq4QmfVj14Iep7cz4r/OWNk36Aq5ZOY7G8/BfCrQFexcwB1OIxB3yERiePfE/REBjEFulag=="], "locate-path": ["locate-path@6.0.0", "", { "dependencies": { "p-locate": "^5.0.0" } }, "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw=="], @@ -1366,7 +1364,7 @@ "lru-cache": ["lru-cache@11.1.0", "", {}, "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A=="], - "magic-string": ["magic-string@0.30.17", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" } }, "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA=="], + "magic-string": ["magic-string@0.30.18", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-yi8swmWbO17qHhwIBNeeZxTceJMeBvWJaId6dyvTSOwTipqeHhMhOrz6513r1sOKnpvQ7zkhlG8tPrpilwTxHQ=="], "markdown-extensions": ["markdown-extensions@2.0.0", "", {}, "sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q=="], @@ -1594,6 +1592,8 @@ "prettier-linter-helpers": ["prettier-linter-helpers@1.0.0", "", { "dependencies": { "fast-diff": "^1.1.2" } }, "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w=="], + "prompts": ["prompts@2.4.2", "", { "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" } }, "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q=="], + "prop-types": ["prop-types@15.8.1", "", { "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", "react-is": "^16.13.1" } }, "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg=="], "property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="], @@ -1668,8 +1668,6 @@ "rimraf": ["rimraf@3.0.2", "", { "dependencies": { "glob": "^7.1.3" }, "bin": { "rimraf": "bin.js" } }, "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA=="], - "rollup": ["rollup@4.46.3", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.46.3", "@rollup/rollup-android-arm64": "4.46.3", "@rollup/rollup-darwin-arm64": "4.46.3", "@rollup/rollup-darwin-x64": "4.46.3", "@rollup/rollup-freebsd-arm64": "4.46.3", "@rollup/rollup-freebsd-x64": "4.46.3", "@rollup/rollup-linux-arm-gnueabihf": "4.46.3", "@rollup/rollup-linux-arm-musleabihf": "4.46.3", "@rollup/rollup-linux-arm64-gnu": "4.46.3", "@rollup/rollup-linux-arm64-musl": "4.46.3", "@rollup/rollup-linux-loongarch64-gnu": "4.46.3", "@rollup/rollup-linux-ppc64-gnu": "4.46.3", "@rollup/rollup-linux-riscv64-gnu": "4.46.3", "@rollup/rollup-linux-riscv64-musl": "4.46.3", "@rollup/rollup-linux-s390x-gnu": "4.46.3", "@rollup/rollup-linux-x64-gnu": "4.46.3", "@rollup/rollup-linux-x64-musl": "4.46.3", "@rollup/rollup-win32-arm64-msvc": "4.46.3", "@rollup/rollup-win32-ia32-msvc": "4.46.3", "@rollup/rollup-win32-x64-msvc": "4.46.3", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-RZn2XTjXb8t5g13f5YclGoilU/kwT696DIkY3sywjdZidNSi3+vseaQov7D7BZXVJCPv3pDWUN69C78GGbXsKw=="], - "run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="], "safe-array-concat": ["safe-array-concat@1.1.3", "", { "dependencies": { "call-bind": "^1.0.8", "call-bound": "^1.0.2", "get-intrinsic": "^1.2.6", "has-symbols": "^1.1.0", "isarray": "^2.0.5" } }, "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q=="], @@ -1712,6 +1710,8 @@ "simple-swizzle": ["simple-swizzle@0.2.2", "", { "dependencies": { "is-arrayish": "^0.3.1" } }, "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg=="], + "sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="], + "slash": ["slash@3.0.0", "", {}, "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="], "slice-ansi": ["slice-ansi@5.0.0", "", { "dependencies": { "ansi-styles": "^6.0.0", "is-fullwidth-code-point": "^4.0.0" } }, "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ=="], @@ -1776,7 +1776,7 @@ "tailwindcss": ["tailwindcss@4.1.12", "", {}, "sha512-DzFtxOi+7NsFf7DBtI3BJsynR+0Yp6etH+nRPTbpWnS2pZBaSksv/JGctNwSWzbFjp0vxSqknaUylseZqMDGrA=="], - "tapable": ["tapable@2.2.2", "", {}, "sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg=="], + "tapable": ["tapable@2.2.3", "", {}, "sha512-ZL6DDuAlRlLGghwcfmSn9sK3Hr6ArtyudlSAiCqQ6IfE+b+HHbydbYDIG15IfS5do+7XQQBdBiubF/cV2dnDzg=="], "tar": ["tar@7.4.3", "", { "dependencies": { "@isaacs/fs-minipass": "^4.0.0", "chownr": "^3.0.0", "minipass": "^7.1.2", "minizlib": "^3.0.1", "mkdirp": "^3.0.1", "yallist": "^5.0.0" } }, "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw=="], @@ -1828,7 +1828,7 @@ "typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], - "typescript-eslint": ["typescript-eslint@8.39.1", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.39.1", "@typescript-eslint/parser": "8.39.1", "@typescript-eslint/typescript-estree": "8.39.1", "@typescript-eslint/utils": "8.39.1" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-GDUv6/NDYngUlNvwaHM1RamYftxf782IyEDbdj3SeaIHHv8fNQVRC++fITT7kUJV/5rIA/tkoRSSskt6osEfqg=="], + "typescript-eslint": ["typescript-eslint@8.40.0", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.40.0", "@typescript-eslint/parser": "8.40.0", "@typescript-eslint/typescript-estree": "8.40.0", "@typescript-eslint/utils": "8.40.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-Xvd2l+ZmFDPEt4oj1QEXzA4A2uUK6opvKu3eGN9aGjB8au02lIVcLyi375w94hHyejTOmzIU77L8ol2sRg9n7Q=="], "unbox-primitive": ["unbox-primitive@1.1.0", "", { "dependencies": { "call-bound": "^1.0.3", "has-bigints": "^1.0.2", "has-symbols": "^1.1.0", "which-boxed-primitive": "^1.1.1" } }, "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw=="], @@ -1864,8 +1864,6 @@ "vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="], - "vite": ["vite@7.1.2", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.6", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.14" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-J0SQBPlQiEXAF7tajiH+rUooJPo0l8KQgyg4/aMunNtrOa7bwuZJsJbDWzeljqQpgftxuq5yNJxQ91O9ts29UQ=="], - "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="], "which-boxed-primitive": ["which-boxed-primitive@1.1.1", "", { "dependencies": { "is-bigint": "^1.1.0", "is-boolean-object": "^1.2.1", "is-number-object": "^1.1.1", "is-string": "^1.1.1", "is-symbol": "^1.1.1" } }, "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA=="], @@ -1926,7 +1924,7 @@ "@solana/errors/chalk": ["chalk@5.6.0", "", {}, "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ=="], - "@solana/rpc-transport-http/undici-types": ["undici-types@7.14.0", "", {}, "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA=="], + "@solana/rpc-transport-http/undici-types": ["undici-types@7.15.0", "", {}, "sha512-Xyn5T99wU4kPhLZMm+ElE6M+IoSeG8Se7eG9xoZ82ZgVHJ07wb/IWcDZeXe2GOPkavcJ8ko5oSlXMDRl/QgY9Q=="], "@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.4.5", "", { "dependencies": { "@emnapi/wasi-threads": "1.0.4", "tslib": "^2.4.0" }, "bundled": true }, "sha512-XsLw1dEOpkSX/WucdqUhPWP7hDxSvZiY+fsUC14h+FtQ2Ifni4znbBt8punRX+Uj2JG/uDb8nEHVKvrVlvdZ5Q=="], @@ -2008,8 +2006,6 @@ "tinyglobby/picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="], - "vite/picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="], - "wrap-ansi/ansi-styles": ["ansi-styles@6.2.1", "", {}, "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="], "wrap-ansi/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="], diff --git a/clients/kamino-lending/README.md b/clients/kamino-lending/README.md new file mode 100644 index 00000000..cba48cd4 --- /dev/null +++ b/clients/kamino-lending/README.md @@ -0,0 +1,83 @@ +# @macalinao/clients-kamino-lending + +[![npm version](https://img.shields.io/npm/v/@macalinao/clients-kamino-lending.svg)](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/clients-kamino-lending.svg)](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) + +TypeScript client for the Kamino Lending program on Solana. + +## Installation + +```bash +bun add @macalinao/clients-kamino-lending +``` + +Or with npm: + +```bash +npm install @macalinao/clients-kamino-lending +``` + +## Program Information + +- **Program ID**: `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD` +- **Network**: Mainnet-beta + +## Usage + +```typescript +import { + createInitializeInstruction, + fetchLendingMarket, + // ... other exports +} from "@macalinao/clients-kamino-lending"; +import { createSolanaRpc } from "@solana/web3.js"; + +// Connect to Solana +const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com"); + +// Fetch account data +const lendingMarket = await fetchLendingMarket(rpc, marketAddress); + +// Create instructions +const instruction = createInitializeInstruction({ + // ... instruction parameters +}); +``` + +## Generated Code + +This client is automatically generated from the Kamino Lending IDL using [Coda](https://coda.ianm.com). The generated code includes: + +- **Instructions**: Builders for all program instructions +- **Accounts**: Decoders and fetchers for all account types +- **Types**: TypeScript types for all program structures +- **Errors**: Typed error codes and messages +- **PDAs**: Helper functions for program-derived addresses + +## Development + +### Regenerate Client + +To regenerate the client code after IDL updates: + +```bash +bun run codegen +``` + +### Build + +```bash +bun run build +``` + +### Clean + +```bash +bun run clean +``` + +## License + +Copyright © 2025 Ian Macalinao + +Licensed under the Apache License, Version 2.0 diff --git a/clients/kamino-lending/coda.config.mjs b/clients/kamino-lending/coda.config.mjs new file mode 100644 index 00000000..723d6944 --- /dev/null +++ b/clients/kamino-lending/coda.config.mjs @@ -0,0 +1,129 @@ +import { + addPdasVisitor, + constantPdaSeedNodeFromString, + defineConfig, + numberTypeNode, + publicKeyTypeNode, + renameVisitor, + stringTypeNode, + variablePdaSeedNode, +} from "@macalinao/coda"; + +/** @type {import("@macalinao/coda").CodaConfig} */ +export default defineConfig({ + // Use glob pattern to match both IDL files + outputDir: "./src/generated", + docs: { + npmPackageName: "@macalinao/clients-kamino-lending", + }, + // We can add custom visitors here later if needed + visitors: [ + addPdasVisitor({ + farms: [ + { + name: "obligationFarmState", + seeds: [ + constantPdaSeedNodeFromString("utf8", "user"), + variablePdaSeedNode("farm", publicKeyTypeNode()), + variablePdaSeedNode("obligation", publicKeyTypeNode()), + ], + }, + ], + kaminoLending: [ + { + name: "obligation", + seeds: [ + variablePdaSeedNode("tag", numberTypeNode("u8", "le")), + variablePdaSeedNode("id", numberTypeNode("u8", "le")), + variablePdaSeedNode("user", publicKeyTypeNode()), + variablePdaSeedNode("market", publicKeyTypeNode()), + variablePdaSeedNode("seed1Account", publicKeyTypeNode()), + variablePdaSeedNode("seed2Account", publicKeyTypeNode()), + ], + }, + { + name: "lendingMarketAuth", + seeds: [ + constantPdaSeedNodeFromString("utf8", "lma"), + variablePdaSeedNode("lendingMarket", publicKeyTypeNode()), + ], + }, + { + name: "reserveLiquiditySupply", + seeds: [ + constantPdaSeedNodeFromString("utf8", "reserve_liq_supply"), + variablePdaSeedNode("lendingMarket", publicKeyTypeNode()), + variablePdaSeedNode("mint", publicKeyTypeNode()), + ], + }, + { + name: "reserveFeeVault", + seeds: [ + constantPdaSeedNodeFromString("utf8", "fee_receiver"), + variablePdaSeedNode("lendingMarket", publicKeyTypeNode()), + variablePdaSeedNode("mint", publicKeyTypeNode()), + ], + }, + { + name: "reserveCollateralMint", + seeds: [ + constantPdaSeedNodeFromString("utf8", "reserve_coll_mint"), + variablePdaSeedNode("lendingMarket", publicKeyTypeNode()), + variablePdaSeedNode("mint", publicKeyTypeNode()), + ], + }, + { + name: "reserveCollateralSupply", + seeds: [ + constantPdaSeedNodeFromString("utf8", "reserve_coll_supply"), + variablePdaSeedNode("lendingMarket", publicKeyTypeNode()), + variablePdaSeedNode("mint", publicKeyTypeNode()), + ], + }, + { + name: "userMetadata", + seeds: [ + constantPdaSeedNodeFromString("utf8", "user_meta"), + variablePdaSeedNode("user", publicKeyTypeNode()), + ], + }, + { + name: "referrerTokenState", + seeds: [ + constantPdaSeedNodeFromString("utf8", "referrer_acc"), + variablePdaSeedNode("referrer", publicKeyTypeNode()), + variablePdaSeedNode("reserve", publicKeyTypeNode()), + ], + }, + { + name: "referrerState", + seeds: [ + constantPdaSeedNodeFromString("utf8", "ref_state"), + variablePdaSeedNode("referrer", publicKeyTypeNode()), + ], + }, + { + name: "shortUrl", + seeds: [ + constantPdaSeedNodeFromString("utf8", "short_url"), + variablePdaSeedNode("shortUrl", stringTypeNode("utf8")), + ], + }, + ], + }), + renameVisitor({ + farms: { + accounts: { + userState: "farmsUserState", + }, + instructions: { + idlMissingTypes: "farmsIdlMissingTypes", + }, + definedTypes: { + tokenInfo: "farmsTokenInfo", + userState: "farmsUserState", + }, + }, + }), + ], +}); diff --git a/clients/kamino-lending/docs/farms.md b/clients/kamino-lending/docs/farms.md new file mode 100644 index 00000000..a7b7e0aa --- /dev/null +++ b/clients/kamino-lending/docs/farms.md @@ -0,0 +1,854 @@ +# Farms Program + +[![npm version](https://badge.fury.io/js/%40macalinao%2Fclients-kamino-lending.svg)](https://www.npmjs.com/package/%40macalinao%2Fclients-kamino-lending) + +- Program ID: `FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr` +- TypeScript Client: [`@macalinao/clients-kamino-lending`](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) + +## Table of Contents + +- [Accounts](#accounts) + - [farmState](#farmState) + - [globalConfig](#globalConfig) + - [farmsUserState](#farmsUserState) + - [oraclePrices](#oraclePrices) +- [Instructions](#instructions) + - [initializeGlobalConfig](#initializeGlobalConfig) + - [updateGlobalConfig](#updateGlobalConfig) + - [initializeFarm](#initializeFarm) + - [initializeFarmDelegated](#initializeFarmDelegated) + - [initializeReward](#initializeReward) + - [addRewards](#addRewards) + - [updateFarmConfig](#updateFarmConfig) + - [initializeUser](#initializeUser) + - [transferOwnership](#transferOwnership) + - [rewardUserOnce](#rewardUserOnce) + - [refreshFarm](#refreshFarm) + - [stake](#stake) + - [setStakeDelegated](#setStakeDelegated) + - [harvestReward](#harvestReward) + - [unstake](#unstake) + - [refreshUserState](#refreshUserState) + - [withdrawUnstakedDeposits](#withdrawUnstakedDeposits) + - [withdrawTreasury](#withdrawTreasury) + - [depositToFarmVault](#depositToFarmVault) + - [withdrawFromFarmVault](#withdrawFromFarmVault) + - [withdrawSlashedAmount](#withdrawSlashedAmount) + - [updateFarmAdmin](#updateFarmAdmin) + - [updateGlobalConfigAdmin](#updateGlobalConfigAdmin) + - [withdrawReward](#withdrawReward) + - [farmsIdlMissingTypes](#farmsIdlMissingTypes) +- [PDAs](#pdas) + - [obligationFarmState](#obligationFarmState) +- [Types](#types) + - [farmConfigOption](#farmConfigOption) + - [globalConfigOption](#globalConfigOption) + - [lockingMode](#lockingMode) + - [rewardInfo](#rewardInfo) + - [rewardPerTimeUnitPoint](#rewardPerTimeUnitPoint) + - [rewardScheduleCurve](#rewardScheduleCurve) + - [rewardType](#rewardType) + - [timeUnit](#timeUnit) + - [farmsTokenInfo](#farmsTokenInfo) + - [datedPrice](#datedPrice) + - [price](#price) +- [Errors](#errors) + +## Accounts + +### farmState + +**Fields:** + +| Field | Type | Description | +| ---------------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `discriminator` | `unknown` | | +| `farmAdmin` | `PublicKey` | | +| `globalConfig` | `PublicKey` | | +| `token` | [tokenInfo](#tokenInfo-3) | | +| `rewardInfos` | [rewardInfo](#rewardInfo-3)[10] | | +| `numRewardTokens` | `u64` | | +| `numUsers` | `u64` | Data used to calculate the rewards of the user | +| `totalStakedAmount` | `u64` | The number of token in the `farm_vault` staked (getting rewards and fees) Set such as `farm_vault.amount = total_staked_amount + total_pending_amount` | +| `farmVault` | `PublicKey` | | +| `farmVaultsAuthority` | `PublicKey` | | +| `farmVaultsAuthorityBump` | `u64` | | +| `delegateAuthority` | `PublicKey` | Only used for delegate farms Set to `default()` otherwise | +| `timeUnit` | `u8` | Raw representation of a `TimeUnit` Seconds = 0, Slots = 1 | +| `isFarmFrozen` | `u8` | Automatically set to true in case of a full authority withdrawal If true, the farm is frozen and no more deposits are allowed | +| `isFarmDelegated` | `u8` | Indicates if the farm is a delegate farm If true, the farm is a delegate farm and the `delegate_authority` is set\* | +| `padding0` | `u8`[5] | | +| `withdrawAuthority` | `PublicKey` | Withdraw authority for the farm, allowed to lock deposited funds and withdraw them Set to `default()` if unused (only the depositors can withdraw their funds) | +| `depositWarmupPeriod` | `u32` | Delay between a user deposit and the moment it is considered as staked 0 if unused | +| `withdrawalCooldownPeriod` | `u32` | Delay between a user unstake and the ability to withdraw his deposit. | +| `totalActiveStakeScaled` | `u128` | Total active stake of tokens in the farm (scaled from `Decimal` representation). | +| `totalPendingStakeScaled` | `u128` | Total pending stake of tokens in the farm (scaled from `Decimal` representation). (can be used by `withdraw_authority` but don't get rewards or fees) | +| `totalPendingAmount` | `u64` | Total pending amount of tokens in the farm | +| `slashedAmountCurrent` | `u64` | Slashed amounts from early withdrawal | +| `slashedAmountCumulative` | `u64` | | +| `slashedAmountSpillAddress` | `PublicKey` | | +| `lockingMode` | `u64` | Locking stake | +| `lockingStartTimestamp` | `u64` | | +| `lockingDuration` | `u64` | | +| `lockingEarlyWithdrawalPenaltyBps` | `u64` | | +| `depositCapAmount` | `u64` | | +| `scopePrices` | `PublicKey` | | +| `scopeOraclePriceId` | `u64` | | +| `scopeOracleMaxAge` | `u64` | | +| `pendingFarmAdmin` | `PublicKey` | | +| `strategyId` | `PublicKey` | | +| `delegatedRpsAdmin` | `PublicKey` | | +| `vaultId` | `PublicKey` | | +| `padding` | `u64`[78] | | + +### globalConfig + +**Fields:** + +| Field | Type | Description | +| ----------------------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `globalAdmin` | `PublicKey` | | +| `treasuryFeeBps` | `u64` | | +| `treasuryVaultsAuthority` | `PublicKey` | | +| `treasuryVaultsAuthorityBump` | `u64` | | +| `pendingGlobalAdmin` | `PublicKey` | | +| `padding1` | `u128`[126] | | + +### farmsUserState + +**Fields:** + +| Field | Type | Description | +| -------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------ | +| `discriminator` | `unknown` | | +| `userId` | `u64` | | +| `farmState` | `PublicKey` | | +| `owner` | `PublicKey` | | +| `isFarmDelegated` | `u8` | Indicate if this user state is part of a delegated farm | +| `padding0` | `u8`[7] | | +| `rewardsTallyScaled` | `u128`[10] | Rewards tally used for computation of gained rewards (scaled from `Decimal` representation). | +| `rewardsIssuedUnclaimed` | `u64`[10] | Number of reward tokens ready for claim | +| `lastClaimTs` | `u64`[10] | | +| `activeStakeScaled` | `u128` | User stake deposited and usable, generating rewards and fees. (scaled from `Decimal` representation). | +| `pendingDepositStakeScaled` | `u128` | User stake deposited but not usable and not generating rewards yet. (scaled from `Decimal` representation). | +| `pendingDepositStakeTs` | `u64` | After this timestamp, pending user stake can be moved to user stake Initialized to now() + delayed user stake period | +| `pendingWithdrawalUnstakeScaled` | `u128` | User deposits unstaked, pending for withdrawal, not usable and not generating rewards. (scaled from `Decimal` representation). | +| `pendingWithdrawalUnstakeTs` | `u64` | After this timestamp, user can withdraw their deposit. | +| `bump` | `u64` | User bump used for account address validation | +| `delegatee` | `PublicKey` | Delegatee used for initialisation - useful to check against | +| `lastStakeTs` | `u64` | | +| `padding1` | `u64`[50] | | + +### oraclePrices + +**Fields:** + +| Field | Type | Description | +| ---------------- | -------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `oracleMappings` | `PublicKey` | | +| `prices` | [datedPrice](#datedPrice-3)[512] | | + +## Instructions + +### initializeGlobalConfig + +**Accounts:** + +| Account | Type | Description | +| ------------------------- | ---------------- | ----------- | +| `globalAdmin` | signer, writable | | +| `globalConfig` | writable | | +| `treasuryVaultsAuthority` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### updateGlobalConfig + +**Accounts:** + +| Account | Type | Description | +| -------------- | -------- | ----------- | +| `globalAdmin` | signer | | +| `globalConfig` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u8` | | +| `value` | `u8`[32] | | + +### initializeFarm + +**Accounts:** + +| Account | Type | Description | +| --------------------- | ---------------- | ----------- | +| `farmAdmin` | signer, writable | | +| `farmState` | writable | | +| `globalConfig` | readonly | | +| `farmVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `tokenMint` | readonly | | +| `tokenProgram` | readonly | | +| `systemProgram` | readonly | | +| `rent` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initializeFarmDelegated + +**Accounts:** + +| Account | Type | Description | +| --------------------- | ---------------- | ----------- | +| `farmAdmin` | signer, writable | | +| `farmDelegate` | signer | | +| `farmState` | writable | | +| `globalConfig` | readonly | | +| `farmVaultsAuthority` | readonly | | +| `systemProgram` | readonly | | +| `rent` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initializeReward + +**Accounts:** + +| Account | Type | Description | +| ------------------------- | ---------------- | ----------- | +| `farmAdmin` | signer, writable | | +| `farmState` | writable | | +| `globalConfig` | readonly | | +| `rewardMint` | readonly | | +| `rewardVault` | writable | | +| `rewardTreasuryVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `treasuryVaultsAuthority` | readonly | | +| `tokenProgram` | readonly | | +| `systemProgram` | readonly | | +| `rent` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### addRewards + +**Accounts:** + +| Account | Type | Description | +| --------------------- | ---------------- | ----------- | +| `payer` | signer, writable | | +| `farmState` | writable | | +| `rewardMint` | readonly | | +| `rewardVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `payerRewardTokenAta` | writable | | +| `scopePrices` | optional | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | +| `rewardIndex` | `u64` | | + +### updateFarmConfig + +**Accounts:** + +| Account | Type | Description | +| ------------- | ---------------- | ----------- | +| `signer` | signer, writable | | +| `farmState` | writable | | +| `scopePrices` | optional | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u16` | | +| `data` | `unknown` | | + +### initializeUser + +**Accounts:** + +| Account | Type | Description | +| --------------- | ---------------- | ----------- | +| `authority` | signer | | +| `payer` | signer, writable | | +| `owner` | readonly | | +| `delegatee` | readonly | | +| `userState` | writable | | +| `farmState` | writable | | +| `systemProgram` | readonly | | +| `rent` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### transferOwnership + +**Accounts:** + +| Account | Type | Description | +| ----------- | -------- | ----------- | +| `owner` | signer | | +| `userState` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `newOwner` | `PublicKey` | | + +### rewardUserOnce + +**Accounts:** + +| Account | Type | Description | +| ----------- | ---------------- | ----------- | +| `farmAdmin` | signer, writable | | +| `farmState` | writable | | +| `userState` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `rewardIndex` | `u64` | | +| `amount` | `u64` | | + +### refreshFarm + +**Accounts:** + +| Account | Type | Description | +| ------------- | -------- | ----------- | +| `farmState` | writable | | +| `scopePrices` | optional | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### stake + +**Accounts:** + +| Account | Type | Description | +| -------------- | -------- | ----------- | +| `owner` | signer | | +| `userState` | writable | | +| `farmState` | writable | | +| `farmVault` | writable | | +| `userAta` | writable | | +| `tokenMint` | readonly | | +| `scopePrices` | optional | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | + +### setStakeDelegated + +**Accounts:** + +| Account | Type | Description | +| ------------------- | -------- | ----------- | +| `delegateAuthority` | signer | | +| `userState` | writable | | +| `farmState` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `newAmount` | `u64` | | + +### harvestReward + +**Accounts:** + +| Account | Type | Description | +| ---------------------- | ---------------- | ----------- | +| `owner` | signer, writable | | +| `userState` | writable | | +| `farmState` | writable | | +| `globalConfig` | readonly | | +| `rewardMint` | readonly | | +| `userRewardAta` | writable | | +| `rewardsVault` | writable | | +| `rewardsTreasuryVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `scopePrices` | optional | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `rewardIndex` | `u64` | | + +### unstake + +**Accounts:** + +| Account | Type | Description | +| ------------- | ---------------- | ----------- | +| `owner` | signer, writable | | +| `userState` | writable | | +| `farmState` | writable | | +| `scopePrices` | optional | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `stakeSharesScaled` | `u128` | | + +### refreshUserState + +**Accounts:** + +| Account | Type | Description | +| ------------- | -------- | ----------- | +| `userState` | writable | | +| `farmState` | writable | | +| `scopePrices` | optional | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### withdrawUnstakedDeposits + +**Accounts:** + +| Account | Type | Description | +| --------------------- | ---------------- | ----------- | +| `owner` | signer, writable | | +| `userState` | writable | | +| `farmState` | writable | | +| `userAta` | writable | | +| `farmVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### withdrawTreasury + +**Accounts:** + +| Account | Type | Description | +| --------------------------------- | ---------------- | ----------- | +| `globalAdmin` | signer, writable | | +| `globalConfig` | readonly | | +| `rewardMint` | readonly | | +| `rewardTreasuryVault` | writable | | +| `treasuryVaultAuthority` | readonly | | +| `withdrawDestinationTokenAccount` | writable | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | + +### depositToFarmVault + +**Accounts:** + +| Account | Type | Description | +| -------------- | -------- | ----------- | +| `depositor` | signer | | +| `farmState` | writable | | +| `farmVault` | writable | | +| `depositorAta` | writable | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | + +### withdrawFromFarmVault + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | ---------------- | ----------- | +| `withdrawAuthority` | signer, writable | | +| `farmState` | writable | | +| `withdrawerTokenAccount` | writable | | +| `farmVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | + +### withdrawSlashedAmount + +**Accounts:** + +| Account | Type | Description | +| --------------------------- | ---------------- | ----------- | +| `crank` | signer, writable | | +| `farmState` | writable | | +| `slashedAmountSpillAddress` | writable | | +| `farmVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### updateFarmAdmin + +**Accounts:** + +| Account | Type | Description | +| ------------------ | ---------------- | ----------- | +| `pendingFarmAdmin` | signer, writable | | +| `farmState` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### updateGlobalConfigAdmin + +**Accounts:** + +| Account | Type | Description | +| -------------------- | -------- | ----------- | +| `pendingGlobalAdmin` | signer | | +| `globalConfig` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### withdrawReward + +**Accounts:** + +| Account | Type | Description | +| --------------------- | ---------------- | ----------- | +| `farmAdmin` | signer, writable | | +| `farmState` | writable | | +| `rewardMint` | readonly | | +| `rewardVault` | writable | | +| `farmVaultsAuthority` | readonly | | +| `adminRewardTokenAta` | writable | | +| `scopePrices` | optional | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | +| `rewardIndex` | `u64` | | + +### farmsIdlMissingTypes + +**Accounts:** + +| Account | Type | Description | +| -------------- | -------- | ----------- | +| `globalAdmin` | signer | | +| `globalConfig` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------------ | ------------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `globalConfigOptionKind` | [globalConfigOption](#globalConfigOption-3) | | +| `farmConfigOptionKind` | [farmConfigOption](#farmConfigOption-3) | | +| `timeUnit` | [timeUnit](#timeUnit-3) | | +| `lockingMode` | [lockingMode](#lockingMode-3) | | +| `rewardType` | [rewardType](#rewardType-3) | | + +## PDAs + +### obligationFarmState + +**Seeds:** + +| Seed | Type | Description | +| ------------ | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `farm` | `PublicKey` | | +| `obligation` | `PublicKey` | | + +## Types + +### farmConfigOption + +**Definition:** + +```typescript +| { kind: "updateRewardRps" } + | { kind: "updateRewardMinClaimDuration" } + | { kind: "withdrawAuthority" } + | { kind: "depositWarmupPeriod" } + | { kind: "withdrawCooldownPeriod" } + | { kind: "rewardType" } + | { kind: "rpsDecimals" } + | { kind: "lockingMode" } + | { kind: "lockingStartTimestamp" } + | { kind: "lockingDuration" } + | { kind: "lockingEarlyWithdrawalPenaltyBps" } + | { kind: "depositCapAmount" } + | { kind: "slashedAmountSpillAddress" } + | { kind: "scopePricesAccount" } + | { kind: "scopeOraclePriceId" } + | { kind: "scopeOracleMaxAge" } + | { kind: "updateRewardScheduleCurvePoints" } + | { kind: "updatePendingFarmAdmin" } + | { kind: "updateStrategyId" } + | { kind: "updateDelegatedRpsAdmin" } + | { kind: "updateVaultId" } +``` + +### globalConfigOption + +**Definition:** + +```typescript +| { kind: "setPendingGlobalAdmin" } + | { kind: "setTreasuryFeeBps" } +``` + +### lockingMode + +**Definition:** + +```typescript +| { kind: "none" } + | { kind: "continuous" } + | { kind: "withExpiry" } +``` + +### rewardInfo + +**Definition:** + +```typescript +{ + token: tokenInfo; + rewardsVault: PublicKey; + rewardsAvailable: bigint; + rewardScheduleCurve: rewardScheduleCurve; + minClaimDurationSeconds: bigint; + lastIssuanceTs: bigint; + rewardsIssuedUnclaimed: bigint; + rewardsIssuedCumulative: bigint; + rewardPerShareScaled: bigint; + placeholder0: bigint; + rewardType: bigint; + rewardsPerSecondDecimals: bigint; + padding0: bigint[6]; + padding1: bigint[20]; +} +``` + +### rewardPerTimeUnitPoint + +**Definition:** + +```typescript +{ + tsStart: bigint; + rewardPerTimeUnit: bigint; +} +``` + +### rewardScheduleCurve + +**Definition:** + +```typescript +{ + points: rewardPerTimeUnitPoint[20]; +} +``` + +### rewardType + +**Definition:** + +```typescript +| { kind: "proportional" } + | { kind: "constant" } +``` + +### timeUnit + +**Definition:** + +```typescript +| { kind: "seconds" } + | { kind: "slots" } +``` + +### farmsTokenInfo + +**Definition:** + +```typescript +{ + mint: PublicKey; + decimals: bigint; + tokenProgram: PublicKey; + padding: bigint[6]; +} +``` + +### datedPrice + +**Definition:** + +```typescript +{ + price: price; + lastUpdatedSlot: bigint; + unixTimestamp: bigint; + reserved: bigint[2]; + reserved2: bigint[3]; + index: bigint; +} +``` + +### price + +**Definition:** + +```typescript +{ + value: bigint; + exp: bigint; +} +``` + +## Errors + +- **6000 - StakeZero**: Cannot stake 0 amount _(Hex: `0x1770`)_ +- **6001 - UnstakeZero**: Cannot unstake 0 amount _(Hex: `0x1771`)_ +- **6002 - NothingToUnstake**: Nothing to unstake _(Hex: `0x1772`)_ +- **6003 - NoRewardToHarvest**: No reward to harvest _(Hex: `0x1773`)_ +- **6004 - NoRewardInList**: Reward not present in reward list _(Hex: `0x1774`)_ +- **6005 - RewardAlreadyInitialized**: Reward already initialized _(Hex: `0x1775`)_ +- **6006 - MaxRewardNumberReached**: Max number of reward tokens reached _(Hex: `0x1776`)_ +- **6007 - RewardDoesNotExist**: Reward does not exist _(Hex: `0x1777`)_ +- **6008 - WrongRewardVaultAccount**: Reward vault exists but the account is wrong _(Hex: `0x1778`)_ +- **6009 - RewardVaultMismatch**: Reward vault pubkey does not match staking pool vault _(Hex: `0x1779`)_ +- **6010 - RewardVaultAuthorityMismatch**: Reward vault authority pubkey does not match staking pool vault _(Hex: `0x177a`)_ +- **6011 - NothingStaked**: Nothing staked, cannot collect any rewards _(Hex: `0x177b`)_ +- **6012 - IntegerOverflow**: Integer overflow _(Hex: `0x177c`)_ +- **6013 - ConversionFailure**: Conversion failure _(Hex: `0x177d`)_ +- **6014 - UnexpectedAccount**: Unexpected account in instruction _(Hex: `0x177e`)_ +- **6015 - OperationForbidden**: Operation forbidden _(Hex: `0x177f`)_ +- **6016 - MathOverflow**: Mathematical operation with overflow _(Hex: `0x1780`)_ +- **6017 - MinClaimDurationNotReached**: Minimum claim duration has not been reached _(Hex: `0x1781`)_ +- **6018 - RewardsVaultHasDelegate**: Reward vault has a delegate _(Hex: `0x1782`)_ +- **6019 - RewardsVaultHasCloseAuthority**: Reward vault has a close authority _(Hex: `0x1783`)_ +- **6020 - FarmVaultHasDelegate**: Farm vault has a delegate _(Hex: `0x1784`)_ +- **6021 - FarmVaultHasCloseAuthority**: Farm vault has a close authority _(Hex: `0x1785`)_ +- **6022 - RewardsTreasuryVaultHasDelegate**: Reward vault has a delegate _(Hex: `0x1786`)_ +- **6023 - RewardsTreasuryVaultHasCloseAuthority**: Reward vault has a close authority _(Hex: `0x1787`)_ +- **6024 - UserAtaRewardVaultMintMissmatch**: User ata and reward vault have different mints _(Hex: `0x1788`)_ +- **6025 - UserAtaFarmTokenMintMissmatch**: User ata and farm token have different mints _(Hex: `0x1789`)_ +- **6026 - TokenFarmTokenMintMissmatch**: Token mint and farm token have different mints _(Hex: `0x178a`)_ +- **6027 - RewardAtaRewardMintMissmatch**: Reward ata mint is different than reward mint _(Hex: `0x178b`)_ +- **6028 - RewardAtaOwnerNotPayer**: Reward ata owner is different than payer _(Hex: `0x178c`)_ +- **6029 - InvalidGlobalConfigMode**: Mode to update global_config is invalid _(Hex: `0x178d`)_ +- **6030 - RewardIndexOutOfRange**: Reward Index is higher than number of rewards _(Hex: `0x178e`)_ +- **6031 - NothingToWithdraw**: No tokens available to withdraw _(Hex: `0x178f`)_ +- **6032 - UserDelegatedFarmNonDelegatedMissmatch**: user, user_ref, authority and payer must match for non-delegated farm _(Hex: `0x1790`)_ +- **6033 - AuthorityFarmDelegateMissmatch**: Authority must match farm delegate authority _(Hex: `0x1791`)_ +- **6034 - FarmNotDelegated**: Farm not delegated, can not set stake _(Hex: `0x1792`)_ +- **6035 - FarmDelegated**: Operation not allowed for delegated farm _(Hex: `0x1793`)_ +- **6036 - UnstakeNotElapsed**: Unstake lockup period is not elapsed. Deposit is locked until end of unstake period _(Hex: `0x1794`)_ +- **6037 - PendingWithdrawalNotWithdrawnYet**: Pending withdrawal already exist and not withdrawn yet _(Hex: `0x1795`)_ +- **6038 - DepositZero**: Cannot deposit zero amount directly to farm vault _(Hex: `0x1796`)_ +- **6039 - InvalidConfigValue**: Invalid config value _(Hex: `0x1797`)_ +- **6040 - InvalidPenaltyPercentage**: Invalid penalty percentage _(Hex: `0x1798`)_ +- **6041 - EarlyWithdrawalNotAllowed**: Early withdrawal not allowed _(Hex: `0x1799`)_ +- **6042 - InvalidLockingTimestamps**: Invalid locking timestamps _(Hex: `0x179a`)_ +- **6043 - InvalidRpsCurvePoint**: Invalid reward rate curve point _(Hex: `0x179b`)_ +- **6044 - InvalidTimestamp**: Invalid timestamp _(Hex: `0x179c`)_ +- **6045 - DepositCapReached**: Deposit cap reached _(Hex: `0x179d`)_ +- **6046 - MissingScopePrices**: Missing Scope Prices _(Hex: `0x179e`)_ +- **6047 - ScopeOraclePriceTooOld**: Scope Oracle Price Too Old _(Hex: `0x179f`)_ +- **6048 - InvalidOracleConfig**: Invalid Oracle Config _(Hex: `0x17a0`)_ +- **6049 - CouldNotDeserializeScope**: Could not deserialize scope _(Hex: `0x17a1`)_ +- **6050 - RewardAtaOwnerNotAdmin**: Reward ata owner is different than farm admin _(Hex: `0x17a2`)_ +- **6051 - WithdrawRewardZeroAvailable**: Cannot withdraw reward as available amount is zero _(Hex: `0x17a3`)_ +- **6052 - RewardScheduleCurveSet**: Cannot withdraw reward as reward schedule is set _(Hex: `0x17a4`)_ +- **6053 - UnsupportedTokenExtension**: Cannot initialize farm while having a mint with token22 and requested extensions _(Hex: `0x17a5`)_ +- **6054 - InvalidFarmConfigUpdateAuthority**: Invalid authority for updating farm config _(Hex: `0x17a6`)_ diff --git a/clients/kamino-lending/docs/kamino-lending.md b/clients/kamino-lending/docs/kamino-lending.md new file mode 100644 index 00000000..da6557a7 --- /dev/null +++ b/clients/kamino-lending/docs/kamino-lending.md @@ -0,0 +1,2000 @@ +# Kamino Lending Program + +[![npm version](https://badge.fury.io/js/%40macalinao%2Fclients-kamino-lending.svg)](https://www.npmjs.com/package/%40macalinao%2Fclients-kamino-lending) + +- Program ID: `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD` +- TypeScript Client: [`@macalinao/clients-kamino-lending`](https://www.npmjs.com/package/@macalinao/clients-kamino-lending) + +## Table of Contents + +- [Accounts](#accounts) + - [userState](#userState) + - [lendingMarket](#lendingMarket) + - [obligation](#obligation) + - [referrerState](#referrerState) + - [referrerTokenState](#referrerTokenState) + - [shortUrl](#shortUrl) + - [userMetadata](#userMetadata) + - [reserve](#reserve) +- [Instructions](#instructions) + - [initLendingMarket](#initLendingMarket) + - [updateLendingMarket](#updateLendingMarket) + - [updateLendingMarketOwner](#updateLendingMarketOwner) + - [initReserve](#initReserve) + - [initFarmsForReserve](#initFarmsForReserve) + - [updateReserveConfig](#updateReserveConfig) + - [redeemFees](#redeemFees) + - [withdrawProtocolFee](#withdrawProtocolFee) + - [socializeLoss](#socializeLoss) + - [socializeLossV2](#socializeLossV2) + - [markObligationForDeleveraging](#markObligationForDeleveraging) + - [refreshReservesBatch](#refreshReservesBatch) + - [refreshReserve](#refreshReserve) + - [depositReserveLiquidity](#depositReserveLiquidity) + - [redeemReserveCollateral](#redeemReserveCollateral) + - [initObligation](#initObligation) + - [initObligationFarmsForReserve](#initObligationFarmsForReserve) + - [refreshObligationFarmsForReserve](#refreshObligationFarmsForReserve) + - [refreshObligation](#refreshObligation) + - [depositObligationCollateral](#depositObligationCollateral) + - [depositObligationCollateralV2](#depositObligationCollateralV2) + - [withdrawObligationCollateral](#withdrawObligationCollateral) + - [withdrawObligationCollateralV2](#withdrawObligationCollateralV2) + - [borrowObligationLiquidity](#borrowObligationLiquidity) + - [borrowObligationLiquidityV2](#borrowObligationLiquidityV2) + - [repayObligationLiquidity](#repayObligationLiquidity) + - [repayObligationLiquidityV2](#repayObligationLiquidityV2) + - [repayAndWithdrawAndRedeem](#repayAndWithdrawAndRedeem) + - [depositAndWithdraw](#depositAndWithdraw) + - [depositReserveLiquidityAndObligationCollateral](#depositReserveLiquidityAndObligationCollateral) + - [depositReserveLiquidityAndObligationCollateralV2](#depositReserveLiquidityAndObligationCollateralV2) + - [withdrawObligationCollateralAndRedeemReserveCollateral](#withdrawObligationCollateralAndRedeemReserveCollateral) + - [withdrawObligationCollateralAndRedeemReserveCollateralV2](#withdrawObligationCollateralAndRedeemReserveCollateralV2) + - [liquidateObligationAndRedeemReserveCollateral](#liquidateObligationAndRedeemReserveCollateral) + - [liquidateObligationAndRedeemReserveCollateralV2](#liquidateObligationAndRedeemReserveCollateralV2) + - [flashRepayReserveLiquidity](#flashRepayReserveLiquidity) + - [flashBorrowReserveLiquidity](#flashBorrowReserveLiquidity) + - [requestElevationGroup](#requestElevationGroup) + - [initReferrerTokenState](#initReferrerTokenState) + - [initUserMetadata](#initUserMetadata) + - [withdrawReferrerFees](#withdrawReferrerFees) + - [initReferrerStateAndShortUrl](#initReferrerStateAndShortUrl) + - [deleteReferrerStateAndShortUrl](#deleteReferrerStateAndShortUrl) + - [idlMissingTypes](#idlMissingTypes) +- [PDAs](#pdas) + - [obligation](#obligation) + - [lendingMarketAuth](#lendingMarketAuth) + - [reserveLiquiditySupply](#reserveLiquiditySupply) + - [reserveFeeVault](#reserveFeeVault) + - [reserveCollateralMint](#reserveCollateralMint) + - [reserveCollateralSupply](#reserveCollateralSupply) + - [userMetadata](#userMetadata) + - [referrerTokenState](#referrerTokenState) + - [referrerState](#referrerState) + - [shortUrl](#shortUrl) +- [Types](#types) + - [updateConfigMode](#updateConfigMode) + - [updateLendingMarketConfigValue](#updateLendingMarketConfigValue) + - [updateLendingMarketMode](#updateLendingMarketMode) + - [lastUpdate](#lastUpdate) + - [elevationGroupLendingMarket](#elevationGroupLendingMarket) + - [elevationGroup](#elevationGroup) + - [initObligationArgs](#initObligationArgs) + - [obligationCollateral](#obligationCollateral) + - [obligationLiquidity](#obligationLiquidity) + - [assetTier](#assetTier) + - [bigFractionBytes](#bigFractionBytes) + - [feeCalculation](#feeCalculation) + - [reserveCollateral](#reserveCollateral) + - [reserveConfig](#reserveConfig) + - [reserveFarmKind](#reserveFarmKind) + - [reserveFees](#reserveFees) + - [reserveLiquidity](#reserveLiquidity) + - [reserveStatus](#reserveStatus) + - [withdrawalCaps](#withdrawalCaps) + - [priceHeuristic](#priceHeuristic) + - [pythConfiguration](#pythConfiguration) + - [scopeConfiguration](#scopeConfiguration) + - [switchboardConfiguration](#switchboardConfiguration) + - [tokenInfo](#tokenInfo) + - [borrowRateCurve](#borrowRateCurve) + - [curvePoint](#curvePoint) +- [Errors](#errors) + +## Accounts + +### userState + +**Fields:** + +| Field | Type | Description | +| -------------------------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `userId` | `u64` | | +| `farmState` | `PublicKey` | | +| `owner` | `PublicKey` | | +| `isFarmDelegated` | `u8` | | +| `padding0` | `u8`[7] | | +| `rewardsTallyScaled` | `u128`[10] | | +| `rewardsIssuedUnclaimed` | `u64`[10] | | +| `lastClaimTs` | `u64`[10] | | +| `activeStakeScaled` | `u128` | | +| `pendingDepositStakeScaled` | `u128` | | +| `pendingDepositStakeTs` | `u64` | | +| `pendingWithdrawalUnstakeScaled` | `u128` | | +| `pendingWithdrawalUnstakeTs` | `u64` | | +| `bump` | `u64` | | +| `delegatee` | `PublicKey` | | +| `lastStakeTs` | `u64` | | +| `padding1` | `u64`[50] | | + +### lendingMarket + +**Fields:** + +| Field | Type | Description | +| ---------------------------------------------- | ----------------------------------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `version` | `u64` | | +| `bumpSeed` | `u64` | | +| `lendingMarketOwner` | `PublicKey` | | +| `lendingMarketOwnerCached` | `PublicKey` | | +| `quoteCurrency` | `u8`[32] | | +| `referralFeeBps` | `u16` | | +| `emergencyMode` | `u8` | | +| `autodeleverageEnabled` | `u8` | | +| `borrowDisabled` | `u8` | | +| `priceRefreshTriggerToMaxAgePct` | `u8` | | +| `liquidationMaxDebtCloseFactorPct` | `u8` | | +| `insolvencyRiskUnhealthyLtvPct` | `u8` | | +| `minFullLiquidationValueThreshold` | `u64` | | +| `maxLiquidatableDebtMarketValueAtOnce` | `u64` | | +| `reserved0` | `u8`[8] | | +| `globalAllowedBorrowValue` | `u64` | | +| `riskCouncil` | `PublicKey` | | +| `reserved1` | `u8`[8] | | +| `elevationGroups` | [elevationGroupLendingMarket](#elevationGroupLendingMarket-3)[32] | | +| `elevationGroupPadding` | `u64`[90] | | +| `minNetValueInObligationSf` | `u128` | | +| `minValueSkipLiquidationLtvChecks` | `u64` | | +| `name` | `u8`[32] | | +| `minValueSkipLiquidationBfChecks` | `u64` | | +| `individualAutodeleverageMarginCallPeriodSecs` | `u64` | | +| `minInitialDepositAmount` | `u64` | | +| `padding1` | `u64`[170] | | + +### obligation + +**Fields:** + +| Field | Type | Description | +| ------------------------------------------ | -------------------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `tag` | `u64` | | +| `lastUpdate` | [lastUpdate](#lastUpdate-3) | | +| `lendingMarket` | `PublicKey` | | +| `owner` | `PublicKey` | | +| `deposits` | [obligationCollateral](#obligationCollateral-3)[8] | | +| `lowestReserveDepositLiquidationLtv` | `u64` | | +| `depositedValueSf` | `u128` | | +| `borrows` | [obligationLiquidity](#obligationLiquidity-3)[5] | | +| `borrowFactorAdjustedDebtValueSf` | `u128` | | +| `borrowedAssetsMarketValueSf` | `u128` | | +| `allowedBorrowValueSf` | `u128` | | +| `unhealthyBorrowValueSf` | `u128` | | +| `depositsAssetTiers` | `u8`[8] | | +| `borrowsAssetTiers` | `u8`[5] | | +| `elevationGroup` | `u8` | | +| `numOfObsoleteReserves` | `u8` | | +| `hasDebt` | `u8` | | +| `referrer` | `PublicKey` | | +| `borrowingDisabled` | `u8` | | +| `autodeleverageTargetLtvPct` | `u8` | | +| `lowestReserveDepositMaxLtvPct` | `u8` | | +| `reserved` | `u8`[5] | | +| `highestBorrowFactorPct` | `u64` | | +| `autodeleverageMarginCallStartedTimestamp` | `u64` | | +| `padding3` | `u64`[125] | | + +### referrerState + +**Fields:** + +| Field | Type | Description | +| --------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `shortUrl` | `PublicKey` | | +| `owner` | `PublicKey` | | + +### referrerTokenState + +**Fields:** + +| Field | Type | Description | +| -------------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `referrer` | `PublicKey` | | +| `mint` | `PublicKey` | | +| `amountUnclaimedSf` | `u128` | | +| `amountCumulativeSf` | `u128` | | +| `bump` | `u64` | | +| `padding` | `u64`[31] | | + +### shortUrl + +**Fields:** + +| Field | Type | Description | +| --------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `referrer` | `PublicKey` | | +| `shortUrl` | `unknown` | | + +### userMetadata + +**Fields:** + +| Field | Type | Description | +| ----------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `referrer` | `PublicKey` | | +| `bump` | `u64` | | +| `userLookupTable` | `PublicKey` | | +| `owner` | `PublicKey` | | +| `padding1` | `u64`[51] | | +| `padding2` | `u64`[64] | | + +### reserve + +**Fields:** + +| Field | Type | Description | +| ---------------------------------------------------- | ----------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `version` | `u64` | | +| `lastUpdate` | [lastUpdate](#lastUpdate-3) | | +| `lendingMarket` | `PublicKey` | | +| `farmCollateral` | `PublicKey` | | +| `farmDebt` | `PublicKey` | | +| `liquidity` | [reserveLiquidity](#reserveLiquidity-3) | | +| `reserveLiquidityPadding` | `u64`[150] | | +| `collateral` | [reserveCollateral](#reserveCollateral-3) | | +| `reserveCollateralPadding` | `u64`[150] | | +| `config` | [reserveConfig](#reserveConfig-3) | | +| `configPadding` | `u64`[116] | | +| `borrowedAmountOutsideElevationGroup` | `u64` | | +| `borrowedAmountsAgainstThisReserveInElevationGroups` | `u64`[32] | | +| `padding` | `u64`[207] | | + +## Instructions + +### initLendingMarket + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | ---------------- | ----------- | +| `lendingMarketOwner` | signer, writable | | +| `lendingMarket` | writable | | +| `lendingMarketAuthority` | readonly | | +| `systemProgram` | readonly | | +| `rent` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `quoteCurrency` | `u8`[32] | | + +### updateLendingMarket + +**Accounts:** + +| Account | Type | Description | +| -------------------- | -------- | ----------- | +| `lendingMarketOwner` | signer | | +| `lendingMarket` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u64` | | +| `value` | `u8`[72] | | + +### updateLendingMarketOwner + +**Accounts:** + +| Account | Type | Description | +| -------------------------- | -------- | ----------- | +| `lendingMarketOwnerCached` | signer | | +| `lendingMarket` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initReserve + +**Accounts:** + +| Account | Type | Description | +| ------------------------- | ---------------- | ----------- | +| `lendingMarketOwner` | signer, writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveLiquiditySupply` | writable | | +| `feeReceiver` | writable | | +| `reserveCollateralMint` | writable | | +| `reserveCollateralSupply` | writable | | +| `initialLiquiditySource` | writable | | +| `rent` | readonly | | +| `liquidityTokenProgram` | readonly | | +| `collateralTokenProgram` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initFarmsForReserve + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | ---------------- | ----------- | +| `lendingMarketOwner` | signer, writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `reserve` | writable | | +| `farmsProgram` | readonly | | +| `farmsGlobalConfig` | readonly | | +| `farmState` | writable | | +| `farmsVaultAuthority` | readonly | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u8` | | + +### updateReserveConfig + +**Accounts:** + +| Account | Type | Description | +| -------------------- | -------- | ----------- | +| `lendingMarketOwner` | signer | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| ---------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u64` | | +| `value` | `unknown` | | +| `skipValidation` | `boolean` | | + +### redeemFees + +**Accounts:** + +| Account | Type | Description | +| ----------------------------- | -------- | ----------- | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveLiquidityFeeReceiver` | writable | | +| `reserveSupplyLiquidity` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### withdrawProtocolFee + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | -------- | ----------- | +| `lendingMarketOwner` | signer | | +| `lendingMarket` | readonly | | +| `reserve` | readonly | | +| `reserveLiquidityMint` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `feeVault` | writable | | +| `lendingMarketOwnerAta` | writable | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `amount` | `u64` | | + +### socializeLoss + +**Accounts:** + +| Account | Type | Description | +| -------------------------- | -------- | ----------- | +| `riskCouncil` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### socializeLossV2 + +**Accounts:** + +| Account | Type | Description | +| ----------------------------------------------------- | ------------------ | ----------- | +| `socializeLossAccountsRiskCouncil` | signer | | +| `socializeLossAccountsObligation` | writable | | +| `socializeLossAccountsLendingMarket` | readonly | | +| `socializeLossAccountsReserve` | writable | | +| `socializeLossAccountsInstructionSysvarAccount` | readonly | | +| `socializeLossV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `socializeLossV2FarmsAccountsReserveFarmState` | writable, optional | | +| `lendingMarketAuthority` | readonly | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### markObligationForDeleveraging + +**Accounts:** + +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `riskCouncil` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ---------------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `autodeleverageTargetLtvPct` | `u8` | | + +### refreshReservesBatch + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `skipPriceUpdates` | `boolean` | | + +### refreshReserve + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | -------- | ----------- | +| `reserve` | writable | | +| `lendingMarket` | readonly | | +| `pythOracle` | optional | | +| `switchboardPriceOracle` | optional | | +| `switchboardTwapOracle` | optional | | +| `scopePrices` | optional | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### depositReserveLiquidity + +**Accounts:** + +| Account | Type | Description | +| --------------------------- | -------- | ----------- | +| `owner` | signer | | +| `reserve` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `reserveLiquidityMint` | readonly | | +| `reserveLiquiditySupply` | writable | | +| `reserveCollateralMint` | writable | | +| `userSourceLiquidity` | writable | | +| `userDestinationCollateral` | writable | | +| `collateralTokenProgram` | readonly | | +| `liquidityTokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### redeemReserveCollateral + +**Accounts:** + +| Account | Type | Description | +| -------------------------- | -------- | ----------- | +| `owner` | signer | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | +| `lendingMarketAuthority` | readonly | | +| `reserveLiquidityMint` | readonly | | +| `reserveCollateralMint` | writable | | +| `reserveLiquiditySupply` | writable | | +| `userSourceCollateral` | writable | | +| `userDestinationLiquidity` | writable | | +| `collateralTokenProgram` | readonly | | +| `liquidityTokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### initObligation + +**Accounts:** + +| Account | Type | Description | +| ------------------- | ---------------- | ----------- | +| `obligationOwner` | signer | | +| `feePayer` | signer, writable | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `seed1Account` | readonly | | +| `seed2Account` | readonly | | +| `ownerUserMetadata` | readonly | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | ------------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `args` | [initObligationArgs](#initObligationArgs-3) | | + +### initObligationFarmsForReserve + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | ---------------- | ----------- | +| `payer` | signer, writable | | +| `owner` | readonly | | +| `obligation` | writable | | +| `lendingMarketAuthority` | readonly | | +| `reserve` | writable | | +| `reserveFarmState` | writable | | +| `obligationFarm` | writable | | +| `lendingMarket` | readonly | | +| `farmsProgram` | readonly | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u8` | | + +### refreshObligationFarmsForReserve + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------- | -------- | ----------- | +| `crank` | signer | | +| `baseAccountsObligation` | readonly | | +| `baseAccountsLendingMarketAuthority` | readonly | | +| `baseAccountsReserve` | readonly | | +| `baseAccountsReserveFarmState` | writable | | +| `baseAccountsObligationFarmUserState` | writable | | +| `baseAccountsLendingMarket` | readonly | | +| `farmsProgram` | readonly | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `mode` | `u8` | | + +### refreshObligation + +**Accounts:** + +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `lendingMarket` | readonly | | +| `obligation` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### depositObligationCollateral + +**Accounts:** + +| Account | Type | Description | +| ------------------------------ | -------- | ----------- | +| `owner` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `depositReserve` | writable | | +| `reserveDestinationCollateral` | writable | | +| `userSourceCollateral` | writable | | +| `tokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### depositObligationCollateralV2 + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------------------------------------- | ------------------ | ----------- | +| `depositAccountsOwner` | signer | | +| `depositAccountsObligation` | writable | | +| `depositAccountsLendingMarket` | readonly | | +| `depositAccountsDepositReserve` | writable | | +| `depositAccountsReserveDestinationCollateral` | writable | | +| `depositAccountsUserSourceCollateral` | writable | | +| `depositAccountsTokenProgram` | readonly | | +| `depositAccountsInstructionSysvarAccount` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `depositObligationCollateralV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `depositObligationCollateralV2FarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### withdrawObligationCollateral + +**Accounts:** + +| Account | Type | Description | +| --------------------------- | -------- | ----------- | +| `owner` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `withdrawReserve` | writable | | +| `reserveSourceCollateral` | writable | | +| `userDestinationCollateral` | writable | | +| `tokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### withdrawObligationCollateralV2 + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------------- | ------------------ | ----------- | +| `withdrawAccountsOwner` | signer | | +| `withdrawAccountsObligation` | writable | | +| `withdrawAccountsLendingMarket` | readonly | | +| `withdrawAccountsLendingMarketAuthority` | readonly | | +| `withdrawAccountsWithdrawReserve` | writable | | +| `withdrawAccountsReserveSourceCollateral` | writable | | +| `withdrawAccountsUserDestinationCollateral` | writable | | +| `withdrawAccountsTokenProgram` | readonly | | +| `withdrawAccountsInstructionSysvarAccount` | readonly | | +| `farmsAccountsObligationFarmUserState` | writable, optional | | +| `farmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### borrowObligationLiquidity + +**Accounts:** + +| Account | Type | Description | +| ----------------------------------- | ------------------ | ----------- | +| `owner` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `borrowReserve` | writable | | +| `borrowReserveLiquidityMint` | readonly | | +| `reserveSourceLiquidity` | writable | | +| `borrowReserveLiquidityFeeReceiver` | writable | | +| `userDestinationLiquidity` | writable | | +| `referrerTokenState` | writable, optional | | +| `tokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### borrowObligationLiquidityV2 + +**Accounts:** + +| Account | Type | Description | +| ----------------------------------------------------------------- | ------------------ | ----------- | +| `borrowAccountsOwner` | signer | | +| `borrowAccountsObligation` | writable | | +| `borrowAccountsLendingMarket` | readonly | | +| `borrowAccountsLendingMarketAuthority` | readonly | | +| `borrowAccountsBorrowReserve` | writable | | +| `borrowAccountsBorrowReserveLiquidityMint` | readonly | | +| `borrowAccountsReserveSourceLiquidity` | writable | | +| `borrowAccountsBorrowReserveLiquidityFeeReceiver` | writable | | +| `borrowAccountsUserDestinationLiquidity` | writable | | +| `borrowAccountsReferrerTokenState` | writable, optional | | +| `borrowAccountsTokenProgram` | readonly | | +| `borrowAccountsInstructionSysvarAccount` | readonly | | +| `borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `borrowObligationLiquidityV2FarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### repayObligationLiquidity + +**Accounts:** + +| Account | Type | Description | +| ----------------------------- | -------- | ----------- | +| `owner` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `repayReserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveDestinationLiquidity` | writable | | +| `userSourceLiquidity` | writable | | +| `tokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### repayObligationLiquidityV2 + +**Accounts:** + +| Account | Type | Description | +| ---------------------------------------------------------------- | ------------------ | ----------- | +| `repayAccountsOwner` | signer | | +| `repayAccountsObligation` | writable | | +| `repayAccountsLendingMarket` | readonly | | +| `repayAccountsRepayReserve` | writable | | +| `repayAccountsReserveLiquidityMint` | readonly | | +| `repayAccountsReserveDestinationLiquidity` | writable | | +| `repayAccountsUserSourceLiquidity` | writable | | +| `repayAccountsTokenProgram` | readonly | | +| `repayAccountsInstructionSysvarAccount` | readonly | | +| `repayObligationLiquidityV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `repayObligationLiquidityV2FarmsAccountsReserveFarmState` | writable, optional | | +| `lendingMarketAuthority` | readonly | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### repayAndWithdrawAndRedeem + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------------------------ | ------------------ | ----------- | +| `repayAccountsOwner` | signer | | +| `repayAccountsObligation` | writable | | +| `repayAccountsLendingMarket` | readonly | | +| `repayAccountsRepayReserve` | writable | | +| `repayAccountsReserveLiquidityMint` | readonly | | +| `repayAccountsReserveDestinationLiquidity` | writable | | +| `repayAccountsUserSourceLiquidity` | writable | | +| `repayAccountsTokenProgram` | readonly | | +| `repayAccountsInstructionSysvarAccount` | readonly | | +| `withdrawAccountsOwner` | signer, writable | | +| `withdrawAccountsObligation` | writable | | +| `withdrawAccountsLendingMarket` | readonly | | +| `withdrawAccountsLendingMarketAuthority` | readonly | | +| `withdrawAccountsWithdrawReserve` | writable | | +| `withdrawAccountsReserveLiquidityMint` | readonly | | +| `withdrawAccountsReserveSourceCollateral` | writable | | +| `withdrawAccountsReserveCollateralMint` | writable | | +| `withdrawAccountsReserveLiquiditySupply` | writable | | +| `withdrawAccountsUserDestinationLiquidity` | writable | | +| `withdrawAccountsPlaceholderUserDestinationCollateral` | optional | | +| `withdrawAccountsCollateralTokenProgram` | readonly | | +| `withdrawAccountsLiquidityTokenProgram` | readonly | | +| `withdrawAccountsInstructionSysvarAccount` | readonly | | +| `collateralFarmsAccountsObligationFarmUserState` | writable, optional | | +| `collateralFarmsAccountsReserveFarmState` | writable, optional | | +| `repayDebtFarmsAccountsObligationFarmUserState` | writable, optional | | +| `repayDebtFarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| -------------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `repayAmount` | `u64` | | +| `withdrawCollateralAmount` | `u64` | | + +### depositAndWithdraw + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------------------------ | ------------------ | ----------- | +| `depositAccountsOwner` | signer, writable | | +| `depositAccountsObligation` | writable | | +| `depositAccountsLendingMarket` | readonly | | +| `depositAccountsLendingMarketAuthority` | readonly | | +| `depositAccountsReserve` | writable | | +| `depositAccountsReserveLiquidityMint` | readonly | | +| `depositAccountsReserveLiquiditySupply` | writable | | +| `depositAccountsReserveCollateralMint` | writable | | +| `depositAccountsReserveDestinationDepositCollateral` | writable | | +| `depositAccountsUserSourceLiquidity` | writable | | +| `depositAccountsPlaceholderUserDestinationCollateral` | optional | | +| `depositAccountsCollateralTokenProgram` | readonly | | +| `depositAccountsLiquidityTokenProgram` | readonly | | +| `depositAccountsInstructionSysvarAccount` | readonly | | +| `withdrawAccountsOwner` | signer, writable | | +| `withdrawAccountsObligation` | writable | | +| `withdrawAccountsLendingMarket` | readonly | | +| `withdrawAccountsLendingMarketAuthority` | readonly | | +| `withdrawAccountsWithdrawReserve` | writable | | +| `withdrawAccountsReserveLiquidityMint` | readonly | | +| `withdrawAccountsReserveSourceCollateral` | writable | | +| `withdrawAccountsReserveCollateralMint` | writable | | +| `withdrawAccountsReserveLiquiditySupply` | writable | | +| `withdrawAccountsUserDestinationLiquidity` | writable | | +| `withdrawAccountsPlaceholderUserDestinationCollateral` | optional | | +| `withdrawAccountsCollateralTokenProgram` | readonly | | +| `withdrawAccountsLiquidityTokenProgram` | readonly | | +| `withdrawAccountsInstructionSysvarAccount` | readonly | | +| `depositFarmsAccountsObligationFarmUserState` | writable, optional | | +| `depositFarmsAccountsReserveFarmState` | writable, optional | | +| `withdrawFarmsAccountsObligationFarmUserState` | writable, optional | | +| `withdrawFarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| -------------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | +| `withdrawCollateralAmount` | `u64` | | + +### depositReserveLiquidityAndObligationCollateral + +**Accounts:** + +| Account | Type | Description | +| -------------------------------------- | ---------------- | ----------- | +| `owner` | signer, writable | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveLiquiditySupply` | writable | | +| `reserveCollateralMint` | writable | | +| `reserveDestinationDepositCollateral` | writable | | +| `userSourceLiquidity` | writable | | +| `placeholderUserDestinationCollateral` | optional | | +| `collateralTokenProgram` | readonly | | +| `liquidityTokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### depositReserveLiquidityAndObligationCollateralV2 + +**Accounts:** + +| Account | Type | Description | +| -------------------------------------------------------------------------------------- | ------------------ | ----------- | +| `depositAccountsOwner` | signer, writable | | +| `depositAccountsObligation` | writable | | +| `depositAccountsLendingMarket` | readonly | | +| `depositAccountsLendingMarketAuthority` | readonly | | +| `depositAccountsReserve` | writable | | +| `depositAccountsReserveLiquidityMint` | readonly | | +| `depositAccountsReserveLiquiditySupply` | writable | | +| `depositAccountsReserveCollateralMint` | writable | | +| `depositAccountsReserveDestinationDepositCollateral` | writable | | +| `depositAccountsUserSourceLiquidity` | writable | | +| `depositAccountsPlaceholderUserDestinationCollateral` | optional | | +| `depositAccountsCollateralTokenProgram` | readonly | | +| `depositAccountsLiquidityTokenProgram` | readonly | | +| `depositAccountsInstructionSysvarAccount` | readonly | | +| `depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### withdrawObligationCollateralAndRedeemReserveCollateral + +**Accounts:** + +| Account | Type | Description | +| -------------------------------------- | ---------------- | ----------- | +| `owner` | signer, writable | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `withdrawReserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveSourceCollateral` | writable | | +| `reserveCollateralMint` | writable | | +| `reserveLiquiditySupply` | writable | | +| `userDestinationLiquidity` | writable | | +| `placeholderUserDestinationCollateral` | optional | | +| `collateralTokenProgram` | readonly | | +| `liquidityTokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### withdrawObligationCollateralAndRedeemReserveCollateralV2 + +**Accounts:** + +| Account | Type | Description | +| ---------------------------------------------------------------------------------------------- | ------------------ | ----------- | +| `withdrawAccountsOwner` | signer, writable | | +| `withdrawAccountsObligation` | writable | | +| `withdrawAccountsLendingMarket` | readonly | | +| `withdrawAccountsLendingMarketAuthority` | readonly | | +| `withdrawAccountsWithdrawReserve` | writable | | +| `withdrawAccountsReserveLiquidityMint` | readonly | | +| `withdrawAccountsReserveSourceCollateral` | writable | | +| `withdrawAccountsReserveCollateralMint` | writable | | +| `withdrawAccountsReserveLiquiditySupply` | writable | | +| `withdrawAccountsUserDestinationLiquidity` | writable | | +| `withdrawAccountsPlaceholderUserDestinationCollateral` | optional | | +| `withdrawAccountsCollateralTokenProgram` | readonly | | +| `withdrawAccountsLiquidityTokenProgram` | readonly | | +| `withdrawAccountsInstructionSysvarAccount` | readonly | | +| `withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState` | writable, optional | | +| `withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `collateralAmount` | `u64` | | + +### liquidateObligationAndRedeemReserveCollateral + +**Accounts:** + +| Account | Type | Description | +| ------------------------------------- | -------- | ----------- | +| `liquidator` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `repayReserve` | writable | | +| `repayReserveLiquidityMint` | readonly | | +| `repayReserveLiquiditySupply` | writable | | +| `withdrawReserve` | writable | | +| `withdrawReserveLiquidityMint` | readonly | | +| `withdrawReserveCollateralMint` | writable | | +| `withdrawReserveCollateralSupply` | writable | | +| `withdrawReserveLiquiditySupply` | writable | | +| `withdrawReserveLiquidityFeeReceiver` | writable | | +| `userSourceLiquidity` | writable | | +| `userDestinationCollateral` | writable | | +| `userDestinationLiquidity` | writable | | +| `collateralTokenProgram` | readonly | | +| `repayLiquidityTokenProgram` | readonly | | +| `withdrawLiquidityTokenProgram` | readonly | | +| `instructionSysvarAccount` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| -------------------------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | +| `minAcceptableReceivedLiquidityAmount` | `u64` | | +| `maxAllowedLtvOverridePercent` | `u64` | | + +### liquidateObligationAndRedeemReserveCollateralV2 + +**Accounts:** + +| Account | Type | Description | +| -------------------------------------------------------- | ------------------ | ----------- | +| `liquidationAccountsLiquidator` | signer | | +| `liquidationAccountsObligation` | writable | | +| `liquidationAccountsLendingMarket` | readonly | | +| `liquidationAccountsLendingMarketAuthority` | readonly | | +| `liquidationAccountsRepayReserve` | writable | | +| `liquidationAccountsRepayReserveLiquidityMint` | readonly | | +| `liquidationAccountsRepayReserveLiquiditySupply` | writable | | +| `liquidationAccountsWithdrawReserve` | writable | | +| `liquidationAccountsWithdrawReserveLiquidityMint` | readonly | | +| `liquidationAccountsWithdrawReserveCollateralMint` | writable | | +| `liquidationAccountsWithdrawReserveCollateralSupply` | writable | | +| `liquidationAccountsWithdrawReserveLiquiditySupply` | writable | | +| `liquidationAccountsWithdrawReserveLiquidityFeeReceiver` | writable | | +| `liquidationAccountsUserSourceLiquidity` | writable | | +| `liquidationAccountsUserDestinationCollateral` | writable | | +| `liquidationAccountsUserDestinationLiquidity` | writable | | +| `liquidationAccountsCollateralTokenProgram` | readonly | | +| `liquidationAccountsRepayLiquidityTokenProgram` | readonly | | +| `liquidationAccountsWithdrawLiquidityTokenProgram` | readonly | | +| `liquidationAccountsInstructionSysvarAccount` | readonly | | +| `collateralFarmsAccountsV2ObligationFarmUserState` | writable, optional | | +| `collateralFarmsAccountsV2ReserveFarmState` | writable, optional | | +| `debtFarmsAccountsObligationFarmUserState` | writable, optional | | +| `debtFarmsAccountsReserveFarmState` | writable, optional | | +| `farmsProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| -------------------------------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | +| `minAcceptableReceivedLiquidityAmount` | `u64` | | +| `maxAllowedLtvOverridePercent` | `u64` | | + +### flashRepayReserveLiquidity + +**Accounts:** + +| Account | Type | Description | +| ----------------------------- | ------------------ | ----------- | +| `userTransferAuthority` | signer | | +| `lendingMarketAuthority` | readonly | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveDestinationLiquidity` | writable | | +| `userSourceLiquidity` | writable | | +| `reserveLiquidityFeeReceiver` | writable | | +| `referrerTokenState` | writable, optional | | +| `referrerAccount` | writable, optional | | +| `sysvarInfo` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ------------------------ | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | +| `borrowInstructionIndex` | `u8` | | + +### flashBorrowReserveLiquidity + +**Accounts:** + +| Account | Type | Description | +| ----------------------------- | ------------------ | ----------- | +| `userTransferAuthority` | signer | | +| `lendingMarketAuthority` | readonly | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveSourceLiquidity` | writable | | +| `userDestinationLiquidity` | writable | | +| `reserveLiquidityFeeReceiver` | writable | | +| `referrerTokenState` | writable, optional | | +| `referrerAccount` | writable, optional | | +| `sysvarInfo` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `liquidityAmount` | `u64` | | + +### requestElevationGroup + +**Accounts:** + +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `owner` | signer | | +| `obligation` | writable | | +| `lendingMarket` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ---------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `elevationGroup` | `u8` | | + +### initReferrerTokenState + +**Accounts:** + +| Account | Type | Description | +| -------------------- | ---------------- | ----------- | +| `payer` | signer, writable | | +| `lendingMarket` | readonly | | +| `reserve` | readonly | | +| `referrer` | readonly | | +| `referrerTokenState` | writable | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initUserMetadata + +**Accounts:** + +| Account | Type | Description | +| ---------------------- | ---------------- | ----------- | +| `owner` | signer | | +| `feePayer` | signer, writable | | +| `userMetadata` | writable | | +| `referrerUserMetadata` | optional | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| ----------------- | ----------- | ----------- | +| `discriminator` | `unknown` | | +| `userLookupTable` | `PublicKey` | | + +### withdrawReferrerFees + +**Accounts:** + +| Account | Type | Description | +| ------------------------ | ---------------- | ----------- | +| `referrer` | signer, writable | | +| `referrerTokenState` | writable | | +| `reserve` | writable | | +| `reserveLiquidityMint` | readonly | | +| `reserveSupplyLiquidity` | writable | | +| `referrerTokenAccount` | writable | | +| `lendingMarket` | readonly | | +| `lendingMarketAuthority` | readonly | | +| `tokenProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### initReferrerStateAndShortUrl + +**Accounts:** + +| Account | Type | Description | +| ---------------------- | ---------------- | ----------- | +| `referrer` | signer, writable | | +| `referrerState` | writable | | +| `referrerShortUrl` | writable | | +| `referrerUserMetadata` | readonly | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | +| `shortUrl` | `unknown` | | + +### deleteReferrerStateAndShortUrl + +**Accounts:** + +| Account | Type | Description | +| --------------- | ---------------- | ----------- | +| `referrer` | signer, writable | | +| `referrerState` | writable | | +| `shortUrl` | writable | | +| `rent` | readonly | | +| `systemProgram` | readonly | | + +**Arguments:** + +| Argument | Type | Description | +| --------------- | --------- | ----------- | +| `discriminator` | `unknown` | | + +### idlMissingTypes + +**Accounts:** + +| Account | Type | Description | +| -------------------- | -------- | ----------- | +| `lendingMarketOwner` | signer | | +| `lendingMarket` | readonly | | +| `reserve` | writable | | + +**Arguments:** + +| Argument | Type | Description | +| -------------------------------- | ------------------------------------------------------------------- | ----------- | +| `discriminator` | `unknown` | | +| `reserveFarmKind` | [reserveFarmKind](#reserveFarmKind-3) | | +| `assetTier` | [assetTier](#assetTier-3) | | +| `feeCalculation` | [feeCalculation](#feeCalculation-3) | | +| `reserveStatus` | [reserveStatus](#reserveStatus-3) | | +| `updateConfigMode` | [updateConfigMode](#updateConfigMode-3) | | +| `updateLendingMarketConfigValue` | [updateLendingMarketConfigValue](#updateLendingMarketConfigValue-3) | | +| `updateLendingMarketConfigMode` | [updateLendingMarketMode](#updateLendingMarketMode-3) | | + +## PDAs + +### obligation + +**Seeds:** + +| Seed | Type | Description | +| -------------- | ----------- | ----------- | +| `tag` | `u8` | | +| `id` | `u8` | | +| `user` | `PublicKey` | | +| `market` | `PublicKey` | | +| `seed1Account` | `PublicKey` | | +| `seed2Account` | `PublicKey` | | + +### lendingMarketAuth + +**Seeds:** + +| Seed | Type | Description | +| --------------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `lendingMarket` | `PublicKey` | | + +### reserveLiquiditySupply + +**Seeds:** + +| Seed | Type | Description | +| --------------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `lendingMarket` | `PublicKey` | | +| `mint` | `PublicKey` | | + +### reserveFeeVault + +**Seeds:** + +| Seed | Type | Description | +| --------------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `lendingMarket` | `PublicKey` | | +| `mint` | `PublicKey` | | + +### reserveCollateralMint + +**Seeds:** + +| Seed | Type | Description | +| --------------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `lendingMarket` | `PublicKey` | | +| `mint` | `PublicKey` | | + +### reserveCollateralSupply + +**Seeds:** + +| Seed | Type | Description | +| --------------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `lendingMarket` | `PublicKey` | | +| `mint` | `PublicKey` | | + +### userMetadata + +**Seeds:** + +| Seed | Type | Description | +| ---------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `user` | `PublicKey` | | + +### referrerTokenState + +**Seeds:** + +| Seed | Type | Description | +| ---------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `referrer` | `PublicKey` | | +| `reserve` | `PublicKey` | | + +### referrerState + +**Seeds:** + +| Seed | Type | Description | +| ---------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `referrer` | `PublicKey` | | + +### shortUrl + +**Seeds:** + +| Seed | Type | Description | +| ---------- | ---------------- | ----------- | +| `constant` | bytes (constant) | - | +| `shortUrl` | `string` | | + +## Types + +### updateConfigMode + +**Definition:** + +```typescript +| { kind: "updateLoanToValuePct" } + | { kind: "updateMaxLiquidationBonusBps" } + | { kind: "updateLiquidationThresholdPct" } + | { kind: "updateProtocolLiquidationFee" } + | { kind: "updateProtocolTakeRate" } + | { kind: "updateFeesBorrowFee" } + | { kind: "updateFeesFlashLoanFee" } + | { kind: "updateFeesReferralFeeBps" } + | { kind: "updateDepositLimit" } + | { kind: "updateBorrowLimit" } + | { kind: "updateTokenInfoLowerHeuristic" } + | { kind: "updateTokenInfoUpperHeuristic" } + | { kind: "updateTokenInfoExpHeuristic" } + | { kind: "updateTokenInfoTwapDivergence" } + | { kind: "updateTokenInfoScopeTwap" } + | { kind: "updateTokenInfoScopeChain" } + | { kind: "updateTokenInfoName" } + | { kind: "updateTokenInfoPriceMaxAge" } + | { kind: "updateTokenInfoTwapMaxAge" } + | { kind: "updateScopePriceFeed" } + | { kind: "updatePythPrice" } + | { kind: "updateSwitchboardFeed" } + | { kind: "updateSwitchboardTwapFeed" } + | { kind: "updateBorrowRateCurve" } + | { kind: "updateEntireReserveConfig" } + | { kind: "updateDebtWithdrawalCap" } + | { kind: "updateDepositWithdrawalCap" } + | { kind: "updateDebtWithdrawalCapCurrentTotal" } + | { kind: "updateDepositWithdrawalCapCurrentTotal" } + | { kind: "updateBadDebtLiquidationBonusBps" } + | { kind: "updateMinLiquidationBonusBps" } + | { kind: "updateDeleveragingMarginCallPeriod" } + | { kind: "updateBorrowFactor" } + | { kind: "updateAssetTier" } + | { kind: "updateElevationGroup" } + | { kind: "updateDeleveragingThresholdDecreaseBpsPerDay" } + | { kind: "deprecatedUpdateMultiplierSideBoost" } + | { kind: "deprecatedUpdateMultiplierTagBoost" } + | { kind: "updateReserveStatus" } + | { kind: "updateFarmCollateral" } + | { kind: "updateFarmDebt" } + | { kind: "updateDisableUsageAsCollateralOutsideEmode" } + | { kind: "updateBlockBorrowingAboveUtilizationPct" } + | { kind: "updateBlockPriceUsage" } + | { kind: "updateBorrowLimitOutsideElevationGroup" } + | { kind: "updateBorrowLimitsInElevationGroupAgainstThisReserve" } + | { kind: "updateHostFixedInterestRateBps" } + | { kind: "updateAutodeleverageEnabled" } + | { kind: "updateDeleveragingBonusIncreaseBpsPerDay" } +``` + +### updateLendingMarketConfigValue + +**Definition:** + +```typescript +| { kind: "bool"; value: [boolean] } + | { kind: "u8"; value: [bigint] } + | { kind: "u8Array"; value: [bigint[8]] } + | { kind: "u16"; value: [bigint] } + | { kind: "u64"; value: [bigint] } + | { kind: "u128"; value: [bigint] } + | { kind: "pubkey"; value: [PublicKey] } + | { kind: "elevationGroup"; value: [elevationGroup] } + | { kind: "name"; value: [bigint[32]] } +``` + +### updateLendingMarketMode + +**Definition:** + +```typescript +| { kind: "updateOwner" } + | { kind: "updateEmergencyMode" } + | { kind: "updateLiquidationCloseFactor" } + | { kind: "updateLiquidationMaxValue" } + | { kind: "deprecatedUpdateGlobalUnhealthyBorrow" } + | { kind: "updateGlobalAllowedBorrow" } + | { kind: "updateRiskCouncil" } + | { kind: "updateMinFullLiquidationThreshold" } + | { kind: "updateInsolvencyRiskLtv" } + | { kind: "updateElevationGroup" } + | { kind: "updateReferralFeeBps" } + | { kind: "deprecatedUpdateMultiplierPoints" } + | { kind: "updatePriceRefreshTriggerToMaxAgePct" } + | { kind: "updateAutodeleverageEnabled" } + | { kind: "updateBorrowingDisabled" } + | { kind: "updateMinNetValueObligationPostAction" } + | { kind: "updateMinValueLtvSkipPriorityLiqCheck" } + | { kind: "updateMinValueBfSkipPriorityLiqCheck" } + | { kind: "updatePaddingFields" } + | { kind: "updateName" } + | { kind: "updateIndividualAutodeleverageMarginCallPeriodSecs" } + | { kind: "updateInitialDepositAmount" } +``` + +### lastUpdate + +**Definition:** + +```typescript +{ + slot: bigint; + stale: bigint; + priceStatus: bigint; + placeholder: bigint[6]; +} +``` + +### elevationGroupLendingMarket + +**Definition:** + +```typescript +{ + maxLiquidationBonusBps: bigint; + id: bigint; + ltvPct: bigint; + liquidationThresholdPct: bigint; + allowNewLoans: bigint; + maxReservesAsCollateral: bigint; + padding0: bigint; + debtReserve: PublicKey; + padding1: bigint[4]; +} +``` + +### elevationGroup + +**Definition:** + +```typescript +{ + maxLiquidationBonusBps: bigint; + id: bigint; + ltvPct: bigint; + liquidationThresholdPct: bigint; + allowNewLoans: bigint; + maxReservesAsCollateral: bigint; + padding0: bigint; + debtReserve: PublicKey; + padding1: bigint[4]; +} +``` + +### initObligationArgs + +**Definition:** + +```typescript +{ + tag: bigint; + id: bigint; +} +``` + +### obligationCollateral + +**Definition:** + +```typescript +{ + depositReserve: PublicKey; + depositedAmount: bigint; + marketValueSf: bigint; + borrowedAmountAgainstThisCollateralInElevationGroup: bigint; + padding: bigint[9]; +} +``` + +### obligationLiquidity + +**Definition:** + +```typescript +{ + borrowReserve: PublicKey; + cumulativeBorrowRateBsf: bigFractionBytes; + padding: bigint; + borrowedAmountSf: bigint; + marketValueSf: bigint; + borrowFactorAdjustedMarketValueSf: bigint; + borrowedAmountOutsideElevationGroups: bigint; + padding2: bigint[7]; +} +``` + +### assetTier + +**Definition:** + +```typescript +| { kind: "regular" } + | { kind: "isolatedCollateral" } + | { kind: "isolatedDebt" } +``` + +### bigFractionBytes + +**Definition:** + +```typescript +{ + value: bigint[4]; + padding: bigint[2]; +} +``` + +### feeCalculation + +**Definition:** + +```typescript +| { kind: "exclusive" } + | { kind: "inclusive" } +``` + +### reserveCollateral + +**Definition:** + +```typescript +{ + mintPubkey: PublicKey; + mintTotalSupply: bigint; + supplyVault: PublicKey; + padding1: bigint[32]; + padding2: bigint[32]; +} +``` + +### reserveConfig + +**Definition:** + +```typescript +{ + status: bigint; + assetTier: bigint; + hostFixedInterestRateBps: bigint; + reserved2: bigint[2]; + reserved3: bigint[8]; + protocolTakeRatePct: bigint; + protocolLiquidationFeePct: bigint; + loanToValuePct: bigint; + liquidationThresholdPct: bigint; + minLiquidationBonusBps: bigint; + maxLiquidationBonusBps: bigint; + badDebtLiquidationBonusBps: bigint; + deleveragingMarginCallPeriodSecs: bigint; + deleveragingThresholdDecreaseBpsPerDay: bigint; + fees: reserveFees; + borrowRateCurve: borrowRateCurve; + borrowFactorPct: bigint; + depositLimit: bigint; + borrowLimit: bigint; + tokenInfo: tokenInfo; + depositWithdrawalCap: withdrawalCaps; + debtWithdrawalCap: withdrawalCaps; + elevationGroups: bigint[20]; + disableUsageAsCollOutsideEmode: bigint; + utilizationLimitBlockBorrowingAbovePct: bigint; + autodeleverageEnabled: bigint; + reserved1: bigint[1]; + borrowLimitOutsideElevationGroup: bigint; + borrowLimitAgainstThisCollateralInElevationGroup: bigint[32]; + deleveragingBonusIncreaseBpsPerDay: bigint; +} +``` + +### reserveFarmKind + +**Definition:** + +```typescript +| { kind: "collateral" } + | { kind: "debt" } +``` + +### reserveFees + +**Definition:** + +```typescript +{ + borrowFeeSf: bigint; + flashLoanFeeSf: bigint; + padding: bigint[8]; +} +``` + +### reserveLiquidity + +**Definition:** + +```typescript +{ + mintPubkey: PublicKey; + supplyVault: PublicKey; + feeVault: PublicKey; + availableAmount: bigint; + borrowedAmountSf: bigint; + marketPriceSf: bigint; + marketPriceLastUpdatedTs: bigint; + mintDecimals: bigint; + depositLimitCrossedTimestamp: bigint; + borrowLimitCrossedTimestamp: bigint; + cumulativeBorrowRateBsf: bigFractionBytes; + accumulatedProtocolFeesSf: bigint; + accumulatedReferrerFeesSf: bigint; + pendingReferrerFeesSf: bigint; + absoluteReferralRateSf: bigint; + tokenProgram: PublicKey; + padding2: bigint[51]; + padding3: bigint[32]; +} +``` + +### reserveStatus + +**Definition:** + +```typescript +| { kind: "active" } + | { kind: "obsolete" } + | { kind: "hidden" } +``` + +### withdrawalCaps + +**Definition:** + +```typescript +{ + configCapacity: bigint; + currentTotal: bigint; + lastIntervalStartTimestamp: bigint; + configIntervalLengthSeconds: bigint; +} +``` + +### priceHeuristic + +**Definition:** + +```typescript +{ + lower: bigint; + upper: bigint; + exp: bigint; +} +``` + +### pythConfiguration + +**Definition:** + +```typescript +{ + price: PublicKey; +} +``` + +### scopeConfiguration + +**Definition:** + +```typescript +{ + priceFeed: PublicKey; + priceChain: bigint[4]; + twapChain: bigint[4]; +} +``` + +### switchboardConfiguration + +**Definition:** + +```typescript +{ + priceAggregator: PublicKey; + twapAggregator: PublicKey; +} +``` + +### tokenInfo + +**Definition:** + +```typescript +{ + name: bigint[32]; + heuristic: priceHeuristic; + maxTwapDivergenceBps: bigint; + maxAgePriceSeconds: bigint; + maxAgeTwapSeconds: bigint; + scopeConfiguration: scopeConfiguration; + switchboardConfiguration: switchboardConfiguration; + pythConfiguration: pythConfiguration; + blockPriceUsage: bigint; + reserved: bigint[7]; + padding: bigint[19]; +} +``` + +### borrowRateCurve + +**Definition:** + +```typescript +{ + points: curvePoint[11]; +} +``` + +### curvePoint + +**Definition:** + +```typescript +{ + utilizationRateBps: bigint; + borrowRateBps: bigint; +} +``` + +## Errors + +- **6000 - InvalidMarketAuthority**: Market authority is invalid _(Hex: `0x1770`)_ +- **6001 - InvalidMarketOwner**: Market owner is invalid _(Hex: `0x1771`)_ +- **6002 - InvalidAccountOwner**: Input account owner is not the program address _(Hex: `0x1772`)_ +- **6003 - InvalidAmount**: Input amount is invalid _(Hex: `0x1773`)_ +- **6004 - InvalidConfig**: Input config value is invalid _(Hex: `0x1774`)_ +- **6005 - InvalidSigner**: Input account must be a signer _(Hex: `0x1775`)_ +- **6006 - InvalidAccountInput**: Invalid account input _(Hex: `0x1776`)_ +- **6007 - MathOverflow**: Math operation overflow _(Hex: `0x1777`)_ +- **6008 - InsufficientLiquidity**: Insufficient liquidity available _(Hex: `0x1778`)_ +- **6009 - ReserveStale**: Reserve state needs to be refreshed _(Hex: `0x1779`)_ +- **6010 - WithdrawTooSmall**: Withdraw amount too small _(Hex: `0x177a`)_ +- **6011 - WithdrawTooLarge**: Withdraw amount too large _(Hex: `0x177b`)_ +- **6012 - BorrowTooSmall**: Borrow amount too small to receive liquidity after fees _(Hex: `0x177c`)_ +- **6013 - BorrowTooLarge**: Borrow amount too large for deposited collateral _(Hex: `0x177d`)_ +- **6014 - RepayTooSmall**: Repay amount too small to transfer liquidity _(Hex: `0x177e`)_ +- **6015 - LiquidationTooSmall**: Liquidation amount too small to receive collateral _(Hex: `0x177f`)_ +- **6016 - ObligationHealthy**: Cannot liquidate healthy obligations _(Hex: `0x1780`)_ +- **6017 - ObligationStale**: Obligation state needs to be refreshed _(Hex: `0x1781`)_ +- **6018 - ObligationReserveLimit**: Obligation reserve limit exceeded _(Hex: `0x1782`)_ +- **6019 - InvalidObligationOwner**: Obligation owner is invalid _(Hex: `0x1783`)_ +- **6020 - ObligationDepositsEmpty**: Obligation deposits are empty _(Hex: `0x1784`)_ +- **6021 - ObligationBorrowsEmpty**: Obligation borrows are empty _(Hex: `0x1785`)_ +- **6022 - ObligationDepositsZero**: Obligation deposits have zero value _(Hex: `0x1786`)_ +- **6023 - ObligationBorrowsZero**: Obligation borrows have zero value _(Hex: `0x1787`)_ +- **6024 - InvalidObligationCollateral**: Invalid obligation collateral _(Hex: `0x1788`)_ +- **6025 - InvalidObligationLiquidity**: Invalid obligation liquidity _(Hex: `0x1789`)_ +- **6026 - ObligationCollateralEmpty**: Obligation collateral is empty _(Hex: `0x178a`)_ +- **6027 - ObligationLiquidityEmpty**: Obligation liquidity is empty _(Hex: `0x178b`)_ +- **6028 - NegativeInterestRate**: Interest rate is negative _(Hex: `0x178c`)_ +- **6029 - InvalidOracleConfig**: Input oracle config is invalid _(Hex: `0x178d`)_ +- **6030 - InsufficientProtocolFeesToRedeem**: Insufficient protocol fees to claim or no liquidity available _(Hex: `0x178e`)_ +- **6031 - FlashBorrowCpi**: No cpi flash borrows allowed _(Hex: `0x178f`)_ +- **6032 - NoFlashRepayFound**: No corresponding repay found for flash borrow _(Hex: `0x1790`)_ +- **6033 - InvalidFlashRepay**: Invalid repay found _(Hex: `0x1791`)_ +- **6034 - FlashRepayCpi**: No cpi flash repays allowed _(Hex: `0x1792`)_ +- **6035 - MultipleFlashBorrows**: Multiple flash borrows not allowed in the same transaction _(Hex: `0x1793`)_ +- **6036 - FlashLoansDisabled**: Flash loans are disabled for this reserve _(Hex: `0x1794`)_ +- **6037 - SwitchboardV2Error**: Switchboard error _(Hex: `0x1795`)_ +- **6038 - CouldNotDeserializeScope**: Cannot deserialize the scope price account _(Hex: `0x1796`)_ +- **6039 - PriceTooOld**: Price too old _(Hex: `0x1797`)_ +- **6040 - PriceTooDivergentFromTwap**: Price too divergent from twap _(Hex: `0x1798`)_ +- **6041 - InvalidTwapPrice**: Invalid twap price _(Hex: `0x1799`)_ +- **6042 - GlobalEmergencyMode**: Emergency mode is enabled _(Hex: `0x179a`)_ +- **6043 - InvalidFlag**: Invalid lending market config _(Hex: `0x179b`)_ +- **6044 - PriceNotValid**: Price is not valid _(Hex: `0x179c`)_ +- **6045 - PriceIsBiggerThanHeuristic**: Price is bigger than allowed by heuristic _(Hex: `0x179d`)_ +- **6046 - PriceIsLowerThanHeuristic**: Price lower than allowed by heuristic _(Hex: `0x179e`)_ +- **6047 - PriceIsZero**: Price is zero _(Hex: `0x179f`)_ +- **6048 - PriceConfidenceTooWide**: Price confidence too wide _(Hex: `0x17a0`)_ +- **6049 - IntegerOverflow**: Conversion between integers failed _(Hex: `0x17a1`)_ +- **6050 - NoFarmForReserve**: This reserve does not have a farm _(Hex: `0x17a2`)_ +- **6051 - IncorrectInstructionInPosition**: Wrong instruction at expected position _(Hex: `0x17a3`)_ +- **6052 - NoPriceFound**: No price found _(Hex: `0x17a4`)_ +- **6053 - InvalidTwapConfig**: Invalid Twap configuration: Twap is enabled but one of the enabled price doesn't have a twap _(Hex: `0x17a5`)_ +- **6054 - InvalidPythPriceAccount**: Pyth price account does not match configuration _(Hex: `0x17a6`)_ +- **6055 - InvalidSwitchboardAccount**: Switchboard account(s) do not match configuration _(Hex: `0x17a7`)_ +- **6056 - InvalidScopePriceAccount**: Scope price account does not match configuration _(Hex: `0x17a8`)_ +- **6057 - ObligationCollateralLtvZero**: The obligation has one collateral with an LTV set to 0. Withdraw it before withdrawing other collaterals _(Hex: `0x17a9`)_ +- **6058 - InvalidObligationSeedsValue**: Seeds must be default pubkeys for tag 0, and mint addresses for tag 1 or 2 _(Hex: `0x17aa`)_ +- **6059 - DeprecatedInvalidObligationId**: [DEPRECATED] Obligation id must be 0 _(Hex: `0x17ab`)_ +- **6060 - InvalidBorrowRateCurvePoint**: Invalid borrow rate curve point _(Hex: `0x17ac`)_ +- **6061 - InvalidUtilizationRate**: Invalid utilization rate _(Hex: `0x17ad`)_ +- **6062 - CannotSocializeObligationWithCollateral**: Obligation hasn't been fully liquidated and debt cannot be socialized. _(Hex: `0x17ae`)_ +- **6063 - ObligationEmpty**: Obligation has no borrows or deposits. _(Hex: `0x17af`)_ +- **6064 - WithdrawalCapReached**: Withdrawal cap is reached _(Hex: `0x17b0`)_ +- **6065 - LastTimestampGreaterThanCurrent**: The last interval start timestamp is greater than the current timestamp _(Hex: `0x17b1`)_ +- **6066 - LiquidationRewardTooSmall**: The reward amount is less than the minimum acceptable received liquidity _(Hex: `0x17b2`)_ +- **6067 - IsolatedAssetTierViolation**: Isolated Asset Tier Violation _(Hex: `0x17b3`)_ +- **6068 - InconsistentElevationGroup**: The obligation's elevation group and the reserve's are not the same _(Hex: `0x17b4`)_ +- **6069 - InvalidElevationGroup**: The elevation group chosen for the reserve does not exist in the lending market _(Hex: `0x17b5`)_ +- **6070 - InvalidElevationGroupConfig**: The elevation group updated has wrong parameters set _(Hex: `0x17b6`)_ +- **6071 - UnhealthyElevationGroupLtv**: The current obligation must have most or all its debt repaid before changing the elevation group _(Hex: `0x17b7`)_ +- **6072 - ElevationGroupNewLoansDisabled**: Elevation group does not accept any new loans or any new borrows/withdrawals _(Hex: `0x17b8`)_ +- **6073 - ReserveDeprecated**: Reserve was deprecated, no longer usable _(Hex: `0x17b9`)_ +- **6074 - ReferrerAccountNotInitialized**: Referrer account not initialized _(Hex: `0x17ba`)_ +- **6075 - ReferrerAccountMintMissmatch**: Referrer account mint does not match the operation reserve mint _(Hex: `0x17bb`)_ +- **6076 - ReferrerAccountWrongAddress**: Referrer account address is not a valid program address _(Hex: `0x17bc`)_ +- **6077 - ReferrerAccountReferrerMissmatch**: Referrer account referrer does not match the owner referrer _(Hex: `0x17bd`)_ +- **6078 - ReferrerAccountMissing**: Referrer account missing for obligation with referrer _(Hex: `0x17be`)_ +- **6079 - InsufficientReferralFeesToRedeem**: Insufficient referral fees to claim or no liquidity available _(Hex: `0x17bf`)_ +- **6080 - CpiDisabled**: CPI disabled for this instruction _(Hex: `0x17c0`)_ +- **6081 - ShortUrlNotAsciiAlphanumeric**: Referrer short_url is not ascii alphanumeric _(Hex: `0x17c1`)_ +- **6082 - ReserveObsolete**: Reserve is marked as obsolete _(Hex: `0x17c2`)_ +- **6083 - ElevationGroupAlreadyActivated**: Obligation already part of the same elevation group _(Hex: `0x17c3`)_ +- **6084 - ObligationInDeprecatedReserve**: Obligation has a deposit in a deprecated reserve _(Hex: `0x17c4`)_ +- **6085 - ReferrerStateOwnerMismatch**: Referrer state owner does not match the given signer _(Hex: `0x17c5`)_ +- **6086 - UserMetadataOwnerAlreadySet**: User metadata owner is already set _(Hex: `0x17c6`)_ +- **6087 - CollateralNonLiquidatable**: This collateral cannot be liquidated (LTV set to 0) _(Hex: `0x17c7`)_ +- **6088 - BorrowingDisabled**: Borrowing is disabled _(Hex: `0x17c8`)_ +- **6089 - BorrowLimitExceeded**: Cannot borrow above borrow limit _(Hex: `0x17c9`)_ +- **6090 - DepositLimitExceeded**: Cannot deposit above deposit limit _(Hex: `0x17ca`)_ +- **6091 - BorrowingDisabledOutsideElevationGroup**: Reserve does not accept any new borrows outside elevation group _(Hex: `0x17cb`)_ +- **6092 - NetValueRemainingTooSmall**: Net value remaining too small _(Hex: `0x17cc`)_ +- **6093 - WorseLTVBlocked**: Cannot get the obligation in a worse position _(Hex: `0x17cd`)_ +- **6094 - LiabilitiesBiggerThanAssets**: Cannot have more liabilities than assets in a position _(Hex: `0x17ce`)_ +- **6095 - ReserveTokenBalanceMismatch**: Reserve state and token account cannot drift _(Hex: `0x17cf`)_ +- **6096 - ReserveVaultBalanceMismatch**: Reserve token account has been unexpectedly modified _(Hex: `0x17d0`)_ +- **6097 - ReserveAccountingMismatch**: Reserve internal state accounting has been unexpectedly modified _(Hex: `0x17d1`)_ +- **6098 - BorrowingAboveUtilizationRateDisabled**: Borrowing above set utilization rate is disabled _(Hex: `0x17d2`)_ +- **6099 - LiquidationBorrowFactorPriority**: Liquidation must prioritize the debt with the highest borrow factor _(Hex: `0x17d3`)_ +- **6100 - LiquidationLowestLTVPriority**: Liquidation must prioritize the collateral with the lowest LTV _(Hex: `0x17d4`)_ +- **6101 - ElevationGroupBorrowLimitExceeded**: Elevation group borrow limit exceeded _(Hex: `0x17d5`)_ +- **6102 - ElevationGroupWithoutDebtReserve**: The elevation group does not have a debt reserve defined _(Hex: `0x17d6`)_ +- **6103 - ElevationGroupMaxCollateralReserveZero**: The elevation group does not allow any collateral reserves _(Hex: `0x17d7`)_ +- **6104 - ElevationGroupHasAnotherDebtReserve**: In elevation group attempt to borrow from a reserve that is not the debt reserve _(Hex: `0x17d8`)_ +- **6105 - ElevationGroupDebtReserveAsCollateral**: The elevation group's debt reserve cannot be used as a collateral reserve _(Hex: `0x17d9`)_ +- **6106 - ObligationCollateralExceedsElevationGroupLimit**: Obligation have more collateral than the maximum allowed by the elevation group _(Hex: `0x17da`)_ +- **6107 - ObligationElevationGroupMultipleDebtReserve**: Obligation is an elevation group but have more than one debt reserve _(Hex: `0x17db`)_ +- **6108 - UnsupportedTokenExtension**: Mint has a token (2022) extension that is not supported _(Hex: `0x17dc`)_ +- **6109 - InvalidTokenAccount**: Can't have an spl token mint with a t22 account _(Hex: `0x17dd`)_ +- **6110 - DepositDisabledOutsideElevationGroup**: Can't deposit into this reserve outside elevation group _(Hex: `0x17de`)_ +- **6111 - CannotCalculateReferralAmountDueToSlotsMismatch**: Cannot calculate referral amount due to slots mismatch _(Hex: `0x17df`)_ +- **6112 - ObligationOwnersMustMatch**: Obligation owners must match _(Hex: `0x17e0`)_ +- **6113 - ObligationsMustMatch**: Obligations must match _(Hex: `0x17e1`)_ +- **6114 - LendingMarketsMustMatch**: Lending markets must match _(Hex: `0x17e2`)_ +- **6115 - ObligationCurrentlyMarkedForDeleveraging**: Obligation is already marked for deleveraging _(Hex: `0x17e3`)_ +- **6116 - MaximumWithdrawValueZero**: Maximum withdrawable value of this collateral is zero, LTV needs improved _(Hex: `0x17e4`)_ +- **6117 - ZeroMaxLtvAssetsInDeposits**: No max LTV 0 assets allowed in deposits for repay and withdraw _(Hex: `0x17e5`)_ +- **6118 - MinLtvAssetsPriority**: The operation must prioritize the collateral with the lowest LTV _(Hex: `0x17e6`)_ +- **6119 - WorseLTVThanUnhealthyLTV**: Cannot get the obligation liquidatable _(Hex: `0x17e7`)_ +- **6120 - FarmAccountsMissing**: Farm accounts to refresh are missing _(Hex: `0x17e8`)_ +- **6121 - RepayTooSmallForFullLiquidation**: Repay amount is too small to satisfy the mandatory full liquidation _(Hex: `0x17e9`)_ +- **6122 - InsufficientRepayAmount**: Liquidator provided repay amount lower than required by liquidation rules _(Hex: `0x17ea`)_ diff --git a/clients/kamino-lending/eslint.config.js b/clients/kamino-lending/eslint.config.js new file mode 100644 index 00000000..f157753e --- /dev/null +++ b/clients/kamino-lending/eslint.config.js @@ -0,0 +1,31 @@ +import { configs } from "@macalinao/eslint-config"; + +export default [ + ...configs.fast, + { + languageOptions: { + parserOptions: { + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ["src/generated/**/*.ts"], + rules: { + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/prefer-nullish-coalescing": "off", + }, + }, + { + files: [ + "src/generated/instructions/*.ts", + "src/generated/types/*.ts", + "src/generated/errors/*.ts", + ], + rules: { + "@typescript-eslint/no-unnecessary-condition": "off", + "no-constant-condition": "off", + "@typescript-eslint/no-empty-object-type": "off", + }, + }, +]; diff --git a/clients/kamino-lending/idls/farms.json b/clients/kamino-lending/idls/farms.json new file mode 100644 index 00000000..659311ec --- /dev/null +++ b/clients/kamino-lending/idls/farms.json @@ -0,0 +1,1880 @@ +{ + "address": "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr", + "metadata": { + "name": "farms", + "version": "0.1.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "initialize_global_config", + "discriminator": [113, 216, 122, 131, 225, 209, 22, 55], + "accounts": [ + { + "name": "global_admin", + "writable": true, + "signer": true + }, + { + "name": "global_config", + "writable": true + }, + { + "name": "treasury_vaults_authority" + }, + { + "name": "system_program" + } + ], + "args": [] + }, + { + "name": "update_global_config", + "discriminator": [164, 84, 130, 189, 111, 58, 250, 200], + "accounts": [ + { + "name": "global_admin", + "signer": true + }, + { + "name": "global_config", + "writable": true + } + ], + "args": [ + { + "name": "mode", + "type": "u8" + }, + { + "name": "value", + "type": { + "array": ["u8", 32] + } + } + ] + }, + { + "name": "initialize_farm", + "discriminator": [252, 28, 185, 172, 244, 74, 117, 165], + "accounts": [ + { + "name": "farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "global_config" + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "token_mint" + }, + { + "name": "token_program" + }, + { + "name": "system_program" + }, + { + "name": "rent" + } + ], + "args": [] + }, + { + "name": "initialize_farm_delegated", + "discriminator": [250, 84, 101, 25, 51, 77, 204, 91], + "accounts": [ + { + "name": "farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_delegate", + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "global_config" + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "system_program" + }, + { + "name": "rent" + } + ], + "args": [] + }, + { + "name": "initialize_reward", + "discriminator": [95, 135, 192, 196, 242, 129, 230, 68], + "accounts": [ + { + "name": "farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "global_config" + }, + { + "name": "reward_mint" + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_treasury_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "treasury_vaults_authority" + }, + { + "name": "token_program" + }, + { + "name": "system_program" + }, + { + "name": "rent" + } + ], + "args": [] + }, + { + "name": "add_rewards", + "discriminator": [88, 186, 25, 227, 38, 137, 81, 23], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "payer_reward_token_ata", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "reward_index", + "type": "u64" + } + ] + }, + { + "name": "update_farm_config", + "discriminator": [214, 176, 188, 244, 203, 59, 230, 207], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + } + ], + "args": [ + { + "name": "mode", + "type": "u16" + }, + { + "name": "data", + "type": "bytes" + } + ] + }, + { + "name": "initialize_user", + "discriminator": [111, 17, 185, 250, 60, 122, 38, 254], + "accounts": [ + { + "name": "authority", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner" + }, + { + "name": "delegatee" + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "system_program" + }, + { + "name": "rent" + } + ], + "args": [] + }, + { + "name": "transfer_ownership", + "discriminator": [65, 177, 215, 73, 53, 45, 99, 47], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "user_state", + "writable": true + } + ], + "args": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + }, + { + "name": "reward_user_once", + "discriminator": [219, 137, 57, 22, 94, 186, 96, 114], + "accounts": [ + { + "name": "farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "user_state", + "writable": true + } + ], + "args": [ + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "refresh_farm", + "discriminator": [214, 131, 138, 183, 144, 194, 172, 42], + "accounts": [ + { + "name": "farm_state", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + } + ], + "args": [] + }, + { + "name": "stake", + "discriminator": [206, 176, 202, 18, 200, 209, 179, 108], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "user_ata", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "scope_prices", + "optional": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "set_stake_delegated", + "discriminator": [73, 171, 184, 75, 30, 56, 198, 223], + "accounts": [ + { + "name": "delegate_authority", + "signer": true + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + } + ], + "args": [ + { + "name": "new_amount", + "type": "u64" + } + ] + }, + { + "name": "harvest_reward", + "discriminator": [68, 200, 228, 233, 184, 32, 226, 188], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "global_config" + }, + { + "name": "reward_mint" + }, + { + "name": "user_reward_ata", + "writable": true + }, + { + "name": "rewards_vault", + "writable": true + }, + { + "name": "rewards_treasury_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "scope_prices", + "optional": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "reward_index", + "type": "u64" + } + ] + }, + { + "name": "unstake", + "discriminator": [90, 95, 107, 42, 205, 124, 50, 225], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + } + ], + "args": [ + { + "name": "stake_shares_scaled", + "type": "u128" + } + ] + }, + { + "name": "refresh_user_state", + "discriminator": [1, 135, 12, 62, 243, 140, 77, 108], + "accounts": [ + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + } + ], + "args": [] + }, + { + "name": "withdraw_unstaked_deposits", + "discriminator": [36, 102, 187, 49, 220, 36, 132, 67], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "user_ata", + "writable": true + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "withdraw_treasury", + "discriminator": [40, 63, 122, 158, 144, 216, 83, 96], + "accounts": [ + { + "name": "global_admin", + "writable": true, + "signer": true + }, + { + "name": "global_config" + }, + { + "name": "reward_mint" + }, + { + "name": "reward_treasury_vault", + "writable": true + }, + { + "name": "treasury_vault_authority" + }, + { + "name": "withdraw_destination_token_account", + "writable": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_to_farm_vault", + "discriminator": [131, 166, 64, 94, 108, 213, 114, 183], + "accounts": [ + { + "name": "depositor", + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "depositor_ata", + "writable": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_from_farm_vault", + "discriminator": [22, 82, 128, 250, 86, 79, 124, 78], + "accounts": [ + { + "name": "withdraw_authority", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "withdrawer_token_account", + "writable": true + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_slashed_amount", + "discriminator": [202, 217, 67, 74, 172, 22, 140, 216], + "accounts": [ + { + "name": "crank", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "slashed_amount_spill_address", + "writable": true + }, + { + "name": "farm_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "update_farm_admin", + "discriminator": [20, 37, 136, 19, 122, 239, 36, 130], + "accounts": [ + { + "name": "pending_farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + } + ], + "args": [] + }, + { + "name": "update_global_config_admin", + "discriminator": [184, 87, 23, 193, 156, 238, 175, 119], + "accounts": [ + { + "name": "pending_global_admin", + "signer": true + }, + { + "name": "global_config", + "writable": true + } + ], + "args": [] + }, + { + "name": "withdraw_reward", + "discriminator": [191, 187, 176, 137, 9, 25, 187, 244], + "accounts": [ + { + "name": "farm_admin", + "writable": true, + "signer": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "admin_reward_token_ata", + "writable": true + }, + { + "name": "scope_prices", + "optional": true + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "reward_index", + "type": "u64" + } + ] + }, + { + "name": "idl_missing_types", + "discriminator": [130, 80, 38, 153, 80, 212, 182, 253], + "accounts": [ + { + "name": "global_admin", + "signer": true + }, + { + "name": "global_config", + "writable": true + } + ], + "args": [ + { + "name": "global_config_option_kind", + "type": { + "defined": { + "name": "GlobalConfigOption" + } + } + }, + { + "name": "farm_config_option_kind", + "type": { + "defined": { + "name": "FarmConfigOption" + } + } + }, + { + "name": "time_unit", + "type": { + "defined": { + "name": "TimeUnit" + } + } + }, + { + "name": "locking_mode", + "type": { + "defined": { + "name": "LockingMode" + } + } + }, + { + "name": "reward_type", + "type": { + "defined": { + "name": "RewardType" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "FarmState", + "discriminator": [198, 102, 216, 74, 63, 66, 163, 190] + }, + { + "name": "GlobalConfig", + "discriminator": [149, 8, 156, 202, 160, 252, 176, 217] + }, + { + "name": "UserState", + "discriminator": [72, 177, 85, 249, 76, 167, 186, 126] + }, + { + "name": "OraclePrices", + "discriminator": [89, 128, 118, 221, 6, 72, 180, 146] + } + ], + "errors": [ + { + "code": 6000, + "name": "StakeZero", + "msg": "Cannot stake 0 amount" + }, + { + "code": 6001, + "name": "UnstakeZero", + "msg": "Cannot unstake 0 amount" + }, + { + "code": 6002, + "name": "NothingToUnstake", + "msg": "Nothing to unstake" + }, + { + "code": 6003, + "name": "NoRewardToHarvest", + "msg": "No reward to harvest" + }, + { + "code": 6004, + "name": "NoRewardInList", + "msg": "Reward not present in reward list" + }, + { + "code": 6005, + "name": "RewardAlreadyInitialized", + "msg": "Reward already initialized" + }, + { + "code": 6006, + "name": "MaxRewardNumberReached", + "msg": "Max number of reward tokens reached" + }, + { + "code": 6007, + "name": "RewardDoesNotExist", + "msg": "Reward does not exist" + }, + { + "code": 6008, + "name": "WrongRewardVaultAccount", + "msg": "Reward vault exists but the account is wrong" + }, + { + "code": 6009, + "name": "RewardVaultMismatch", + "msg": "Reward vault pubkey does not match staking pool vault" + }, + { + "code": 6010, + "name": "RewardVaultAuthorityMismatch", + "msg": "Reward vault authority pubkey does not match staking pool vault" + }, + { + "code": 6011, + "name": "NothingStaked", + "msg": "Nothing staked, cannot collect any rewards" + }, + { + "code": 6012, + "name": "IntegerOverflow", + "msg": "Integer overflow" + }, + { + "code": 6013, + "name": "ConversionFailure", + "msg": "Conversion failure" + }, + { + "code": 6014, + "name": "UnexpectedAccount", + "msg": "Unexpected account in instruction" + }, + { + "code": 6015, + "name": "OperationForbidden", + "msg": "Operation forbidden" + }, + { + "code": 6016, + "name": "MathOverflow", + "msg": "Mathematical operation with overflow" + }, + { + "code": 6017, + "name": "MinClaimDurationNotReached", + "msg": "Minimum claim duration has not been reached" + }, + { + "code": 6018, + "name": "RewardsVaultHasDelegate", + "msg": "Reward vault has a delegate" + }, + { + "code": 6019, + "name": "RewardsVaultHasCloseAuthority", + "msg": "Reward vault has a close authority" + }, + { + "code": 6020, + "name": "FarmVaultHasDelegate", + "msg": "Farm vault has a delegate" + }, + { + "code": 6021, + "name": "FarmVaultHasCloseAuthority", + "msg": "Farm vault has a close authority" + }, + { + "code": 6022, + "name": "RewardsTreasuryVaultHasDelegate", + "msg": "Reward vault has a delegate" + }, + { + "code": 6023, + "name": "RewardsTreasuryVaultHasCloseAuthority", + "msg": "Reward vault has a close authority" + }, + { + "code": 6024, + "name": "UserAtaRewardVaultMintMissmatch", + "msg": "User ata and reward vault have different mints" + }, + { + "code": 6025, + "name": "UserAtaFarmTokenMintMissmatch", + "msg": "User ata and farm token have different mints" + }, + { + "code": 6026, + "name": "TokenFarmTokenMintMissmatch", + "msg": "Token mint and farm token have different mints" + }, + { + "code": 6027, + "name": "RewardAtaRewardMintMissmatch", + "msg": "Reward ata mint is different than reward mint" + }, + { + "code": 6028, + "name": "RewardAtaOwnerNotPayer", + "msg": "Reward ata owner is different than payer" + }, + { + "code": 6029, + "name": "InvalidGlobalConfigMode", + "msg": "Mode to update global_config is invalid" + }, + { + "code": 6030, + "name": "RewardIndexOutOfRange", + "msg": "Reward Index is higher than number of rewards" + }, + { + "code": 6031, + "name": "NothingToWithdraw", + "msg": "No tokens available to withdraw" + }, + { + "code": 6032, + "name": "UserDelegatedFarmNonDelegatedMissmatch", + "msg": "user, user_ref, authority and payer must match for non-delegated farm" + }, + { + "code": 6033, + "name": "AuthorityFarmDelegateMissmatch", + "msg": "Authority must match farm delegate authority" + }, + { + "code": 6034, + "name": "FarmNotDelegated", + "msg": "Farm not delegated, can not set stake" + }, + { + "code": 6035, + "name": "FarmDelegated", + "msg": "Operation not allowed for delegated farm" + }, + { + "code": 6036, + "name": "UnstakeNotElapsed", + "msg": "Unstake lockup period is not elapsed. Deposit is locked until end of unstake period" + }, + { + "code": 6037, + "name": "PendingWithdrawalNotWithdrawnYet", + "msg": "Pending withdrawal already exist and not withdrawn yet" + }, + { + "code": 6038, + "name": "DepositZero", + "msg": "Cannot deposit zero amount directly to farm vault" + }, + { + "code": 6039, + "name": "InvalidConfigValue", + "msg": "Invalid config value" + }, + { + "code": 6040, + "name": "InvalidPenaltyPercentage", + "msg": "Invalid penalty percentage" + }, + { + "code": 6041, + "name": "EarlyWithdrawalNotAllowed", + "msg": "Early withdrawal not allowed" + }, + { + "code": 6042, + "name": "InvalidLockingTimestamps", + "msg": "Invalid locking timestamps" + }, + { + "code": 6043, + "name": "InvalidRpsCurvePoint", + "msg": "Invalid reward rate curve point" + }, + { + "code": 6044, + "name": "InvalidTimestamp", + "msg": "Invalid timestamp" + }, + { + "code": 6045, + "name": "DepositCapReached", + "msg": "Deposit cap reached" + }, + { + "code": 6046, + "name": "MissingScopePrices", + "msg": "Missing Scope Prices" + }, + { + "code": 6047, + "name": "ScopeOraclePriceTooOld", + "msg": "Scope Oracle Price Too Old" + }, + { + "code": 6048, + "name": "InvalidOracleConfig", + "msg": "Invalid Oracle Config" + }, + { + "code": 6049, + "name": "CouldNotDeserializeScope", + "msg": "Could not deserialize scope" + }, + { + "code": 6050, + "name": "RewardAtaOwnerNotAdmin", + "msg": "Reward ata owner is different than farm admin" + }, + { + "code": 6051, + "name": "WithdrawRewardZeroAvailable", + "msg": "Cannot withdraw reward as available amount is zero" + }, + { + "code": 6052, + "name": "RewardScheduleCurveSet", + "msg": "Cannot withdraw reward as reward schedule is set" + }, + { + "code": 6053, + "name": "UnsupportedTokenExtension", + "msg": "Cannot initialize farm while having a mint with token22 and requested extensions" + }, + { + "code": 6054, + "name": "InvalidFarmConfigUpdateAuthority", + "msg": "Invalid authority for updating farm config" + } + ], + "types": [ + { + "name": "FarmConfigOption", + "type": { + "kind": "enum", + "variants": [ + { + "name": "UpdateRewardRps" + }, + { + "name": "UpdateRewardMinClaimDuration" + }, + { + "name": "WithdrawAuthority" + }, + { + "name": "DepositWarmupPeriod" + }, + { + "name": "WithdrawCooldownPeriod" + }, + { + "name": "RewardType" + }, + { + "name": "RpsDecimals" + }, + { + "name": "LockingMode" + }, + { + "name": "LockingStartTimestamp" + }, + { + "name": "LockingDuration" + }, + { + "name": "LockingEarlyWithdrawalPenaltyBps" + }, + { + "name": "DepositCapAmount" + }, + { + "name": "SlashedAmountSpillAddress" + }, + { + "name": "ScopePricesAccount" + }, + { + "name": "ScopeOraclePriceId" + }, + { + "name": "ScopeOracleMaxAge" + }, + { + "name": "UpdateRewardScheduleCurvePoints" + }, + { + "name": "UpdatePendingFarmAdmin" + }, + { + "name": "UpdateStrategyId" + }, + { + "name": "UpdateDelegatedRpsAdmin" + }, + { + "name": "UpdateVaultId" + } + ] + } + }, + { + "name": "GlobalConfigOption", + "type": { + "kind": "enum", + "variants": [ + { + "name": "SetPendingGlobalAdmin" + }, + { + "name": "SetTreasuryFeeBps" + } + ] + } + }, + { + "name": "LockingMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" + }, + { + "name": "Continuous" + }, + { + "name": "WithExpiry" + } + ] + } + }, + { + "name": "RewardInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "token", + "type": { + "defined": { + "name": "TokenInfo" + } + } + }, + { + "name": "rewards_vault", + "type": "pubkey" + }, + { + "name": "rewards_available", + "type": "u64" + }, + { + "name": "reward_schedule_curve", + "type": { + "defined": { + "name": "RewardScheduleCurve" + } + } + }, + { + "name": "min_claim_duration_seconds", + "type": "u64" + }, + { + "name": "last_issuance_ts", + "type": "u64" + }, + { + "name": "rewards_issued_unclaimed", + "type": "u64" + }, + { + "name": "rewards_issued_cumulative", + "type": "u64" + }, + { + "name": "reward_per_share_scaled", + "type": "u128" + }, + { + "name": "placeholder0", + "type": "u64" + }, + { + "name": "reward_type", + "type": "u8" + }, + { + "name": "rewards_per_second_decimals", + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": ["u8", 6] + } + }, + { + "name": "padding1", + "type": { + "array": ["u64", 20] + } + } + ] + } + }, + { + "name": "RewardPerTimeUnitPoint", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts_start", + "type": "u64" + }, + { + "name": "reward_per_time_unit", + "type": "u64" + } + ] + } + }, + { + "name": "RewardScheduleCurve", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "points", + "docs": [ + "This is a stepwise function, meaning that each point represents", + "how many rewards are issued per time unit since the beginning", + "of that point until the beginning of the next point.", + "This is not a linear curve, there is no interpolation going on.", + "A curve can be [[t0, 100], [t1, 50], [t2, 0]]", + "meaning that from t0 to t1, 100 rewards are issued per time unit,", + "from t1 to t2, 50 rewards are issued per time unit, and after t2 it stops", + "Another curve, can be [[t0, 100], [u64::max, 0]]", + "meaning that from t0 to u64::max, 100 rewards are issued per time unit" + ], + "type": { + "array": [ + { + "defined": { + "name": "RewardPerTimeUnitPoint" + } + }, + 20 + ] + } + } + ] + } + }, + { + "name": "RewardType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Proportional" + }, + { + "name": "Constant" + } + ] + } + }, + { + "name": "TimeUnit", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Seconds" + }, + { + "name": "Slots" + } + ] + } + }, + { + "name": "TokenInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "decimals", + "type": "u64" + }, + { + "name": "token_program", + "type": "pubkey" + }, + { + "name": "padding", + "type": { + "array": ["u64", 6] + } + } + ] + } + }, + { + "name": "DatedPrice", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": { + "defined": { + "name": "Price" + } + } + }, + { + "name": "last_updated_slot", + "type": "u64" + }, + { + "name": "unix_timestamp", + "type": "u64" + }, + { + "name": "reserved", + "type": { + "array": ["u64", 2] + } + }, + { + "name": "reserved2", + "type": { + "array": ["u16", 3] + } + }, + { + "name": "index", + "type": "u16" + } + ] + } + }, + { + "name": "Price", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "value", + "type": "u64" + }, + { + "name": "exp", + "type": "u64" + } + ] + } + }, + { + "name": "FarmState", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "farm_admin", + "type": "pubkey" + }, + { + "name": "global_config", + "type": "pubkey" + }, + { + "name": "token", + "type": { + "defined": { + "name": "TokenInfo" + } + } + }, + { + "name": "reward_infos", + "type": { + "array": [ + { + "defined": { + "name": "RewardInfo" + } + }, + 10 + ] + } + }, + { + "name": "num_reward_tokens", + "type": "u64" + }, + { + "name": "num_users", + "docs": ["Data used to calculate the rewards of the user"], + "type": "u64" + }, + { + "name": "total_staked_amount", + "docs": [ + "The number of token in the `farm_vault` staked (getting rewards and fees)", + "Set such as `farm_vault.amount = total_staked_amount + total_pending_amount`" + ], + "type": "u64" + }, + { + "name": "farm_vault", + "type": "pubkey" + }, + { + "name": "farm_vaults_authority", + "type": "pubkey" + }, + { + "name": "farm_vaults_authority_bump", + "type": "u64" + }, + { + "name": "delegate_authority", + "docs": [ + "Only used for delegate farms", + "Set to `default()` otherwise" + ], + "type": "pubkey" + }, + { + "name": "time_unit", + "docs": [ + "Raw representation of a `TimeUnit`", + "Seconds = 0, Slots = 1" + ], + "type": "u8" + }, + { + "name": "is_farm_frozen", + "docs": [ + "Automatically set to true in case of a full authority withdrawal", + "If true, the farm is frozen and no more deposits are allowed" + ], + "type": "u8" + }, + { + "name": "is_farm_delegated", + "docs": [ + "Indicates if the farm is a delegate farm", + "If true, the farm is a delegate farm and the `delegate_authority` is set*" + ], + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "withdraw_authority", + "docs": [ + "Withdraw authority for the farm, allowed to lock deposited funds and withdraw them", + "Set to `default()` if unused (only the depositors can withdraw their funds)" + ], + "type": "pubkey" + }, + { + "name": "deposit_warmup_period", + "docs": [ + "Delay between a user deposit and the moment it is considered as staked", + "0 if unused" + ], + "type": "u32" + }, + { + "name": "withdrawal_cooldown_period", + "docs": [ + "Delay between a user unstake and the ability to withdraw his deposit." + ], + "type": "u32" + }, + { + "name": "total_active_stake_scaled", + "docs": [ + "Total active stake of tokens in the farm (scaled from `Decimal` representation)." + ], + "type": "u128" + }, + { + "name": "total_pending_stake_scaled", + "docs": [ + "Total pending stake of tokens in the farm (scaled from `Decimal` representation).", + "(can be used by `withdraw_authority` but don't get rewards or fees)" + ], + "type": "u128" + }, + { + "name": "total_pending_amount", + "docs": ["Total pending amount of tokens in the farm"], + "type": "u64" + }, + { + "name": "slashed_amount_current", + "docs": ["Slashed amounts from early withdrawal"], + "type": "u64" + }, + { + "name": "slashed_amount_cumulative", + "type": "u64" + }, + { + "name": "slashed_amount_spill_address", + "type": "pubkey" + }, + { + "name": "locking_mode", + "docs": ["Locking stake"], + "type": "u64" + }, + { + "name": "locking_start_timestamp", + "type": "u64" + }, + { + "name": "locking_duration", + "type": "u64" + }, + { + "name": "locking_early_withdrawal_penalty_bps", + "type": "u64" + }, + { + "name": "deposit_cap_amount", + "type": "u64" + }, + { + "name": "scope_prices", + "type": "pubkey" + }, + { + "name": "scope_oracle_price_id", + "type": "u64" + }, + { + "name": "scope_oracle_max_age", + "type": "u64" + }, + { + "name": "pending_farm_admin", + "type": "pubkey" + }, + { + "name": "strategy_id", + "type": "pubkey" + }, + { + "name": "delegated_rps_admin", + "type": "pubkey" + }, + { + "name": "vault_id", + "type": "pubkey" + }, + { + "name": "padding", + "type": { + "array": ["u64", 78] + } + } + ] + } + }, + { + "name": "GlobalConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "global_admin", + "type": "pubkey" + }, + { + "name": "treasury_fee_bps", + "type": "u64" + }, + { + "name": "treasury_vaults_authority", + "type": "pubkey" + }, + { + "name": "treasury_vaults_authority_bump", + "type": "u64" + }, + { + "name": "pending_global_admin", + "type": "pubkey" + }, + { + "name": "padding1", + "type": { + "array": ["u128", 126] + } + } + ] + } + }, + { + "name": "UserState", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "user_id", + "type": "u64" + }, + { + "name": "farm_state", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "is_farm_delegated", + "docs": ["Indicate if this user state is part of a delegated farm"], + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": ["u8", 7] + } + }, + { + "name": "rewards_tally_scaled", + "docs": [ + "Rewards tally used for computation of gained rewards", + "(scaled from `Decimal` representation)." + ], + "type": { + "array": ["u128", 10] + } + }, + { + "name": "rewards_issued_unclaimed", + "docs": ["Number of reward tokens ready for claim"], + "type": { + "array": ["u64", 10] + } + }, + { + "name": "last_claim_ts", + "type": { + "array": ["u64", 10] + } + }, + { + "name": "active_stake_scaled", + "docs": [ + "User stake deposited and usable, generating rewards and fees.", + "(scaled from `Decimal` representation)." + ], + "type": "u128" + }, + { + "name": "pending_deposit_stake_scaled", + "docs": [ + "User stake deposited but not usable and not generating rewards yet.", + "(scaled from `Decimal` representation)." + ], + "type": "u128" + }, + { + "name": "pending_deposit_stake_ts", + "docs": [ + "After this timestamp, pending user stake can be moved to user stake", + "Initialized to now() + delayed user stake period" + ], + "type": "u64" + }, + { + "name": "pending_withdrawal_unstake_scaled", + "docs": [ + "User deposits unstaked, pending for withdrawal, not usable and not generating rewards.", + "(scaled from `Decimal` representation)." + ], + "type": "u128" + }, + { + "name": "pending_withdrawal_unstake_ts", + "docs": ["After this timestamp, user can withdraw their deposit."], + "type": "u64" + }, + { + "name": "bump", + "docs": ["User bump used for account address validation"], + "type": "u64" + }, + { + "name": "delegatee", + "docs": [ + "Delegatee used for initialisation - useful to check against" + ], + "type": "pubkey" + }, + { + "name": "last_stake_ts", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 50] + } + } + ] + } + }, + { + "name": "OraclePrices", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle_mappings", + "type": "pubkey" + }, + { + "name": "prices", + "type": { + "array": [ + { + "defined": { + "name": "DatedPrice" + } + }, + 512 + ] + } + } + ] + } + } + ] +} diff --git a/clients/kamino-lending/idls/kamino_lending.json b/clients/kamino-lending/idls/kamino_lending.json new file mode 100644 index 00000000..02581295 --- /dev/null +++ b/clients/kamino-lending/idls/kamino_lending.json @@ -0,0 +1,4794 @@ +{ + "address": "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD", + "metadata": { + "name": "kamino_lending", + "version": "1.11.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "init_lending_market", + "discriminator": [34, 162, 116, 14, 101, 137, 94, 239], + "accounts": [ + { + "name": "lending_market_owner", + "writable": true, + "signer": true + }, + { + "name": "lending_market", + "writable": true + }, + { + "name": "lending_market_authority" + }, + { + "name": "system_program" + }, + { + "name": "rent" + } + ], + "args": [ + { + "name": "quote_currency", + "type": { + "array": ["u8", 32] + } + } + ] + }, + { + "name": "update_lending_market", + "discriminator": [209, 157, 53, 210, 97, 180, 31, 45], + "accounts": [ + { + "name": "lending_market_owner", + "signer": true + }, + { + "name": "lending_market", + "writable": true + } + ], + "args": [ + { + "name": "mode", + "type": "u64" + }, + { + "name": "value", + "type": { + "array": ["u8", 72] + } + } + ] + }, + { + "name": "update_lending_market_owner", + "discriminator": [118, 224, 10, 62, 196, 230, 184, 89], + "accounts": [ + { + "name": "lending_market_owner_cached", + "signer": true + }, + { + "name": "lending_market", + "writable": true + } + ], + "args": [] + }, + { + "name": "init_reserve", + "discriminator": [138, 245, 71, 225, 153, 4, 3, 43], + "accounts": [ + { + "name": "lending_market_owner", + "writable": true, + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "fee_receiver", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_collateral_supply", + "writable": true + }, + { + "name": "initial_liquidity_source", + "writable": true + }, + { + "name": "rent" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "collateral_token_program" + }, + { + "name": "system_program" + } + ], + "args": [] + }, + { + "name": "init_farms_for_reserve", + "discriminator": [218, 6, 62, 233, 1, 33, 232, 82], + "accounts": [ + { + "name": "lending_market_owner", + "writable": true, + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "farms_program" + }, + { + "name": "farms_global_config" + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "farms_vault_authority" + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "mode", + "type": "u8" + } + ] + }, + { + "name": "update_reserve_config", + "discriminator": [61, 148, 100, 70, 143, 107, 17, 13], + "accounts": [ + { + "name": "lending_market_owner", + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + } + ], + "args": [ + { + "name": "mode", + "type": "u64" + }, + { + "name": "value", + "type": "bytes" + }, + { + "name": "skip_validation", + "type": "bool" + } + ] + }, + { + "name": "redeem_fees", + "discriminator": [215, 39, 180, 41, 173, 46, 248, 220], + "accounts": [ + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "reserve_supply_liquidity", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "withdraw_protocol_fee", + "discriminator": [158, 201, 158, 189, 33, 93, 162, 103], + "accounts": [ + { + "name": "lending_market_owner", + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve" + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "lending_market_authority" + }, + { + "name": "fee_vault", + "writable": true + }, + { + "name": "lending_market_owner_ata", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "socialize_loss", + "discriminator": [245, 75, 91, 0, 236, 97, 19, 3], + "accounts": [ + { + "name": "risk_council", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "socialize_loss_v2", + "discriminator": [238, 95, 98, 220, 187, 40, 204, 154], + "accounts": [ + { + "name": "socialize_loss_accounts", + "accounts": [ + { + "name": "risk_council", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "socialize_loss_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "lending_market_authority" + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "mark_obligation_for_deleveraging", + "discriminator": [164, 35, 182, 19, 0, 116, 243, 127], + "accounts": [ + { + "name": "risk_council", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + } + ], + "args": [ + { + "name": "autodeleverage_target_ltv_pct", + "type": "u8" + } + ] + }, + { + "name": "refresh_reserves_batch", + "discriminator": [144, 110, 26, 103, 162, 204, 252, 147], + "accounts": [], + "args": [ + { + "name": "skip_price_updates", + "type": "bool" + } + ] + }, + { + "name": "refresh_reserve", + "discriminator": [2, 218, 138, 235, 79, 201, 25, 102], + "accounts": [ + { + "name": "reserve", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "pyth_oracle", + "optional": true + }, + { + "name": "switchboard_price_oracle", + "optional": true + }, + { + "name": "switchboard_twap_oracle", + "optional": true + }, + { + "name": "scope_prices", + "optional": true + } + ], + "args": [] + }, + { + "name": "deposit_reserve_liquidity", + "discriminator": [169, 201, 30, 126, 6, 205, 102, 68], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "user_destination_collateral", + "writable": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "redeem_reserve_collateral", + "discriminator": [234, 117, 181, 125, 185, 142, 220, 29], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "user_source_collateral", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "init_obligation", + "discriminator": [251, 10, 231, 76, 27, 11, 159, 96], + "accounts": [ + { + "name": "obligation_owner", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "seed1_account" + }, + { + "name": "seed2_account" + }, + { + "name": "owner_user_metadata" + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": { + "name": "InitObligationArgs" + } + } + } + ] + }, + { + "name": "init_obligation_farms_for_reserve", + "discriminator": [136, 63, 15, 186, 211, 152, 168, 164], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner" + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_farm_state", + "writable": true + }, + { + "name": "obligation_farm", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "farms_program" + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "mode", + "type": "u8" + } + ] + }, + { + "name": "refresh_obligation_farms_for_reserve", + "discriminator": [140, 144, 253, 21, 10, 74, 248, 3], + "accounts": [ + { + "name": "crank", + "signer": true + }, + { + "name": "base_accounts", + "accounts": [ + { + "name": "obligation" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve" + }, + { + "name": "reserve_farm_state", + "writable": true + }, + { + "name": "obligation_farm_user_state", + "writable": true + }, + { + "name": "lending_market" + } + ] + }, + { + "name": "farms_program" + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "mode", + "type": "u8" + } + ] + }, + { + "name": "refresh_obligation", + "discriminator": [33, 132, 147, 228, 151, 192, 72, 89], + "accounts": [ + { + "name": "lending_market" + }, + { + "name": "obligation", + "writable": true + } + ], + "args": [] + }, + { + "name": "deposit_obligation_collateral", + "discriminator": [108, 209, 4, 72, 21, 22, 118, 133], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "deposit_reserve", + "writable": true + }, + { + "name": "reserve_destination_collateral", + "writable": true + }, + { + "name": "user_source_collateral", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_obligation_collateral_v2", + "discriminator": [137, 145, 151, 94, 167, 113, 4, 145], + "accounts": [ + { + "name": "deposit_accounts", + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "deposit_reserve", + "writable": true + }, + { + "name": "reserve_destination_collateral", + "writable": true + }, + { + "name": "user_source_collateral", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "lending_market_authority" + }, + { + "name": "deposit_obligation_collateral_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_obligation_collateral", + "discriminator": [37, 116, 205, 103, 243, 192, 92, 198], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "user_destination_collateral", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_obligation_collateral_v2", + "discriminator": [202, 249, 117, 114, 231, 192, 47, 138], + "accounts": [ + { + "name": "withdraw_accounts", + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "user_destination_collateral", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "borrow_obligation_liquidity", + "discriminator": [121, 127, 18, 204, 73, 245, 225, 65], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "borrow_reserve", + "writable": true + }, + { + "name": "borrow_reserve_liquidity_mint" + }, + { + "name": "reserve_source_liquidity", + "writable": true + }, + { + "name": "borrow_reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "referrer_token_state", + "writable": true, + "optional": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "borrow_obligation_liquidity_v2", + "discriminator": [161, 128, 143, 245, 171, 199, 194, 6], + "accounts": [ + { + "name": "borrow_accounts", + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "borrow_reserve", + "writable": true + }, + { + "name": "borrow_reserve_liquidity_mint" + }, + { + "name": "reserve_source_liquidity", + "writable": true + }, + { + "name": "borrow_reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "referrer_token_state", + "writable": true, + "optional": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "borrow_obligation_liquidity_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "repay_obligation_liquidity", + "discriminator": [145, 178, 13, 225, 76, 240, 147, 72], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "repay_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_destination_liquidity", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "repay_obligation_liquidity_v2", + "discriminator": [116, 174, 213, 76, 180, 53, 210, 144], + "accounts": [ + { + "name": "repay_accounts", + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "repay_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_destination_liquidity", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "repay_obligation_liquidity_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "lending_market_authority" + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "repay_and_withdraw_and_redeem", + "discriminator": [2, 54, 152, 3, 148, 96, 109, 218], + "accounts": [ + { + "name": "repay_accounts", + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "repay_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_destination_liquidity", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "withdraw_accounts", + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "collateral_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "repay_debt_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "repay_amount", + "type": "u64" + }, + { + "name": "withdraw_collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_and_withdraw", + "discriminator": [141, 153, 39, 15, 64, 61, 88, 84], + "accounts": [ + { + "name": "deposit_accounts", + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_destination_deposit_collateral", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "withdraw_accounts", + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "deposit_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "withdraw_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + }, + { + "name": "withdraw_collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_reserve_liquidity_and_obligation_collateral", + "discriminator": [129, 199, 4, 2, 222, 39, 26, 46], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_destination_deposit_collateral", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_reserve_liquidity_and_obligation_collateral_v2", + "discriminator": [216, 224, 191, 27, 204, 151, 102, 175], + "accounts": [ + { + "name": "deposit_accounts", + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_destination_deposit_collateral", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "deposit_reserve_liquidity_and_obligation_collateral_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_obligation_collateral_and_redeem_reserve_collateral", + "discriminator": [75, 93, 93, 220, 34, 150, 218, 196], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_obligation_collateral_and_redeem_reserve_collateral_v2", + "discriminator": [235, 52, 119, 152, 149, 197, 20, 7], + "accounts": [ + { + "name": "withdraw_accounts", + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_source_collateral", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "writable": true + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "placeholder_user_destination_collateral", + "optional": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "withdraw_obligation_collateral_and_redeem_reserve_collateral_v2_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "collateral_amount", + "type": "u64" + } + ] + }, + { + "name": "liquidate_obligation_and_redeem_reserve_collateral", + "discriminator": [177, 71, 154, 188, 226, 133, 74, 55], + "accounts": [ + { + "name": "liquidator", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "repay_reserve", + "writable": true + }, + { + "name": "repay_reserve_liquidity_mint" + }, + { + "name": "repay_reserve_liquidity_supply", + "writable": true + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_mint" + }, + { + "name": "withdraw_reserve_collateral_mint", + "writable": true + }, + { + "name": "withdraw_reserve_collateral_supply", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_supply", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "user_destination_collateral", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "repay_liquidity_token_program" + }, + { + "name": "withdraw_liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + }, + { + "name": "min_acceptable_received_liquidity_amount", + "type": "u64" + }, + { + "name": "max_allowed_ltv_override_percent", + "type": "u64" + } + ] + }, + { + "name": "liquidate_obligation_and_redeem_reserve_collateral_v2", + "discriminator": [162, 161, 35, 143, 30, 187, 185, 103], + "accounts": [ + { + "name": "liquidation_accounts", + "accounts": [ + { + "name": "liquidator", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "repay_reserve", + "writable": true + }, + { + "name": "repay_reserve_liquidity_mint" + }, + { + "name": "repay_reserve_liquidity_supply", + "writable": true + }, + { + "name": "withdraw_reserve", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_mint" + }, + { + "name": "withdraw_reserve_collateral_mint", + "writable": true + }, + { + "name": "withdraw_reserve_collateral_supply", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_supply", + "writable": true + }, + { + "name": "withdraw_reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "user_destination_collateral", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "collateral_token_program" + }, + { + "name": "repay_liquidity_token_program" + }, + { + "name": "withdraw_liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ] + }, + { + "name": "collateral_farms_accounts_v2", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "debt_farms_accounts", + "accounts": [ + { + "name": "obligation_farm_user_state", + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + } + ] + }, + { + "name": "farms_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + }, + { + "name": "min_acceptable_received_liquidity_amount", + "type": "u64" + }, + { + "name": "max_allowed_ltv_override_percent", + "type": "u64" + } + ] + }, + { + "name": "flash_repay_reserve_liquidity", + "discriminator": [185, 117, 0, 203, 96, 245, 180, 186], + "accounts": [ + { + "name": "user_transfer_authority", + "signer": true + }, + { + "name": "lending_market_authority" + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_destination_liquidity", + "writable": true + }, + { + "name": "user_source_liquidity", + "writable": true + }, + { + "name": "reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "referrer_token_state", + "writable": true, + "optional": true + }, + { + "name": "referrer_account", + "writable": true, + "optional": true + }, + { + "name": "sysvar_info", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + }, + { + "name": "borrow_instruction_index", + "type": "u8" + } + ] + }, + { + "name": "flash_borrow_reserve_liquidity", + "discriminator": [135, 231, 52, 167, 7, 52, 212, 193], + "accounts": [ + { + "name": "user_transfer_authority", + "signer": true + }, + { + "name": "lending_market_authority" + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_source_liquidity", + "writable": true + }, + { + "name": "user_destination_liquidity", + "writable": true + }, + { + "name": "reserve_liquidity_fee_receiver", + "writable": true + }, + { + "name": "referrer_token_state", + "writable": true, + "optional": true + }, + { + "name": "referrer_account", + "writable": true, + "optional": true + }, + { + "name": "sysvar_info", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "liquidity_amount", + "type": "u64" + } + ] + }, + { + "name": "request_elevation_group", + "discriminator": [36, 119, 251, 129, 34, 240, 7, 147], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "obligation", + "writable": true + }, + { + "name": "lending_market" + } + ], + "args": [ + { + "name": "elevation_group", + "type": "u8" + } + ] + }, + { + "name": "init_referrer_token_state", + "discriminator": [116, 45, 66, 148, 58, 13, 218, 115], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve" + }, + { + "name": "referrer" + }, + { + "name": "referrer_token_state", + "writable": true + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [] + }, + { + "name": "init_user_metadata", + "discriminator": [117, 169, 176, 69, 197, 23, 15, 162], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "user_metadata", + "writable": true + }, + { + "name": "referrer_user_metadata", + "optional": true + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "user_lookup_table", + "type": "pubkey" + } + ] + }, + { + "name": "withdraw_referrer_fees", + "discriminator": [171, 118, 121, 201, 233, 140, 23, 228], + "accounts": [ + { + "name": "referrer", + "writable": true, + "signer": true + }, + { + "name": "referrer_token_state", + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "reserve_liquidity_mint" + }, + { + "name": "reserve_supply_liquidity", + "writable": true + }, + { + "name": "referrer_token_account", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "init_referrer_state_and_short_url", + "discriminator": [165, 19, 25, 127, 100, 55, 31, 90], + "accounts": [ + { + "name": "referrer", + "writable": true, + "signer": true + }, + { + "name": "referrer_state", + "writable": true + }, + { + "name": "referrer_short_url", + "writable": true + }, + { + "name": "referrer_user_metadata" + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "short_url", + "type": "string" + } + ] + }, + { + "name": "delete_referrer_state_and_short_url", + "discriminator": [153, 185, 99, 28, 228, 179, 187, 150], + "accounts": [ + { + "name": "referrer", + "writable": true, + "signer": true + }, + { + "name": "referrer_state", + "writable": true + }, + { + "name": "short_url", + "writable": true + }, + { + "name": "rent" + }, + { + "name": "system_program" + } + ], + "args": [] + }, + { + "name": "idl_missing_types", + "discriminator": [130, 80, 38, 153, 80, 212, 182, 253], + "accounts": [ + { + "name": "lending_market_owner", + "signer": true + }, + { + "name": "lending_market" + }, + { + "name": "reserve", + "writable": true + } + ], + "args": [ + { + "name": "reserve_farm_kind", + "type": { + "defined": { + "name": "ReserveFarmKind" + } + } + }, + { + "name": "asset_tier", + "type": { + "defined": { + "name": "AssetTier" + } + } + }, + { + "name": "fee_calculation", + "type": { + "defined": { + "name": "FeeCalculation" + } + } + }, + { + "name": "reserve_status", + "type": { + "defined": { + "name": "ReserveStatus" + } + } + }, + { + "name": "update_config_mode", + "type": { + "defined": { + "name": "UpdateConfigMode" + } + } + }, + { + "name": "update_lending_market_config_value", + "type": { + "defined": { + "name": "UpdateLendingMarketConfigValue" + } + } + }, + { + "name": "update_lending_market_config_mode", + "type": { + "defined": { + "name": "UpdateLendingMarketMode" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "UserState", + "discriminator": [72, 177, 85, 249, 76, 167, 186, 126] + }, + { + "name": "LendingMarket", + "discriminator": [246, 114, 50, 98, 72, 157, 28, 120] + }, + { + "name": "Obligation", + "discriminator": [168, 206, 141, 106, 88, 76, 172, 167] + }, + { + "name": "ReferrerState", + "discriminator": [194, 81, 217, 103, 12, 19, 12, 66] + }, + { + "name": "ReferrerTokenState", + "discriminator": [39, 15, 208, 77, 32, 195, 105, 56] + }, + { + "name": "ShortUrl", + "discriminator": [28, 89, 174, 25, 226, 124, 126, 212] + }, + { + "name": "UserMetadata", + "discriminator": [157, 214, 220, 235, 98, 135, 171, 28] + }, + { + "name": "Reserve", + "discriminator": [43, 242, 204, 202, 26, 247, 59, 127] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidMarketAuthority", + "msg": "Market authority is invalid" + }, + { + "code": 6001, + "name": "InvalidMarketOwner", + "msg": "Market owner is invalid" + }, + { + "code": 6002, + "name": "InvalidAccountOwner", + "msg": "Input account owner is not the program address" + }, + { + "code": 6003, + "name": "InvalidAmount", + "msg": "Input amount is invalid" + }, + { + "code": 6004, + "name": "InvalidConfig", + "msg": "Input config value is invalid" + }, + { + "code": 6005, + "name": "InvalidSigner", + "msg": "Input account must be a signer" + }, + { + "code": 6006, + "name": "InvalidAccountInput", + "msg": "Invalid account input" + }, + { + "code": 6007, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6008, + "name": "InsufficientLiquidity", + "msg": "Insufficient liquidity available" + }, + { + "code": 6009, + "name": "ReserveStale", + "msg": "Reserve state needs to be refreshed" + }, + { + "code": 6010, + "name": "WithdrawTooSmall", + "msg": "Withdraw amount too small" + }, + { + "code": 6011, + "name": "WithdrawTooLarge", + "msg": "Withdraw amount too large" + }, + { + "code": 6012, + "name": "BorrowTooSmall", + "msg": "Borrow amount too small to receive liquidity after fees" + }, + { + "code": 6013, + "name": "BorrowTooLarge", + "msg": "Borrow amount too large for deposited collateral" + }, + { + "code": 6014, + "name": "RepayTooSmall", + "msg": "Repay amount too small to transfer liquidity" + }, + { + "code": 6015, + "name": "LiquidationTooSmall", + "msg": "Liquidation amount too small to receive collateral" + }, + { + "code": 6016, + "name": "ObligationHealthy", + "msg": "Cannot liquidate healthy obligations" + }, + { + "code": 6017, + "name": "ObligationStale", + "msg": "Obligation state needs to be refreshed" + }, + { + "code": 6018, + "name": "ObligationReserveLimit", + "msg": "Obligation reserve limit exceeded" + }, + { + "code": 6019, + "name": "InvalidObligationOwner", + "msg": "Obligation owner is invalid" + }, + { + "code": 6020, + "name": "ObligationDepositsEmpty", + "msg": "Obligation deposits are empty" + }, + { + "code": 6021, + "name": "ObligationBorrowsEmpty", + "msg": "Obligation borrows are empty" + }, + { + "code": 6022, + "name": "ObligationDepositsZero", + "msg": "Obligation deposits have zero value" + }, + { + "code": 6023, + "name": "ObligationBorrowsZero", + "msg": "Obligation borrows have zero value" + }, + { + "code": 6024, + "name": "InvalidObligationCollateral", + "msg": "Invalid obligation collateral" + }, + { + "code": 6025, + "name": "InvalidObligationLiquidity", + "msg": "Invalid obligation liquidity" + }, + { + "code": 6026, + "name": "ObligationCollateralEmpty", + "msg": "Obligation collateral is empty" + }, + { + "code": 6027, + "name": "ObligationLiquidityEmpty", + "msg": "Obligation liquidity is empty" + }, + { + "code": 6028, + "name": "NegativeInterestRate", + "msg": "Interest rate is negative" + }, + { + "code": 6029, + "name": "InvalidOracleConfig", + "msg": "Input oracle config is invalid" + }, + { + "code": 6030, + "name": "InsufficientProtocolFeesToRedeem", + "msg": "Insufficient protocol fees to claim or no liquidity available" + }, + { + "code": 6031, + "name": "FlashBorrowCpi", + "msg": "No cpi flash borrows allowed" + }, + { + "code": 6032, + "name": "NoFlashRepayFound", + "msg": "No corresponding repay found for flash borrow" + }, + { + "code": 6033, + "name": "InvalidFlashRepay", + "msg": "Invalid repay found" + }, + { + "code": 6034, + "name": "FlashRepayCpi", + "msg": "No cpi flash repays allowed" + }, + { + "code": 6035, + "name": "MultipleFlashBorrows", + "msg": "Multiple flash borrows not allowed in the same transaction" + }, + { + "code": 6036, + "name": "FlashLoansDisabled", + "msg": "Flash loans are disabled for this reserve" + }, + { + "code": 6037, + "name": "SwitchboardV2Error", + "msg": "Switchboard error" + }, + { + "code": 6038, + "name": "CouldNotDeserializeScope", + "msg": "Cannot deserialize the scope price account" + }, + { + "code": 6039, + "name": "PriceTooOld", + "msg": "Price too old" + }, + { + "code": 6040, + "name": "PriceTooDivergentFromTwap", + "msg": "Price too divergent from twap" + }, + { + "code": 6041, + "name": "InvalidTwapPrice", + "msg": "Invalid twap price" + }, + { + "code": 6042, + "name": "GlobalEmergencyMode", + "msg": "Emergency mode is enabled" + }, + { + "code": 6043, + "name": "InvalidFlag", + "msg": "Invalid lending market config" + }, + { + "code": 6044, + "name": "PriceNotValid", + "msg": "Price is not valid" + }, + { + "code": 6045, + "name": "PriceIsBiggerThanHeuristic", + "msg": "Price is bigger than allowed by heuristic" + }, + { + "code": 6046, + "name": "PriceIsLowerThanHeuristic", + "msg": "Price lower than allowed by heuristic" + }, + { + "code": 6047, + "name": "PriceIsZero", + "msg": "Price is zero" + }, + { + "code": 6048, + "name": "PriceConfidenceTooWide", + "msg": "Price confidence too wide" + }, + { + "code": 6049, + "name": "IntegerOverflow", + "msg": "Conversion between integers failed" + }, + { + "code": 6050, + "name": "NoFarmForReserve", + "msg": "This reserve does not have a farm" + }, + { + "code": 6051, + "name": "IncorrectInstructionInPosition", + "msg": "Wrong instruction at expected position" + }, + { + "code": 6052, + "name": "NoPriceFound", + "msg": "No price found" + }, + { + "code": 6053, + "name": "InvalidTwapConfig", + "msg": "Invalid Twap configuration: Twap is enabled but one of the enabled price doesn't have a twap" + }, + { + "code": 6054, + "name": "InvalidPythPriceAccount", + "msg": "Pyth price account does not match configuration" + }, + { + "code": 6055, + "name": "InvalidSwitchboardAccount", + "msg": "Switchboard account(s) do not match configuration" + }, + { + "code": 6056, + "name": "InvalidScopePriceAccount", + "msg": "Scope price account does not match configuration" + }, + { + "code": 6057, + "name": "ObligationCollateralLtvZero", + "msg": "The obligation has one collateral with an LTV set to 0. Withdraw it before withdrawing other collaterals" + }, + { + "code": 6058, + "name": "InvalidObligationSeedsValue", + "msg": "Seeds must be default pubkeys for tag 0, and mint addresses for tag 1 or 2" + }, + { + "code": 6059, + "name": "DeprecatedInvalidObligationId", + "msg": "[DEPRECATED] Obligation id must be 0" + }, + { + "code": 6060, + "name": "InvalidBorrowRateCurvePoint", + "msg": "Invalid borrow rate curve point" + }, + { + "code": 6061, + "name": "InvalidUtilizationRate", + "msg": "Invalid utilization rate" + }, + { + "code": 6062, + "name": "CannotSocializeObligationWithCollateral", + "msg": "Obligation hasn't been fully liquidated and debt cannot be socialized." + }, + { + "code": 6063, + "name": "ObligationEmpty", + "msg": "Obligation has no borrows or deposits." + }, + { + "code": 6064, + "name": "WithdrawalCapReached", + "msg": "Withdrawal cap is reached" + }, + { + "code": 6065, + "name": "LastTimestampGreaterThanCurrent", + "msg": "The last interval start timestamp is greater than the current timestamp" + }, + { + "code": 6066, + "name": "LiquidationRewardTooSmall", + "msg": "The reward amount is less than the minimum acceptable received liquidity" + }, + { + "code": 6067, + "name": "IsolatedAssetTierViolation", + "msg": "Isolated Asset Tier Violation" + }, + { + "code": 6068, + "name": "InconsistentElevationGroup", + "msg": "The obligation's elevation group and the reserve's are not the same" + }, + { + "code": 6069, + "name": "InvalidElevationGroup", + "msg": "The elevation group chosen for the reserve does not exist in the lending market" + }, + { + "code": 6070, + "name": "InvalidElevationGroupConfig", + "msg": "The elevation group updated has wrong parameters set" + }, + { + "code": 6071, + "name": "UnhealthyElevationGroupLtv", + "msg": "The current obligation must have most or all its debt repaid before changing the elevation group" + }, + { + "code": 6072, + "name": "ElevationGroupNewLoansDisabled", + "msg": "Elevation group does not accept any new loans or any new borrows/withdrawals" + }, + { + "code": 6073, + "name": "ReserveDeprecated", + "msg": "Reserve was deprecated, no longer usable" + }, + { + "code": 6074, + "name": "ReferrerAccountNotInitialized", + "msg": "Referrer account not initialized" + }, + { + "code": 6075, + "name": "ReferrerAccountMintMissmatch", + "msg": "Referrer account mint does not match the operation reserve mint" + }, + { + "code": 6076, + "name": "ReferrerAccountWrongAddress", + "msg": "Referrer account address is not a valid program address" + }, + { + "code": 6077, + "name": "ReferrerAccountReferrerMissmatch", + "msg": "Referrer account referrer does not match the owner referrer" + }, + { + "code": 6078, + "name": "ReferrerAccountMissing", + "msg": "Referrer account missing for obligation with referrer" + }, + { + "code": 6079, + "name": "InsufficientReferralFeesToRedeem", + "msg": "Insufficient referral fees to claim or no liquidity available" + }, + { + "code": 6080, + "name": "CpiDisabled", + "msg": "CPI disabled for this instruction" + }, + { + "code": 6081, + "name": "ShortUrlNotAsciiAlphanumeric", + "msg": "Referrer short_url is not ascii alphanumeric" + }, + { + "code": 6082, + "name": "ReserveObsolete", + "msg": "Reserve is marked as obsolete" + }, + { + "code": 6083, + "name": "ElevationGroupAlreadyActivated", + "msg": "Obligation already part of the same elevation group" + }, + { + "code": 6084, + "name": "ObligationInDeprecatedReserve", + "msg": "Obligation has a deposit in a deprecated reserve" + }, + { + "code": 6085, + "name": "ReferrerStateOwnerMismatch", + "msg": "Referrer state owner does not match the given signer" + }, + { + "code": 6086, + "name": "UserMetadataOwnerAlreadySet", + "msg": "User metadata owner is already set" + }, + { + "code": 6087, + "name": "CollateralNonLiquidatable", + "msg": "This collateral cannot be liquidated (LTV set to 0)" + }, + { + "code": 6088, + "name": "BorrowingDisabled", + "msg": "Borrowing is disabled" + }, + { + "code": 6089, + "name": "BorrowLimitExceeded", + "msg": "Cannot borrow above borrow limit" + }, + { + "code": 6090, + "name": "DepositLimitExceeded", + "msg": "Cannot deposit above deposit limit" + }, + { + "code": 6091, + "name": "BorrowingDisabledOutsideElevationGroup", + "msg": "Reserve does not accept any new borrows outside elevation group" + }, + { + "code": 6092, + "name": "NetValueRemainingTooSmall", + "msg": "Net value remaining too small" + }, + { + "code": 6093, + "name": "WorseLTVBlocked", + "msg": "Cannot get the obligation in a worse position" + }, + { + "code": 6094, + "name": "LiabilitiesBiggerThanAssets", + "msg": "Cannot have more liabilities than assets in a position" + }, + { + "code": 6095, + "name": "ReserveTokenBalanceMismatch", + "msg": "Reserve state and token account cannot drift" + }, + { + "code": 6096, + "name": "ReserveVaultBalanceMismatch", + "msg": "Reserve token account has been unexpectedly modified" + }, + { + "code": 6097, + "name": "ReserveAccountingMismatch", + "msg": "Reserve internal state accounting has been unexpectedly modified" + }, + { + "code": 6098, + "name": "BorrowingAboveUtilizationRateDisabled", + "msg": "Borrowing above set utilization rate is disabled" + }, + { + "code": 6099, + "name": "LiquidationBorrowFactorPriority", + "msg": "Liquidation must prioritize the debt with the highest borrow factor" + }, + { + "code": 6100, + "name": "LiquidationLowestLTVPriority", + "msg": "Liquidation must prioritize the collateral with the lowest LTV" + }, + { + "code": 6101, + "name": "ElevationGroupBorrowLimitExceeded", + "msg": "Elevation group borrow limit exceeded" + }, + { + "code": 6102, + "name": "ElevationGroupWithoutDebtReserve", + "msg": "The elevation group does not have a debt reserve defined" + }, + { + "code": 6103, + "name": "ElevationGroupMaxCollateralReserveZero", + "msg": "The elevation group does not allow any collateral reserves" + }, + { + "code": 6104, + "name": "ElevationGroupHasAnotherDebtReserve", + "msg": "In elevation group attempt to borrow from a reserve that is not the debt reserve" + }, + { + "code": 6105, + "name": "ElevationGroupDebtReserveAsCollateral", + "msg": "The elevation group's debt reserve cannot be used as a collateral reserve" + }, + { + "code": 6106, + "name": "ObligationCollateralExceedsElevationGroupLimit", + "msg": "Obligation have more collateral than the maximum allowed by the elevation group" + }, + { + "code": 6107, + "name": "ObligationElevationGroupMultipleDebtReserve", + "msg": "Obligation is an elevation group but have more than one debt reserve" + }, + { + "code": 6108, + "name": "UnsupportedTokenExtension", + "msg": "Mint has a token (2022) extension that is not supported" + }, + { + "code": 6109, + "name": "InvalidTokenAccount", + "msg": "Can't have an spl token mint with a t22 account" + }, + { + "code": 6110, + "name": "DepositDisabledOutsideElevationGroup", + "msg": "Can't deposit into this reserve outside elevation group" + }, + { + "code": 6111, + "name": "CannotCalculateReferralAmountDueToSlotsMismatch", + "msg": "Cannot calculate referral amount due to slots mismatch" + }, + { + "code": 6112, + "name": "ObligationOwnersMustMatch", + "msg": "Obligation owners must match" + }, + { + "code": 6113, + "name": "ObligationsMustMatch", + "msg": "Obligations must match" + }, + { + "code": 6114, + "name": "LendingMarketsMustMatch", + "msg": "Lending markets must match" + }, + { + "code": 6115, + "name": "ObligationCurrentlyMarkedForDeleveraging", + "msg": "Obligation is already marked for deleveraging" + }, + { + "code": 6116, + "name": "MaximumWithdrawValueZero", + "msg": "Maximum withdrawable value of this collateral is zero, LTV needs improved" + }, + { + "code": 6117, + "name": "ZeroMaxLtvAssetsInDeposits", + "msg": "No max LTV 0 assets allowed in deposits for repay and withdraw" + }, + { + "code": 6118, + "name": "MinLtvAssetsPriority", + "msg": "The operation must prioritize the collateral with the lowest LTV" + }, + { + "code": 6119, + "name": "WorseLTVThanUnhealthyLTV", + "msg": "Cannot get the obligation liquidatable" + }, + { + "code": 6120, + "name": "FarmAccountsMissing", + "msg": "Farm accounts to refresh are missing" + }, + { + "code": 6121, + "name": "RepayTooSmallForFullLiquidation", + "msg": "Repay amount is too small to satisfy the mandatory full liquidation" + }, + { + "code": 6122, + "name": "InsufficientRepayAmount", + "msg": "Liquidator provided repay amount lower than required by liquidation rules" + } + ], + "types": [ + { + "name": "UpdateConfigMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "UpdateLoanToValuePct" + }, + { + "name": "UpdateMaxLiquidationBonusBps" + }, + { + "name": "UpdateLiquidationThresholdPct" + }, + { + "name": "UpdateProtocolLiquidationFee" + }, + { + "name": "UpdateProtocolTakeRate" + }, + { + "name": "UpdateFeesBorrowFee" + }, + { + "name": "UpdateFeesFlashLoanFee" + }, + { + "name": "UpdateFeesReferralFeeBps" + }, + { + "name": "UpdateDepositLimit" + }, + { + "name": "UpdateBorrowLimit" + }, + { + "name": "UpdateTokenInfoLowerHeuristic" + }, + { + "name": "UpdateTokenInfoUpperHeuristic" + }, + { + "name": "UpdateTokenInfoExpHeuristic" + }, + { + "name": "UpdateTokenInfoTwapDivergence" + }, + { + "name": "UpdateTokenInfoScopeTwap" + }, + { + "name": "UpdateTokenInfoScopeChain" + }, + { + "name": "UpdateTokenInfoName" + }, + { + "name": "UpdateTokenInfoPriceMaxAge" + }, + { + "name": "UpdateTokenInfoTwapMaxAge" + }, + { + "name": "UpdateScopePriceFeed" + }, + { + "name": "UpdatePythPrice" + }, + { + "name": "UpdateSwitchboardFeed" + }, + { + "name": "UpdateSwitchboardTwapFeed" + }, + { + "name": "UpdateBorrowRateCurve" + }, + { + "name": "UpdateEntireReserveConfig" + }, + { + "name": "UpdateDebtWithdrawalCap" + }, + { + "name": "UpdateDepositWithdrawalCap" + }, + { + "name": "UpdateDebtWithdrawalCapCurrentTotal" + }, + { + "name": "UpdateDepositWithdrawalCapCurrentTotal" + }, + { + "name": "UpdateBadDebtLiquidationBonusBps" + }, + { + "name": "UpdateMinLiquidationBonusBps" + }, + { + "name": "UpdateDeleveragingMarginCallPeriod" + }, + { + "name": "UpdateBorrowFactor" + }, + { + "name": "UpdateAssetTier" + }, + { + "name": "UpdateElevationGroup" + }, + { + "name": "UpdateDeleveragingThresholdDecreaseBpsPerDay" + }, + { + "name": "DeprecatedUpdateMultiplierSideBoost" + }, + { + "name": "DeprecatedUpdateMultiplierTagBoost" + }, + { + "name": "UpdateReserveStatus" + }, + { + "name": "UpdateFarmCollateral" + }, + { + "name": "UpdateFarmDebt" + }, + { + "name": "UpdateDisableUsageAsCollateralOutsideEmode" + }, + { + "name": "UpdateBlockBorrowingAboveUtilizationPct" + }, + { + "name": "UpdateBlockPriceUsage" + }, + { + "name": "UpdateBorrowLimitOutsideElevationGroup" + }, + { + "name": "UpdateBorrowLimitsInElevationGroupAgainstThisReserve" + }, + { + "name": "UpdateHostFixedInterestRateBps" + }, + { + "name": "UpdateAutodeleverageEnabled" + }, + { + "name": "UpdateDeleveragingBonusIncreaseBpsPerDay" + } + ] + } + }, + { + "name": "UpdateLendingMarketConfigValue", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Bool", + "fields": ["bool"] + }, + { + "name": "U8", + "fields": ["u8"] + }, + { + "name": "U8Array", + "fields": [ + { + "array": ["u8", 8] + } + ] + }, + { + "name": "U16", + "fields": ["u16"] + }, + { + "name": "U64", + "fields": ["u64"] + }, + { + "name": "U128", + "fields": ["u128"] + }, + { + "name": "Pubkey", + "fields": ["pubkey"] + }, + { + "name": "ElevationGroup", + "fields": [ + { + "defined": { + "name": "ElevationGroup" + } + } + ] + }, + { + "name": "Name", + "fields": [ + { + "array": ["u8", 32] + } + ] + } + ] + } + }, + { + "name": "UpdateLendingMarketMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "UpdateOwner" + }, + { + "name": "UpdateEmergencyMode" + }, + { + "name": "UpdateLiquidationCloseFactor" + }, + { + "name": "UpdateLiquidationMaxValue" + }, + { + "name": "DeprecatedUpdateGlobalUnhealthyBorrow" + }, + { + "name": "UpdateGlobalAllowedBorrow" + }, + { + "name": "UpdateRiskCouncil" + }, + { + "name": "UpdateMinFullLiquidationThreshold" + }, + { + "name": "UpdateInsolvencyRiskLtv" + }, + { + "name": "UpdateElevationGroup" + }, + { + "name": "UpdateReferralFeeBps" + }, + { + "name": "DeprecatedUpdateMultiplierPoints" + }, + { + "name": "UpdatePriceRefreshTriggerToMaxAgePct" + }, + { + "name": "UpdateAutodeleverageEnabled" + }, + { + "name": "UpdateBorrowingDisabled" + }, + { + "name": "UpdateMinNetValueObligationPostAction" + }, + { + "name": "UpdateMinValueLtvSkipPriorityLiqCheck" + }, + { + "name": "UpdateMinValueBfSkipPriorityLiqCheck" + }, + { + "name": "UpdatePaddingFields" + }, + { + "name": "UpdateName" + }, + { + "name": "UpdateIndividualAutodeleverageMarginCallPeriodSecs" + }, + { + "name": "UpdateInitialDepositAmount" + } + ] + } + }, + { + "name": "LastUpdate", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "slot", + "type": "u64" + }, + { + "name": "stale", + "type": "u8" + }, + { + "name": "price_status", + "type": "u8" + }, + { + "name": "placeholder", + "type": { + "array": ["u8", 6] + } + } + ] + } + }, + { + "name": "ElevationGroupLendingMarket", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "max_liquidation_bonus_bps", + "type": "u16" + }, + { + "name": "id", + "type": "u8" + }, + { + "name": "ltv_pct", + "type": "u8" + }, + { + "name": "liquidation_threshold_pct", + "type": "u8" + }, + { + "name": "allow_new_loans", + "type": "u8" + }, + { + "name": "max_reserves_as_collateral", + "type": "u8" + }, + { + "name": "padding0", + "type": "u8" + }, + { + "name": "debt_reserve", + "type": "pubkey" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 4] + } + } + ] + } + }, + { + "name": "ElevationGroup", + "type": { + "kind": "struct", + "fields": [ + { + "name": "max_liquidation_bonus_bps", + "type": "u16" + }, + { + "name": "id", + "type": "u8" + }, + { + "name": "ltv_pct", + "type": "u8" + }, + { + "name": "liquidation_threshold_pct", + "type": "u8" + }, + { + "name": "allow_new_loans", + "type": "u8" + }, + { + "name": "max_reserves_as_collateral", + "type": "u8" + }, + { + "name": "padding0", + "type": "u8" + }, + { + "name": "debt_reserve", + "type": "pubkey" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 4] + } + } + ] + } + }, + { + "name": "InitObligationArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tag", + "type": "u8" + }, + { + "name": "id", + "type": "u8" + } + ] + } + }, + { + "name": "ObligationCollateral", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "deposit_reserve", + "type": "pubkey" + }, + { + "name": "deposited_amount", + "type": "u64" + }, + { + "name": "market_value_sf", + "type": "u128" + }, + { + "name": "borrowed_amount_against_this_collateral_in_elevation_group", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": ["u64", 9] + } + } + ] + } + }, + { + "name": "ObligationLiquidity", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "borrow_reserve", + "type": "pubkey" + }, + { + "name": "cumulative_borrow_rate_bsf", + "type": { + "defined": { + "name": "BigFractionBytes" + } + } + }, + { + "name": "padding", + "type": "u64" + }, + { + "name": "borrowed_amount_sf", + "type": "u128" + }, + { + "name": "market_value_sf", + "type": "u128" + }, + { + "name": "borrow_factor_adjusted_market_value_sf", + "type": "u128" + }, + { + "name": "borrowed_amount_outside_elevation_groups", + "type": "u64" + }, + { + "name": "padding2", + "type": { + "array": ["u64", 7] + } + } + ] + } + }, + { + "name": "AssetTier", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Regular" + }, + { + "name": "IsolatedCollateral" + }, + { + "name": "IsolatedDebt" + } + ] + } + }, + { + "name": "BigFractionBytes", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "value", + "type": { + "array": ["u64", 4] + } + }, + { + "name": "padding", + "type": { + "array": ["u64", 2] + } + } + ] + } + }, + { + "name": "FeeCalculation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Exclusive" + }, + { + "name": "Inclusive" + } + ] + } + }, + { + "name": "ReserveCollateral", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint_pubkey", + "type": "pubkey" + }, + { + "name": "mint_total_supply", + "type": "u64" + }, + { + "name": "supply_vault", + "type": "pubkey" + }, + { + "name": "padding1", + "type": { + "array": ["u128", 32] + } + }, + { + "name": "padding2", + "type": { + "array": ["u128", 32] + } + } + ] + } + }, + { + "name": "ReserveConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "status", + "type": "u8" + }, + { + "name": "asset_tier", + "type": "u8" + }, + { + "name": "host_fixed_interest_rate_bps", + "type": "u16" + }, + { + "name": "reserved2", + "type": { + "array": ["u8", 2] + } + }, + { + "name": "reserved3", + "type": { + "array": ["u8", 8] + } + }, + { + "name": "protocol_take_rate_pct", + "type": "u8" + }, + { + "name": "protocol_liquidation_fee_pct", + "type": "u8" + }, + { + "name": "loan_to_value_pct", + "type": "u8" + }, + { + "name": "liquidation_threshold_pct", + "type": "u8" + }, + { + "name": "min_liquidation_bonus_bps", + "type": "u16" + }, + { + "name": "max_liquidation_bonus_bps", + "type": "u16" + }, + { + "name": "bad_debt_liquidation_bonus_bps", + "type": "u16" + }, + { + "name": "deleveraging_margin_call_period_secs", + "type": "u64" + }, + { + "name": "deleveraging_threshold_decrease_bps_per_day", + "type": "u64" + }, + { + "name": "fees", + "type": { + "defined": { + "name": "ReserveFees" + } + } + }, + { + "name": "borrow_rate_curve", + "type": { + "defined": { + "name": "BorrowRateCurve" + } + } + }, + { + "name": "borrow_factor_pct", + "type": "u64" + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "borrow_limit", + "type": "u64" + }, + { + "name": "token_info", + "type": { + "defined": { + "name": "TokenInfo" + } + } + }, + { + "name": "deposit_withdrawal_cap", + "type": { + "defined": { + "name": "WithdrawalCaps" + } + } + }, + { + "name": "debt_withdrawal_cap", + "type": { + "defined": { + "name": "WithdrawalCaps" + } + } + }, + { + "name": "elevation_groups", + "type": { + "array": ["u8", 20] + } + }, + { + "name": "disable_usage_as_coll_outside_emode", + "type": "u8" + }, + { + "name": "utilization_limit_block_borrowing_above_pct", + "type": "u8" + }, + { + "name": "autodeleverage_enabled", + "type": "u8" + }, + { + "name": "reserved1", + "type": { + "array": ["u8", 1] + } + }, + { + "name": "borrow_limit_outside_elevation_group", + "type": "u64" + }, + { + "name": "borrow_limit_against_this_collateral_in_elevation_group", + "type": { + "array": ["u64", 32] + } + }, + { + "name": "deleveraging_bonus_increase_bps_per_day", + "type": "u64" + } + ] + } + }, + { + "name": "ReserveFarmKind", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Collateral" + }, + { + "name": "Debt" + } + ] + } + }, + { + "name": "ReserveFees", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "borrow_fee_sf", + "type": "u64" + }, + { + "name": "flash_loan_fee_sf", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": ["u8", 8] + } + } + ] + } + }, + { + "name": "ReserveLiquidity", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint_pubkey", + "type": "pubkey" + }, + { + "name": "supply_vault", + "type": "pubkey" + }, + { + "name": "fee_vault", + "type": "pubkey" + }, + { + "name": "available_amount", + "type": "u64" + }, + { + "name": "borrowed_amount_sf", + "type": "u128" + }, + { + "name": "market_price_sf", + "type": "u128" + }, + { + "name": "market_price_last_updated_ts", + "type": "u64" + }, + { + "name": "mint_decimals", + "type": "u64" + }, + { + "name": "deposit_limit_crossed_timestamp", + "type": "u64" + }, + { + "name": "borrow_limit_crossed_timestamp", + "type": "u64" + }, + { + "name": "cumulative_borrow_rate_bsf", + "type": { + "defined": { + "name": "BigFractionBytes" + } + } + }, + { + "name": "accumulated_protocol_fees_sf", + "type": "u128" + }, + { + "name": "accumulated_referrer_fees_sf", + "type": "u128" + }, + { + "name": "pending_referrer_fees_sf", + "type": "u128" + }, + { + "name": "absolute_referral_rate_sf", + "type": "u128" + }, + { + "name": "token_program", + "type": "pubkey" + }, + { + "name": "padding2", + "type": { + "array": ["u64", 51] + } + }, + { + "name": "padding3", + "type": { + "array": ["u128", 32] + } + } + ] + } + }, + { + "name": "ReserveStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Active" + }, + { + "name": "Obsolete" + }, + { + "name": "Hidden" + } + ] + } + }, + { + "name": "WithdrawalCaps", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "config_capacity", + "type": "i64" + }, + { + "name": "current_total", + "type": "i64" + }, + { + "name": "last_interval_start_timestamp", + "type": "u64" + }, + { + "name": "config_interval_length_seconds", + "type": "u64" + } + ] + } + }, + { + "name": "PriceHeuristic", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lower", + "type": "u64" + }, + { + "name": "upper", + "type": "u64" + }, + { + "name": "exp", + "type": "u64" + } + ] + } + }, + { + "name": "PythConfiguration", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "pubkey" + } + ] + } + }, + { + "name": "ScopeConfiguration", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price_feed", + "type": "pubkey" + }, + { + "name": "price_chain", + "type": { + "array": ["u16", 4] + } + }, + { + "name": "twap_chain", + "type": { + "array": ["u16", 4] + } + } + ] + } + }, + { + "name": "SwitchboardConfiguration", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price_aggregator", + "type": "pubkey" + }, + { + "name": "twap_aggregator", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "name", + "type": { + "array": ["u8", 32] + } + }, + { + "name": "heuristic", + "type": { + "defined": { + "name": "PriceHeuristic" + } + } + }, + { + "name": "max_twap_divergence_bps", + "type": "u64" + }, + { + "name": "max_age_price_seconds", + "type": "u64" + }, + { + "name": "max_age_twap_seconds", + "type": "u64" + }, + { + "name": "scope_configuration", + "type": { + "defined": { + "name": "ScopeConfiguration" + } + } + }, + { + "name": "switchboard_configuration", + "type": { + "defined": { + "name": "SwitchboardConfiguration" + } + } + }, + { + "name": "pyth_configuration", + "type": { + "defined": { + "name": "PythConfiguration" + } + } + }, + { + "name": "block_price_usage", + "type": "u8" + }, + { + "name": "reserved", + "type": { + "array": ["u8", 7] + } + }, + { + "name": "padding", + "type": { + "array": ["u64", 19] + } + } + ] + } + }, + { + "name": "BorrowRateCurve", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "points", + "type": { + "array": [ + { + "defined": { + "name": "CurvePoint" + } + }, + 11 + ] + } + } + ] + } + }, + { + "name": "CurvePoint", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "utilization_rate_bps", + "type": "u32" + }, + { + "name": "borrow_rate_bps", + "type": "u32" + } + ] + } + }, + { + "name": "UserState", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "user_id", + "type": "u64" + }, + { + "name": "farm_state", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "is_farm_delegated", + "type": "u8" + }, + { + "name": "padding0", + "type": { + "array": ["u8", 7] + } + }, + { + "name": "rewards_tally_scaled", + "type": { + "array": ["u128", 10] + } + }, + { + "name": "rewards_issued_unclaimed", + "type": { + "array": ["u64", 10] + } + }, + { + "name": "last_claim_ts", + "type": { + "array": ["u64", 10] + } + }, + { + "name": "active_stake_scaled", + "type": "u128" + }, + { + "name": "pending_deposit_stake_scaled", + "type": "u128" + }, + { + "name": "pending_deposit_stake_ts", + "type": "u64" + }, + { + "name": "pending_withdrawal_unstake_scaled", + "type": "u128" + }, + { + "name": "pending_withdrawal_unstake_ts", + "type": "u64" + }, + { + "name": "bump", + "type": "u64" + }, + { + "name": "delegatee", + "type": "pubkey" + }, + { + "name": "last_stake_ts", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 50] + } + } + ] + } + }, + { + "name": "LendingMarket", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "version", + "type": "u64" + }, + { + "name": "bump_seed", + "type": "u64" + }, + { + "name": "lending_market_owner", + "type": "pubkey" + }, + { + "name": "lending_market_owner_cached", + "type": "pubkey" + }, + { + "name": "quote_currency", + "type": { + "array": ["u8", 32] + } + }, + { + "name": "referral_fee_bps", + "type": "u16" + }, + { + "name": "emergency_mode", + "type": "u8" + }, + { + "name": "autodeleverage_enabled", + "type": "u8" + }, + { + "name": "borrow_disabled", + "type": "u8" + }, + { + "name": "price_refresh_trigger_to_max_age_pct", + "type": "u8" + }, + { + "name": "liquidation_max_debt_close_factor_pct", + "type": "u8" + }, + { + "name": "insolvency_risk_unhealthy_ltv_pct", + "type": "u8" + }, + { + "name": "min_full_liquidation_value_threshold", + "type": "u64" + }, + { + "name": "max_liquidatable_debt_market_value_at_once", + "type": "u64" + }, + { + "name": "reserved0", + "type": { + "array": ["u8", 8] + } + }, + { + "name": "global_allowed_borrow_value", + "type": "u64" + }, + { + "name": "risk_council", + "type": "pubkey" + }, + { + "name": "reserved1", + "type": { + "array": ["u8", 8] + } + }, + { + "name": "elevation_groups", + "type": { + "array": [ + { + "defined": { + "name": "ElevationGroupLendingMarket" + } + }, + 32 + ] + } + }, + { + "name": "elevation_group_padding", + "type": { + "array": ["u64", 90] + } + }, + { + "name": "min_net_value_in_obligation_sf", + "type": "u128" + }, + { + "name": "min_value_skip_liquidation_ltv_checks", + "type": "u64" + }, + { + "name": "name", + "type": { + "array": ["u8", 32] + } + }, + { + "name": "min_value_skip_liquidation_bf_checks", + "type": "u64" + }, + { + "name": "individual_autodeleverage_margin_call_period_secs", + "type": "u64" + }, + { + "name": "min_initial_deposit_amount", + "type": "u64" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 170] + } + } + ] + } + }, + { + "name": "Obligation", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "tag", + "type": "u64" + }, + { + "name": "last_update", + "type": { + "defined": { + "name": "LastUpdate" + } + } + }, + { + "name": "lending_market", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "deposits", + "type": { + "array": [ + { + "defined": { + "name": "ObligationCollateral" + } + }, + 8 + ] + } + }, + { + "name": "lowest_reserve_deposit_liquidation_ltv", + "type": "u64" + }, + { + "name": "deposited_value_sf", + "type": "u128" + }, + { + "name": "borrows", + "type": { + "array": [ + { + "defined": { + "name": "ObligationLiquidity" + } + }, + 5 + ] + } + }, + { + "name": "borrow_factor_adjusted_debt_value_sf", + "type": "u128" + }, + { + "name": "borrowed_assets_market_value_sf", + "type": "u128" + }, + { + "name": "allowed_borrow_value_sf", + "type": "u128" + }, + { + "name": "unhealthy_borrow_value_sf", + "type": "u128" + }, + { + "name": "deposits_asset_tiers", + "type": { + "array": ["u8", 8] + } + }, + { + "name": "borrows_asset_tiers", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "elevation_group", + "type": "u8" + }, + { + "name": "num_of_obsolete_reserves", + "type": "u8" + }, + { + "name": "has_debt", + "type": "u8" + }, + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "borrowing_disabled", + "type": "u8" + }, + { + "name": "autodeleverage_target_ltv_pct", + "type": "u8" + }, + { + "name": "lowest_reserve_deposit_max_ltv_pct", + "type": "u8" + }, + { + "name": "reserved", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "highest_borrow_factor_pct", + "type": "u64" + }, + { + "name": "autodeleverage_margin_call_started_timestamp", + "type": "u64" + }, + { + "name": "padding3", + "type": { + "array": ["u64", 125] + } + } + ] + } + }, + { + "name": "ReferrerState", + "type": { + "kind": "struct", + "fields": [ + { + "name": "short_url", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "ReferrerTokenState", + "type": { + "kind": "struct", + "fields": [ + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "amount_unclaimed_sf", + "type": "u128" + }, + { + "name": "amount_cumulative_sf", + "type": "u128" + }, + { + "name": "bump", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": ["u64", 31] + } + } + ] + } + }, + { + "name": "ShortUrl", + "type": { + "kind": "struct", + "fields": [ + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "short_url", + "type": "string" + } + ] + } + }, + { + "name": "UserMetadata", + "type": { + "kind": "struct", + "fields": [ + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u64" + }, + { + "name": "user_lookup_table", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "padding1", + "type": { + "array": ["u64", 51] + } + }, + { + "name": "padding2", + "type": { + "array": ["u64", 64] + } + } + ] + } + }, + { + "name": "Reserve", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "version", + "type": "u64" + }, + { + "name": "last_update", + "type": { + "defined": { + "name": "LastUpdate" + } + } + }, + { + "name": "lending_market", + "type": "pubkey" + }, + { + "name": "farm_collateral", + "type": "pubkey" + }, + { + "name": "farm_debt", + "type": "pubkey" + }, + { + "name": "liquidity", + "type": { + "defined": { + "name": "ReserveLiquidity" + } + } + }, + { + "name": "reserve_liquidity_padding", + "type": { + "array": ["u64", 150] + } + }, + { + "name": "collateral", + "type": { + "defined": { + "name": "ReserveCollateral" + } + } + }, + { + "name": "reserve_collateral_padding", + "type": { + "array": ["u64", 150] + } + }, + { + "name": "config", + "type": { + "defined": { + "name": "ReserveConfig" + } + } + }, + { + "name": "config_padding", + "type": { + "array": ["u64", 116] + } + }, + { + "name": "borrowed_amount_outside_elevation_group", + "type": "u64" + }, + { + "name": "borrowed_amounts_against_this_reserve_in_elevation_groups", + "type": { + "array": ["u64", 32] + } + }, + { + "name": "padding", + "type": { + "array": ["u64", 207] + } + } + ] + } + } + ] +} diff --git a/clients/kamino-lending/package.json b/clients/kamino-lending/package.json new file mode 100644 index 00000000..096165c8 --- /dev/null +++ b/clients/kamino-lending/package.json @@ -0,0 +1,66 @@ +{ + "name": "@macalinao/clients-kamino-lending", + "version": "0.0.1", + "description": "TypeScript client for the Kamino Lending program", + "type": "module", + "sideEffects": false, + "author": "Ian Macalinao ", + "homepage": "https://coda.ianm.com", + "license": "Apache-2.0", + "keywords": [ + "coda", + "solana", + "kamino", + "lending", + "defi", + "client", + "esm", + "typescript", + "ian-macalinao" + ], + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + } + }, + "files": [ + "dist/", + "src/" + ], + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/macalinao/coda.git", + "directory": "clients/kamino-lending" + }, + "scripts": { + "build": "tsc", + "clean": "rm -fr dist/", + "lint": "eslint . --cache", + "test": "echo 'No tests yet'", + "codegen": "coda generate" + }, + "peerDependencies": { + "@solana/kit": "*" + }, + "devDependencies": { + "@macalinao/coda": "workspace:*", + "@macalinao/eslint-config": "catalog:", + "@macalinao/tsconfig": "catalog:", + "@solana/kit": "*", + "eslint": "catalog:", + "typescript": "catalog:" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}": [ + "biome check --write --no-errors-on-unmatched", + "eslint --fix --cache" + ], + "*.{json,jsonc,html}": "biome format --write --no-errors-on-unmatched" + } +} diff --git a/clients/kamino-lending/src/generated/accounts/farmState.ts b/clients/kamino-lending/src/generated/accounts/farmState.ts new file mode 100644 index 00000000..866c6d0d --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/farmState.ts @@ -0,0 +1,371 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + Codec, + Decoder, + EncodedAccount, + Encoder, + FetchAccountConfig, + FetchAccountsConfig, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; +import type { + RewardInfo, + RewardInfoArgs, + TokenInfo, + TokenInfoArgs, +} from "../types/index.js"; +import { + getRewardInfoDecoder, + getRewardInfoEncoder, + getTokenInfoDecoder, + getTokenInfoEncoder, +} from "../types/index.js"; + +export const FARM_STATE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 198, 102, 216, 74, 63, 66, 163, 190, +]); + +export function getFarmStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(FARM_STATE_DISCRIMINATOR); +} + +export interface FarmState { + discriminator: ReadonlyUint8Array; + farmAdmin: Address; + globalConfig: Address; + token: TokenInfo; + rewardInfos: RewardInfo[]; + numRewardTokens: bigint; + /** Data used to calculate the rewards of the user */ + numUsers: bigint; + /** + * The number of token in the `farm_vault` staked (getting rewards and fees) + * Set such as `farm_vault.amount = total_staked_amount + total_pending_amount` + */ + totalStakedAmount: bigint; + farmVault: Address; + farmVaultsAuthority: Address; + farmVaultsAuthorityBump: bigint; + /** + * Only used for delegate farms + * Set to `default()` otherwise + */ + delegateAuthority: Address; + /** + * Raw representation of a `TimeUnit` + * Seconds = 0, Slots = 1 + */ + timeUnit: number; + /** + * Automatically set to true in case of a full authority withdrawal + * If true, the farm is frozen and no more deposits are allowed + */ + isFarmFrozen: number; + /** + * Indicates if the farm is a delegate farm + * If true, the farm is a delegate farm and the `delegate_authority` is set* + */ + isFarmDelegated: number; + padding0: number[]; + /** + * Withdraw authority for the farm, allowed to lock deposited funds and withdraw them + * Set to `default()` if unused (only the depositors can withdraw their funds) + */ + withdrawAuthority: Address; + /** + * Delay between a user deposit and the moment it is considered as staked + * 0 if unused + */ + depositWarmupPeriod: number; + /** Delay between a user unstake and the ability to withdraw his deposit. */ + withdrawalCooldownPeriod: number; + /** Total active stake of tokens in the farm (scaled from `Decimal` representation). */ + totalActiveStakeScaled: bigint; + /** + * Total pending stake of tokens in the farm (scaled from `Decimal` representation). + * (can be used by `withdraw_authority` but don't get rewards or fees) + */ + totalPendingStakeScaled: bigint; + /** Total pending amount of tokens in the farm */ + totalPendingAmount: bigint; + /** Slashed amounts from early withdrawal */ + slashedAmountCurrent: bigint; + slashedAmountCumulative: bigint; + slashedAmountSpillAddress: Address; + /** Locking stake */ + lockingMode: bigint; + lockingStartTimestamp: bigint; + lockingDuration: bigint; + lockingEarlyWithdrawalPenaltyBps: bigint; + depositCapAmount: bigint; + scopePrices: Address; + scopeOraclePriceId: bigint; + scopeOracleMaxAge: bigint; + pendingFarmAdmin: Address; + strategyId: Address; + delegatedRpsAdmin: Address; + vaultId: Address; + padding: bigint[]; +} + +export interface FarmStateArgs { + farmAdmin: Address; + globalConfig: Address; + token: TokenInfoArgs; + rewardInfos: RewardInfoArgs[]; + numRewardTokens: number | bigint; + /** Data used to calculate the rewards of the user */ + numUsers: number | bigint; + /** + * The number of token in the `farm_vault` staked (getting rewards and fees) + * Set such as `farm_vault.amount = total_staked_amount + total_pending_amount` + */ + totalStakedAmount: number | bigint; + farmVault: Address; + farmVaultsAuthority: Address; + farmVaultsAuthorityBump: number | bigint; + /** + * Only used for delegate farms + * Set to `default()` otherwise + */ + delegateAuthority: Address; + /** + * Raw representation of a `TimeUnit` + * Seconds = 0, Slots = 1 + */ + timeUnit: number; + /** + * Automatically set to true in case of a full authority withdrawal + * If true, the farm is frozen and no more deposits are allowed + */ + isFarmFrozen: number; + /** + * Indicates if the farm is a delegate farm + * If true, the farm is a delegate farm and the `delegate_authority` is set* + */ + isFarmDelegated: number; + padding0: number[]; + /** + * Withdraw authority for the farm, allowed to lock deposited funds and withdraw them + * Set to `default()` if unused (only the depositors can withdraw their funds) + */ + withdrawAuthority: Address; + /** + * Delay between a user deposit and the moment it is considered as staked + * 0 if unused + */ + depositWarmupPeriod: number; + /** Delay between a user unstake and the ability to withdraw his deposit. */ + withdrawalCooldownPeriod: number; + /** Total active stake of tokens in the farm (scaled from `Decimal` representation). */ + totalActiveStakeScaled: number | bigint; + /** + * Total pending stake of tokens in the farm (scaled from `Decimal` representation). + * (can be used by `withdraw_authority` but don't get rewards or fees) + */ + totalPendingStakeScaled: number | bigint; + /** Total pending amount of tokens in the farm */ + totalPendingAmount: number | bigint; + /** Slashed amounts from early withdrawal */ + slashedAmountCurrent: number | bigint; + slashedAmountCumulative: number | bigint; + slashedAmountSpillAddress: Address; + /** Locking stake */ + lockingMode: number | bigint; + lockingStartTimestamp: number | bigint; + lockingDuration: number | bigint; + lockingEarlyWithdrawalPenaltyBps: number | bigint; + depositCapAmount: number | bigint; + scopePrices: Address; + scopeOraclePriceId: number | bigint; + scopeOracleMaxAge: number | bigint; + pendingFarmAdmin: Address; + strategyId: Address; + delegatedRpsAdmin: Address; + vaultId: Address; + padding: (number | bigint)[]; +} + +export function getFarmStateEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["farmAdmin", getAddressEncoder()], + ["globalConfig", getAddressEncoder()], + ["token", getTokenInfoEncoder()], + ["rewardInfos", getArrayEncoder(getRewardInfoEncoder(), { size: 10 })], + ["numRewardTokens", getU64Encoder()], + ["numUsers", getU64Encoder()], + ["totalStakedAmount", getU64Encoder()], + ["farmVault", getAddressEncoder()], + ["farmVaultsAuthority", getAddressEncoder()], + ["farmVaultsAuthorityBump", getU64Encoder()], + ["delegateAuthority", getAddressEncoder()], + ["timeUnit", getU8Encoder()], + ["isFarmFrozen", getU8Encoder()], + ["isFarmDelegated", getU8Encoder()], + ["padding0", getArrayEncoder(getU8Encoder(), { size: 5 })], + ["withdrawAuthority", getAddressEncoder()], + ["depositWarmupPeriod", getU32Encoder()], + ["withdrawalCooldownPeriod", getU32Encoder()], + ["totalActiveStakeScaled", getU128Encoder()], + ["totalPendingStakeScaled", getU128Encoder()], + ["totalPendingAmount", getU64Encoder()], + ["slashedAmountCurrent", getU64Encoder()], + ["slashedAmountCumulative", getU64Encoder()], + ["slashedAmountSpillAddress", getAddressEncoder()], + ["lockingMode", getU64Encoder()], + ["lockingStartTimestamp", getU64Encoder()], + ["lockingDuration", getU64Encoder()], + ["lockingEarlyWithdrawalPenaltyBps", getU64Encoder()], + ["depositCapAmount", getU64Encoder()], + ["scopePrices", getAddressEncoder()], + ["scopeOraclePriceId", getU64Encoder()], + ["scopeOracleMaxAge", getU64Encoder()], + ["pendingFarmAdmin", getAddressEncoder()], + ["strategyId", getAddressEncoder()], + ["delegatedRpsAdmin", getAddressEncoder()], + ["vaultId", getAddressEncoder()], + ["padding", getArrayEncoder(getU64Encoder(), { size: 78 })], + ]), + (value) => ({ ...value, discriminator: FARM_STATE_DISCRIMINATOR }), + ); +} + +export function getFarmStateDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["farmAdmin", getAddressDecoder()], + ["globalConfig", getAddressDecoder()], + ["token", getTokenInfoDecoder()], + ["rewardInfos", getArrayDecoder(getRewardInfoDecoder(), { size: 10 })], + ["numRewardTokens", getU64Decoder()], + ["numUsers", getU64Decoder()], + ["totalStakedAmount", getU64Decoder()], + ["farmVault", getAddressDecoder()], + ["farmVaultsAuthority", getAddressDecoder()], + ["farmVaultsAuthorityBump", getU64Decoder()], + ["delegateAuthority", getAddressDecoder()], + ["timeUnit", getU8Decoder()], + ["isFarmFrozen", getU8Decoder()], + ["isFarmDelegated", getU8Decoder()], + ["padding0", getArrayDecoder(getU8Decoder(), { size: 5 })], + ["withdrawAuthority", getAddressDecoder()], + ["depositWarmupPeriod", getU32Decoder()], + ["withdrawalCooldownPeriod", getU32Decoder()], + ["totalActiveStakeScaled", getU128Decoder()], + ["totalPendingStakeScaled", getU128Decoder()], + ["totalPendingAmount", getU64Decoder()], + ["slashedAmountCurrent", getU64Decoder()], + ["slashedAmountCumulative", getU64Decoder()], + ["slashedAmountSpillAddress", getAddressDecoder()], + ["lockingMode", getU64Decoder()], + ["lockingStartTimestamp", getU64Decoder()], + ["lockingDuration", getU64Decoder()], + ["lockingEarlyWithdrawalPenaltyBps", getU64Decoder()], + ["depositCapAmount", getU64Decoder()], + ["scopePrices", getAddressDecoder()], + ["scopeOraclePriceId", getU64Decoder()], + ["scopeOracleMaxAge", getU64Decoder()], + ["pendingFarmAdmin", getAddressDecoder()], + ["strategyId", getAddressDecoder()], + ["delegatedRpsAdmin", getAddressDecoder()], + ["vaultId", getAddressDecoder()], + ["padding", getArrayDecoder(getU64Decoder(), { size: 78 })], + ]); +} + +export function getFarmStateCodec(): Codec { + return combineCodec(getFarmStateEncoder(), getFarmStateDecoder()); +} + +export function decodeFarmState( + encodedAccount: EncodedAccount, +): Account; +export function decodeFarmState( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeFarmState( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getFarmStateDecoder(), + ); +} + +export async function fetchFarmState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeFarmState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeFarmState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeFarmState(maybeAccount); +} + +export async function fetchAllFarmState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeFarmState(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeFarmState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeFarmState(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/farmsUserState.ts b/clients/kamino-lending/src/generated/accounts/farmsUserState.ts new file mode 100644 index 00000000..fded2f3f --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/farmsUserState.ts @@ -0,0 +1,266 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; + +export const FARMS_USER_STATE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([72, 177, 85, 249, 76, 167, 186, 126]); + +export function getFarmsUserStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FARMS_USER_STATE_DISCRIMINATOR, + ); +} + +export interface FarmsUserState { + discriminator: ReadonlyUint8Array; + userId: bigint; + farmState: Address; + owner: Address; + /** Indicate if this user state is part of a delegated farm */ + isFarmDelegated: number; + padding0: number[]; + /** + * Rewards tally used for computation of gained rewards + * (scaled from `Decimal` representation). + */ + rewardsTallyScaled: bigint[]; + /** Number of reward tokens ready for claim */ + rewardsIssuedUnclaimed: bigint[]; + lastClaimTs: bigint[]; + /** + * User stake deposited and usable, generating rewards and fees. + * (scaled from `Decimal` representation). + */ + activeStakeScaled: bigint; + /** + * User stake deposited but not usable and not generating rewards yet. + * (scaled from `Decimal` representation). + */ + pendingDepositStakeScaled: bigint; + /** + * After this timestamp, pending user stake can be moved to user stake + * Initialized to now() + delayed user stake period + */ + pendingDepositStakeTs: bigint; + /** + * User deposits unstaked, pending for withdrawal, not usable and not generating rewards. + * (scaled from `Decimal` representation). + */ + pendingWithdrawalUnstakeScaled: bigint; + /** After this timestamp, user can withdraw their deposit. */ + pendingWithdrawalUnstakeTs: bigint; + /** User bump used for account address validation */ + bump: bigint; + /** Delegatee used for initialisation - useful to check against */ + delegatee: Address; + lastStakeTs: bigint; + padding1: bigint[]; +} + +export interface FarmsUserStateArgs { + userId: number | bigint; + farmState: Address; + owner: Address; + /** Indicate if this user state is part of a delegated farm */ + isFarmDelegated: number; + padding0: number[]; + /** + * Rewards tally used for computation of gained rewards + * (scaled from `Decimal` representation). + */ + rewardsTallyScaled: (number | bigint)[]; + /** Number of reward tokens ready for claim */ + rewardsIssuedUnclaimed: (number | bigint)[]; + lastClaimTs: (number | bigint)[]; + /** + * User stake deposited and usable, generating rewards and fees. + * (scaled from `Decimal` representation). + */ + activeStakeScaled: number | bigint; + /** + * User stake deposited but not usable and not generating rewards yet. + * (scaled from `Decimal` representation). + */ + pendingDepositStakeScaled: number | bigint; + /** + * After this timestamp, pending user stake can be moved to user stake + * Initialized to now() + delayed user stake period + */ + pendingDepositStakeTs: number | bigint; + /** + * User deposits unstaked, pending for withdrawal, not usable and not generating rewards. + * (scaled from `Decimal` representation). + */ + pendingWithdrawalUnstakeScaled: number | bigint; + /** After this timestamp, user can withdraw their deposit. */ + pendingWithdrawalUnstakeTs: number | bigint; + /** User bump used for account address validation */ + bump: number | bigint; + /** Delegatee used for initialisation - useful to check against */ + delegatee: Address; + lastStakeTs: number | bigint; + padding1: (number | bigint)[]; +} + +export function getFarmsUserStateEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["userId", getU64Encoder()], + ["farmState", getAddressEncoder()], + ["owner", getAddressEncoder()], + ["isFarmDelegated", getU8Encoder()], + ["padding0", getArrayEncoder(getU8Encoder(), { size: 7 })], + ["rewardsTallyScaled", getArrayEncoder(getU128Encoder(), { size: 10 })], + [ + "rewardsIssuedUnclaimed", + getArrayEncoder(getU64Encoder(), { size: 10 }), + ], + ["lastClaimTs", getArrayEncoder(getU64Encoder(), { size: 10 })], + ["activeStakeScaled", getU128Encoder()], + ["pendingDepositStakeScaled", getU128Encoder()], + ["pendingDepositStakeTs", getU64Encoder()], + ["pendingWithdrawalUnstakeScaled", getU128Encoder()], + ["pendingWithdrawalUnstakeTs", getU64Encoder()], + ["bump", getU64Encoder()], + ["delegatee", getAddressEncoder()], + ["lastStakeTs", getU64Encoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 50 })], + ]), + (value) => ({ ...value, discriminator: FARMS_USER_STATE_DISCRIMINATOR }), + ); +} + +export function getFarmsUserStateDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["userId", getU64Decoder()], + ["farmState", getAddressDecoder()], + ["owner", getAddressDecoder()], + ["isFarmDelegated", getU8Decoder()], + ["padding0", getArrayDecoder(getU8Decoder(), { size: 7 })], + ["rewardsTallyScaled", getArrayDecoder(getU128Decoder(), { size: 10 })], + ["rewardsIssuedUnclaimed", getArrayDecoder(getU64Decoder(), { size: 10 })], + ["lastClaimTs", getArrayDecoder(getU64Decoder(), { size: 10 })], + ["activeStakeScaled", getU128Decoder()], + ["pendingDepositStakeScaled", getU128Decoder()], + ["pendingDepositStakeTs", getU64Decoder()], + ["pendingWithdrawalUnstakeScaled", getU128Decoder()], + ["pendingWithdrawalUnstakeTs", getU64Decoder()], + ["bump", getU64Decoder()], + ["delegatee", getAddressDecoder()], + ["lastStakeTs", getU64Decoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 50 })], + ]); +} + +export function getFarmsUserStateCodec(): FixedSizeCodec< + FarmsUserStateArgs, + FarmsUserState +> { + return combineCodec(getFarmsUserStateEncoder(), getFarmsUserStateDecoder()); +} + +export function decodeFarmsUserState( + encodedAccount: EncodedAccount, +): Account; +export function decodeFarmsUserState( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeFarmsUserState( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getFarmsUserStateDecoder(), + ); +} + +export async function fetchFarmsUserState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeFarmsUserState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeFarmsUserState< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeFarmsUserState(maybeAccount); +} + +export async function fetchAllFarmsUserState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeFarmsUserState( + rpc, + addresses, + config, + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeFarmsUserState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeFarmsUserState(maybeAccount), + ); +} diff --git a/clients/kamino-lending/src/generated/accounts/globalConfig.ts b/clients/kamino-lending/src/generated/accounts/globalConfig.ts new file mode 100644 index 00000000..c7374a56 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/globalConfig.ts @@ -0,0 +1,160 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; + +export const GLOBAL_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 149, 8, 156, 202, 160, 252, 176, 217, +]); + +export function getGlobalConfigDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + GLOBAL_CONFIG_DISCRIMINATOR, + ); +} + +export interface GlobalConfig { + discriminator: ReadonlyUint8Array; + globalAdmin: Address; + treasuryFeeBps: bigint; + treasuryVaultsAuthority: Address; + treasuryVaultsAuthorityBump: bigint; + pendingGlobalAdmin: Address; + padding1: bigint[]; +} + +export interface GlobalConfigArgs { + globalAdmin: Address; + treasuryFeeBps: number | bigint; + treasuryVaultsAuthority: Address; + treasuryVaultsAuthorityBump: number | bigint; + pendingGlobalAdmin: Address; + padding1: (number | bigint)[]; +} + +export function getGlobalConfigEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["globalAdmin", getAddressEncoder()], + ["treasuryFeeBps", getU64Encoder()], + ["treasuryVaultsAuthority", getAddressEncoder()], + ["treasuryVaultsAuthorityBump", getU64Encoder()], + ["pendingGlobalAdmin", getAddressEncoder()], + ["padding1", getArrayEncoder(getU128Encoder(), { size: 126 })], + ]), + (value) => ({ ...value, discriminator: GLOBAL_CONFIG_DISCRIMINATOR }), + ); +} + +export function getGlobalConfigDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["globalAdmin", getAddressDecoder()], + ["treasuryFeeBps", getU64Decoder()], + ["treasuryVaultsAuthority", getAddressDecoder()], + ["treasuryVaultsAuthorityBump", getU64Decoder()], + ["pendingGlobalAdmin", getAddressDecoder()], + ["padding1", getArrayDecoder(getU128Decoder(), { size: 126 })], + ]); +} + +export function getGlobalConfigCodec(): FixedSizeCodec< + GlobalConfigArgs, + GlobalConfig +> { + return combineCodec(getGlobalConfigEncoder(), getGlobalConfigDecoder()); +} + +export function decodeGlobalConfig( + encodedAccount: EncodedAccount, +): Account; +export function decodeGlobalConfig( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeGlobalConfig( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getGlobalConfigDecoder(), + ); +} + +export async function fetchGlobalConfig( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeGlobalConfig(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeGlobalConfig( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeGlobalConfig(maybeAccount); +} + +export async function fetchAllGlobalConfig( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeGlobalConfig(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeGlobalConfig( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeGlobalConfig(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/index.ts b/clients/kamino-lending/src/generated/accounts/index.ts new file mode 100644 index 00000000..6b27b29d --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/index.ts @@ -0,0 +1,20 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./farmState.js"; +export * from "./farmsUserState.js"; +export * from "./globalConfig.js"; +export * from "./lendingMarket.js"; +export * from "./obligation.js"; +export * from "./oraclePrices.js"; +export * from "./referrerState.js"; +export * from "./referrerTokenState.js"; +export * from "./reserve.js"; +export * from "./shortUrl.js"; +export * from "./userMetadata.js"; +export * from "./userState.js"; diff --git a/clients/kamino-lending/src/generated/accounts/lendingMarket.ts b/clients/kamino-lending/src/generated/accounts/lendingMarket.ts new file mode 100644 index 00000000..48480849 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/lendingMarket.ts @@ -0,0 +1,266 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; +import type { + ElevationGroupLendingMarket, + ElevationGroupLendingMarketArgs, +} from "../types/index.js"; +import { + getElevationGroupLendingMarketDecoder, + getElevationGroupLendingMarketEncoder, +} from "../types/index.js"; + +export const LENDING_MARKET_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 246, 114, 50, 98, 72, 157, 28, 120, +]); + +export function getLendingMarketDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + LENDING_MARKET_DISCRIMINATOR, + ); +} + +export interface LendingMarket { + discriminator: ReadonlyUint8Array; + version: bigint; + bumpSeed: bigint; + lendingMarketOwner: Address; + lendingMarketOwnerCached: Address; + quoteCurrency: number[]; + referralFeeBps: number; + emergencyMode: number; + autodeleverageEnabled: number; + borrowDisabled: number; + priceRefreshTriggerToMaxAgePct: number; + liquidationMaxDebtCloseFactorPct: number; + insolvencyRiskUnhealthyLtvPct: number; + minFullLiquidationValueThreshold: bigint; + maxLiquidatableDebtMarketValueAtOnce: bigint; + reserved0: number[]; + globalAllowedBorrowValue: bigint; + riskCouncil: Address; + reserved1: number[]; + elevationGroups: ElevationGroupLendingMarket[]; + elevationGroupPadding: bigint[]; + minNetValueInObligationSf: bigint; + minValueSkipLiquidationLtvChecks: bigint; + name: number[]; + minValueSkipLiquidationBfChecks: bigint; + individualAutodeleverageMarginCallPeriodSecs: bigint; + minInitialDepositAmount: bigint; + padding1: bigint[]; +} + +export interface LendingMarketArgs { + version: number | bigint; + bumpSeed: number | bigint; + lendingMarketOwner: Address; + lendingMarketOwnerCached: Address; + quoteCurrency: number[]; + referralFeeBps: number; + emergencyMode: number; + autodeleverageEnabled: number; + borrowDisabled: number; + priceRefreshTriggerToMaxAgePct: number; + liquidationMaxDebtCloseFactorPct: number; + insolvencyRiskUnhealthyLtvPct: number; + minFullLiquidationValueThreshold: number | bigint; + maxLiquidatableDebtMarketValueAtOnce: number | bigint; + reserved0: number[]; + globalAllowedBorrowValue: number | bigint; + riskCouncil: Address; + reserved1: number[]; + elevationGroups: ElevationGroupLendingMarketArgs[]; + elevationGroupPadding: (number | bigint)[]; + minNetValueInObligationSf: number | bigint; + minValueSkipLiquidationLtvChecks: number | bigint; + name: number[]; + minValueSkipLiquidationBfChecks: number | bigint; + individualAutodeleverageMarginCallPeriodSecs: number | bigint; + minInitialDepositAmount: number | bigint; + padding1: (number | bigint)[]; +} + +export function getLendingMarketEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["version", getU64Encoder()], + ["bumpSeed", getU64Encoder()], + ["lendingMarketOwner", getAddressEncoder()], + ["lendingMarketOwnerCached", getAddressEncoder()], + ["quoteCurrency", getArrayEncoder(getU8Encoder(), { size: 32 })], + ["referralFeeBps", getU16Encoder()], + ["emergencyMode", getU8Encoder()], + ["autodeleverageEnabled", getU8Encoder()], + ["borrowDisabled", getU8Encoder()], + ["priceRefreshTriggerToMaxAgePct", getU8Encoder()], + ["liquidationMaxDebtCloseFactorPct", getU8Encoder()], + ["insolvencyRiskUnhealthyLtvPct", getU8Encoder()], + ["minFullLiquidationValueThreshold", getU64Encoder()], + ["maxLiquidatableDebtMarketValueAtOnce", getU64Encoder()], + ["reserved0", getArrayEncoder(getU8Encoder(), { size: 8 })], + ["globalAllowedBorrowValue", getU64Encoder()], + ["riskCouncil", getAddressEncoder()], + ["reserved1", getArrayEncoder(getU8Encoder(), { size: 8 })], + [ + "elevationGroups", + getArrayEncoder(getElevationGroupLendingMarketEncoder(), { size: 32 }), + ], + ["elevationGroupPadding", getArrayEncoder(getU64Encoder(), { size: 90 })], + ["minNetValueInObligationSf", getU128Encoder()], + ["minValueSkipLiquidationLtvChecks", getU64Encoder()], + ["name", getArrayEncoder(getU8Encoder(), { size: 32 })], + ["minValueSkipLiquidationBfChecks", getU64Encoder()], + ["individualAutodeleverageMarginCallPeriodSecs", getU64Encoder()], + ["minInitialDepositAmount", getU64Encoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 170 })], + ]), + (value) => ({ ...value, discriminator: LENDING_MARKET_DISCRIMINATOR }), + ); +} + +export function getLendingMarketDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["version", getU64Decoder()], + ["bumpSeed", getU64Decoder()], + ["lendingMarketOwner", getAddressDecoder()], + ["lendingMarketOwnerCached", getAddressDecoder()], + ["quoteCurrency", getArrayDecoder(getU8Decoder(), { size: 32 })], + ["referralFeeBps", getU16Decoder()], + ["emergencyMode", getU8Decoder()], + ["autodeleverageEnabled", getU8Decoder()], + ["borrowDisabled", getU8Decoder()], + ["priceRefreshTriggerToMaxAgePct", getU8Decoder()], + ["liquidationMaxDebtCloseFactorPct", getU8Decoder()], + ["insolvencyRiskUnhealthyLtvPct", getU8Decoder()], + ["minFullLiquidationValueThreshold", getU64Decoder()], + ["maxLiquidatableDebtMarketValueAtOnce", getU64Decoder()], + ["reserved0", getArrayDecoder(getU8Decoder(), { size: 8 })], + ["globalAllowedBorrowValue", getU64Decoder()], + ["riskCouncil", getAddressDecoder()], + ["reserved1", getArrayDecoder(getU8Decoder(), { size: 8 })], + [ + "elevationGroups", + getArrayDecoder(getElevationGroupLendingMarketDecoder(), { size: 32 }), + ], + ["elevationGroupPadding", getArrayDecoder(getU64Decoder(), { size: 90 })], + ["minNetValueInObligationSf", getU128Decoder()], + ["minValueSkipLiquidationLtvChecks", getU64Decoder()], + ["name", getArrayDecoder(getU8Decoder(), { size: 32 })], + ["minValueSkipLiquidationBfChecks", getU64Decoder()], + ["individualAutodeleverageMarginCallPeriodSecs", getU64Decoder()], + ["minInitialDepositAmount", getU64Decoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 170 })], + ]); +} + +export function getLendingMarketCodec(): FixedSizeCodec< + LendingMarketArgs, + LendingMarket +> { + return combineCodec(getLendingMarketEncoder(), getLendingMarketDecoder()); +} + +export function decodeLendingMarket( + encodedAccount: EncodedAccount, +): Account; +export function decodeLendingMarket( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeLendingMarket( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getLendingMarketDecoder(), + ); +} + +export async function fetchLendingMarket( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeLendingMarket(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeLendingMarket( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeLendingMarket(maybeAccount); +} + +export async function fetchAllLendingMarket( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeLendingMarket( + rpc, + addresses, + config, + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeLendingMarket( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeLendingMarket(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/obligation.ts b/clients/kamino-lending/src/generated/accounts/obligation.ts new file mode 100644 index 00000000..a48fa5b8 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/obligation.ts @@ -0,0 +1,261 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; +import type { + LastUpdate, + LastUpdateArgs, + ObligationCollateral, + ObligationCollateralArgs, + ObligationLiquidity, + ObligationLiquidityArgs, +} from "../types/index.js"; +import { + getLastUpdateDecoder, + getLastUpdateEncoder, + getObligationCollateralDecoder, + getObligationCollateralEncoder, + getObligationLiquidityDecoder, + getObligationLiquidityEncoder, +} from "../types/index.js"; + +export const OBLIGATION_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 168, 206, 141, 106, 88, 76, 172, 167, +]); + +export function getObligationDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(OBLIGATION_DISCRIMINATOR); +} + +export interface Obligation { + discriminator: ReadonlyUint8Array; + tag: bigint; + lastUpdate: LastUpdate; + lendingMarket: Address; + owner: Address; + deposits: ObligationCollateral[]; + lowestReserveDepositLiquidationLtv: bigint; + depositedValueSf: bigint; + borrows: ObligationLiquidity[]; + borrowFactorAdjustedDebtValueSf: bigint; + borrowedAssetsMarketValueSf: bigint; + allowedBorrowValueSf: bigint; + unhealthyBorrowValueSf: bigint; + depositsAssetTiers: number[]; + borrowsAssetTiers: number[]; + elevationGroup: number; + numOfObsoleteReserves: number; + hasDebt: number; + referrer: Address; + borrowingDisabled: number; + autodeleverageTargetLtvPct: number; + lowestReserveDepositMaxLtvPct: number; + reserved: number[]; + highestBorrowFactorPct: bigint; + autodeleverageMarginCallStartedTimestamp: bigint; + padding3: bigint[]; +} + +export interface ObligationArgs { + tag: number | bigint; + lastUpdate: LastUpdateArgs; + lendingMarket: Address; + owner: Address; + deposits: ObligationCollateralArgs[]; + lowestReserveDepositLiquidationLtv: number | bigint; + depositedValueSf: number | bigint; + borrows: ObligationLiquidityArgs[]; + borrowFactorAdjustedDebtValueSf: number | bigint; + borrowedAssetsMarketValueSf: number | bigint; + allowedBorrowValueSf: number | bigint; + unhealthyBorrowValueSf: number | bigint; + depositsAssetTiers: number[]; + borrowsAssetTiers: number[]; + elevationGroup: number; + numOfObsoleteReserves: number; + hasDebt: number; + referrer: Address; + borrowingDisabled: number; + autodeleverageTargetLtvPct: number; + lowestReserveDepositMaxLtvPct: number; + reserved: number[]; + highestBorrowFactorPct: number | bigint; + autodeleverageMarginCallStartedTimestamp: number | bigint; + padding3: (number | bigint)[]; +} + +export function getObligationEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["tag", getU64Encoder()], + ["lastUpdate", getLastUpdateEncoder()], + ["lendingMarket", getAddressEncoder()], + ["owner", getAddressEncoder()], + [ + "deposits", + getArrayEncoder(getObligationCollateralEncoder(), { size: 8 }), + ], + ["lowestReserveDepositLiquidationLtv", getU64Encoder()], + ["depositedValueSf", getU128Encoder()], + [ + "borrows", + getArrayEncoder(getObligationLiquidityEncoder(), { size: 5 }), + ], + ["borrowFactorAdjustedDebtValueSf", getU128Encoder()], + ["borrowedAssetsMarketValueSf", getU128Encoder()], + ["allowedBorrowValueSf", getU128Encoder()], + ["unhealthyBorrowValueSf", getU128Encoder()], + ["depositsAssetTiers", getArrayEncoder(getU8Encoder(), { size: 8 })], + ["borrowsAssetTiers", getArrayEncoder(getU8Encoder(), { size: 5 })], + ["elevationGroup", getU8Encoder()], + ["numOfObsoleteReserves", getU8Encoder()], + ["hasDebt", getU8Encoder()], + ["referrer", getAddressEncoder()], + ["borrowingDisabled", getU8Encoder()], + ["autodeleverageTargetLtvPct", getU8Encoder()], + ["lowestReserveDepositMaxLtvPct", getU8Encoder()], + ["reserved", getArrayEncoder(getU8Encoder(), { size: 5 })], + ["highestBorrowFactorPct", getU64Encoder()], + ["autodeleverageMarginCallStartedTimestamp", getU64Encoder()], + ["padding3", getArrayEncoder(getU64Encoder(), { size: 125 })], + ]), + (value) => ({ ...value, discriminator: OBLIGATION_DISCRIMINATOR }), + ); +} + +export function getObligationDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["tag", getU64Decoder()], + ["lastUpdate", getLastUpdateDecoder()], + ["lendingMarket", getAddressDecoder()], + ["owner", getAddressDecoder()], + [ + "deposits", + getArrayDecoder(getObligationCollateralDecoder(), { size: 8 }), + ], + ["lowestReserveDepositLiquidationLtv", getU64Decoder()], + ["depositedValueSf", getU128Decoder()], + ["borrows", getArrayDecoder(getObligationLiquidityDecoder(), { size: 5 })], + ["borrowFactorAdjustedDebtValueSf", getU128Decoder()], + ["borrowedAssetsMarketValueSf", getU128Decoder()], + ["allowedBorrowValueSf", getU128Decoder()], + ["unhealthyBorrowValueSf", getU128Decoder()], + ["depositsAssetTiers", getArrayDecoder(getU8Decoder(), { size: 8 })], + ["borrowsAssetTiers", getArrayDecoder(getU8Decoder(), { size: 5 })], + ["elevationGroup", getU8Decoder()], + ["numOfObsoleteReserves", getU8Decoder()], + ["hasDebt", getU8Decoder()], + ["referrer", getAddressDecoder()], + ["borrowingDisabled", getU8Decoder()], + ["autodeleverageTargetLtvPct", getU8Decoder()], + ["lowestReserveDepositMaxLtvPct", getU8Decoder()], + ["reserved", getArrayDecoder(getU8Decoder(), { size: 5 })], + ["highestBorrowFactorPct", getU64Decoder()], + ["autodeleverageMarginCallStartedTimestamp", getU64Decoder()], + ["padding3", getArrayDecoder(getU64Decoder(), { size: 125 })], + ]); +} + +export function getObligationCodec(): FixedSizeCodec< + ObligationArgs, + Obligation +> { + return combineCodec(getObligationEncoder(), getObligationDecoder()); +} + +export function decodeObligation( + encodedAccount: EncodedAccount, +): Account; +export function decodeObligation( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeObligation( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getObligationDecoder(), + ); +} + +export async function fetchObligation( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeObligation(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeObligation( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeObligation(maybeAccount); +} + +export async function fetchAllObligation( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeObligation(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeObligation( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeObligation(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/oraclePrices.ts b/clients/kamino-lending/src/generated/accounts/oraclePrices.ts new file mode 100644 index 00000000..cafc7d46 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/oraclePrices.ts @@ -0,0 +1,142 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import type { DatedPrice, DatedPriceArgs } from "../types/index.js"; +import { getDatedPriceDecoder, getDatedPriceEncoder } from "../types/index.js"; + +export const ORACLE_PRICES_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 89, 128, 118, 221, 6, 72, 180, 146, +]); + +export function getOraclePricesDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ORACLE_PRICES_DISCRIMINATOR, + ); +} + +export interface OraclePrices { + discriminator: ReadonlyUint8Array; + oracleMappings: Address; + prices: DatedPrice[]; +} + +export interface OraclePricesArgs { + oracleMappings: Address; + prices: DatedPriceArgs[]; +} + +export function getOraclePricesEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["oracleMappings", getAddressEncoder()], + ["prices", getArrayEncoder(getDatedPriceEncoder(), { size: 512 })], + ]), + (value) => ({ ...value, discriminator: ORACLE_PRICES_DISCRIMINATOR }), + ); +} + +export function getOraclePricesDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["oracleMappings", getAddressDecoder()], + ["prices", getArrayDecoder(getDatedPriceDecoder(), { size: 512 })], + ]); +} + +export function getOraclePricesCodec(): FixedSizeCodec< + OraclePricesArgs, + OraclePrices +> { + return combineCodec(getOraclePricesEncoder(), getOraclePricesDecoder()); +} + +export function decodeOraclePrices( + encodedAccount: EncodedAccount, +): Account; +export function decodeOraclePrices( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeOraclePrices( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getOraclePricesDecoder(), + ); +} + +export async function fetchOraclePrices( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeOraclePrices(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeOraclePrices( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeOraclePrices(maybeAccount); +} + +export async function fetchAllOraclePrices( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeOraclePrices(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeOraclePrices( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeOraclePrices(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/referrerState.ts b/clients/kamino-lending/src/generated/accounts/referrerState.ts new file mode 100644 index 00000000..d67a9de6 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/referrerState.ts @@ -0,0 +1,142 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; + +export const REFERRER_STATE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 194, 81, 217, 103, 12, 19, 12, 66, +]); + +export function getReferrerStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFERRER_STATE_DISCRIMINATOR, + ); +} + +export interface ReferrerState { + discriminator: ReadonlyUint8Array; + shortUrl: Address; + owner: Address; +} + +export interface ReferrerStateArgs { + shortUrl: Address; + owner: Address; +} + +export function getReferrerStateEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["shortUrl", getAddressEncoder()], + ["owner", getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: REFERRER_STATE_DISCRIMINATOR }), + ); +} + +export function getReferrerStateDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["shortUrl", getAddressDecoder()], + ["owner", getAddressDecoder()], + ]); +} + +export function getReferrerStateCodec(): FixedSizeCodec< + ReferrerStateArgs, + ReferrerState +> { + return combineCodec(getReferrerStateEncoder(), getReferrerStateDecoder()); +} + +export function decodeReferrerState( + encodedAccount: EncodedAccount, +): Account; +export function decodeReferrerState( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeReferrerState( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getReferrerStateDecoder(), + ); +} + +export async function fetchReferrerState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeReferrerState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeReferrerState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeReferrerState(maybeAccount); +} + +export async function fetchAllReferrerState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeReferrerState( + rpc, + addresses, + config, + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeReferrerState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeReferrerState(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/referrerTokenState.ts b/clients/kamino-lending/src/generated/accounts/referrerTokenState.ts new file mode 100644 index 00000000..668534b7 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/referrerTokenState.ts @@ -0,0 +1,175 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; + +export const REFERRER_TOKEN_STATE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([39, 15, 208, 77, 32, 195, 105, 56]); + +export function getReferrerTokenStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFERRER_TOKEN_STATE_DISCRIMINATOR, + ); +} + +export interface ReferrerTokenState { + discriminator: ReadonlyUint8Array; + referrer: Address; + mint: Address; + amountUnclaimedSf: bigint; + amountCumulativeSf: bigint; + bump: bigint; + padding: bigint[]; +} + +export interface ReferrerTokenStateArgs { + referrer: Address; + mint: Address; + amountUnclaimedSf: number | bigint; + amountCumulativeSf: number | bigint; + bump: number | bigint; + padding: (number | bigint)[]; +} + +export function getReferrerTokenStateEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["referrer", getAddressEncoder()], + ["mint", getAddressEncoder()], + ["amountUnclaimedSf", getU128Encoder()], + ["amountCumulativeSf", getU128Encoder()], + ["bump", getU64Encoder()], + ["padding", getArrayEncoder(getU64Encoder(), { size: 31 })], + ]), + (value) => ({ + ...value, + discriminator: REFERRER_TOKEN_STATE_DISCRIMINATOR, + }), + ); +} + +export function getReferrerTokenStateDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["referrer", getAddressDecoder()], + ["mint", getAddressDecoder()], + ["amountUnclaimedSf", getU128Decoder()], + ["amountCumulativeSf", getU128Decoder()], + ["bump", getU64Decoder()], + ["padding", getArrayDecoder(getU64Decoder(), { size: 31 })], + ]); +} + +export function getReferrerTokenStateCodec(): FixedSizeCodec< + ReferrerTokenStateArgs, + ReferrerTokenState +> { + return combineCodec( + getReferrerTokenStateEncoder(), + getReferrerTokenStateDecoder(), + ); +} + +export function decodeReferrerTokenState( + encodedAccount: EncodedAccount, +): Account; +export function decodeReferrerTokenState( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeReferrerTokenState( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getReferrerTokenStateDecoder(), + ); +} + +export async function fetchReferrerTokenState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeReferrerTokenState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeReferrerTokenState< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeReferrerTokenState(maybeAccount); +} + +export async function fetchAllReferrerTokenState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeReferrerTokenState( + rpc, + addresses, + config, + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeReferrerTokenState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeReferrerTokenState(maybeAccount), + ); +} diff --git a/clients/kamino-lending/src/generated/accounts/reserve.ts b/clients/kamino-lending/src/generated/accounts/reserve.ts new file mode 100644 index 00000000..6f3a4629 --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/reserve.ts @@ -0,0 +1,223 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import type { + LastUpdate, + LastUpdateArgs, + ReserveCollateral, + ReserveCollateralArgs, + ReserveConfig, + ReserveConfigArgs, + ReserveLiquidity, + ReserveLiquidityArgs, +} from "../types/index.js"; +import { + getLastUpdateDecoder, + getLastUpdateEncoder, + getReserveCollateralDecoder, + getReserveCollateralEncoder, + getReserveConfigDecoder, + getReserveConfigEncoder, + getReserveLiquidityDecoder, + getReserveLiquidityEncoder, +} from "../types/index.js"; + +export const RESERVE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 43, 242, 204, 202, 26, 247, 59, 127, +]); + +export function getReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(RESERVE_DISCRIMINATOR); +} + +export interface Reserve { + discriminator: ReadonlyUint8Array; + version: bigint; + lastUpdate: LastUpdate; + lendingMarket: Address; + farmCollateral: Address; + farmDebt: Address; + liquidity: ReserveLiquidity; + reserveLiquidityPadding: bigint[]; + collateral: ReserveCollateral; + reserveCollateralPadding: bigint[]; + config: ReserveConfig; + configPadding: bigint[]; + borrowedAmountOutsideElevationGroup: bigint; + borrowedAmountsAgainstThisReserveInElevationGroups: bigint[]; + padding: bigint[]; +} + +export interface ReserveArgs { + version: number | bigint; + lastUpdate: LastUpdateArgs; + lendingMarket: Address; + farmCollateral: Address; + farmDebt: Address; + liquidity: ReserveLiquidityArgs; + reserveLiquidityPadding: (number | bigint)[]; + collateral: ReserveCollateralArgs; + reserveCollateralPadding: (number | bigint)[]; + config: ReserveConfigArgs; + configPadding: (number | bigint)[]; + borrowedAmountOutsideElevationGroup: number | bigint; + borrowedAmountsAgainstThisReserveInElevationGroups: (number | bigint)[]; + padding: (number | bigint)[]; +} + +export function getReserveEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["version", getU64Encoder()], + ["lastUpdate", getLastUpdateEncoder()], + ["lendingMarket", getAddressEncoder()], + ["farmCollateral", getAddressEncoder()], + ["farmDebt", getAddressEncoder()], + ["liquidity", getReserveLiquidityEncoder()], + [ + "reserveLiquidityPadding", + getArrayEncoder(getU64Encoder(), { size: 150 }), + ], + ["collateral", getReserveCollateralEncoder()], + [ + "reserveCollateralPadding", + getArrayEncoder(getU64Encoder(), { size: 150 }), + ], + ["config", getReserveConfigEncoder()], + ["configPadding", getArrayEncoder(getU64Encoder(), { size: 116 })], + ["borrowedAmountOutsideElevationGroup", getU64Encoder()], + [ + "borrowedAmountsAgainstThisReserveInElevationGroups", + getArrayEncoder(getU64Encoder(), { size: 32 }), + ], + ["padding", getArrayEncoder(getU64Encoder(), { size: 207 })], + ]), + (value) => ({ ...value, discriminator: RESERVE_DISCRIMINATOR }), + ); +} + +export function getReserveDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["version", getU64Decoder()], + ["lastUpdate", getLastUpdateDecoder()], + ["lendingMarket", getAddressDecoder()], + ["farmCollateral", getAddressDecoder()], + ["farmDebt", getAddressDecoder()], + ["liquidity", getReserveLiquidityDecoder()], + [ + "reserveLiquidityPadding", + getArrayDecoder(getU64Decoder(), { size: 150 }), + ], + ["collateral", getReserveCollateralDecoder()], + [ + "reserveCollateralPadding", + getArrayDecoder(getU64Decoder(), { size: 150 }), + ], + ["config", getReserveConfigDecoder()], + ["configPadding", getArrayDecoder(getU64Decoder(), { size: 116 })], + ["borrowedAmountOutsideElevationGroup", getU64Decoder()], + [ + "borrowedAmountsAgainstThisReserveInElevationGroups", + getArrayDecoder(getU64Decoder(), { size: 32 }), + ], + ["padding", getArrayDecoder(getU64Decoder(), { size: 207 })], + ]); +} + +export function getReserveCodec(): FixedSizeCodec { + return combineCodec(getReserveEncoder(), getReserveDecoder()); +} + +export function decodeReserve( + encodedAccount: EncodedAccount, +): Account; +export function decodeReserve( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeReserve( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getReserveDecoder(), + ); +} + +export async function fetchReserve( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeReserve(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeReserve( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeReserve(maybeAccount); +} + +export async function fetchAllReserve( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeReserve(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeReserve( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeReserve(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/shortUrl.ts b/clients/kamino-lending/src/generated/accounts/shortUrl.ts new file mode 100644 index 00000000..2e23841d --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/shortUrl.ts @@ -0,0 +1,139 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + Codec, + Decoder, + EncodedAccount, + Encoder, + FetchAccountConfig, + FetchAccountsConfig, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + addDecoderSizePrefix, + addEncoderSizePrefix, + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, + transformEncoder, +} from "@solana/kit"; + +export const SHORT_URL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 28, 89, 174, 25, 226, 124, 126, 212, +]); + +export function getShortUrlDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(SHORT_URL_DISCRIMINATOR); +} + +export interface ShortUrl { + discriminator: ReadonlyUint8Array; + referrer: Address; + shortUrl: string; +} + +export interface ShortUrlArgs { + referrer: Address; + shortUrl: string; +} + +export function getShortUrlEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["referrer", getAddressEncoder()], + ["shortUrl", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: SHORT_URL_DISCRIMINATOR }), + ); +} + +export function getShortUrlDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["referrer", getAddressDecoder()], + ["shortUrl", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ]); +} + +export function getShortUrlCodec(): Codec { + return combineCodec(getShortUrlEncoder(), getShortUrlDecoder()); +} + +export function decodeShortUrl( + encodedAccount: EncodedAccount, +): Account; +export function decodeShortUrl( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeShortUrl( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getShortUrlDecoder(), + ); +} + +export async function fetchShortUrl( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeShortUrl(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeShortUrl( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeShortUrl(maybeAccount); +} + +export async function fetchAllShortUrl( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeShortUrl(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeShortUrl( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeShortUrl(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/userMetadata.ts b/clients/kamino-lending/src/generated/accounts/userMetadata.ts new file mode 100644 index 00000000..2b8310af --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/userMetadata.ts @@ -0,0 +1,158 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; + +export const USER_METADATA_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 157, 214, 220, 235, 98, 135, 171, 28, +]); + +export function getUserMetadataDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + USER_METADATA_DISCRIMINATOR, + ); +} + +export interface UserMetadata { + discriminator: ReadonlyUint8Array; + referrer: Address; + bump: bigint; + userLookupTable: Address; + owner: Address; + padding1: bigint[]; + padding2: bigint[]; +} + +export interface UserMetadataArgs { + referrer: Address; + bump: number | bigint; + userLookupTable: Address; + owner: Address; + padding1: (number | bigint)[]; + padding2: (number | bigint)[]; +} + +export function getUserMetadataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["referrer", getAddressEncoder()], + ["bump", getU64Encoder()], + ["userLookupTable", getAddressEncoder()], + ["owner", getAddressEncoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 51 })], + ["padding2", getArrayEncoder(getU64Encoder(), { size: 64 })], + ]), + (value) => ({ ...value, discriminator: USER_METADATA_DISCRIMINATOR }), + ); +} + +export function getUserMetadataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["referrer", getAddressDecoder()], + ["bump", getU64Decoder()], + ["userLookupTable", getAddressDecoder()], + ["owner", getAddressDecoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 51 })], + ["padding2", getArrayDecoder(getU64Decoder(), { size: 64 })], + ]); +} + +export function getUserMetadataCodec(): FixedSizeCodec< + UserMetadataArgs, + UserMetadata +> { + return combineCodec(getUserMetadataEncoder(), getUserMetadataDecoder()); +} + +export function decodeUserMetadata( + encodedAccount: EncodedAccount, +): Account; +export function decodeUserMetadata( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeUserMetadata( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getUserMetadataDecoder(), + ); +} + +export async function fetchUserMetadata( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeUserMetadata(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeUserMetadata( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeUserMetadata(maybeAccount); +} + +export async function fetchAllUserMetadata( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeUserMetadata(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeUserMetadata( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeUserMetadata(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/accounts/userState.ts b/clients/kamino-lending/src/generated/accounts/userState.ts new file mode 100644 index 00000000..7967aaae --- /dev/null +++ b/clients/kamino-lending/src/generated/accounts/userState.ts @@ -0,0 +1,204 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Account, + Address, + EncodedAccount, + FetchAccountConfig, + FetchAccountsConfig, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + MaybeAccount, + MaybeEncodedAccount, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; + +export const USER_STATE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 72, 177, 85, 249, 76, 167, 186, 126, +]); + +export function getUserStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(USER_STATE_DISCRIMINATOR); +} + +export interface UserState { + discriminator: ReadonlyUint8Array; + userId: bigint; + farmState: Address; + owner: Address; + isFarmDelegated: number; + padding0: number[]; + rewardsTallyScaled: bigint[]; + rewardsIssuedUnclaimed: bigint[]; + lastClaimTs: bigint[]; + activeStakeScaled: bigint; + pendingDepositStakeScaled: bigint; + pendingDepositStakeTs: bigint; + pendingWithdrawalUnstakeScaled: bigint; + pendingWithdrawalUnstakeTs: bigint; + bump: bigint; + delegatee: Address; + lastStakeTs: bigint; + padding1: bigint[]; +} + +export interface UserStateArgs { + userId: number | bigint; + farmState: Address; + owner: Address; + isFarmDelegated: number; + padding0: number[]; + rewardsTallyScaled: (number | bigint)[]; + rewardsIssuedUnclaimed: (number | bigint)[]; + lastClaimTs: (number | bigint)[]; + activeStakeScaled: number | bigint; + pendingDepositStakeScaled: number | bigint; + pendingDepositStakeTs: number | bigint; + pendingWithdrawalUnstakeScaled: number | bigint; + pendingWithdrawalUnstakeTs: number | bigint; + bump: number | bigint; + delegatee: Address; + lastStakeTs: number | bigint; + padding1: (number | bigint)[]; +} + +export function getUserStateEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["userId", getU64Encoder()], + ["farmState", getAddressEncoder()], + ["owner", getAddressEncoder()], + ["isFarmDelegated", getU8Encoder()], + ["padding0", getArrayEncoder(getU8Encoder(), { size: 7 })], + ["rewardsTallyScaled", getArrayEncoder(getU128Encoder(), { size: 10 })], + [ + "rewardsIssuedUnclaimed", + getArrayEncoder(getU64Encoder(), { size: 10 }), + ], + ["lastClaimTs", getArrayEncoder(getU64Encoder(), { size: 10 })], + ["activeStakeScaled", getU128Encoder()], + ["pendingDepositStakeScaled", getU128Encoder()], + ["pendingDepositStakeTs", getU64Encoder()], + ["pendingWithdrawalUnstakeScaled", getU128Encoder()], + ["pendingWithdrawalUnstakeTs", getU64Encoder()], + ["bump", getU64Encoder()], + ["delegatee", getAddressEncoder()], + ["lastStakeTs", getU64Encoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 50 })], + ]), + (value) => ({ ...value, discriminator: USER_STATE_DISCRIMINATOR }), + ); +} + +export function getUserStateDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["userId", getU64Decoder()], + ["farmState", getAddressDecoder()], + ["owner", getAddressDecoder()], + ["isFarmDelegated", getU8Decoder()], + ["padding0", getArrayDecoder(getU8Decoder(), { size: 7 })], + ["rewardsTallyScaled", getArrayDecoder(getU128Decoder(), { size: 10 })], + ["rewardsIssuedUnclaimed", getArrayDecoder(getU64Decoder(), { size: 10 })], + ["lastClaimTs", getArrayDecoder(getU64Decoder(), { size: 10 })], + ["activeStakeScaled", getU128Decoder()], + ["pendingDepositStakeScaled", getU128Decoder()], + ["pendingDepositStakeTs", getU64Decoder()], + ["pendingWithdrawalUnstakeScaled", getU128Decoder()], + ["pendingWithdrawalUnstakeTs", getU64Decoder()], + ["bump", getU64Decoder()], + ["delegatee", getAddressDecoder()], + ["lastStakeTs", getU64Decoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 50 })], + ]); +} + +export function getUserStateCodec(): FixedSizeCodec { + return combineCodec(getUserStateEncoder(), getUserStateDecoder()); +} + +export function decodeUserState( + encodedAccount: EncodedAccount, +): Account; +export function decodeUserState( + encodedAccount: MaybeEncodedAccount, +): MaybeAccount; +export function decodeUserState( + encodedAccount: EncodedAccount | MaybeEncodedAccount, +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getUserStateDecoder(), + ); +} + +export async function fetchUserState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchMaybeUserState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeUserState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig, +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeUserState(maybeAccount); +} + +export async function fetchAllUserState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchAllMaybeUserState(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeUserState( + rpc: Parameters[0], + addresses: Address[], + config?: FetchAccountsConfig, +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeUserState(maybeAccount)); +} diff --git a/clients/kamino-lending/src/generated/errors/farms.ts b/clients/kamino-lending/src/generated/errors/farms.ts new file mode 100644 index 00000000..867a0698 --- /dev/null +++ b/clients/kamino-lending/src/generated/errors/farms.ts @@ -0,0 +1,294 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, + SolanaError, +} from "@solana/kit"; +import { isProgramError } from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; + +/** StakeZero: Cannot stake 0 amount */ +export const FARMS_ERROR__STAKE_ZERO = 0x1770; // 6000 +/** UnstakeZero: Cannot unstake 0 amount */ +export const FARMS_ERROR__UNSTAKE_ZERO = 0x1771; // 6001 +/** NothingToUnstake: Nothing to unstake */ +export const FARMS_ERROR__NOTHING_TO_UNSTAKE = 0x1772; // 6002 +/** NoRewardToHarvest: No reward to harvest */ +export const FARMS_ERROR__NO_REWARD_TO_HARVEST = 0x1773; // 6003 +/** NoRewardInList: Reward not present in reward list */ +export const FARMS_ERROR__NO_REWARD_IN_LIST = 0x1774; // 6004 +/** RewardAlreadyInitialized: Reward already initialized */ +export const FARMS_ERROR__REWARD_ALREADY_INITIALIZED = 0x1775; // 6005 +/** MaxRewardNumberReached: Max number of reward tokens reached */ +export const FARMS_ERROR__MAX_REWARD_NUMBER_REACHED = 0x1776; // 6006 +/** RewardDoesNotExist: Reward does not exist */ +export const FARMS_ERROR__REWARD_DOES_NOT_EXIST = 0x1777; // 6007 +/** WrongRewardVaultAccount: Reward vault exists but the account is wrong */ +export const FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT = 0x1778; // 6008 +/** RewardVaultMismatch: Reward vault pubkey does not match staking pool vault */ +export const FARMS_ERROR__REWARD_VAULT_MISMATCH = 0x1779; // 6009 +/** RewardVaultAuthorityMismatch: Reward vault authority pubkey does not match staking pool vault */ +export const FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH = 0x177a; // 6010 +/** NothingStaked: Nothing staked, cannot collect any rewards */ +export const FARMS_ERROR__NOTHING_STAKED = 0x177b; // 6011 +/** IntegerOverflow: Integer overflow */ +export const FARMS_ERROR__INTEGER_OVERFLOW = 0x177c; // 6012 +/** ConversionFailure: Conversion failure */ +export const FARMS_ERROR__CONVERSION_FAILURE = 0x177d; // 6013 +/** UnexpectedAccount: Unexpected account in instruction */ +export const FARMS_ERROR__UNEXPECTED_ACCOUNT = 0x177e; // 6014 +/** OperationForbidden: Operation forbidden */ +export const FARMS_ERROR__OPERATION_FORBIDDEN = 0x177f; // 6015 +/** MathOverflow: Mathematical operation with overflow */ +export const FARMS_ERROR__MATH_OVERFLOW = 0x1780; // 6016 +/** MinClaimDurationNotReached: Minimum claim duration has not been reached */ +export const FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED = 0x1781; // 6017 +/** RewardsVaultHasDelegate: Reward vault has a delegate */ +export const FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE = 0x1782; // 6018 +/** RewardsVaultHasCloseAuthority: Reward vault has a close authority */ +export const FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY = 0x1783; // 6019 +/** FarmVaultHasDelegate: Farm vault has a delegate */ +export const FARMS_ERROR__FARM_VAULT_HAS_DELEGATE = 0x1784; // 6020 +/** FarmVaultHasCloseAuthority: Farm vault has a close authority */ +export const FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY = 0x1785; // 6021 +/** RewardsTreasuryVaultHasDelegate: Reward vault has a delegate */ +export const FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE = 0x1786; // 6022 +/** RewardsTreasuryVaultHasCloseAuthority: Reward vault has a close authority */ +export const FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY = 0x1787; // 6023 +/** UserAtaRewardVaultMintMissmatch: User ata and reward vault have different mints */ +export const FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH = 0x1788; // 6024 +/** UserAtaFarmTokenMintMissmatch: User ata and farm token have different mints */ +export const FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH = 0x1789; // 6025 +/** TokenFarmTokenMintMissmatch: Token mint and farm token have different mints */ +export const FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH = 0x178a; // 6026 +/** RewardAtaRewardMintMissmatch: Reward ata mint is different than reward mint */ +export const FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH = 0x178b; // 6027 +/** RewardAtaOwnerNotPayer: Reward ata owner is different than payer */ +export const FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER = 0x178c; // 6028 +/** InvalidGlobalConfigMode: Mode to update global_config is invalid */ +export const FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE = 0x178d; // 6029 +/** RewardIndexOutOfRange: Reward Index is higher than number of rewards */ +export const FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE = 0x178e; // 6030 +/** NothingToWithdraw: No tokens available to withdraw */ +export const FARMS_ERROR__NOTHING_TO_WITHDRAW = 0x178f; // 6031 +/** UserDelegatedFarmNonDelegatedMissmatch: user, user_ref, authority and payer must match for non-delegated farm */ +export const FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH = 0x1790; // 6032 +/** AuthorityFarmDelegateMissmatch: Authority must match farm delegate authority */ +export const FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH = 0x1791; // 6033 +/** FarmNotDelegated: Farm not delegated, can not set stake */ +export const FARMS_ERROR__FARM_NOT_DELEGATED = 0x1792; // 6034 +/** FarmDelegated: Operation not allowed for delegated farm */ +export const FARMS_ERROR__FARM_DELEGATED = 0x1793; // 6035 +/** UnstakeNotElapsed: Unstake lockup period is not elapsed. Deposit is locked until end of unstake period */ +export const FARMS_ERROR__UNSTAKE_NOT_ELAPSED = 0x1794; // 6036 +/** PendingWithdrawalNotWithdrawnYet: Pending withdrawal already exist and not withdrawn yet */ +export const FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET = 0x1795; // 6037 +/** DepositZero: Cannot deposit zero amount directly to farm vault */ +export const FARMS_ERROR__DEPOSIT_ZERO = 0x1796; // 6038 +/** InvalidConfigValue: Invalid config value */ +export const FARMS_ERROR__INVALID_CONFIG_VALUE = 0x1797; // 6039 +/** InvalidPenaltyPercentage: Invalid penalty percentage */ +export const FARMS_ERROR__INVALID_PENALTY_PERCENTAGE = 0x1798; // 6040 +/** EarlyWithdrawalNotAllowed: Early withdrawal not allowed */ +export const FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED = 0x1799; // 6041 +/** InvalidLockingTimestamps: Invalid locking timestamps */ +export const FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS = 0x179a; // 6042 +/** InvalidRpsCurvePoint: Invalid reward rate curve point */ +export const FARMS_ERROR__INVALID_RPS_CURVE_POINT = 0x179b; // 6043 +/** InvalidTimestamp: Invalid timestamp */ +export const FARMS_ERROR__INVALID_TIMESTAMP = 0x179c; // 6044 +/** DepositCapReached: Deposit cap reached */ +export const FARMS_ERROR__DEPOSIT_CAP_REACHED = 0x179d; // 6045 +/** MissingScopePrices: Missing Scope Prices */ +export const FARMS_ERROR__MISSING_SCOPE_PRICES = 0x179e; // 6046 +/** ScopeOraclePriceTooOld: Scope Oracle Price Too Old */ +export const FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD = 0x179f; // 6047 +/** InvalidOracleConfig: Invalid Oracle Config */ +export const FARMS_ERROR__INVALID_ORACLE_CONFIG = 0x17a0; // 6048 +/** CouldNotDeserializeScope: Could not deserialize scope */ +export const FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE = 0x17a1; // 6049 +/** RewardAtaOwnerNotAdmin: Reward ata owner is different than farm admin */ +export const FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN = 0x17a2; // 6050 +/** WithdrawRewardZeroAvailable: Cannot withdraw reward as available amount is zero */ +export const FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE = 0x17a3; // 6051 +/** RewardScheduleCurveSet: Cannot withdraw reward as reward schedule is set */ +export const FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET = 0x17a4; // 6052 +/** UnsupportedTokenExtension: Cannot initialize farm while having a mint with token22 and requested extensions */ +export const FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION = 0x17a5; // 6053 +/** InvalidFarmConfigUpdateAuthority: Invalid authority for updating farm config */ +export const FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY = 0x17a6; // 6054 + +export type FarmsError = + | typeof FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH + | typeof FARMS_ERROR__CONVERSION_FAILURE + | typeof FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE + | typeof FARMS_ERROR__DEPOSIT_CAP_REACHED + | typeof FARMS_ERROR__DEPOSIT_ZERO + | typeof FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED + | typeof FARMS_ERROR__FARM_DELEGATED + | typeof FARMS_ERROR__FARM_NOT_DELEGATED + | typeof FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY + | typeof FARMS_ERROR__FARM_VAULT_HAS_DELEGATE + | typeof FARMS_ERROR__INTEGER_OVERFLOW + | typeof FARMS_ERROR__INVALID_CONFIG_VALUE + | typeof FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY + | typeof FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE + | typeof FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS + | typeof FARMS_ERROR__INVALID_ORACLE_CONFIG + | typeof FARMS_ERROR__INVALID_PENALTY_PERCENTAGE + | typeof FARMS_ERROR__INVALID_RPS_CURVE_POINT + | typeof FARMS_ERROR__INVALID_TIMESTAMP + | typeof FARMS_ERROR__MATH_OVERFLOW + | typeof FARMS_ERROR__MAX_REWARD_NUMBER_REACHED + | typeof FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED + | typeof FARMS_ERROR__MISSING_SCOPE_PRICES + | typeof FARMS_ERROR__NO_REWARD_IN_LIST + | typeof FARMS_ERROR__NO_REWARD_TO_HARVEST + | typeof FARMS_ERROR__NOTHING_STAKED + | typeof FARMS_ERROR__NOTHING_TO_UNSTAKE + | typeof FARMS_ERROR__NOTHING_TO_WITHDRAW + | typeof FARMS_ERROR__OPERATION_FORBIDDEN + | typeof FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET + | typeof FARMS_ERROR__REWARD_ALREADY_INITIALIZED + | typeof FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN + | typeof FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER + | typeof FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH + | typeof FARMS_ERROR__REWARD_DOES_NOT_EXIST + | typeof FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE + | typeof FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET + | typeof FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY + | typeof FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE + | typeof FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY + | typeof FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE + | typeof FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH + | typeof FARMS_ERROR__REWARD_VAULT_MISMATCH + | typeof FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD + | typeof FARMS_ERROR__STAKE_ZERO + | typeof FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH + | typeof FARMS_ERROR__UNEXPECTED_ACCOUNT + | typeof FARMS_ERROR__UNSTAKE_NOT_ELAPSED + | typeof FARMS_ERROR__UNSTAKE_ZERO + | typeof FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION + | typeof FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH + | typeof FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH + | typeof FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH + | typeof FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE + | typeof FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT; + +let farmsErrorMessages: Record | undefined; +if (true) { + farmsErrorMessages = { + [FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH]: + "Authority must match farm delegate authority", + [FARMS_ERROR__CONVERSION_FAILURE]: "Conversion failure", + [FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE]: "Could not deserialize scope", + [FARMS_ERROR__DEPOSIT_CAP_REACHED]: "Deposit cap reached", + [FARMS_ERROR__DEPOSIT_ZERO]: + "Cannot deposit zero amount directly to farm vault", + [FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED]: "Early withdrawal not allowed", + [FARMS_ERROR__FARM_DELEGATED]: "Operation not allowed for delegated farm", + [FARMS_ERROR__FARM_NOT_DELEGATED]: "Farm not delegated, can not set stake", + [FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY]: + "Farm vault has a close authority", + [FARMS_ERROR__FARM_VAULT_HAS_DELEGATE]: "Farm vault has a delegate", + [FARMS_ERROR__INTEGER_OVERFLOW]: "Integer overflow", + [FARMS_ERROR__INVALID_CONFIG_VALUE]: "Invalid config value", + [FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY]: + "Invalid authority for updating farm config", + [FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE]: + "Mode to update global_config is invalid", + [FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS]: "Invalid locking timestamps", + [FARMS_ERROR__INVALID_ORACLE_CONFIG]: "Invalid Oracle Config", + [FARMS_ERROR__INVALID_PENALTY_PERCENTAGE]: "Invalid penalty percentage", + [FARMS_ERROR__INVALID_RPS_CURVE_POINT]: "Invalid reward rate curve point", + [FARMS_ERROR__INVALID_TIMESTAMP]: "Invalid timestamp", + [FARMS_ERROR__MATH_OVERFLOW]: "Mathematical operation with overflow", + [FARMS_ERROR__MAX_REWARD_NUMBER_REACHED]: + "Max number of reward tokens reached", + [FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED]: + "Minimum claim duration has not been reached", + [FARMS_ERROR__MISSING_SCOPE_PRICES]: "Missing Scope Prices", + [FARMS_ERROR__NO_REWARD_IN_LIST]: "Reward not present in reward list", + [FARMS_ERROR__NO_REWARD_TO_HARVEST]: "No reward to harvest", + [FARMS_ERROR__NOTHING_STAKED]: "Nothing staked, cannot collect any rewards", + [FARMS_ERROR__NOTHING_TO_UNSTAKE]: "Nothing to unstake", + [FARMS_ERROR__NOTHING_TO_WITHDRAW]: "No tokens available to withdraw", + [FARMS_ERROR__OPERATION_FORBIDDEN]: "Operation forbidden", + [FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET]: + "Pending withdrawal already exist and not withdrawn yet", + [FARMS_ERROR__REWARD_ALREADY_INITIALIZED]: "Reward already initialized", + [FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN]: + "Reward ata owner is different than farm admin", + [FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER]: + "Reward ata owner is different than payer", + [FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH]: + "Reward ata mint is different than reward mint", + [FARMS_ERROR__REWARD_DOES_NOT_EXIST]: "Reward does not exist", + [FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE]: + "Reward Index is higher than number of rewards", + [FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET]: + "Cannot withdraw reward as reward schedule is set", + [FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY]: + "Reward vault has a close authority", + [FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE]: + "Reward vault has a delegate", + [FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY]: + "Reward vault has a close authority", + [FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE]: "Reward vault has a delegate", + [FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH]: + "Reward vault authority pubkey does not match staking pool vault", + [FARMS_ERROR__REWARD_VAULT_MISMATCH]: + "Reward vault pubkey does not match staking pool vault", + [FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD]: "Scope Oracle Price Too Old", + [FARMS_ERROR__STAKE_ZERO]: "Cannot stake 0 amount", + [FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH]: + "Token mint and farm token have different mints", + [FARMS_ERROR__UNEXPECTED_ACCOUNT]: "Unexpected account in instruction", + [FARMS_ERROR__UNSTAKE_NOT_ELAPSED]: + "Unstake lockup period is not elapsed. Deposit is locked until end of unstake period", + [FARMS_ERROR__UNSTAKE_ZERO]: "Cannot unstake 0 amount", + [FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION]: + "Cannot initialize farm while having a mint with token22 and requested extensions", + [FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH]: + "User ata and farm token have different mints", + [FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH]: + "User ata and reward vault have different mints", + [FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH]: + "user, user_ref, authority and payer must match for non-delegated farm", + [FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE]: + "Cannot withdraw reward as available amount is zero", + [FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT]: + "Reward vault exists but the account is wrong", + }; +} + +export function getFarmsErrorMessage(code: FarmsError): string { + if (true) { + return farmsErrorMessages![code]; + } + + return "Error message not available in production bundles."; +} + +export function isFarmsError( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode, +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + FARMS_PROGRAM_ADDRESS, + code, + ); +} diff --git a/clients/kamino-lending/src/generated/errors/index.ts b/clients/kamino-lending/src/generated/errors/index.ts new file mode 100644 index 00000000..7ec4a2ee --- /dev/null +++ b/clients/kamino-lending/src/generated/errors/index.ts @@ -0,0 +1,10 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./farms.js"; +export * from "./kaminoLending.js"; diff --git a/clients/kamino-lending/src/generated/errors/kaminoLending.ts b/clients/kamino-lending/src/generated/errors/kaminoLending.ts new file mode 100644 index 00000000..e48b7c75 --- /dev/null +++ b/clients/kamino-lending/src/generated/errors/kaminoLending.ts @@ -0,0 +1,634 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, + SolanaError, +} from "@solana/kit"; +import { isProgramError } from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; + +/** InvalidMarketAuthority: Market authority is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_MARKET_AUTHORITY = 0x1770; // 6000 +/** InvalidMarketOwner: Market owner is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_MARKET_OWNER = 0x1771; // 6001 +/** InvalidAccountOwner: Input account owner is not the program address */ +export const KAMINO_LENDING_ERROR__INVALID_ACCOUNT_OWNER = 0x1772; // 6002 +/** InvalidAmount: Input amount is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_AMOUNT = 0x1773; // 6003 +/** InvalidConfig: Input config value is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_CONFIG = 0x1774; // 6004 +/** InvalidSigner: Input account must be a signer */ +export const KAMINO_LENDING_ERROR__INVALID_SIGNER = 0x1775; // 6005 +/** InvalidAccountInput: Invalid account input */ +export const KAMINO_LENDING_ERROR__INVALID_ACCOUNT_INPUT = 0x1776; // 6006 +/** MathOverflow: Math operation overflow */ +export const KAMINO_LENDING_ERROR__MATH_OVERFLOW = 0x1777; // 6007 +/** InsufficientLiquidity: Insufficient liquidity available */ +export const KAMINO_LENDING_ERROR__INSUFFICIENT_LIQUIDITY = 0x1778; // 6008 +/** ReserveStale: Reserve state needs to be refreshed */ +export const KAMINO_LENDING_ERROR__RESERVE_STALE = 0x1779; // 6009 +/** WithdrawTooSmall: Withdraw amount too small */ +export const KAMINO_LENDING_ERROR__WITHDRAW_TOO_SMALL = 0x177a; // 6010 +/** WithdrawTooLarge: Withdraw amount too large */ +export const KAMINO_LENDING_ERROR__WITHDRAW_TOO_LARGE = 0x177b; // 6011 +/** BorrowTooSmall: Borrow amount too small to receive liquidity after fees */ +export const KAMINO_LENDING_ERROR__BORROW_TOO_SMALL = 0x177c; // 6012 +/** BorrowTooLarge: Borrow amount too large for deposited collateral */ +export const KAMINO_LENDING_ERROR__BORROW_TOO_LARGE = 0x177d; // 6013 +/** RepayTooSmall: Repay amount too small to transfer liquidity */ +export const KAMINO_LENDING_ERROR__REPAY_TOO_SMALL = 0x177e; // 6014 +/** LiquidationTooSmall: Liquidation amount too small to receive collateral */ +export const KAMINO_LENDING_ERROR__LIQUIDATION_TOO_SMALL = 0x177f; // 6015 +/** ObligationHealthy: Cannot liquidate healthy obligations */ +export const KAMINO_LENDING_ERROR__OBLIGATION_HEALTHY = 0x1780; // 6016 +/** ObligationStale: Obligation state needs to be refreshed */ +export const KAMINO_LENDING_ERROR__OBLIGATION_STALE = 0x1781; // 6017 +/** ObligationReserveLimit: Obligation reserve limit exceeded */ +export const KAMINO_LENDING_ERROR__OBLIGATION_RESERVE_LIMIT = 0x1782; // 6018 +/** InvalidObligationOwner: Obligation owner is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_OBLIGATION_OWNER = 0x1783; // 6019 +/** ObligationDepositsEmpty: Obligation deposits are empty */ +export const KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_EMPTY = 0x1784; // 6020 +/** ObligationBorrowsEmpty: Obligation borrows are empty */ +export const KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_EMPTY = 0x1785; // 6021 +/** ObligationDepositsZero: Obligation deposits have zero value */ +export const KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_ZERO = 0x1786; // 6022 +/** ObligationBorrowsZero: Obligation borrows have zero value */ +export const KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_ZERO = 0x1787; // 6023 +/** InvalidObligationCollateral: Invalid obligation collateral */ +export const KAMINO_LENDING_ERROR__INVALID_OBLIGATION_COLLATERAL = 0x1788; // 6024 +/** InvalidObligationLiquidity: Invalid obligation liquidity */ +export const KAMINO_LENDING_ERROR__INVALID_OBLIGATION_LIQUIDITY = 0x1789; // 6025 +/** ObligationCollateralEmpty: Obligation collateral is empty */ +export const KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EMPTY = 0x178a; // 6026 +/** ObligationLiquidityEmpty: Obligation liquidity is empty */ +export const KAMINO_LENDING_ERROR__OBLIGATION_LIQUIDITY_EMPTY = 0x178b; // 6027 +/** NegativeInterestRate: Interest rate is negative */ +export const KAMINO_LENDING_ERROR__NEGATIVE_INTEREST_RATE = 0x178c; // 6028 +/** InvalidOracleConfig: Input oracle config is invalid */ +export const KAMINO_LENDING_ERROR__INVALID_ORACLE_CONFIG = 0x178d; // 6029 +/** InsufficientProtocolFeesToRedeem: Insufficient protocol fees to claim or no liquidity available */ +export const KAMINO_LENDING_ERROR__INSUFFICIENT_PROTOCOL_FEES_TO_REDEEM = 0x178e; // 6030 +/** FlashBorrowCpi: No cpi flash borrows allowed */ +export const KAMINO_LENDING_ERROR__FLASH_BORROW_CPI = 0x178f; // 6031 +/** NoFlashRepayFound: No corresponding repay found for flash borrow */ +export const KAMINO_LENDING_ERROR__NO_FLASH_REPAY_FOUND = 0x1790; // 6032 +/** InvalidFlashRepay: Invalid repay found */ +export const KAMINO_LENDING_ERROR__INVALID_FLASH_REPAY = 0x1791; // 6033 +/** FlashRepayCpi: No cpi flash repays allowed */ +export const KAMINO_LENDING_ERROR__FLASH_REPAY_CPI = 0x1792; // 6034 +/** MultipleFlashBorrows: Multiple flash borrows not allowed in the same transaction */ +export const KAMINO_LENDING_ERROR__MULTIPLE_FLASH_BORROWS = 0x1793; // 6035 +/** FlashLoansDisabled: Flash loans are disabled for this reserve */ +export const KAMINO_LENDING_ERROR__FLASH_LOANS_DISABLED = 0x1794; // 6036 +/** SwitchboardV2Error: Switchboard error */ +export const KAMINO_LENDING_ERROR__SWITCHBOARD_V2_ERROR = 0x1795; // 6037 +/** CouldNotDeserializeScope: Cannot deserialize the scope price account */ +export const KAMINO_LENDING_ERROR__COULD_NOT_DESERIALIZE_SCOPE = 0x1796; // 6038 +/** PriceTooOld: Price too old */ +export const KAMINO_LENDING_ERROR__PRICE_TOO_OLD = 0x1797; // 6039 +/** PriceTooDivergentFromTwap: Price too divergent from twap */ +export const KAMINO_LENDING_ERROR__PRICE_TOO_DIVERGENT_FROM_TWAP = 0x1798; // 6040 +/** InvalidTwapPrice: Invalid twap price */ +export const KAMINO_LENDING_ERROR__INVALID_TWAP_PRICE = 0x1799; // 6041 +/** GlobalEmergencyMode: Emergency mode is enabled */ +export const KAMINO_LENDING_ERROR__GLOBAL_EMERGENCY_MODE = 0x179a; // 6042 +/** InvalidFlag: Invalid lending market config */ +export const KAMINO_LENDING_ERROR__INVALID_FLAG = 0x179b; // 6043 +/** PriceNotValid: Price is not valid */ +export const KAMINO_LENDING_ERROR__PRICE_NOT_VALID = 0x179c; // 6044 +/** PriceIsBiggerThanHeuristic: Price is bigger than allowed by heuristic */ +export const KAMINO_LENDING_ERROR__PRICE_IS_BIGGER_THAN_HEURISTIC = 0x179d; // 6045 +/** PriceIsLowerThanHeuristic: Price lower than allowed by heuristic */ +export const KAMINO_LENDING_ERROR__PRICE_IS_LOWER_THAN_HEURISTIC = 0x179e; // 6046 +/** PriceIsZero: Price is zero */ +export const KAMINO_LENDING_ERROR__PRICE_IS_ZERO = 0x179f; // 6047 +/** PriceConfidenceTooWide: Price confidence too wide */ +export const KAMINO_LENDING_ERROR__PRICE_CONFIDENCE_TOO_WIDE = 0x17a0; // 6048 +/** IntegerOverflow: Conversion between integers failed */ +export const KAMINO_LENDING_ERROR__INTEGER_OVERFLOW = 0x17a1; // 6049 +/** NoFarmForReserve: This reserve does not have a farm */ +export const KAMINO_LENDING_ERROR__NO_FARM_FOR_RESERVE = 0x17a2; // 6050 +/** IncorrectInstructionInPosition: Wrong instruction at expected position */ +export const KAMINO_LENDING_ERROR__INCORRECT_INSTRUCTION_IN_POSITION = 0x17a3; // 6051 +/** NoPriceFound: No price found */ +export const KAMINO_LENDING_ERROR__NO_PRICE_FOUND = 0x17a4; // 6052 +/** InvalidTwapConfig: Invalid Twap configuration: Twap is enabled but one of the enabled price doesn't have a twap */ +export const KAMINO_LENDING_ERROR__INVALID_TWAP_CONFIG = 0x17a5; // 6053 +/** InvalidPythPriceAccount: Pyth price account does not match configuration */ +export const KAMINO_LENDING_ERROR__INVALID_PYTH_PRICE_ACCOUNT = 0x17a6; // 6054 +/** InvalidSwitchboardAccount: Switchboard account(s) do not match configuration */ +export const KAMINO_LENDING_ERROR__INVALID_SWITCHBOARD_ACCOUNT = 0x17a7; // 6055 +/** InvalidScopePriceAccount: Scope price account does not match configuration */ +export const KAMINO_LENDING_ERROR__INVALID_SCOPE_PRICE_ACCOUNT = 0x17a8; // 6056 +/** ObligationCollateralLtvZero: The obligation has one collateral with an LTV set to 0. Withdraw it before withdrawing other collaterals */ +export const KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_LTV_ZERO = 0x17a9; // 6057 +/** InvalidObligationSeedsValue: Seeds must be default pubkeys for tag 0, and mint addresses for tag 1 or 2 */ +export const KAMINO_LENDING_ERROR__INVALID_OBLIGATION_SEEDS_VALUE = 0x17aa; // 6058 +/** DeprecatedInvalidObligationId: [DEPRECATED] Obligation id must be 0 */ +export const KAMINO_LENDING_ERROR__DEPRECATED_INVALID_OBLIGATION_ID = 0x17ab; // 6059 +/** InvalidBorrowRateCurvePoint: Invalid borrow rate curve point */ +export const KAMINO_LENDING_ERROR__INVALID_BORROW_RATE_CURVE_POINT = 0x17ac; // 6060 +/** InvalidUtilizationRate: Invalid utilization rate */ +export const KAMINO_LENDING_ERROR__INVALID_UTILIZATION_RATE = 0x17ad; // 6061 +/** CannotSocializeObligationWithCollateral: Obligation hasn't been fully liquidated and debt cannot be socialized. */ +export const KAMINO_LENDING_ERROR__CANNOT_SOCIALIZE_OBLIGATION_WITH_COLLATERAL = 0x17ae; // 6062 +/** ObligationEmpty: Obligation has no borrows or deposits. */ +export const KAMINO_LENDING_ERROR__OBLIGATION_EMPTY = 0x17af; // 6063 +/** WithdrawalCapReached: Withdrawal cap is reached */ +export const KAMINO_LENDING_ERROR__WITHDRAWAL_CAP_REACHED = 0x17b0; // 6064 +/** LastTimestampGreaterThanCurrent: The last interval start timestamp is greater than the current timestamp */ +export const KAMINO_LENDING_ERROR__LAST_TIMESTAMP_GREATER_THAN_CURRENT = 0x17b1; // 6065 +/** LiquidationRewardTooSmall: The reward amount is less than the minimum acceptable received liquidity */ +export const KAMINO_LENDING_ERROR__LIQUIDATION_REWARD_TOO_SMALL = 0x17b2; // 6066 +/** IsolatedAssetTierViolation: Isolated Asset Tier Violation */ +export const KAMINO_LENDING_ERROR__ISOLATED_ASSET_TIER_VIOLATION = 0x17b3; // 6067 +/** InconsistentElevationGroup: The obligation's elevation group and the reserve's are not the same */ +export const KAMINO_LENDING_ERROR__INCONSISTENT_ELEVATION_GROUP = 0x17b4; // 6068 +/** InvalidElevationGroup: The elevation group chosen for the reserve does not exist in the lending market */ +export const KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP = 0x17b5; // 6069 +/** InvalidElevationGroupConfig: The elevation group updated has wrong parameters set */ +export const KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP_CONFIG = 0x17b6; // 6070 +/** UnhealthyElevationGroupLtv: The current obligation must have most or all its debt repaid before changing the elevation group */ +export const KAMINO_LENDING_ERROR__UNHEALTHY_ELEVATION_GROUP_LTV = 0x17b7; // 6071 +/** ElevationGroupNewLoansDisabled: Elevation group does not accept any new loans or any new borrows/withdrawals */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_NEW_LOANS_DISABLED = 0x17b8; // 6072 +/** ReserveDeprecated: Reserve was deprecated, no longer usable */ +export const KAMINO_LENDING_ERROR__RESERVE_DEPRECATED = 0x17b9; // 6073 +/** ReferrerAccountNotInitialized: Referrer account not initialized */ +export const KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_NOT_INITIALIZED = 0x17ba; // 6074 +/** ReferrerAccountMintMissmatch: Referrer account mint does not match the operation reserve mint */ +export const KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MINT_MISSMATCH = 0x17bb; // 6075 +/** ReferrerAccountWrongAddress: Referrer account address is not a valid program address */ +export const KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_WRONG_ADDRESS = 0x17bc; // 6076 +/** ReferrerAccountReferrerMissmatch: Referrer account referrer does not match the owner referrer */ +export const KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_REFERRER_MISSMATCH = 0x17bd; // 6077 +/** ReferrerAccountMissing: Referrer account missing for obligation with referrer */ +export const KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MISSING = 0x17be; // 6078 +/** InsufficientReferralFeesToRedeem: Insufficient referral fees to claim or no liquidity available */ +export const KAMINO_LENDING_ERROR__INSUFFICIENT_REFERRAL_FEES_TO_REDEEM = 0x17bf; // 6079 +/** CpiDisabled: CPI disabled for this instruction */ +export const KAMINO_LENDING_ERROR__CPI_DISABLED = 0x17c0; // 6080 +/** ShortUrlNotAsciiAlphanumeric: Referrer short_url is not ascii alphanumeric */ +export const KAMINO_LENDING_ERROR__SHORT_URL_NOT_ASCII_ALPHANUMERIC = 0x17c1; // 6081 +/** ReserveObsolete: Reserve is marked as obsolete */ +export const KAMINO_LENDING_ERROR__RESERVE_OBSOLETE = 0x17c2; // 6082 +/** ElevationGroupAlreadyActivated: Obligation already part of the same elevation group */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_ALREADY_ACTIVATED = 0x17c3; // 6083 +/** ObligationInDeprecatedReserve: Obligation has a deposit in a deprecated reserve */ +export const KAMINO_LENDING_ERROR__OBLIGATION_IN_DEPRECATED_RESERVE = 0x17c4; // 6084 +/** ReferrerStateOwnerMismatch: Referrer state owner does not match the given signer */ +export const KAMINO_LENDING_ERROR__REFERRER_STATE_OWNER_MISMATCH = 0x17c5; // 6085 +/** UserMetadataOwnerAlreadySet: User metadata owner is already set */ +export const KAMINO_LENDING_ERROR__USER_METADATA_OWNER_ALREADY_SET = 0x17c6; // 6086 +/** CollateralNonLiquidatable: This collateral cannot be liquidated (LTV set to 0) */ +export const KAMINO_LENDING_ERROR__COLLATERAL_NON_LIQUIDATABLE = 0x17c7; // 6087 +/** BorrowingDisabled: Borrowing is disabled */ +export const KAMINO_LENDING_ERROR__BORROWING_DISABLED = 0x17c8; // 6088 +/** BorrowLimitExceeded: Cannot borrow above borrow limit */ +export const KAMINO_LENDING_ERROR__BORROW_LIMIT_EXCEEDED = 0x17c9; // 6089 +/** DepositLimitExceeded: Cannot deposit above deposit limit */ +export const KAMINO_LENDING_ERROR__DEPOSIT_LIMIT_EXCEEDED = 0x17ca; // 6090 +/** BorrowingDisabledOutsideElevationGroup: Reserve does not accept any new borrows outside elevation group */ +export const KAMINO_LENDING_ERROR__BORROWING_DISABLED_OUTSIDE_ELEVATION_GROUP = 0x17cb; // 6091 +/** NetValueRemainingTooSmall: Net value remaining too small */ +export const KAMINO_LENDING_ERROR__NET_VALUE_REMAINING_TOO_SMALL = 0x17cc; // 6092 +/** WorseLTVBlocked: Cannot get the obligation in a worse position */ +export const KAMINO_LENDING_ERROR__WORSE_L_T_V_BLOCKED = 0x17cd; // 6093 +/** LiabilitiesBiggerThanAssets: Cannot have more liabilities than assets in a position */ +export const KAMINO_LENDING_ERROR__LIABILITIES_BIGGER_THAN_ASSETS = 0x17ce; // 6094 +/** ReserveTokenBalanceMismatch: Reserve state and token account cannot drift */ +export const KAMINO_LENDING_ERROR__RESERVE_TOKEN_BALANCE_MISMATCH = 0x17cf; // 6095 +/** ReserveVaultBalanceMismatch: Reserve token account has been unexpectedly modified */ +export const KAMINO_LENDING_ERROR__RESERVE_VAULT_BALANCE_MISMATCH = 0x17d0; // 6096 +/** ReserveAccountingMismatch: Reserve internal state accounting has been unexpectedly modified */ +export const KAMINO_LENDING_ERROR__RESERVE_ACCOUNTING_MISMATCH = 0x17d1; // 6097 +/** BorrowingAboveUtilizationRateDisabled: Borrowing above set utilization rate is disabled */ +export const KAMINO_LENDING_ERROR__BORROWING_ABOVE_UTILIZATION_RATE_DISABLED = 0x17d2; // 6098 +/** LiquidationBorrowFactorPriority: Liquidation must prioritize the debt with the highest borrow factor */ +export const KAMINO_LENDING_ERROR__LIQUIDATION_BORROW_FACTOR_PRIORITY = 0x17d3; // 6099 +/** LiquidationLowestLTVPriority: Liquidation must prioritize the collateral with the lowest LTV */ +export const KAMINO_LENDING_ERROR__LIQUIDATION_LOWEST_L_T_V_PRIORITY = 0x17d4; // 6100 +/** ElevationGroupBorrowLimitExceeded: Elevation group borrow limit exceeded */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_BORROW_LIMIT_EXCEEDED = 0x17d5; // 6101 +/** ElevationGroupWithoutDebtReserve: The elevation group does not have a debt reserve defined */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_WITHOUT_DEBT_RESERVE = 0x17d6; // 6102 +/** ElevationGroupMaxCollateralReserveZero: The elevation group does not allow any collateral reserves */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_MAX_COLLATERAL_RESERVE_ZERO = 0x17d7; // 6103 +/** ElevationGroupHasAnotherDebtReserve: In elevation group attempt to borrow from a reserve that is not the debt reserve */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_HAS_ANOTHER_DEBT_RESERVE = 0x17d8; // 6104 +/** ElevationGroupDebtReserveAsCollateral: The elevation group's debt reserve cannot be used as a collateral reserve */ +export const KAMINO_LENDING_ERROR__ELEVATION_GROUP_DEBT_RESERVE_AS_COLLATERAL = 0x17d9; // 6105 +/** ObligationCollateralExceedsElevationGroupLimit: Obligation have more collateral than the maximum allowed by the elevation group */ +export const KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EXCEEDS_ELEVATION_GROUP_LIMIT = 0x17da; // 6106 +/** ObligationElevationGroupMultipleDebtReserve: Obligation is an elevation group but have more than one debt reserve */ +export const KAMINO_LENDING_ERROR__OBLIGATION_ELEVATION_GROUP_MULTIPLE_DEBT_RESERVE = 0x17db; // 6107 +/** UnsupportedTokenExtension: Mint has a token (2022) extension that is not supported */ +export const KAMINO_LENDING_ERROR__UNSUPPORTED_TOKEN_EXTENSION = 0x17dc; // 6108 +/** InvalidTokenAccount: Can't have an spl token mint with a t22 account */ +export const KAMINO_LENDING_ERROR__INVALID_TOKEN_ACCOUNT = 0x17dd; // 6109 +/** DepositDisabledOutsideElevationGroup: Can't deposit into this reserve outside elevation group */ +export const KAMINO_LENDING_ERROR__DEPOSIT_DISABLED_OUTSIDE_ELEVATION_GROUP = 0x17de; // 6110 +/** CannotCalculateReferralAmountDueToSlotsMismatch: Cannot calculate referral amount due to slots mismatch */ +export const KAMINO_LENDING_ERROR__CANNOT_CALCULATE_REFERRAL_AMOUNT_DUE_TO_SLOTS_MISMATCH = 0x17df; // 6111 +/** ObligationOwnersMustMatch: Obligation owners must match */ +export const KAMINO_LENDING_ERROR__OBLIGATION_OWNERS_MUST_MATCH = 0x17e0; // 6112 +/** ObligationsMustMatch: Obligations must match */ +export const KAMINO_LENDING_ERROR__OBLIGATIONS_MUST_MATCH = 0x17e1; // 6113 +/** LendingMarketsMustMatch: Lending markets must match */ +export const KAMINO_LENDING_ERROR__LENDING_MARKETS_MUST_MATCH = 0x17e2; // 6114 +/** ObligationCurrentlyMarkedForDeleveraging: Obligation is already marked for deleveraging */ +export const KAMINO_LENDING_ERROR__OBLIGATION_CURRENTLY_MARKED_FOR_DELEVERAGING = 0x17e3; // 6115 +/** MaximumWithdrawValueZero: Maximum withdrawable value of this collateral is zero, LTV needs improved */ +export const KAMINO_LENDING_ERROR__MAXIMUM_WITHDRAW_VALUE_ZERO = 0x17e4; // 6116 +/** ZeroMaxLtvAssetsInDeposits: No max LTV 0 assets allowed in deposits for repay and withdraw */ +export const KAMINO_LENDING_ERROR__ZERO_MAX_LTV_ASSETS_IN_DEPOSITS = 0x17e5; // 6117 +/** MinLtvAssetsPriority: The operation must prioritize the collateral with the lowest LTV */ +export const KAMINO_LENDING_ERROR__MIN_LTV_ASSETS_PRIORITY = 0x17e6; // 6118 +/** WorseLTVThanUnhealthyLTV: Cannot get the obligation liquidatable */ +export const KAMINO_LENDING_ERROR__WORSE_L_T_V_THAN_UNHEALTHY_L_T_V = 0x17e7; // 6119 +/** FarmAccountsMissing: Farm accounts to refresh are missing */ +export const KAMINO_LENDING_ERROR__FARM_ACCOUNTS_MISSING = 0x17e8; // 6120 +/** RepayTooSmallForFullLiquidation: Repay amount is too small to satisfy the mandatory full liquidation */ +export const KAMINO_LENDING_ERROR__REPAY_TOO_SMALL_FOR_FULL_LIQUIDATION = 0x17e9; // 6121 +/** InsufficientRepayAmount: Liquidator provided repay amount lower than required by liquidation rules */ +export const KAMINO_LENDING_ERROR__INSUFFICIENT_REPAY_AMOUNT = 0x17ea; // 6122 + +export type KaminoLendingError = + | typeof KAMINO_LENDING_ERROR__BORROWING_ABOVE_UTILIZATION_RATE_DISABLED + | typeof KAMINO_LENDING_ERROR__BORROWING_DISABLED + | typeof KAMINO_LENDING_ERROR__BORROWING_DISABLED_OUTSIDE_ELEVATION_GROUP + | typeof KAMINO_LENDING_ERROR__BORROW_LIMIT_EXCEEDED + | typeof KAMINO_LENDING_ERROR__BORROW_TOO_LARGE + | typeof KAMINO_LENDING_ERROR__BORROW_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__CANNOT_CALCULATE_REFERRAL_AMOUNT_DUE_TO_SLOTS_MISMATCH + | typeof KAMINO_LENDING_ERROR__CANNOT_SOCIALIZE_OBLIGATION_WITH_COLLATERAL + | typeof KAMINO_LENDING_ERROR__COLLATERAL_NON_LIQUIDATABLE + | typeof KAMINO_LENDING_ERROR__COULD_NOT_DESERIALIZE_SCOPE + | typeof KAMINO_LENDING_ERROR__CPI_DISABLED + | typeof KAMINO_LENDING_ERROR__DEPOSIT_DISABLED_OUTSIDE_ELEVATION_GROUP + | typeof KAMINO_LENDING_ERROR__DEPOSIT_LIMIT_EXCEEDED + | typeof KAMINO_LENDING_ERROR__DEPRECATED_INVALID_OBLIGATION_ID + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_ALREADY_ACTIVATED + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_BORROW_LIMIT_EXCEEDED + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_DEBT_RESERVE_AS_COLLATERAL + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_HAS_ANOTHER_DEBT_RESERVE + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_MAX_COLLATERAL_RESERVE_ZERO + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_NEW_LOANS_DISABLED + | typeof KAMINO_LENDING_ERROR__ELEVATION_GROUP_WITHOUT_DEBT_RESERVE + | typeof KAMINO_LENDING_ERROR__FARM_ACCOUNTS_MISSING + | typeof KAMINO_LENDING_ERROR__FLASH_BORROW_CPI + | typeof KAMINO_LENDING_ERROR__FLASH_LOANS_DISABLED + | typeof KAMINO_LENDING_ERROR__FLASH_REPAY_CPI + | typeof KAMINO_LENDING_ERROR__GLOBAL_EMERGENCY_MODE + | typeof KAMINO_LENDING_ERROR__INCONSISTENT_ELEVATION_GROUP + | typeof KAMINO_LENDING_ERROR__INCORRECT_INSTRUCTION_IN_POSITION + | typeof KAMINO_LENDING_ERROR__INSUFFICIENT_LIQUIDITY + | typeof KAMINO_LENDING_ERROR__INSUFFICIENT_PROTOCOL_FEES_TO_REDEEM + | typeof KAMINO_LENDING_ERROR__INSUFFICIENT_REFERRAL_FEES_TO_REDEEM + | typeof KAMINO_LENDING_ERROR__INSUFFICIENT_REPAY_AMOUNT + | typeof KAMINO_LENDING_ERROR__INTEGER_OVERFLOW + | typeof KAMINO_LENDING_ERROR__INVALID_ACCOUNT_INPUT + | typeof KAMINO_LENDING_ERROR__INVALID_ACCOUNT_OWNER + | typeof KAMINO_LENDING_ERROR__INVALID_AMOUNT + | typeof KAMINO_LENDING_ERROR__INVALID_BORROW_RATE_CURVE_POINT + | typeof KAMINO_LENDING_ERROR__INVALID_CONFIG + | typeof KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP + | typeof KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP_CONFIG + | typeof KAMINO_LENDING_ERROR__INVALID_FLAG + | typeof KAMINO_LENDING_ERROR__INVALID_FLASH_REPAY + | typeof KAMINO_LENDING_ERROR__INVALID_MARKET_AUTHORITY + | typeof KAMINO_LENDING_ERROR__INVALID_MARKET_OWNER + | typeof KAMINO_LENDING_ERROR__INVALID_OBLIGATION_COLLATERAL + | typeof KAMINO_LENDING_ERROR__INVALID_OBLIGATION_LIQUIDITY + | typeof KAMINO_LENDING_ERROR__INVALID_OBLIGATION_OWNER + | typeof KAMINO_LENDING_ERROR__INVALID_OBLIGATION_SEEDS_VALUE + | typeof KAMINO_LENDING_ERROR__INVALID_ORACLE_CONFIG + | typeof KAMINO_LENDING_ERROR__INVALID_PYTH_PRICE_ACCOUNT + | typeof KAMINO_LENDING_ERROR__INVALID_SCOPE_PRICE_ACCOUNT + | typeof KAMINO_LENDING_ERROR__INVALID_SIGNER + | typeof KAMINO_LENDING_ERROR__INVALID_SWITCHBOARD_ACCOUNT + | typeof KAMINO_LENDING_ERROR__INVALID_TOKEN_ACCOUNT + | typeof KAMINO_LENDING_ERROR__INVALID_TWAP_CONFIG + | typeof KAMINO_LENDING_ERROR__INVALID_TWAP_PRICE + | typeof KAMINO_LENDING_ERROR__INVALID_UTILIZATION_RATE + | typeof KAMINO_LENDING_ERROR__ISOLATED_ASSET_TIER_VIOLATION + | typeof KAMINO_LENDING_ERROR__LAST_TIMESTAMP_GREATER_THAN_CURRENT + | typeof KAMINO_LENDING_ERROR__LENDING_MARKETS_MUST_MATCH + | typeof KAMINO_LENDING_ERROR__LIABILITIES_BIGGER_THAN_ASSETS + | typeof KAMINO_LENDING_ERROR__LIQUIDATION_BORROW_FACTOR_PRIORITY + | typeof KAMINO_LENDING_ERROR__LIQUIDATION_LOWEST_L_T_V_PRIORITY + | typeof KAMINO_LENDING_ERROR__LIQUIDATION_REWARD_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__LIQUIDATION_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__MATH_OVERFLOW + | typeof KAMINO_LENDING_ERROR__MAXIMUM_WITHDRAW_VALUE_ZERO + | typeof KAMINO_LENDING_ERROR__MIN_LTV_ASSETS_PRIORITY + | typeof KAMINO_LENDING_ERROR__MULTIPLE_FLASH_BORROWS + | typeof KAMINO_LENDING_ERROR__NEGATIVE_INTEREST_RATE + | typeof KAMINO_LENDING_ERROR__NET_VALUE_REMAINING_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__NO_FARM_FOR_RESERVE + | typeof KAMINO_LENDING_ERROR__NO_FLASH_REPAY_FOUND + | typeof KAMINO_LENDING_ERROR__NO_PRICE_FOUND + | typeof KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_EMPTY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_ZERO + | typeof KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EMPTY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EXCEEDS_ELEVATION_GROUP_LIMIT + | typeof KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_LTV_ZERO + | typeof KAMINO_LENDING_ERROR__OBLIGATION_CURRENTLY_MARKED_FOR_DELEVERAGING + | typeof KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_EMPTY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_ZERO + | typeof KAMINO_LENDING_ERROR__OBLIGATION_ELEVATION_GROUP_MULTIPLE_DEBT_RESERVE + | typeof KAMINO_LENDING_ERROR__OBLIGATION_EMPTY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_HEALTHY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_IN_DEPRECATED_RESERVE + | typeof KAMINO_LENDING_ERROR__OBLIGATION_LIQUIDITY_EMPTY + | typeof KAMINO_LENDING_ERROR__OBLIGATION_OWNERS_MUST_MATCH + | typeof KAMINO_LENDING_ERROR__OBLIGATION_RESERVE_LIMIT + | typeof KAMINO_LENDING_ERROR__OBLIGATIONS_MUST_MATCH + | typeof KAMINO_LENDING_ERROR__OBLIGATION_STALE + | typeof KAMINO_LENDING_ERROR__PRICE_CONFIDENCE_TOO_WIDE + | typeof KAMINO_LENDING_ERROR__PRICE_IS_BIGGER_THAN_HEURISTIC + | typeof KAMINO_LENDING_ERROR__PRICE_IS_LOWER_THAN_HEURISTIC + | typeof KAMINO_LENDING_ERROR__PRICE_IS_ZERO + | typeof KAMINO_LENDING_ERROR__PRICE_NOT_VALID + | typeof KAMINO_LENDING_ERROR__PRICE_TOO_DIVERGENT_FROM_TWAP + | typeof KAMINO_LENDING_ERROR__PRICE_TOO_OLD + | typeof KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MINT_MISSMATCH + | typeof KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MISSING + | typeof KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_NOT_INITIALIZED + | typeof KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_REFERRER_MISSMATCH + | typeof KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_WRONG_ADDRESS + | typeof KAMINO_LENDING_ERROR__REFERRER_STATE_OWNER_MISMATCH + | typeof KAMINO_LENDING_ERROR__REPAY_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__REPAY_TOO_SMALL_FOR_FULL_LIQUIDATION + | typeof KAMINO_LENDING_ERROR__RESERVE_ACCOUNTING_MISMATCH + | typeof KAMINO_LENDING_ERROR__RESERVE_DEPRECATED + | typeof KAMINO_LENDING_ERROR__RESERVE_OBSOLETE + | typeof KAMINO_LENDING_ERROR__RESERVE_STALE + | typeof KAMINO_LENDING_ERROR__RESERVE_TOKEN_BALANCE_MISMATCH + | typeof KAMINO_LENDING_ERROR__RESERVE_VAULT_BALANCE_MISMATCH + | typeof KAMINO_LENDING_ERROR__SHORT_URL_NOT_ASCII_ALPHANUMERIC + | typeof KAMINO_LENDING_ERROR__SWITCHBOARD_V2_ERROR + | typeof KAMINO_LENDING_ERROR__UNHEALTHY_ELEVATION_GROUP_LTV + | typeof KAMINO_LENDING_ERROR__UNSUPPORTED_TOKEN_EXTENSION + | typeof KAMINO_LENDING_ERROR__USER_METADATA_OWNER_ALREADY_SET + | typeof KAMINO_LENDING_ERROR__WITHDRAWAL_CAP_REACHED + | typeof KAMINO_LENDING_ERROR__WITHDRAW_TOO_LARGE + | typeof KAMINO_LENDING_ERROR__WITHDRAW_TOO_SMALL + | typeof KAMINO_LENDING_ERROR__WORSE_L_T_V_BLOCKED + | typeof KAMINO_LENDING_ERROR__WORSE_L_T_V_THAN_UNHEALTHY_L_T_V + | typeof KAMINO_LENDING_ERROR__ZERO_MAX_LTV_ASSETS_IN_DEPOSITS; + +let kaminoLendingErrorMessages: Record | undefined; +if (true) { + kaminoLendingErrorMessages = { + [KAMINO_LENDING_ERROR__BORROWING_ABOVE_UTILIZATION_RATE_DISABLED]: + "Borrowing above set utilization rate is disabled", + [KAMINO_LENDING_ERROR__BORROWING_DISABLED]: "Borrowing is disabled", + [KAMINO_LENDING_ERROR__BORROWING_DISABLED_OUTSIDE_ELEVATION_GROUP]: + "Reserve does not accept any new borrows outside elevation group", + [KAMINO_LENDING_ERROR__BORROW_LIMIT_EXCEEDED]: + "Cannot borrow above borrow limit", + [KAMINO_LENDING_ERROR__BORROW_TOO_LARGE]: + "Borrow amount too large for deposited collateral", + [KAMINO_LENDING_ERROR__BORROW_TOO_SMALL]: + "Borrow amount too small to receive liquidity after fees", + [KAMINO_LENDING_ERROR__CANNOT_CALCULATE_REFERRAL_AMOUNT_DUE_TO_SLOTS_MISMATCH]: + "Cannot calculate referral amount due to slots mismatch", + [KAMINO_LENDING_ERROR__CANNOT_SOCIALIZE_OBLIGATION_WITH_COLLATERAL]: `Obligation hasn't been fully liquidated and debt cannot be socialized.`, + [KAMINO_LENDING_ERROR__COLLATERAL_NON_LIQUIDATABLE]: + "This collateral cannot be liquidated (LTV set to 0)", + [KAMINO_LENDING_ERROR__COULD_NOT_DESERIALIZE_SCOPE]: + "Cannot deserialize the scope price account", + [KAMINO_LENDING_ERROR__CPI_DISABLED]: "CPI disabled for this instruction", + [KAMINO_LENDING_ERROR__DEPOSIT_DISABLED_OUTSIDE_ELEVATION_GROUP]: `Can't deposit into this reserve outside elevation group`, + [KAMINO_LENDING_ERROR__DEPOSIT_LIMIT_EXCEEDED]: + "Cannot deposit above deposit limit", + [KAMINO_LENDING_ERROR__DEPRECATED_INVALID_OBLIGATION_ID]: + "[DEPRECATED] Obligation id must be 0", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_ALREADY_ACTIVATED]: + "Obligation already part of the same elevation group", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_BORROW_LIMIT_EXCEEDED]: + "Elevation group borrow limit exceeded", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_DEBT_RESERVE_AS_COLLATERAL]: `The elevation group's debt reserve cannot be used as a collateral reserve`, + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_HAS_ANOTHER_DEBT_RESERVE]: + "In elevation group attempt to borrow from a reserve that is not the debt reserve", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_MAX_COLLATERAL_RESERVE_ZERO]: + "The elevation group does not allow any collateral reserves", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_NEW_LOANS_DISABLED]: + "Elevation group does not accept any new loans or any new borrows/withdrawals", + [KAMINO_LENDING_ERROR__ELEVATION_GROUP_WITHOUT_DEBT_RESERVE]: + "The elevation group does not have a debt reserve defined", + [KAMINO_LENDING_ERROR__FARM_ACCOUNTS_MISSING]: + "Farm accounts to refresh are missing", + [KAMINO_LENDING_ERROR__FLASH_BORROW_CPI]: "No cpi flash borrows allowed", + [KAMINO_LENDING_ERROR__FLASH_LOANS_DISABLED]: + "Flash loans are disabled for this reserve", + [KAMINO_LENDING_ERROR__FLASH_REPAY_CPI]: "No cpi flash repays allowed", + [KAMINO_LENDING_ERROR__GLOBAL_EMERGENCY_MODE]: "Emergency mode is enabled", + [KAMINO_LENDING_ERROR__INCONSISTENT_ELEVATION_GROUP]: `The obligation's elevation group and the reserve's are not the same`, + [KAMINO_LENDING_ERROR__INCORRECT_INSTRUCTION_IN_POSITION]: + "Wrong instruction at expected position", + [KAMINO_LENDING_ERROR__INSUFFICIENT_LIQUIDITY]: + "Insufficient liquidity available", + [KAMINO_LENDING_ERROR__INSUFFICIENT_PROTOCOL_FEES_TO_REDEEM]: + "Insufficient protocol fees to claim or no liquidity available", + [KAMINO_LENDING_ERROR__INSUFFICIENT_REFERRAL_FEES_TO_REDEEM]: + "Insufficient referral fees to claim or no liquidity available", + [KAMINO_LENDING_ERROR__INSUFFICIENT_REPAY_AMOUNT]: + "Liquidator provided repay amount lower than required by liquidation rules", + [KAMINO_LENDING_ERROR__INTEGER_OVERFLOW]: + "Conversion between integers failed", + [KAMINO_LENDING_ERROR__INVALID_ACCOUNT_INPUT]: "Invalid account input", + [KAMINO_LENDING_ERROR__INVALID_ACCOUNT_OWNER]: + "Input account owner is not the program address", + [KAMINO_LENDING_ERROR__INVALID_AMOUNT]: "Input amount is invalid", + [KAMINO_LENDING_ERROR__INVALID_BORROW_RATE_CURVE_POINT]: + "Invalid borrow rate curve point", + [KAMINO_LENDING_ERROR__INVALID_CONFIG]: "Input config value is invalid", + [KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP]: + "The elevation group chosen for the reserve does not exist in the lending market", + [KAMINO_LENDING_ERROR__INVALID_ELEVATION_GROUP_CONFIG]: + "The elevation group updated has wrong parameters set", + [KAMINO_LENDING_ERROR__INVALID_FLAG]: "Invalid lending market config", + [KAMINO_LENDING_ERROR__INVALID_FLASH_REPAY]: "Invalid repay found", + [KAMINO_LENDING_ERROR__INVALID_MARKET_AUTHORITY]: + "Market authority is invalid", + [KAMINO_LENDING_ERROR__INVALID_MARKET_OWNER]: "Market owner is invalid", + [KAMINO_LENDING_ERROR__INVALID_OBLIGATION_COLLATERAL]: + "Invalid obligation collateral", + [KAMINO_LENDING_ERROR__INVALID_OBLIGATION_LIQUIDITY]: + "Invalid obligation liquidity", + [KAMINO_LENDING_ERROR__INVALID_OBLIGATION_OWNER]: + "Obligation owner is invalid", + [KAMINO_LENDING_ERROR__INVALID_OBLIGATION_SEEDS_VALUE]: + "Seeds must be default pubkeys for tag 0, and mint addresses for tag 1 or 2", + [KAMINO_LENDING_ERROR__INVALID_ORACLE_CONFIG]: + "Input oracle config is invalid", + [KAMINO_LENDING_ERROR__INVALID_PYTH_PRICE_ACCOUNT]: + "Pyth price account does not match configuration", + [KAMINO_LENDING_ERROR__INVALID_SCOPE_PRICE_ACCOUNT]: + "Scope price account does not match configuration", + [KAMINO_LENDING_ERROR__INVALID_SIGNER]: "Input account must be a signer", + [KAMINO_LENDING_ERROR__INVALID_SWITCHBOARD_ACCOUNT]: + "Switchboard account(s) do not match configuration", + [KAMINO_LENDING_ERROR__INVALID_TOKEN_ACCOUNT]: `Can't have an spl token mint with a t22 account`, + [KAMINO_LENDING_ERROR__INVALID_TWAP_CONFIG]: `Invalid Twap configuration: Twap is enabled but one of the enabled price doesn't have a twap`, + [KAMINO_LENDING_ERROR__INVALID_TWAP_PRICE]: "Invalid twap price", + [KAMINO_LENDING_ERROR__INVALID_UTILIZATION_RATE]: + "Invalid utilization rate", + [KAMINO_LENDING_ERROR__ISOLATED_ASSET_TIER_VIOLATION]: + "Isolated Asset Tier Violation", + [KAMINO_LENDING_ERROR__LAST_TIMESTAMP_GREATER_THAN_CURRENT]: + "The last interval start timestamp is greater than the current timestamp", + [KAMINO_LENDING_ERROR__LENDING_MARKETS_MUST_MATCH]: + "Lending markets must match", + [KAMINO_LENDING_ERROR__LIABILITIES_BIGGER_THAN_ASSETS]: + "Cannot have more liabilities than assets in a position", + [KAMINO_LENDING_ERROR__LIQUIDATION_BORROW_FACTOR_PRIORITY]: + "Liquidation must prioritize the debt with the highest borrow factor", + [KAMINO_LENDING_ERROR__LIQUIDATION_LOWEST_L_T_V_PRIORITY]: + "Liquidation must prioritize the collateral with the lowest LTV", + [KAMINO_LENDING_ERROR__LIQUIDATION_REWARD_TOO_SMALL]: + "The reward amount is less than the minimum acceptable received liquidity", + [KAMINO_LENDING_ERROR__LIQUIDATION_TOO_SMALL]: + "Liquidation amount too small to receive collateral", + [KAMINO_LENDING_ERROR__MATH_OVERFLOW]: "Math operation overflow", + [KAMINO_LENDING_ERROR__MAXIMUM_WITHDRAW_VALUE_ZERO]: + "Maximum withdrawable value of this collateral is zero, LTV needs improved", + [KAMINO_LENDING_ERROR__MIN_LTV_ASSETS_PRIORITY]: + "The operation must prioritize the collateral with the lowest LTV", + [KAMINO_LENDING_ERROR__MULTIPLE_FLASH_BORROWS]: + "Multiple flash borrows not allowed in the same transaction", + [KAMINO_LENDING_ERROR__NEGATIVE_INTEREST_RATE]: "Interest rate is negative", + [KAMINO_LENDING_ERROR__NET_VALUE_REMAINING_TOO_SMALL]: + "Net value remaining too small", + [KAMINO_LENDING_ERROR__NO_FARM_FOR_RESERVE]: + "This reserve does not have a farm", + [KAMINO_LENDING_ERROR__NO_FLASH_REPAY_FOUND]: + "No corresponding repay found for flash borrow", + [KAMINO_LENDING_ERROR__NO_PRICE_FOUND]: "No price found", + [KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_EMPTY]: + "Obligation borrows are empty", + [KAMINO_LENDING_ERROR__OBLIGATION_BORROWS_ZERO]: + "Obligation borrows have zero value", + [KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EMPTY]: + "Obligation collateral is empty", + [KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_EXCEEDS_ELEVATION_GROUP_LIMIT]: + "Obligation have more collateral than the maximum allowed by the elevation group", + [KAMINO_LENDING_ERROR__OBLIGATION_COLLATERAL_LTV_ZERO]: + "The obligation has one collateral with an LTV set to 0. Withdraw it before withdrawing other collaterals", + [KAMINO_LENDING_ERROR__OBLIGATION_CURRENTLY_MARKED_FOR_DELEVERAGING]: + "Obligation is already marked for deleveraging", + [KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_EMPTY]: + "Obligation deposits are empty", + [KAMINO_LENDING_ERROR__OBLIGATION_DEPOSITS_ZERO]: + "Obligation deposits have zero value", + [KAMINO_LENDING_ERROR__OBLIGATION_ELEVATION_GROUP_MULTIPLE_DEBT_RESERVE]: + "Obligation is an elevation group but have more than one debt reserve", + [KAMINO_LENDING_ERROR__OBLIGATION_EMPTY]: + "Obligation has no borrows or deposits.", + [KAMINO_LENDING_ERROR__OBLIGATION_HEALTHY]: + "Cannot liquidate healthy obligations", + [KAMINO_LENDING_ERROR__OBLIGATION_IN_DEPRECATED_RESERVE]: + "Obligation has a deposit in a deprecated reserve", + [KAMINO_LENDING_ERROR__OBLIGATION_LIQUIDITY_EMPTY]: + "Obligation liquidity is empty", + [KAMINO_LENDING_ERROR__OBLIGATION_OWNERS_MUST_MATCH]: + "Obligation owners must match", + [KAMINO_LENDING_ERROR__OBLIGATION_RESERVE_LIMIT]: + "Obligation reserve limit exceeded", + [KAMINO_LENDING_ERROR__OBLIGATIONS_MUST_MATCH]: "Obligations must match", + [KAMINO_LENDING_ERROR__OBLIGATION_STALE]: + "Obligation state needs to be refreshed", + [KAMINO_LENDING_ERROR__PRICE_CONFIDENCE_TOO_WIDE]: + "Price confidence too wide", + [KAMINO_LENDING_ERROR__PRICE_IS_BIGGER_THAN_HEURISTIC]: + "Price is bigger than allowed by heuristic", + [KAMINO_LENDING_ERROR__PRICE_IS_LOWER_THAN_HEURISTIC]: + "Price lower than allowed by heuristic", + [KAMINO_LENDING_ERROR__PRICE_IS_ZERO]: "Price is zero", + [KAMINO_LENDING_ERROR__PRICE_NOT_VALID]: "Price is not valid", + [KAMINO_LENDING_ERROR__PRICE_TOO_DIVERGENT_FROM_TWAP]: + "Price too divergent from twap", + [KAMINO_LENDING_ERROR__PRICE_TOO_OLD]: "Price too old", + [KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MINT_MISSMATCH]: + "Referrer account mint does not match the operation reserve mint", + [KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_MISSING]: + "Referrer account missing for obligation with referrer", + [KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_NOT_INITIALIZED]: + "Referrer account not initialized", + [KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_REFERRER_MISSMATCH]: + "Referrer account referrer does not match the owner referrer", + [KAMINO_LENDING_ERROR__REFERRER_ACCOUNT_WRONG_ADDRESS]: + "Referrer account address is not a valid program address", + [KAMINO_LENDING_ERROR__REFERRER_STATE_OWNER_MISMATCH]: + "Referrer state owner does not match the given signer", + [KAMINO_LENDING_ERROR__REPAY_TOO_SMALL]: + "Repay amount too small to transfer liquidity", + [KAMINO_LENDING_ERROR__REPAY_TOO_SMALL_FOR_FULL_LIQUIDATION]: + "Repay amount is too small to satisfy the mandatory full liquidation", + [KAMINO_LENDING_ERROR__RESERVE_ACCOUNTING_MISMATCH]: + "Reserve internal state accounting has been unexpectedly modified", + [KAMINO_LENDING_ERROR__RESERVE_DEPRECATED]: + "Reserve was deprecated, no longer usable", + [KAMINO_LENDING_ERROR__RESERVE_OBSOLETE]: "Reserve is marked as obsolete", + [KAMINO_LENDING_ERROR__RESERVE_STALE]: + "Reserve state needs to be refreshed", + [KAMINO_LENDING_ERROR__RESERVE_TOKEN_BALANCE_MISMATCH]: + "Reserve state and token account cannot drift", + [KAMINO_LENDING_ERROR__RESERVE_VAULT_BALANCE_MISMATCH]: + "Reserve token account has been unexpectedly modified", + [KAMINO_LENDING_ERROR__SHORT_URL_NOT_ASCII_ALPHANUMERIC]: + "Referrer short_url is not ascii alphanumeric", + [KAMINO_LENDING_ERROR__SWITCHBOARD_V2_ERROR]: "Switchboard error", + [KAMINO_LENDING_ERROR__UNHEALTHY_ELEVATION_GROUP_LTV]: + "The current obligation must have most or all its debt repaid before changing the elevation group", + [KAMINO_LENDING_ERROR__UNSUPPORTED_TOKEN_EXTENSION]: + "Mint has a token (2022) extension that is not supported", + [KAMINO_LENDING_ERROR__USER_METADATA_OWNER_ALREADY_SET]: + "User metadata owner is already set", + [KAMINO_LENDING_ERROR__WITHDRAWAL_CAP_REACHED]: "Withdrawal cap is reached", + [KAMINO_LENDING_ERROR__WITHDRAW_TOO_LARGE]: "Withdraw amount too large", + [KAMINO_LENDING_ERROR__WITHDRAW_TOO_SMALL]: "Withdraw amount too small", + [KAMINO_LENDING_ERROR__WORSE_L_T_V_BLOCKED]: + "Cannot get the obligation in a worse position", + [KAMINO_LENDING_ERROR__WORSE_L_T_V_THAN_UNHEALTHY_L_T_V]: + "Cannot get the obligation liquidatable", + [KAMINO_LENDING_ERROR__ZERO_MAX_LTV_ASSETS_IN_DEPOSITS]: + "No max LTV 0 assets allowed in deposits for repay and withdraw", + }; +} + +export function getKaminoLendingErrorMessage(code: KaminoLendingError): string { + if (true) { + return kaminoLendingErrorMessages![code]; + } + + return "Error message not available in production bundles."; +} + +export function isKaminoLendingError< + TProgramErrorCode extends KaminoLendingError, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode, +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + KAMINO_LENDING_PROGRAM_ADDRESS, + code, + ); +} diff --git a/clients/kamino-lending/src/generated/index.ts b/clients/kamino-lending/src/generated/index.ts new file mode 100644 index 00000000..ceeafbb9 --- /dev/null +++ b/clients/kamino-lending/src/generated/index.ts @@ -0,0 +1,14 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./accounts/index.js"; +export * from "./errors/index.js"; +export * from "./instructions/index.js"; +export * from "./pdas/index.js"; +export * from "./programs/index.js"; +export * from "./types/index.js"; diff --git a/clients/kamino-lending/src/generated/instructions/addRewards.ts b/clients/kamino-lending/src/generated/instructions/addRewards.ts new file mode 100644 index 00000000..a57793c0 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/addRewards.ts @@ -0,0 +1,303 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const ADD_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 88, 186, 25, 227, 38, 137, 81, 23, +]); + +export function getAddRewardsDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(ADD_REWARDS_DISCRIMINATOR); +} + +export type AddRewardsInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountRewardMint extends string | AccountMeta = string, + TAccountRewardVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountPayerRewardTokenAta extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountRewardMint extends string + ? ReadonlyAccount + : TAccountRewardMint, + TAccountRewardVault extends string + ? WritableAccount + : TAccountRewardVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountPayerRewardTokenAta extends string + ? WritableAccount + : TAccountPayerRewardTokenAta, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface AddRewardsInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; + rewardIndex: bigint; +} + +export interface AddRewardsInstructionDataArgs { + amount: number | bigint; + rewardIndex: number | bigint; +} + +export function getAddRewardsInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ["rewardIndex", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: ADD_REWARDS_DISCRIMINATOR }), + ); +} + +export function getAddRewardsInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ["rewardIndex", getU64Decoder()], + ]); +} + +export function getAddRewardsInstructionDataCodec(): FixedSizeCodec< + AddRewardsInstructionDataArgs, + AddRewardsInstructionData +> { + return combineCodec( + getAddRewardsInstructionDataEncoder(), + getAddRewardsInstructionDataDecoder(), + ); +} + +export interface AddRewardsInput< + TAccountPayer extends string = string, + TAccountFarmState extends string = string, + TAccountRewardMint extends string = string, + TAccountRewardVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountPayerRewardTokenAta extends string = string, + TAccountScopePrices extends string = string, + TAccountTokenProgram extends string = string, +> { + payer: TransactionSigner; + farmState: Address; + rewardMint: Address; + rewardVault: Address; + farmVaultsAuthority: Address; + payerRewardTokenAta: Address; + scopePrices?: Address; + tokenProgram: Address; + amount: AddRewardsInstructionDataArgs["amount"]; + rewardIndex: AddRewardsInstructionDataArgs["rewardIndex"]; +} + +export function getAddRewardsInstruction< + TAccountPayer extends string, + TAccountFarmState extends string, + TAccountRewardMint extends string, + TAccountRewardVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountPayerRewardTokenAta extends string, + TAccountScopePrices extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: AddRewardsInput< + TAccountPayer, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountPayerRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): AddRewardsInstruction< + TProgramAddress, + TAccountPayer, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountPayerRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + rewardMint: { value: input.rewardMint ?? null, isWritable: false }, + rewardVault: { value: input.rewardVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + payerRewardTokenAta: { + value: input.payerRewardTokenAta ?? null, + isWritable: true, + }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.rewardMint), + getAccountMeta(accounts.rewardVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.payerRewardTokenAta), + getAccountMeta(accounts.scopePrices), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getAddRewardsInstructionDataEncoder().encode( + args as AddRewardsInstructionDataArgs, + ), + } as AddRewardsInstruction< + TProgramAddress, + TAccountPayer, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountPayerRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedAddRewardsInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + farmState: TAccountMetas[1]; + rewardMint: TAccountMetas[2]; + rewardVault: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + payerRewardTokenAta: TAccountMetas[5]; + scopePrices?: TAccountMetas[6] | undefined; + tokenProgram: TAccountMetas[7]; + }; + data: AddRewardsInstructionData; +} + +export function parseAddRewardsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedAddRewardsInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + payer: getNextAccount(), + farmState: getNextAccount(), + rewardMint: getNextAccount(), + rewardVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + payerRewardTokenAta: getNextAccount(), + scopePrices: getNextOptionalAccount(), + tokenProgram: getNextAccount(), + }, + data: getAddRewardsInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidity.ts b/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidity.ts new file mode 100644 index 00000000..1affc190 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidity.ts @@ -0,0 +1,386 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const BORROW_OBLIGATION_LIQUIDITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([121, 127, 18, 204, 73, 245, 225, 65]); + +export function getBorrowObligationLiquidityDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + BORROW_OBLIGATION_LIQUIDITY_DISCRIMINATOR, + ); +} + +export type BorrowObligationLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountBorrowReserve extends string | AccountMeta = string, + TAccountBorrowReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveSourceLiquidity extends string | AccountMeta = string, + TAccountBorrowReserveLiquidityFeeReceiver extends + | string + | AccountMeta = string, + TAccountUserDestinationLiquidity extends string | AccountMeta = string, + TAccountReferrerTokenState extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountBorrowReserve extends string + ? WritableAccount + : TAccountBorrowReserve, + TAccountBorrowReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountBorrowReserveLiquidityMint, + TAccountReserveSourceLiquidity extends string + ? WritableAccount + : TAccountReserveSourceLiquidity, + TAccountBorrowReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountBorrowReserveLiquidityFeeReceiver, + TAccountUserDestinationLiquidity extends string + ? WritableAccount + : TAccountUserDestinationLiquidity, + TAccountReferrerTokenState extends string + ? WritableAccount + : TAccountReferrerTokenState, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface BorrowObligationLiquidityInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface BorrowObligationLiquidityInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getBorrowObligationLiquidityInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: BORROW_OBLIGATION_LIQUIDITY_DISCRIMINATOR, + }), + ); +} + +export function getBorrowObligationLiquidityInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getBorrowObligationLiquidityInstructionDataCodec(): FixedSizeCodec< + BorrowObligationLiquidityInstructionDataArgs, + BorrowObligationLiquidityInstructionData +> { + return combineCodec( + getBorrowObligationLiquidityInstructionDataEncoder(), + getBorrowObligationLiquidityInstructionDataDecoder(), + ); +} + +export interface BorrowObligationLiquidityInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountBorrowReserve extends string = string, + TAccountBorrowReserveLiquidityMint extends string = string, + TAccountReserveSourceLiquidity extends string = string, + TAccountBorrowReserveLiquidityFeeReceiver extends string = string, + TAccountUserDestinationLiquidity extends string = string, + TAccountReferrerTokenState extends string = string, + TAccountTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + borrowReserve: Address; + borrowReserveLiquidityMint: Address; + reserveSourceLiquidity: Address; + borrowReserveLiquidityFeeReceiver: Address; + userDestinationLiquidity: Address; + referrerTokenState?: Address; + tokenProgram: Address; + instructionSysvarAccount?: Address; + liquidityAmount: BorrowObligationLiquidityInstructionDataArgs["liquidityAmount"]; +} + +export function getBorrowObligationLiquidityInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountBorrowReserve extends string, + TAccountBorrowReserveLiquidityMint extends string, + TAccountReserveSourceLiquidity extends string, + TAccountBorrowReserveLiquidityFeeReceiver extends string, + TAccountUserDestinationLiquidity extends string, + TAccountReferrerTokenState extends string, + TAccountTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: BorrowObligationLiquidityInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountBorrowReserve, + TAccountBorrowReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountBorrowReserveLiquidityFeeReceiver, + TAccountUserDestinationLiquidity, + TAccountReferrerTokenState, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): BorrowObligationLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountBorrowReserve, + TAccountBorrowReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountBorrowReserveLiquidityFeeReceiver, + TAccountUserDestinationLiquidity, + TAccountReferrerTokenState, + TAccountTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + borrowReserve: { value: input.borrowReserve ?? null, isWritable: true }, + borrowReserveLiquidityMint: { + value: input.borrowReserveLiquidityMint ?? null, + isWritable: false, + }, + reserveSourceLiquidity: { + value: input.reserveSourceLiquidity ?? null, + isWritable: true, + }, + borrowReserveLiquidityFeeReceiver: { + value: input.borrowReserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + userDestinationLiquidity: { + value: input.userDestinationLiquidity ?? null, + isWritable: true, + }, + referrerTokenState: { + value: input.referrerTokenState ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.borrowReserve), + getAccountMeta(accounts.borrowReserveLiquidityMint), + getAccountMeta(accounts.reserveSourceLiquidity), + getAccountMeta(accounts.borrowReserveLiquidityFeeReceiver), + getAccountMeta(accounts.userDestinationLiquidity), + getAccountMeta(accounts.referrerTokenState), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getBorrowObligationLiquidityInstructionDataEncoder().encode( + args as BorrowObligationLiquidityInstructionDataArgs, + ), + } as BorrowObligationLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountBorrowReserve, + TAccountBorrowReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountBorrowReserveLiquidityFeeReceiver, + TAccountUserDestinationLiquidity, + TAccountReferrerTokenState, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedBorrowObligationLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + borrowReserve: TAccountMetas[4]; + borrowReserveLiquidityMint: TAccountMetas[5]; + reserveSourceLiquidity: TAccountMetas[6]; + borrowReserveLiquidityFeeReceiver: TAccountMetas[7]; + userDestinationLiquidity: TAccountMetas[8]; + referrerTokenState?: TAccountMetas[9] | undefined; + tokenProgram: TAccountMetas[10]; + instructionSysvarAccount: TAccountMetas[11]; + }; + data: BorrowObligationLiquidityInstructionData; +} + +export function parseBorrowObligationLiquidityInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedBorrowObligationLiquidityInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + borrowReserve: getNextAccount(), + borrowReserveLiquidityMint: getNextAccount(), + reserveSourceLiquidity: getNextAccount(), + borrowReserveLiquidityFeeReceiver: getNextAccount(), + userDestinationLiquidity: getNextAccount(), + referrerTokenState: getNextOptionalAccount(), + tokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getBorrowObligationLiquidityInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidityV2.ts b/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidityV2.ts new file mode 100644 index 00000000..40836b97 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/borrowObligationLiquidityV2.ts @@ -0,0 +1,481 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const BORROW_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([161, 128, 143, 245, 171, 199, 194, 6]); + +export function getBorrowObligationLiquidityV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + BORROW_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR, + ); +} + +export type BorrowObligationLiquidityV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountBorrowAccountsOwner extends string | AccountMeta = string, + TAccountBorrowAccountsObligation extends string | AccountMeta = string, + TAccountBorrowAccountsLendingMarket extends string | AccountMeta = string, + TAccountBorrowAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountBorrowAccountsBorrowReserve extends string | AccountMeta = string, + TAccountBorrowAccountsBorrowReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountBorrowAccountsReserveSourceLiquidity extends + | string + | AccountMeta = string, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver extends + | string + | AccountMeta = string, + TAccountBorrowAccountsUserDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountBorrowAccountsReferrerTokenState extends + | string + | AccountMeta = string, + TAccountBorrowAccountsTokenProgram extends string | AccountMeta = string, + TAccountBorrowAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountBorrowAccountsOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountBorrowAccountsOwner, + TAccountBorrowAccountsObligation extends string + ? WritableAccount + : TAccountBorrowAccountsObligation, + TAccountBorrowAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountBorrowAccountsLendingMarket, + TAccountBorrowAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountBorrowAccountsLendingMarketAuthority, + TAccountBorrowAccountsBorrowReserve extends string + ? WritableAccount + : TAccountBorrowAccountsBorrowReserve, + TAccountBorrowAccountsBorrowReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountBorrowAccountsBorrowReserveLiquidityMint, + TAccountBorrowAccountsReserveSourceLiquidity extends string + ? WritableAccount + : TAccountBorrowAccountsReserveSourceLiquidity, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver, + TAccountBorrowAccountsUserDestinationLiquidity extends string + ? WritableAccount + : TAccountBorrowAccountsUserDestinationLiquidity, + TAccountBorrowAccountsReferrerTokenState extends string + ? WritableAccount + : TAccountBorrowAccountsReferrerTokenState, + TAccountBorrowAccountsTokenProgram extends string + ? ReadonlyAccount + : TAccountBorrowAccountsTokenProgram, + TAccountBorrowAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountBorrowAccountsInstructionSysvarAccount, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface BorrowObligationLiquidityV2InstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface BorrowObligationLiquidityV2InstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getBorrowObligationLiquidityV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: BORROW_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR, + }), + ); +} + +export function getBorrowObligationLiquidityV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getBorrowObligationLiquidityV2InstructionDataCodec(): FixedSizeCodec< + BorrowObligationLiquidityV2InstructionDataArgs, + BorrowObligationLiquidityV2InstructionData +> { + return combineCodec( + getBorrowObligationLiquidityV2InstructionDataEncoder(), + getBorrowObligationLiquidityV2InstructionDataDecoder(), + ); +} + +export interface BorrowObligationLiquidityV2Input< + TAccountBorrowAccountsOwner extends string = string, + TAccountBorrowAccountsObligation extends string = string, + TAccountBorrowAccountsLendingMarket extends string = string, + TAccountBorrowAccountsLendingMarketAuthority extends string = string, + TAccountBorrowAccountsBorrowReserve extends string = string, + TAccountBorrowAccountsBorrowReserveLiquidityMint extends string = string, + TAccountBorrowAccountsReserveSourceLiquidity extends string = string, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver extends + string = string, + TAccountBorrowAccountsUserDestinationLiquidity extends string = string, + TAccountBorrowAccountsReferrerTokenState extends string = string, + TAccountBorrowAccountsTokenProgram extends string = string, + TAccountBorrowAccountsInstructionSysvarAccount extends string = string, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState extends + string = string, + TAccountFarmsProgram extends string = string, +> { + borrowAccountsOwner: TransactionSigner; + borrowAccountsObligation: Address; + borrowAccountsLendingMarket: Address; + borrowAccountsLendingMarketAuthority: Address; + borrowAccountsBorrowReserve: Address; + borrowAccountsBorrowReserveLiquidityMint: Address; + borrowAccountsReserveSourceLiquidity: Address; + borrowAccountsBorrowReserveLiquidityFeeReceiver: Address; + borrowAccountsUserDestinationLiquidity: Address; + borrowAccountsReferrerTokenState?: Address; + borrowAccountsTokenProgram: Address; + borrowAccountsInstructionSysvarAccount?: Address; + borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState?: Address; + borrowObligationLiquidityV2FarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + liquidityAmount: BorrowObligationLiquidityV2InstructionDataArgs["liquidityAmount"]; +} + +export function getBorrowObligationLiquidityV2Instruction< + TAccountBorrowAccountsOwner extends string, + TAccountBorrowAccountsObligation extends string, + TAccountBorrowAccountsLendingMarket extends string, + TAccountBorrowAccountsLendingMarketAuthority extends string, + TAccountBorrowAccountsBorrowReserve extends string, + TAccountBorrowAccountsBorrowReserveLiquidityMint extends string, + TAccountBorrowAccountsReserveSourceLiquidity extends string, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver extends string, + TAccountBorrowAccountsUserDestinationLiquidity extends string, + TAccountBorrowAccountsReferrerTokenState extends string, + TAccountBorrowAccountsTokenProgram extends string, + TAccountBorrowAccountsInstructionSysvarAccount extends string, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + string, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState extends + string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: BorrowObligationLiquidityV2Input< + TAccountBorrowAccountsOwner, + TAccountBorrowAccountsObligation, + TAccountBorrowAccountsLendingMarket, + TAccountBorrowAccountsLendingMarketAuthority, + TAccountBorrowAccountsBorrowReserve, + TAccountBorrowAccountsBorrowReserveLiquidityMint, + TAccountBorrowAccountsReserveSourceLiquidity, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver, + TAccountBorrowAccountsUserDestinationLiquidity, + TAccountBorrowAccountsReferrerTokenState, + TAccountBorrowAccountsTokenProgram, + TAccountBorrowAccountsInstructionSysvarAccount, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): BorrowObligationLiquidityV2Instruction< + TProgramAddress, + TAccountBorrowAccountsOwner, + TAccountBorrowAccountsObligation, + TAccountBorrowAccountsLendingMarket, + TAccountBorrowAccountsLendingMarketAuthority, + TAccountBorrowAccountsBorrowReserve, + TAccountBorrowAccountsBorrowReserveLiquidityMint, + TAccountBorrowAccountsReserveSourceLiquidity, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver, + TAccountBorrowAccountsUserDestinationLiquidity, + TAccountBorrowAccountsReferrerTokenState, + TAccountBorrowAccountsTokenProgram, + TAccountBorrowAccountsInstructionSysvarAccount, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + borrowAccountsOwner: { + value: input.borrowAccountsOwner ?? null, + isWritable: false, + }, + borrowAccountsObligation: { + value: input.borrowAccountsObligation ?? null, + isWritable: true, + }, + borrowAccountsLendingMarket: { + value: input.borrowAccountsLendingMarket ?? null, + isWritable: false, + }, + borrowAccountsLendingMarketAuthority: { + value: input.borrowAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + borrowAccountsBorrowReserve: { + value: input.borrowAccountsBorrowReserve ?? null, + isWritable: true, + }, + borrowAccountsBorrowReserveLiquidityMint: { + value: input.borrowAccountsBorrowReserveLiquidityMint ?? null, + isWritable: false, + }, + borrowAccountsReserveSourceLiquidity: { + value: input.borrowAccountsReserveSourceLiquidity ?? null, + isWritable: true, + }, + borrowAccountsBorrowReserveLiquidityFeeReceiver: { + value: input.borrowAccountsBorrowReserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + borrowAccountsUserDestinationLiquidity: { + value: input.borrowAccountsUserDestinationLiquidity ?? null, + isWritable: true, + }, + borrowAccountsReferrerTokenState: { + value: input.borrowAccountsReferrerTokenState ?? null, + isWritable: true, + }, + borrowAccountsTokenProgram: { + value: input.borrowAccountsTokenProgram ?? null, + isWritable: false, + }, + borrowAccountsInstructionSysvarAccount: { + value: input.borrowAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState: { + value: + input.borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState ?? + null, + isWritable: true, + }, + borrowObligationLiquidityV2FarmsAccountsReserveFarmState: { + value: + input.borrowObligationLiquidityV2FarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.borrowAccountsInstructionSysvarAccount.value) { + accounts.borrowAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.borrowAccountsOwner), + getAccountMeta(accounts.borrowAccountsObligation), + getAccountMeta(accounts.borrowAccountsLendingMarket), + getAccountMeta(accounts.borrowAccountsLendingMarketAuthority), + getAccountMeta(accounts.borrowAccountsBorrowReserve), + getAccountMeta(accounts.borrowAccountsBorrowReserveLiquidityMint), + getAccountMeta(accounts.borrowAccountsReserveSourceLiquidity), + getAccountMeta(accounts.borrowAccountsBorrowReserveLiquidityFeeReceiver), + getAccountMeta(accounts.borrowAccountsUserDestinationLiquidity), + getAccountMeta(accounts.borrowAccountsReferrerTokenState), + getAccountMeta(accounts.borrowAccountsTokenProgram), + getAccountMeta(accounts.borrowAccountsInstructionSysvarAccount), + getAccountMeta( + accounts.borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta( + accounts.borrowObligationLiquidityV2FarmsAccountsReserveFarmState, + ), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getBorrowObligationLiquidityV2InstructionDataEncoder().encode( + args as BorrowObligationLiquidityV2InstructionDataArgs, + ), + } as BorrowObligationLiquidityV2Instruction< + TProgramAddress, + TAccountBorrowAccountsOwner, + TAccountBorrowAccountsObligation, + TAccountBorrowAccountsLendingMarket, + TAccountBorrowAccountsLendingMarketAuthority, + TAccountBorrowAccountsBorrowReserve, + TAccountBorrowAccountsBorrowReserveLiquidityMint, + TAccountBorrowAccountsReserveSourceLiquidity, + TAccountBorrowAccountsBorrowReserveLiquidityFeeReceiver, + TAccountBorrowAccountsUserDestinationLiquidity, + TAccountBorrowAccountsReferrerTokenState, + TAccountBorrowAccountsTokenProgram, + TAccountBorrowAccountsInstructionSysvarAccount, + TAccountBorrowObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountBorrowObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedBorrowObligationLiquidityV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + borrowAccountsOwner: TAccountMetas[0]; + borrowAccountsObligation: TAccountMetas[1]; + borrowAccountsLendingMarket: TAccountMetas[2]; + borrowAccountsLendingMarketAuthority: TAccountMetas[3]; + borrowAccountsBorrowReserve: TAccountMetas[4]; + borrowAccountsBorrowReserveLiquidityMint: TAccountMetas[5]; + borrowAccountsReserveSourceLiquidity: TAccountMetas[6]; + borrowAccountsBorrowReserveLiquidityFeeReceiver: TAccountMetas[7]; + borrowAccountsUserDestinationLiquidity: TAccountMetas[8]; + borrowAccountsReferrerTokenState?: TAccountMetas[9] | undefined; + borrowAccountsTokenProgram: TAccountMetas[10]; + borrowAccountsInstructionSysvarAccount: TAccountMetas[11]; + borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[12] + | undefined; + borrowObligationLiquidityV2FarmsAccountsReserveFarmState?: + | TAccountMetas[13] + | undefined; + farmsProgram: TAccountMetas[14]; + }; + data: BorrowObligationLiquidityV2InstructionData; +} + +export function parseBorrowObligationLiquidityV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedBorrowObligationLiquidityV2Instruction { + if (instruction.accounts.length < 15) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + borrowAccountsOwner: getNextAccount(), + borrowAccountsObligation: getNextAccount(), + borrowAccountsLendingMarket: getNextAccount(), + borrowAccountsLendingMarketAuthority: getNextAccount(), + borrowAccountsBorrowReserve: getNextAccount(), + borrowAccountsBorrowReserveLiquidityMint: getNextAccount(), + borrowAccountsReserveSourceLiquidity: getNextAccount(), + borrowAccountsBorrowReserveLiquidityFeeReceiver: getNextAccount(), + borrowAccountsUserDestinationLiquidity: getNextAccount(), + borrowAccountsReferrerTokenState: getNextOptionalAccount(), + borrowAccountsTokenProgram: getNextAccount(), + borrowAccountsInstructionSysvarAccount: getNextAccount(), + borrowObligationLiquidityV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + borrowObligationLiquidityV2FarmsAccountsReserveFarmState: + getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getBorrowObligationLiquidityV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/deleteReferrerStateAndShortUrl.ts b/clients/kamino-lending/src/generated/instructions/deleteReferrerStateAndShortUrl.ts new file mode 100644 index 00000000..728deca5 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/deleteReferrerStateAndShortUrl.ts @@ -0,0 +1,236 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DELETE_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([153, 185, 99, 28, 228, 179, 187, 150]); + +export function getDeleteReferrerStateAndShortUrlDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DELETE_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR, + ); +} + +export type DeleteReferrerStateAndShortUrlInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountReferrer extends string | AccountMeta = string, + TAccountReferrerState extends string | AccountMeta = string, + TAccountShortUrl extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountReferrer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountReferrer, + TAccountReferrerState extends string + ? WritableAccount + : TAccountReferrerState, + TAccountShortUrl extends string + ? WritableAccount + : TAccountShortUrl, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface DeleteReferrerStateAndShortUrlInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface DeleteReferrerStateAndShortUrlInstructionDataArgs {} + +export function getDeleteReferrerStateAndShortUrlInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: DELETE_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR, + }), + ); +} + +export function getDeleteReferrerStateAndShortUrlInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getDeleteReferrerStateAndShortUrlInstructionDataCodec(): FixedSizeCodec< + DeleteReferrerStateAndShortUrlInstructionDataArgs, + DeleteReferrerStateAndShortUrlInstructionData +> { + return combineCodec( + getDeleteReferrerStateAndShortUrlInstructionDataEncoder(), + getDeleteReferrerStateAndShortUrlInstructionDataDecoder(), + ); +} + +export interface DeleteReferrerStateAndShortUrlInput< + TAccountReferrer extends string = string, + TAccountReferrerState extends string = string, + TAccountShortUrl extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + referrer: TransactionSigner; + referrerState: Address; + shortUrl: Address; + rent: Address; + systemProgram: Address; +} + +export function getDeleteReferrerStateAndShortUrlInstruction< + TAccountReferrer extends string, + TAccountReferrerState extends string, + TAccountShortUrl extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DeleteReferrerStateAndShortUrlInput< + TAccountReferrer, + TAccountReferrerState, + TAccountShortUrl, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): DeleteReferrerStateAndShortUrlInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerState, + TAccountShortUrl, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + referrer: { value: input.referrer ?? null, isWritable: true }, + referrerState: { value: input.referrerState ?? null, isWritable: true }, + shortUrl: { value: input.shortUrl ?? null, isWritable: true }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.referrer), + getAccountMeta(accounts.referrerState), + getAccountMeta(accounts.shortUrl), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getDeleteReferrerStateAndShortUrlInstructionDataEncoder().encode({}), + } as DeleteReferrerStateAndShortUrlInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerState, + TAccountShortUrl, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedDeleteReferrerStateAndShortUrlInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + referrer: TAccountMetas[0]; + referrerState: TAccountMetas[1]; + shortUrl: TAccountMetas[2]; + rent: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + }; + data: DeleteReferrerStateAndShortUrlInstructionData; +} + +export function parseDeleteReferrerStateAndShortUrlInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDeleteReferrerStateAndShortUrlInstruction { + if (instruction.accounts.length < 5) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + referrer: getNextAccount(), + referrerState: getNextAccount(), + shortUrl: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getDeleteReferrerStateAndShortUrlInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositAndWithdraw.ts b/clients/kamino-lending/src/generated/instructions/depositAndWithdraw.ts new file mode 100644 index 00000000..2a53e1e7 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositAndWithdraw.ts @@ -0,0 +1,826 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_AND_WITHDRAW_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([141, 153, 39, 15, 64, 61, 88, 84]); + +export function getDepositAndWithdrawDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_AND_WITHDRAW_DISCRIMINATOR, + ); +} + +export type DepositAndWithdrawInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountDepositAccountsOwner extends string | AccountMeta = string, + TAccountDepositAccountsObligation extends string | AccountMeta = string, + TAccountDepositAccountsLendingMarket extends string | AccountMeta = string, + TAccountDepositAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserve extends string | AccountMeta = string, + TAccountDepositAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsUserSourceLiquidity extends + | string + | AccountMeta = string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountDepositAccountsLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountDepositAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountWithdrawAccountsOwner extends string | AccountMeta = string, + TAccountWithdrawAccountsObligation extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarket extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsWithdrawReserve extends string | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveSourceCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountDepositFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountDepositFarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountWithdrawFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountWithdrawFarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountDepositAccountsOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation extends string + ? WritableAccount + : TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve extends string + ? WritableAccount + : TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply extends string + ? WritableAccount + : TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint extends string + ? WritableAccount + : TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral extends string + ? WritableAccount + : TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity extends string + ? WritableAccount + : TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountDepositAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation extends string + ? WritableAccount + : TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity extends string + ? WritableAccount + : TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountDepositFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountDepositFarmsAccountsObligationFarmUserState, + TAccountDepositFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountDepositFarmsAccountsReserveFarmState, + TAccountWithdrawFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountWithdrawFarmsAccountsObligationFarmUserState, + TAccountWithdrawFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountWithdrawFarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface DepositAndWithdrawInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; + withdrawCollateralAmount: bigint; +} + +export interface DepositAndWithdrawInstructionDataArgs { + liquidityAmount: number | bigint; + withdrawCollateralAmount: number | bigint; +} + +export function getDepositAndWithdrawInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ["withdrawCollateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_AND_WITHDRAW_DISCRIMINATOR, + }), + ); +} + +export function getDepositAndWithdrawInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ["withdrawCollateralAmount", getU64Decoder()], + ]); +} + +export function getDepositAndWithdrawInstructionDataCodec(): FixedSizeCodec< + DepositAndWithdrawInstructionDataArgs, + DepositAndWithdrawInstructionData +> { + return combineCodec( + getDepositAndWithdrawInstructionDataEncoder(), + getDepositAndWithdrawInstructionDataDecoder(), + ); +} + +export interface DepositAndWithdrawInput< + TAccountDepositAccountsOwner extends string = string, + TAccountDepositAccountsObligation extends string = string, + TAccountDepositAccountsLendingMarket extends string = string, + TAccountDepositAccountsLendingMarketAuthority extends string = string, + TAccountDepositAccountsReserve extends string = string, + TAccountDepositAccountsReserveLiquidityMint extends string = string, + TAccountDepositAccountsReserveLiquiditySupply extends string = string, + TAccountDepositAccountsReserveCollateralMint extends string = string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends + string = string, + TAccountDepositAccountsUserSourceLiquidity extends string = string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends + string = string, + TAccountDepositAccountsCollateralTokenProgram extends string = string, + TAccountDepositAccountsLiquidityTokenProgram extends string = string, + TAccountDepositAccountsInstructionSysvarAccount extends string = string, + TAccountWithdrawAccountsOwner extends string = string, + TAccountWithdrawAccountsObligation extends string = string, + TAccountWithdrawAccountsLendingMarket extends string = string, + TAccountWithdrawAccountsLendingMarketAuthority extends string = string, + TAccountWithdrawAccountsWithdrawReserve extends string = string, + TAccountWithdrawAccountsReserveLiquidityMint extends string = string, + TAccountWithdrawAccountsReserveSourceCollateral extends string = string, + TAccountWithdrawAccountsReserveCollateralMint extends string = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + string = string, + TAccountWithdrawAccountsCollateralTokenProgram extends string = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string = string, + TAccountDepositFarmsAccountsObligationFarmUserState extends string = string, + TAccountDepositFarmsAccountsReserveFarmState extends string = string, + TAccountWithdrawFarmsAccountsObligationFarmUserState extends string = string, + TAccountWithdrawFarmsAccountsReserveFarmState extends string = string, + TAccountFarmsProgram extends string = string, +> { + depositAccountsOwner: TransactionSigner; + depositAccountsObligation: Address; + depositAccountsLendingMarket: Address; + depositAccountsLendingMarketAuthority: Address; + depositAccountsReserve: Address; + depositAccountsReserveLiquidityMint: Address; + depositAccountsReserveLiquiditySupply: Address; + depositAccountsReserveCollateralMint: Address; + depositAccountsReserveDestinationDepositCollateral: Address; + depositAccountsUserSourceLiquidity: Address; + depositAccountsPlaceholderUserDestinationCollateral?: Address; + depositAccountsCollateralTokenProgram: Address; + depositAccountsLiquidityTokenProgram: Address; + depositAccountsInstructionSysvarAccount?: Address; + withdrawAccountsOwner: TransactionSigner; + withdrawAccountsObligation: Address; + withdrawAccountsLendingMarket: Address; + withdrawAccountsLendingMarketAuthority: Address; + withdrawAccountsWithdrawReserve: Address; + withdrawAccountsReserveLiquidityMint: Address; + withdrawAccountsReserveSourceCollateral: Address; + withdrawAccountsReserveCollateralMint: Address; + withdrawAccountsReserveLiquiditySupply: Address; + withdrawAccountsUserDestinationLiquidity: Address; + withdrawAccountsPlaceholderUserDestinationCollateral?: Address; + withdrawAccountsCollateralTokenProgram: Address; + withdrawAccountsLiquidityTokenProgram: Address; + withdrawAccountsInstructionSysvarAccount?: Address; + depositFarmsAccountsObligationFarmUserState?: Address; + depositFarmsAccountsReserveFarmState?: Address; + withdrawFarmsAccountsObligationFarmUserState?: Address; + withdrawFarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + liquidityAmount: DepositAndWithdrawInstructionDataArgs["liquidityAmount"]; + withdrawCollateralAmount: DepositAndWithdrawInstructionDataArgs["withdrawCollateralAmount"]; +} + +export function getDepositAndWithdrawInstruction< + TAccountDepositAccountsOwner extends string, + TAccountDepositAccountsObligation extends string, + TAccountDepositAccountsLendingMarket extends string, + TAccountDepositAccountsLendingMarketAuthority extends string, + TAccountDepositAccountsReserve extends string, + TAccountDepositAccountsReserveLiquidityMint extends string, + TAccountDepositAccountsReserveLiquiditySupply extends string, + TAccountDepositAccountsReserveCollateralMint extends string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends string, + TAccountDepositAccountsUserSourceLiquidity extends string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends string, + TAccountDepositAccountsCollateralTokenProgram extends string, + TAccountDepositAccountsLiquidityTokenProgram extends string, + TAccountDepositAccountsInstructionSysvarAccount extends string, + TAccountWithdrawAccountsOwner extends string, + TAccountWithdrawAccountsObligation extends string, + TAccountWithdrawAccountsLendingMarket extends string, + TAccountWithdrawAccountsLendingMarketAuthority extends string, + TAccountWithdrawAccountsWithdrawReserve extends string, + TAccountWithdrawAccountsReserveLiquidityMint extends string, + TAccountWithdrawAccountsReserveSourceCollateral extends string, + TAccountWithdrawAccountsReserveCollateralMint extends string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string, + TAccountWithdrawAccountsCollateralTokenProgram extends string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string, + TAccountDepositFarmsAccountsObligationFarmUserState extends string, + TAccountDepositFarmsAccountsReserveFarmState extends string, + TAccountWithdrawFarmsAccountsObligationFarmUserState extends string, + TAccountWithdrawFarmsAccountsReserveFarmState extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositAndWithdrawInput< + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountDepositFarmsAccountsObligationFarmUserState, + TAccountDepositFarmsAccountsReserveFarmState, + TAccountWithdrawFarmsAccountsObligationFarmUserState, + TAccountWithdrawFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): DepositAndWithdrawInstruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountDepositFarmsAccountsObligationFarmUserState, + TAccountDepositFarmsAccountsReserveFarmState, + TAccountWithdrawFarmsAccountsObligationFarmUserState, + TAccountWithdrawFarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + depositAccountsOwner: { + value: input.depositAccountsOwner ?? null, + isWritable: true, + }, + depositAccountsObligation: { + value: input.depositAccountsObligation ?? null, + isWritable: true, + }, + depositAccountsLendingMarket: { + value: input.depositAccountsLendingMarket ?? null, + isWritable: false, + }, + depositAccountsLendingMarketAuthority: { + value: input.depositAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + depositAccountsReserve: { + value: input.depositAccountsReserve ?? null, + isWritable: true, + }, + depositAccountsReserveLiquidityMint: { + value: input.depositAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + depositAccountsReserveLiquiditySupply: { + value: input.depositAccountsReserveLiquiditySupply ?? null, + isWritable: true, + }, + depositAccountsReserveCollateralMint: { + value: input.depositAccountsReserveCollateralMint ?? null, + isWritable: true, + }, + depositAccountsReserveDestinationDepositCollateral: { + value: input.depositAccountsReserveDestinationDepositCollateral ?? null, + isWritable: true, + }, + depositAccountsUserSourceLiquidity: { + value: input.depositAccountsUserSourceLiquidity ?? null, + isWritable: true, + }, + depositAccountsPlaceholderUserDestinationCollateral: { + value: input.depositAccountsPlaceholderUserDestinationCollateral ?? null, + isWritable: false, + }, + depositAccountsCollateralTokenProgram: { + value: input.depositAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + depositAccountsLiquidityTokenProgram: { + value: input.depositAccountsLiquidityTokenProgram ?? null, + isWritable: false, + }, + depositAccountsInstructionSysvarAccount: { + value: input.depositAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + withdrawAccountsOwner: { + value: input.withdrawAccountsOwner ?? null, + isWritable: true, + }, + withdrawAccountsObligation: { + value: input.withdrawAccountsObligation ?? null, + isWritable: true, + }, + withdrawAccountsLendingMarket: { + value: input.withdrawAccountsLendingMarket ?? null, + isWritable: false, + }, + withdrawAccountsLendingMarketAuthority: { + value: input.withdrawAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawAccountsWithdrawReserve: { + value: input.withdrawAccountsWithdrawReserve ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquidityMint: { + value: input.withdrawAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + withdrawAccountsReserveSourceCollateral: { + value: input.withdrawAccountsReserveSourceCollateral ?? null, + isWritable: true, + }, + withdrawAccountsReserveCollateralMint: { + value: input.withdrawAccountsReserveCollateralMint ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquiditySupply: { + value: input.withdrawAccountsReserveLiquiditySupply ?? null, + isWritable: true, + }, + withdrawAccountsUserDestinationLiquidity: { + value: input.withdrawAccountsUserDestinationLiquidity ?? null, + isWritable: true, + }, + withdrawAccountsPlaceholderUserDestinationCollateral: { + value: input.withdrawAccountsPlaceholderUserDestinationCollateral ?? null, + isWritable: false, + }, + withdrawAccountsCollateralTokenProgram: { + value: input.withdrawAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsLiquidityTokenProgram: { + value: input.withdrawAccountsLiquidityTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsInstructionSysvarAccount: { + value: input.withdrawAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + depositFarmsAccountsObligationFarmUserState: { + value: input.depositFarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + depositFarmsAccountsReserveFarmState: { + value: input.depositFarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + withdrawFarmsAccountsObligationFarmUserState: { + value: input.withdrawFarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + withdrawFarmsAccountsReserveFarmState: { + value: input.withdrawFarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.depositAccountsInstructionSysvarAccount.value) { + accounts.depositAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + if (!accounts.withdrawAccountsInstructionSysvarAccount.value) { + accounts.withdrawAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.depositAccountsOwner), + getAccountMeta(accounts.depositAccountsObligation), + getAccountMeta(accounts.depositAccountsLendingMarket), + getAccountMeta(accounts.depositAccountsLendingMarketAuthority), + getAccountMeta(accounts.depositAccountsReserve), + getAccountMeta(accounts.depositAccountsReserveLiquidityMint), + getAccountMeta(accounts.depositAccountsReserveLiquiditySupply), + getAccountMeta(accounts.depositAccountsReserveCollateralMint), + getAccountMeta( + accounts.depositAccountsReserveDestinationDepositCollateral, + ), + getAccountMeta(accounts.depositAccountsUserSourceLiquidity), + getAccountMeta( + accounts.depositAccountsPlaceholderUserDestinationCollateral, + ), + getAccountMeta(accounts.depositAccountsCollateralTokenProgram), + getAccountMeta(accounts.depositAccountsLiquidityTokenProgram), + getAccountMeta(accounts.depositAccountsInstructionSysvarAccount), + getAccountMeta(accounts.withdrawAccountsOwner), + getAccountMeta(accounts.withdrawAccountsObligation), + getAccountMeta(accounts.withdrawAccountsLendingMarket), + getAccountMeta(accounts.withdrawAccountsLendingMarketAuthority), + getAccountMeta(accounts.withdrawAccountsWithdrawReserve), + getAccountMeta(accounts.withdrawAccountsReserveLiquidityMint), + getAccountMeta(accounts.withdrawAccountsReserveSourceCollateral), + getAccountMeta(accounts.withdrawAccountsReserveCollateralMint), + getAccountMeta(accounts.withdrawAccountsReserveLiquiditySupply), + getAccountMeta(accounts.withdrawAccountsUserDestinationLiquidity), + getAccountMeta( + accounts.withdrawAccountsPlaceholderUserDestinationCollateral, + ), + getAccountMeta(accounts.withdrawAccountsCollateralTokenProgram), + getAccountMeta(accounts.withdrawAccountsLiquidityTokenProgram), + getAccountMeta(accounts.withdrawAccountsInstructionSysvarAccount), + getAccountMeta(accounts.depositFarmsAccountsObligationFarmUserState), + getAccountMeta(accounts.depositFarmsAccountsReserveFarmState), + getAccountMeta(accounts.withdrawFarmsAccountsObligationFarmUserState), + getAccountMeta(accounts.withdrawFarmsAccountsReserveFarmState), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getDepositAndWithdrawInstructionDataEncoder().encode( + args as DepositAndWithdrawInstructionDataArgs, + ), + } as DepositAndWithdrawInstruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountDepositFarmsAccountsObligationFarmUserState, + TAccountDepositFarmsAccountsReserveFarmState, + TAccountWithdrawFarmsAccountsObligationFarmUserState, + TAccountWithdrawFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedDepositAndWithdrawInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + depositAccountsOwner: TAccountMetas[0]; + depositAccountsObligation: TAccountMetas[1]; + depositAccountsLendingMarket: TAccountMetas[2]; + depositAccountsLendingMarketAuthority: TAccountMetas[3]; + depositAccountsReserve: TAccountMetas[4]; + depositAccountsReserveLiquidityMint: TAccountMetas[5]; + depositAccountsReserveLiquiditySupply: TAccountMetas[6]; + depositAccountsReserveCollateralMint: TAccountMetas[7]; + depositAccountsReserveDestinationDepositCollateral: TAccountMetas[8]; + depositAccountsUserSourceLiquidity: TAccountMetas[9]; + depositAccountsPlaceholderUserDestinationCollateral?: + | TAccountMetas[10] + | undefined; + depositAccountsCollateralTokenProgram: TAccountMetas[11]; + depositAccountsLiquidityTokenProgram: TAccountMetas[12]; + depositAccountsInstructionSysvarAccount: TAccountMetas[13]; + withdrawAccountsOwner: TAccountMetas[14]; + withdrawAccountsObligation: TAccountMetas[15]; + withdrawAccountsLendingMarket: TAccountMetas[16]; + withdrawAccountsLendingMarketAuthority: TAccountMetas[17]; + withdrawAccountsWithdrawReserve: TAccountMetas[18]; + withdrawAccountsReserveLiquidityMint: TAccountMetas[19]; + withdrawAccountsReserveSourceCollateral: TAccountMetas[20]; + withdrawAccountsReserveCollateralMint: TAccountMetas[21]; + withdrawAccountsReserveLiquiditySupply: TAccountMetas[22]; + withdrawAccountsUserDestinationLiquidity: TAccountMetas[23]; + withdrawAccountsPlaceholderUserDestinationCollateral?: + | TAccountMetas[24] + | undefined; + withdrawAccountsCollateralTokenProgram: TAccountMetas[25]; + withdrawAccountsLiquidityTokenProgram: TAccountMetas[26]; + withdrawAccountsInstructionSysvarAccount: TAccountMetas[27]; + depositFarmsAccountsObligationFarmUserState?: TAccountMetas[28] | undefined; + depositFarmsAccountsReserveFarmState?: TAccountMetas[29] | undefined; + withdrawFarmsAccountsObligationFarmUserState?: + | TAccountMetas[30] + | undefined; + withdrawFarmsAccountsReserveFarmState?: TAccountMetas[31] | undefined; + farmsProgram: TAccountMetas[32]; + }; + data: DepositAndWithdrawInstructionData; +} + +export function parseDepositAndWithdrawInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositAndWithdrawInstruction { + if (instruction.accounts.length < 33) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + depositAccountsOwner: getNextAccount(), + depositAccountsObligation: getNextAccount(), + depositAccountsLendingMarket: getNextAccount(), + depositAccountsLendingMarketAuthority: getNextAccount(), + depositAccountsReserve: getNextAccount(), + depositAccountsReserveLiquidityMint: getNextAccount(), + depositAccountsReserveLiquiditySupply: getNextAccount(), + depositAccountsReserveCollateralMint: getNextAccount(), + depositAccountsReserveDestinationDepositCollateral: getNextAccount(), + depositAccountsUserSourceLiquidity: getNextAccount(), + depositAccountsPlaceholderUserDestinationCollateral: + getNextOptionalAccount(), + depositAccountsCollateralTokenProgram: getNextAccount(), + depositAccountsLiquidityTokenProgram: getNextAccount(), + depositAccountsInstructionSysvarAccount: getNextAccount(), + withdrawAccountsOwner: getNextAccount(), + withdrawAccountsObligation: getNextAccount(), + withdrawAccountsLendingMarket: getNextAccount(), + withdrawAccountsLendingMarketAuthority: getNextAccount(), + withdrawAccountsWithdrawReserve: getNextAccount(), + withdrawAccountsReserveLiquidityMint: getNextAccount(), + withdrawAccountsReserveSourceCollateral: getNextAccount(), + withdrawAccountsReserveCollateralMint: getNextAccount(), + withdrawAccountsReserveLiquiditySupply: getNextAccount(), + withdrawAccountsUserDestinationLiquidity: getNextAccount(), + withdrawAccountsPlaceholderUserDestinationCollateral: + getNextOptionalAccount(), + withdrawAccountsCollateralTokenProgram: getNextAccount(), + withdrawAccountsLiquidityTokenProgram: getNextAccount(), + withdrawAccountsInstructionSysvarAccount: getNextAccount(), + depositFarmsAccountsObligationFarmUserState: getNextOptionalAccount(), + depositFarmsAccountsReserveFarmState: getNextOptionalAccount(), + withdrawFarmsAccountsObligationFarmUserState: getNextOptionalAccount(), + withdrawFarmsAccountsReserveFarmState: getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getDepositAndWithdrawInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositObligationCollateral.ts b/clients/kamino-lending/src/generated/instructions/depositObligationCollateral.ts new file mode 100644 index 00000000..3f734702 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositObligationCollateral.ts @@ -0,0 +1,316 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_OBLIGATION_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([108, 209, 4, 72, 21, 22, 118, 133]); + +export function getDepositObligationCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_OBLIGATION_COLLATERAL_DISCRIMINATOR, + ); +} + +export type DepositObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountDepositReserve extends string | AccountMeta = string, + TAccountReserveDestinationCollateral extends string | AccountMeta = string, + TAccountUserSourceCollateral extends string | AccountMeta = string, + TAccountTokenProgram extends + | string + | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountDepositReserve extends string + ? WritableAccount + : TAccountDepositReserve, + TAccountReserveDestinationCollateral extends string + ? WritableAccount + : TAccountReserveDestinationCollateral, + TAccountUserSourceCollateral extends string + ? WritableAccount + : TAccountUserSourceCollateral, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface DepositObligationCollateralInstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface DepositObligationCollateralInstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getDepositObligationCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_OBLIGATION_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getDepositObligationCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getDepositObligationCollateralInstructionDataCodec(): FixedSizeCodec< + DepositObligationCollateralInstructionDataArgs, + DepositObligationCollateralInstructionData +> { + return combineCodec( + getDepositObligationCollateralInstructionDataEncoder(), + getDepositObligationCollateralInstructionDataDecoder(), + ); +} + +export interface DepositObligationCollateralInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountDepositReserve extends string = string, + TAccountReserveDestinationCollateral extends string = string, + TAccountUserSourceCollateral extends string = string, + TAccountTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + depositReserve: Address; + reserveDestinationCollateral: Address; + userSourceCollateral: Address; + tokenProgram?: Address; + instructionSysvarAccount?: Address; + collateralAmount: DepositObligationCollateralInstructionDataArgs["collateralAmount"]; +} + +export function getDepositObligationCollateralInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountDepositReserve extends string, + TAccountReserveDestinationCollateral extends string, + TAccountUserSourceCollateral extends string, + TAccountTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositObligationCollateralInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountDepositReserve, + TAccountReserveDestinationCollateral, + TAccountUserSourceCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): DepositObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountDepositReserve, + TAccountReserveDestinationCollateral, + TAccountUserSourceCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + depositReserve: { value: input.depositReserve ?? null, isWritable: true }, + reserveDestinationCollateral: { + value: input.reserveDestinationCollateral ?? null, + isWritable: true, + }, + userSourceCollateral: { + value: input.userSourceCollateral ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; + } + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.depositReserve), + getAccountMeta(accounts.reserveDestinationCollateral), + getAccountMeta(accounts.userSourceCollateral), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getDepositObligationCollateralInstructionDataEncoder().encode( + args as DepositObligationCollateralInstructionDataArgs, + ), + } as DepositObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountDepositReserve, + TAccountReserveDestinationCollateral, + TAccountUserSourceCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedDepositObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + depositReserve: TAccountMetas[3]; + reserveDestinationCollateral: TAccountMetas[4]; + userSourceCollateral: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + instructionSysvarAccount: TAccountMetas[7]; + }; + data: DepositObligationCollateralInstructionData; +} + +export function parseDepositObligationCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositObligationCollateralInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + depositReserve: getNextAccount(), + reserveDestinationCollateral: getNextAccount(), + userSourceCollateral: getNextAccount(), + tokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getDepositObligationCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositObligationCollateralV2.ts b/clients/kamino-lending/src/generated/instructions/depositObligationCollateralV2.ts new file mode 100644 index 00000000..aa030963 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositObligationCollateralV2.ts @@ -0,0 +1,422 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([137, 145, 151, 94, 167, 113, 4, 145]); + +export function getDepositObligationCollateralV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + ); +} + +export type DepositObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountDepositAccountsOwner extends string | AccountMeta = string, + TAccountDepositAccountsObligation extends string | AccountMeta = string, + TAccountDepositAccountsLendingMarket extends string | AccountMeta = string, + TAccountDepositAccountsDepositReserve extends string | AccountMeta = string, + TAccountDepositAccountsReserveDestinationCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsUserSourceCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsTokenProgram extends string | AccountMeta = string, + TAccountDepositAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountDepositAccountsOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation extends string + ? WritableAccount + : TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsDepositReserve extends string + ? WritableAccount + : TAccountDepositAccountsDepositReserve, + TAccountDepositAccountsReserveDestinationCollateral extends string + ? WritableAccount + : TAccountDepositAccountsReserveDestinationCollateral, + TAccountDepositAccountsUserSourceCollateral extends string + ? WritableAccount + : TAccountDepositAccountsUserSourceCollateral, + TAccountDepositAccountsTokenProgram extends string + ? ReadonlyAccount + : TAccountDepositAccountsTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountDepositAccountsInstructionSysvarAccount, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface DepositObligationCollateralV2InstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface DepositObligationCollateralV2InstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getDepositObligationCollateralV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + }), + ); +} + +export function getDepositObligationCollateralV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getDepositObligationCollateralV2InstructionDataCodec(): FixedSizeCodec< + DepositObligationCollateralV2InstructionDataArgs, + DepositObligationCollateralV2InstructionData +> { + return combineCodec( + getDepositObligationCollateralV2InstructionDataEncoder(), + getDepositObligationCollateralV2InstructionDataDecoder(), + ); +} + +export interface DepositObligationCollateralV2Input< + TAccountDepositAccountsOwner extends string = string, + TAccountDepositAccountsObligation extends string = string, + TAccountDepositAccountsLendingMarket extends string = string, + TAccountDepositAccountsDepositReserve extends string = string, + TAccountDepositAccountsReserveDestinationCollateral extends string = string, + TAccountDepositAccountsUserSourceCollateral extends string = string, + TAccountDepositAccountsTokenProgram extends string = string, + TAccountDepositAccountsInstructionSysvarAccount extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState extends + string = string, + TAccountFarmsProgram extends string = string, +> { + depositAccountsOwner: TransactionSigner; + depositAccountsObligation: Address; + depositAccountsLendingMarket: Address; + depositAccountsDepositReserve: Address; + depositAccountsReserveDestinationCollateral: Address; + depositAccountsUserSourceCollateral: Address; + depositAccountsTokenProgram: Address; + depositAccountsInstructionSysvarAccount?: Address; + lendingMarketAuthority: Address; + depositObligationCollateralV2FarmsAccountsObligationFarmUserState?: Address; + depositObligationCollateralV2FarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + collateralAmount: DepositObligationCollateralV2InstructionDataArgs["collateralAmount"]; +} + +export function getDepositObligationCollateralV2Instruction< + TAccountDepositAccountsOwner extends string, + TAccountDepositAccountsObligation extends string, + TAccountDepositAccountsLendingMarket extends string, + TAccountDepositAccountsDepositReserve extends string, + TAccountDepositAccountsReserveDestinationCollateral extends string, + TAccountDepositAccountsUserSourceCollateral extends string, + TAccountDepositAccountsTokenProgram extends string, + TAccountDepositAccountsInstructionSysvarAccount extends string, + TAccountLendingMarketAuthority extends string, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState extends + string, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState extends + string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositObligationCollateralV2Input< + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsDepositReserve, + TAccountDepositAccountsReserveDestinationCollateral, + TAccountDepositAccountsUserSourceCollateral, + TAccountDepositAccountsTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountLendingMarketAuthority, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): DepositObligationCollateralV2Instruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsDepositReserve, + TAccountDepositAccountsReserveDestinationCollateral, + TAccountDepositAccountsUserSourceCollateral, + TAccountDepositAccountsTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountLendingMarketAuthority, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + depositAccountsOwner: { + value: input.depositAccountsOwner ?? null, + isWritable: false, + }, + depositAccountsObligation: { + value: input.depositAccountsObligation ?? null, + isWritable: true, + }, + depositAccountsLendingMarket: { + value: input.depositAccountsLendingMarket ?? null, + isWritable: false, + }, + depositAccountsDepositReserve: { + value: input.depositAccountsDepositReserve ?? null, + isWritable: true, + }, + depositAccountsReserveDestinationCollateral: { + value: input.depositAccountsReserveDestinationCollateral ?? null, + isWritable: true, + }, + depositAccountsUserSourceCollateral: { + value: input.depositAccountsUserSourceCollateral ?? null, + isWritable: true, + }, + depositAccountsTokenProgram: { + value: input.depositAccountsTokenProgram ?? null, + isWritable: false, + }, + depositAccountsInstructionSysvarAccount: { + value: input.depositAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + depositObligationCollateralV2FarmsAccountsObligationFarmUserState: { + value: + input.depositObligationCollateralV2FarmsAccountsObligationFarmUserState ?? + null, + isWritable: true, + }, + depositObligationCollateralV2FarmsAccountsReserveFarmState: { + value: + input.depositObligationCollateralV2FarmsAccountsReserveFarmState ?? + null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.depositAccountsInstructionSysvarAccount.value) { + accounts.depositAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.depositAccountsOwner), + getAccountMeta(accounts.depositAccountsObligation), + getAccountMeta(accounts.depositAccountsLendingMarket), + getAccountMeta(accounts.depositAccountsDepositReserve), + getAccountMeta(accounts.depositAccountsReserveDestinationCollateral), + getAccountMeta(accounts.depositAccountsUserSourceCollateral), + getAccountMeta(accounts.depositAccountsTokenProgram), + getAccountMeta(accounts.depositAccountsInstructionSysvarAccount), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta( + accounts.depositObligationCollateralV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta( + accounts.depositObligationCollateralV2FarmsAccountsReserveFarmState, + ), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getDepositObligationCollateralV2InstructionDataEncoder().encode( + args as DepositObligationCollateralV2InstructionDataArgs, + ), + } as DepositObligationCollateralV2Instruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsDepositReserve, + TAccountDepositAccountsReserveDestinationCollateral, + TAccountDepositAccountsUserSourceCollateral, + TAccountDepositAccountsTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountLendingMarketAuthority, + TAccountDepositObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedDepositObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + depositAccountsOwner: TAccountMetas[0]; + depositAccountsObligation: TAccountMetas[1]; + depositAccountsLendingMarket: TAccountMetas[2]; + depositAccountsDepositReserve: TAccountMetas[3]; + depositAccountsReserveDestinationCollateral: TAccountMetas[4]; + depositAccountsUserSourceCollateral: TAccountMetas[5]; + depositAccountsTokenProgram: TAccountMetas[6]; + depositAccountsInstructionSysvarAccount: TAccountMetas[7]; + lendingMarketAuthority: TAccountMetas[8]; + depositObligationCollateralV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[9] + | undefined; + depositObligationCollateralV2FarmsAccountsReserveFarmState?: + | TAccountMetas[10] + | undefined; + farmsProgram: TAccountMetas[11]; + }; + data: DepositObligationCollateralV2InstructionData; +} + +export function parseDepositObligationCollateralV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositObligationCollateralV2Instruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + depositAccountsOwner: getNextAccount(), + depositAccountsObligation: getNextAccount(), + depositAccountsLendingMarket: getNextAccount(), + depositAccountsDepositReserve: getNextAccount(), + depositAccountsReserveDestinationCollateral: getNextAccount(), + depositAccountsUserSourceCollateral: getNextAccount(), + depositAccountsTokenProgram: getNextAccount(), + depositAccountsInstructionSysvarAccount: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + depositObligationCollateralV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + depositObligationCollateralV2FarmsAccountsReserveFarmState: + getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getDepositObligationCollateralV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositReserveLiquidity.ts b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidity.ts new file mode 100644 index 00000000..c2eabc03 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidity.ts @@ -0,0 +1,384 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_RESERVE_LIQUIDITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([169, 201, 30, 126, 6, 205, 102, 68]); + +export function getDepositReserveLiquidityDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_RESERVE_LIQUIDITY_DISCRIMINATOR, + ); +} + +export type DepositReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveLiquiditySupply extends string | AccountMeta = string, + TAccountReserveCollateralMint extends string | AccountMeta = string, + TAccountUserSourceLiquidity extends string | AccountMeta = string, + TAccountUserDestinationCollateral extends string | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountLiquidityTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply extends string + ? WritableAccount + : TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint extends string + ? WritableAccount + : TAccountReserveCollateralMint, + TAccountUserSourceLiquidity extends string + ? WritableAccount + : TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral extends string + ? WritableAccount + : TAccountUserDestinationCollateral, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface DepositReserveLiquidityInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface DepositReserveLiquidityInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getDepositReserveLiquidityInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_RESERVE_LIQUIDITY_DISCRIMINATOR, + }), + ); +} + +export function getDepositReserveLiquidityInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getDepositReserveLiquidityInstructionDataCodec(): FixedSizeCodec< + DepositReserveLiquidityInstructionDataArgs, + DepositReserveLiquidityInstructionData +> { + return combineCodec( + getDepositReserveLiquidityInstructionDataEncoder(), + getDepositReserveLiquidityInstructionDataDecoder(), + ); +} + +export interface DepositReserveLiquidityInput< + TAccountOwner extends string = string, + TAccountReserve extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveLiquiditySupply extends string = string, + TAccountReserveCollateralMint extends string = string, + TAccountUserSourceLiquidity extends string = string, + TAccountUserDestinationCollateral extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountLiquidityTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + reserve: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + reserveLiquidityMint: Address; + reserveLiquiditySupply: Address; + reserveCollateralMint: Address; + userSourceLiquidity: Address; + userDestinationCollateral: Address; + collateralTokenProgram: Address; + liquidityTokenProgram: Address; + instructionSysvarAccount?: Address; + liquidityAmount: DepositReserveLiquidityInstructionDataArgs["liquidityAmount"]; +} + +export function getDepositReserveLiquidityInstruction< + TAccountOwner extends string, + TAccountReserve extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveLiquiditySupply extends string, + TAccountReserveCollateralMint extends string, + TAccountUserSourceLiquidity extends string, + TAccountUserDestinationCollateral extends string, + TAccountCollateralTokenProgram extends string, + TAccountLiquidityTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositReserveLiquidityInput< + TAccountOwner, + TAccountReserve, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): DepositReserveLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountReserve, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveLiquiditySupply: { + value: input.reserveLiquiditySupply ?? null, + isWritable: true, + }, + reserveCollateralMint: { + value: input.reserveCollateralMint ?? null, + isWritable: true, + }, + userSourceLiquidity: { + value: input.userSourceLiquidity ?? null, + isWritable: true, + }, + userDestinationCollateral: { + value: input.userDestinationCollateral ?? null, + isWritable: true, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + liquidityTokenProgram: { + value: input.liquidityTokenProgram ?? null, + isWritable: false, + }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveLiquiditySupply), + getAccountMeta(accounts.reserveCollateralMint), + getAccountMeta(accounts.userSourceLiquidity), + getAccountMeta(accounts.userDestinationCollateral), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.liquidityTokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getDepositReserveLiquidityInstructionDataEncoder().encode( + args as DepositReserveLiquidityInstructionDataArgs, + ), + } as DepositReserveLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountReserve, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedDepositReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + reserve: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveLiquiditySupply: TAccountMetas[5]; + reserveCollateralMint: TAccountMetas[6]; + userSourceLiquidity: TAccountMetas[7]; + userDestinationCollateral: TAccountMetas[8]; + collateralTokenProgram: TAccountMetas[9]; + liquidityTokenProgram: TAccountMetas[10]; + instructionSysvarAccount: TAccountMetas[11]; + }; + data: DepositReserveLiquidityInstructionData; +} + +export function parseDepositReserveLiquidityInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositReserveLiquidityInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + reserve: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveLiquiditySupply: getNextAccount(), + reserveCollateralMint: getNextAccount(), + userSourceLiquidity: getNextAccount(), + userDestinationCollateral: getNextAccount(), + collateralTokenProgram: getNextAccount(), + liquidityTokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getDepositReserveLiquidityInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateral.ts b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateral.ts new file mode 100644 index 00000000..c18eb539 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateral.ts @@ -0,0 +1,429 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([129, 199, 4, 2, 222, 39, 26, 46]); + +export function getDepositReserveLiquidityAndObligationCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_DISCRIMINATOR, + ); +} + +export type DepositReserveLiquidityAndObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveLiquiditySupply extends string | AccountMeta = string, + TAccountReserveCollateralMint extends string | AccountMeta = string, + TAccountReserveDestinationDepositCollateral extends + | string + | AccountMeta = string, + TAccountUserSourceLiquidity extends string | AccountMeta = string, + TAccountPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountLiquidityTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply extends string + ? WritableAccount + : TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint extends string + ? WritableAccount + : TAccountReserveCollateralMint, + TAccountReserveDestinationDepositCollateral extends string + ? WritableAccount + : TAccountReserveDestinationDepositCollateral, + TAccountUserSourceLiquidity extends string + ? WritableAccount + : TAccountUserSourceLiquidity, + TAccountPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface DepositReserveLiquidityAndObligationCollateralInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface DepositReserveLiquidityAndObligationCollateralInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getDepositReserveLiquidityAndObligationCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getDepositReserveLiquidityAndObligationCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getDepositReserveLiquidityAndObligationCollateralInstructionDataCodec(): FixedSizeCodec< + DepositReserveLiquidityAndObligationCollateralInstructionDataArgs, + DepositReserveLiquidityAndObligationCollateralInstructionData +> { + return combineCodec( + getDepositReserveLiquidityAndObligationCollateralInstructionDataEncoder(), + getDepositReserveLiquidityAndObligationCollateralInstructionDataDecoder(), + ); +} + +export interface DepositReserveLiquidityAndObligationCollateralInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveLiquiditySupply extends string = string, + TAccountReserveCollateralMint extends string = string, + TAccountReserveDestinationDepositCollateral extends string = string, + TAccountUserSourceLiquidity extends string = string, + TAccountPlaceholderUserDestinationCollateral extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountLiquidityTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + reserve: Address; + reserveLiquidityMint: Address; + reserveLiquiditySupply: Address; + reserveCollateralMint: Address; + reserveDestinationDepositCollateral: Address; + userSourceLiquidity: Address; + placeholderUserDestinationCollateral?: Address; + collateralTokenProgram: Address; + liquidityTokenProgram: Address; + instructionSysvarAccount?: Address; + liquidityAmount: DepositReserveLiquidityAndObligationCollateralInstructionDataArgs["liquidityAmount"]; +} + +export function getDepositReserveLiquidityAndObligationCollateralInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveLiquiditySupply extends string, + TAccountReserveCollateralMint extends string, + TAccountReserveDestinationDepositCollateral extends string, + TAccountUserSourceLiquidity extends string, + TAccountPlaceholderUserDestinationCollateral extends string, + TAccountCollateralTokenProgram extends string, + TAccountLiquidityTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositReserveLiquidityAndObligationCollateralInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountReserveDestinationDepositCollateral, + TAccountUserSourceLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): DepositReserveLiquidityAndObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountReserveDestinationDepositCollateral, + TAccountUserSourceLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: true }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveLiquiditySupply: { + value: input.reserveLiquiditySupply ?? null, + isWritable: true, + }, + reserveCollateralMint: { + value: input.reserveCollateralMint ?? null, + isWritable: true, + }, + reserveDestinationDepositCollateral: { + value: input.reserveDestinationDepositCollateral ?? null, + isWritable: true, + }, + userSourceLiquidity: { + value: input.userSourceLiquidity ?? null, + isWritable: true, + }, + placeholderUserDestinationCollateral: { + value: input.placeholderUserDestinationCollateral ?? null, + isWritable: false, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + liquidityTokenProgram: { + value: input.liquidityTokenProgram ?? null, + isWritable: false, + }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveLiquiditySupply), + getAccountMeta(accounts.reserveCollateralMint), + getAccountMeta(accounts.reserveDestinationDepositCollateral), + getAccountMeta(accounts.userSourceLiquidity), + getAccountMeta(accounts.placeholderUserDestinationCollateral), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.liquidityTokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getDepositReserveLiquidityAndObligationCollateralInstructionDataEncoder().encode( + args as DepositReserveLiquidityAndObligationCollateralInstructionDataArgs, + ), + } as DepositReserveLiquidityAndObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountReserveCollateralMint, + TAccountReserveDestinationDepositCollateral, + TAccountUserSourceLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedDepositReserveLiquidityAndObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + reserve: TAccountMetas[4]; + reserveLiquidityMint: TAccountMetas[5]; + reserveLiquiditySupply: TAccountMetas[6]; + reserveCollateralMint: TAccountMetas[7]; + reserveDestinationDepositCollateral: TAccountMetas[8]; + userSourceLiquidity: TAccountMetas[9]; + placeholderUserDestinationCollateral?: TAccountMetas[10] | undefined; + collateralTokenProgram: TAccountMetas[11]; + liquidityTokenProgram: TAccountMetas[12]; + instructionSysvarAccount: TAccountMetas[13]; + }; + data: DepositReserveLiquidityAndObligationCollateralInstructionData; +} + +export function parseDepositReserveLiquidityAndObligationCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositReserveLiquidityAndObligationCollateralInstruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 14) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveLiquiditySupply: getNextAccount(), + reserveCollateralMint: getNextAccount(), + reserveDestinationDepositCollateral: getNextAccount(), + userSourceLiquidity: getNextAccount(), + placeholderUserDestinationCollateral: getNextOptionalAccount(), + collateralTokenProgram: getNextAccount(), + liquidityTokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getDepositReserveLiquidityAndObligationCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateralV2.ts b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateralV2.ts new file mode 100644 index 00000000..91d9b420 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositReserveLiquidityAndObligationCollateralV2.ts @@ -0,0 +1,536 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([216, 224, 191, 27, 204, 151, 102, 175]); + +export function getDepositReserveLiquidityAndObligationCollateralV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + ); +} + +export type DepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountDepositAccountsOwner extends string | AccountMeta = string, + TAccountDepositAccountsObligation extends string | AccountMeta = string, + TAccountDepositAccountsLendingMarket extends string | AccountMeta = string, + TAccountDepositAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserve extends string | AccountMeta = string, + TAccountDepositAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsUserSourceLiquidity extends + | string + | AccountMeta = string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountDepositAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountDepositAccountsLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountDepositAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountDepositAccountsOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation extends string + ? WritableAccount + : TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve extends string + ? WritableAccount + : TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply extends string + ? WritableAccount + : TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint extends string + ? WritableAccount + : TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral extends string + ? WritableAccount + : TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity extends string + ? WritableAccount + : TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountDepositAccountsInstructionSysvarAccount, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface DepositReserveLiquidityAndObligationCollateralV2InstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface DepositReserveLiquidityAndObligationCollateralV2InstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getDepositReserveLiquidityAndObligationCollateralV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + }), + ); +} + +export function getDepositReserveLiquidityAndObligationCollateralV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getDepositReserveLiquidityAndObligationCollateralV2InstructionDataCodec(): FixedSizeCodec< + DepositReserveLiquidityAndObligationCollateralV2InstructionDataArgs, + DepositReserveLiquidityAndObligationCollateralV2InstructionData +> { + return combineCodec( + getDepositReserveLiquidityAndObligationCollateralV2InstructionDataEncoder(), + getDepositReserveLiquidityAndObligationCollateralV2InstructionDataDecoder(), + ); +} + +export interface DepositReserveLiquidityAndObligationCollateralV2Input< + TAccountDepositAccountsOwner extends string = string, + TAccountDepositAccountsObligation extends string = string, + TAccountDepositAccountsLendingMarket extends string = string, + TAccountDepositAccountsLendingMarketAuthority extends string = string, + TAccountDepositAccountsReserve extends string = string, + TAccountDepositAccountsReserveLiquidityMint extends string = string, + TAccountDepositAccountsReserveLiquiditySupply extends string = string, + TAccountDepositAccountsReserveCollateralMint extends string = string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends + string = string, + TAccountDepositAccountsUserSourceLiquidity extends string = string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends + string = string, + TAccountDepositAccountsCollateralTokenProgram extends string = string, + TAccountDepositAccountsLiquidityTokenProgram extends string = string, + TAccountDepositAccountsInstructionSysvarAccount extends string = string, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState extends + string = string, + TAccountFarmsProgram extends string = string, +> { + depositAccountsOwner: TransactionSigner; + depositAccountsObligation: Address; + depositAccountsLendingMarket: Address; + depositAccountsLendingMarketAuthority: Address; + depositAccountsReserve: Address; + depositAccountsReserveLiquidityMint: Address; + depositAccountsReserveLiquiditySupply: Address; + depositAccountsReserveCollateralMint: Address; + depositAccountsReserveDestinationDepositCollateral: Address; + depositAccountsUserSourceLiquidity: Address; + depositAccountsPlaceholderUserDestinationCollateral?: Address; + depositAccountsCollateralTokenProgram: Address; + depositAccountsLiquidityTokenProgram: Address; + depositAccountsInstructionSysvarAccount?: Address; + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState?: Address; + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + liquidityAmount: DepositReserveLiquidityAndObligationCollateralV2InstructionDataArgs["liquidityAmount"]; +} + +export function getDepositReserveLiquidityAndObligationCollateralV2Instruction< + TAccountDepositAccountsOwner extends string, + TAccountDepositAccountsObligation extends string, + TAccountDepositAccountsLendingMarket extends string, + TAccountDepositAccountsLendingMarketAuthority extends string, + TAccountDepositAccountsReserve extends string, + TAccountDepositAccountsReserveLiquidityMint extends string, + TAccountDepositAccountsReserveLiquiditySupply extends string, + TAccountDepositAccountsReserveCollateralMint extends string, + TAccountDepositAccountsReserveDestinationDepositCollateral extends string, + TAccountDepositAccountsUserSourceLiquidity extends string, + TAccountDepositAccountsPlaceholderUserDestinationCollateral extends string, + TAccountDepositAccountsCollateralTokenProgram extends string, + TAccountDepositAccountsLiquidityTokenProgram extends string, + TAccountDepositAccountsInstructionSysvarAccount extends string, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState extends + string, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState extends + string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: DepositReserveLiquidityAndObligationCollateralV2Input< + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): DepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + depositAccountsOwner: { + value: input.depositAccountsOwner ?? null, + isWritable: true, + }, + depositAccountsObligation: { + value: input.depositAccountsObligation ?? null, + isWritable: true, + }, + depositAccountsLendingMarket: { + value: input.depositAccountsLendingMarket ?? null, + isWritable: false, + }, + depositAccountsLendingMarketAuthority: { + value: input.depositAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + depositAccountsReserve: { + value: input.depositAccountsReserve ?? null, + isWritable: true, + }, + depositAccountsReserveLiquidityMint: { + value: input.depositAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + depositAccountsReserveLiquiditySupply: { + value: input.depositAccountsReserveLiquiditySupply ?? null, + isWritable: true, + }, + depositAccountsReserveCollateralMint: { + value: input.depositAccountsReserveCollateralMint ?? null, + isWritable: true, + }, + depositAccountsReserveDestinationDepositCollateral: { + value: input.depositAccountsReserveDestinationDepositCollateral ?? null, + isWritable: true, + }, + depositAccountsUserSourceLiquidity: { + value: input.depositAccountsUserSourceLiquidity ?? null, + isWritable: true, + }, + depositAccountsPlaceholderUserDestinationCollateral: { + value: input.depositAccountsPlaceholderUserDestinationCollateral ?? null, + isWritable: false, + }, + depositAccountsCollateralTokenProgram: { + value: input.depositAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + depositAccountsLiquidityTokenProgram: { + value: input.depositAccountsLiquidityTokenProgram ?? null, + isWritable: false, + }, + depositAccountsInstructionSysvarAccount: { + value: input.depositAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState: + { + value: + input.depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState ?? + null, + isWritable: true, + }, + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState: + { + value: + input.depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState ?? + null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.depositAccountsInstructionSysvarAccount.value) { + accounts.depositAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.depositAccountsOwner), + getAccountMeta(accounts.depositAccountsObligation), + getAccountMeta(accounts.depositAccountsLendingMarket), + getAccountMeta(accounts.depositAccountsLendingMarketAuthority), + getAccountMeta(accounts.depositAccountsReserve), + getAccountMeta(accounts.depositAccountsReserveLiquidityMint), + getAccountMeta(accounts.depositAccountsReserveLiquiditySupply), + getAccountMeta(accounts.depositAccountsReserveCollateralMint), + getAccountMeta( + accounts.depositAccountsReserveDestinationDepositCollateral, + ), + getAccountMeta(accounts.depositAccountsUserSourceLiquidity), + getAccountMeta( + accounts.depositAccountsPlaceholderUserDestinationCollateral, + ), + getAccountMeta(accounts.depositAccountsCollateralTokenProgram), + getAccountMeta(accounts.depositAccountsLiquidityTokenProgram), + getAccountMeta(accounts.depositAccountsInstructionSysvarAccount), + getAccountMeta( + accounts.depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta( + accounts.depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState, + ), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getDepositReserveLiquidityAndObligationCollateralV2InstructionDataEncoder().encode( + args as DepositReserveLiquidityAndObligationCollateralV2InstructionDataArgs, + ), + } as DepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgramAddress, + TAccountDepositAccountsOwner, + TAccountDepositAccountsObligation, + TAccountDepositAccountsLendingMarket, + TAccountDepositAccountsLendingMarketAuthority, + TAccountDepositAccountsReserve, + TAccountDepositAccountsReserveLiquidityMint, + TAccountDepositAccountsReserveLiquiditySupply, + TAccountDepositAccountsReserveCollateralMint, + TAccountDepositAccountsReserveDestinationDepositCollateral, + TAccountDepositAccountsUserSourceLiquidity, + TAccountDepositAccountsPlaceholderUserDestinationCollateral, + TAccountDepositAccountsCollateralTokenProgram, + TAccountDepositAccountsLiquidityTokenProgram, + TAccountDepositAccountsInstructionSysvarAccount, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState, + TAccountDepositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedDepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + depositAccountsOwner: TAccountMetas[0]; + depositAccountsObligation: TAccountMetas[1]; + depositAccountsLendingMarket: TAccountMetas[2]; + depositAccountsLendingMarketAuthority: TAccountMetas[3]; + depositAccountsReserve: TAccountMetas[4]; + depositAccountsReserveLiquidityMint: TAccountMetas[5]; + depositAccountsReserveLiquiditySupply: TAccountMetas[6]; + depositAccountsReserveCollateralMint: TAccountMetas[7]; + depositAccountsReserveDestinationDepositCollateral: TAccountMetas[8]; + depositAccountsUserSourceLiquidity: TAccountMetas[9]; + depositAccountsPlaceholderUserDestinationCollateral?: + | TAccountMetas[10] + | undefined; + depositAccountsCollateralTokenProgram: TAccountMetas[11]; + depositAccountsLiquidityTokenProgram: TAccountMetas[12]; + depositAccountsInstructionSysvarAccount: TAccountMetas[13]; + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[14] + | undefined; + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState?: + | TAccountMetas[15] + | undefined; + farmsProgram: TAccountMetas[16]; + }; + data: DepositReserveLiquidityAndObligationCollateralV2InstructionData; +} + +export function parseDepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositReserveLiquidityAndObligationCollateralV2Instruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 17) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + depositAccountsOwner: getNextAccount(), + depositAccountsObligation: getNextAccount(), + depositAccountsLendingMarket: getNextAccount(), + depositAccountsLendingMarketAuthority: getNextAccount(), + depositAccountsReserve: getNextAccount(), + depositAccountsReserveLiquidityMint: getNextAccount(), + depositAccountsReserveLiquiditySupply: getNextAccount(), + depositAccountsReserveCollateralMint: getNextAccount(), + depositAccountsReserveDestinationDepositCollateral: getNextAccount(), + depositAccountsUserSourceLiquidity: getNextAccount(), + depositAccountsPlaceholderUserDestinationCollateral: + getNextOptionalAccount(), + depositAccountsCollateralTokenProgram: getNextAccount(), + depositAccountsLiquidityTokenProgram: getNextAccount(), + depositAccountsInstructionSysvarAccount: getNextAccount(), + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + depositReserveLiquidityAndObligationCollateralV2FarmsAccountsReserveFarmState: + getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getDepositReserveLiquidityAndObligationCollateralV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/depositToFarmVault.ts b/clients/kamino-lending/src/generated/instructions/depositToFarmVault.ts new file mode 100644 index 00000000..50bd3c6e --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/depositToFarmVault.ts @@ -0,0 +1,250 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const DEPOSIT_TO_FARM_VAULT_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([131, 166, 64, 94, 108, 213, 114, 183]); + +export function getDepositToFarmVaultDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_TO_FARM_VAULT_DISCRIMINATOR, + ); +} + +export type DepositToFarmVaultInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountDepositor extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountDepositorAta extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountDepositor extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountDepositor, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountDepositorAta extends string + ? WritableAccount + : TAccountDepositorAta, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface DepositToFarmVaultInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; +} + +export interface DepositToFarmVaultInstructionDataArgs { + amount: number | bigint; +} + +export function getDepositToFarmVaultInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_TO_FARM_VAULT_DISCRIMINATOR, + }), + ); +} + +export function getDepositToFarmVaultInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ]); +} + +export function getDepositToFarmVaultInstructionDataCodec(): FixedSizeCodec< + DepositToFarmVaultInstructionDataArgs, + DepositToFarmVaultInstructionData +> { + return combineCodec( + getDepositToFarmVaultInstructionDataEncoder(), + getDepositToFarmVaultInstructionDataDecoder(), + ); +} + +export interface DepositToFarmVaultInput< + TAccountDepositor extends string = string, + TAccountFarmState extends string = string, + TAccountFarmVault extends string = string, + TAccountDepositorAta extends string = string, + TAccountTokenProgram extends string = string, +> { + depositor: TransactionSigner; + farmState: Address; + farmVault: Address; + depositorAta: Address; + tokenProgram: Address; + amount: DepositToFarmVaultInstructionDataArgs["amount"]; +} + +export function getDepositToFarmVaultInstruction< + TAccountDepositor extends string, + TAccountFarmState extends string, + TAccountFarmVault extends string, + TAccountDepositorAta extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: DepositToFarmVaultInput< + TAccountDepositor, + TAccountFarmState, + TAccountFarmVault, + TAccountDepositorAta, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): DepositToFarmVaultInstruction< + TProgramAddress, + TAccountDepositor, + TAccountFarmState, + TAccountFarmVault, + TAccountDepositorAta, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + depositor: { value: input.depositor ?? null, isWritable: false }, + farmState: { value: input.farmState ?? null, isWritable: true }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + depositorAta: { value: input.depositorAta ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.depositor), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.depositorAta), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getDepositToFarmVaultInstructionDataEncoder().encode( + args as DepositToFarmVaultInstructionDataArgs, + ), + } as DepositToFarmVaultInstruction< + TProgramAddress, + TAccountDepositor, + TAccountFarmState, + TAccountFarmVault, + TAccountDepositorAta, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedDepositToFarmVaultInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + depositor: TAccountMetas[0]; + farmState: TAccountMetas[1]; + farmVault: TAccountMetas[2]; + depositorAta: TAccountMetas[3]; + tokenProgram: TAccountMetas[4]; + }; + data: DepositToFarmVaultInstructionData; +} + +export function parseDepositToFarmVaultInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedDepositToFarmVaultInstruction { + if (instruction.accounts.length < 5) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + depositor: getNextAccount(), + farmState: getNextAccount(), + farmVault: getNextAccount(), + depositorAta: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getDepositToFarmVaultInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/farmsIdlMissingTypes.ts b/clients/kamino-lending/src/generated/instructions/farmsIdlMissingTypes.ts new file mode 100644 index 00000000..cc2ed300 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/farmsIdlMissingTypes.ts @@ -0,0 +1,246 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; +import type { + FarmConfigOption, + FarmConfigOptionArgs, + GlobalConfigOption, + GlobalConfigOptionArgs, + LockingMode, + LockingModeArgs, + RewardType, + RewardTypeArgs, + TimeUnit, + TimeUnitArgs, +} from "../types/index.js"; +import { + getFarmConfigOptionDecoder, + getFarmConfigOptionEncoder, + getGlobalConfigOptionDecoder, + getGlobalConfigOptionEncoder, + getLockingModeDecoder, + getLockingModeEncoder, + getRewardTypeDecoder, + getRewardTypeEncoder, + getTimeUnitDecoder, + getTimeUnitEncoder, +} from "../types/index.js"; + +export const FARMS_IDL_MISSING_TYPES_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([130, 80, 38, 153, 80, 212, 182, 253]); + +export function getFarmsIdlMissingTypesDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FARMS_IDL_MISSING_TYPES_DISCRIMINATOR, + ); +} + +export type FarmsIdlMissingTypesInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountGlobalAdmin extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountGlobalAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountGlobalAdmin, + TAccountGlobalConfig extends string + ? WritableAccount + : TAccountGlobalConfig, + ...TRemainingAccounts, + ] + >; + +export interface FarmsIdlMissingTypesInstructionData { + discriminator: ReadonlyUint8Array; + globalConfigOptionKind: GlobalConfigOption; + farmConfigOptionKind: FarmConfigOption; + timeUnit: TimeUnit; + lockingMode: LockingMode; + rewardType: RewardType; +} + +export interface FarmsIdlMissingTypesInstructionDataArgs { + globalConfigOptionKind: GlobalConfigOptionArgs; + farmConfigOptionKind: FarmConfigOptionArgs; + timeUnit: TimeUnitArgs; + lockingMode: LockingModeArgs; + rewardType: RewardTypeArgs; +} + +export function getFarmsIdlMissingTypesInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["globalConfigOptionKind", getGlobalConfigOptionEncoder()], + ["farmConfigOptionKind", getFarmConfigOptionEncoder()], + ["timeUnit", getTimeUnitEncoder()], + ["lockingMode", getLockingModeEncoder()], + ["rewardType", getRewardTypeEncoder()], + ]), + (value) => ({ + ...value, + discriminator: FARMS_IDL_MISSING_TYPES_DISCRIMINATOR, + }), + ); +} + +export function getFarmsIdlMissingTypesInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["globalConfigOptionKind", getGlobalConfigOptionDecoder()], + ["farmConfigOptionKind", getFarmConfigOptionDecoder()], + ["timeUnit", getTimeUnitDecoder()], + ["lockingMode", getLockingModeDecoder()], + ["rewardType", getRewardTypeDecoder()], + ]); +} + +export function getFarmsIdlMissingTypesInstructionDataCodec(): FixedSizeCodec< + FarmsIdlMissingTypesInstructionDataArgs, + FarmsIdlMissingTypesInstructionData +> { + return combineCodec( + getFarmsIdlMissingTypesInstructionDataEncoder(), + getFarmsIdlMissingTypesInstructionDataDecoder(), + ); +} + +export interface FarmsIdlMissingTypesInput< + TAccountGlobalAdmin extends string = string, + TAccountGlobalConfig extends string = string, +> { + globalAdmin: TransactionSigner; + globalConfig: Address; + globalConfigOptionKind: FarmsIdlMissingTypesInstructionDataArgs["globalConfigOptionKind"]; + farmConfigOptionKind: FarmsIdlMissingTypesInstructionDataArgs["farmConfigOptionKind"]; + timeUnit: FarmsIdlMissingTypesInstructionDataArgs["timeUnit"]; + lockingMode: FarmsIdlMissingTypesInstructionDataArgs["lockingMode"]; + rewardType: FarmsIdlMissingTypesInstructionDataArgs["rewardType"]; +} + +export function getFarmsIdlMissingTypesInstruction< + TAccountGlobalAdmin extends string, + TAccountGlobalConfig extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: FarmsIdlMissingTypesInput, + config?: { programAddress?: TProgramAddress }, +): FarmsIdlMissingTypesInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + globalAdmin: { value: input.globalAdmin ?? null, isWritable: false }, + globalConfig: { value: input.globalConfig ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.globalAdmin), + getAccountMeta(accounts.globalConfig), + ], + programAddress, + data: getFarmsIdlMissingTypesInstructionDataEncoder().encode( + args as FarmsIdlMissingTypesInstructionDataArgs, + ), + } as FarmsIdlMissingTypesInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig + >; + + return instruction; +} + +export interface ParsedFarmsIdlMissingTypesInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + globalAdmin: TAccountMetas[0]; + globalConfig: TAccountMetas[1]; + }; + data: FarmsIdlMissingTypesInstructionData; +} + +export function parseFarmsIdlMissingTypesInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedFarmsIdlMissingTypesInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + globalAdmin: getNextAccount(), + globalConfig: getNextAccount(), + }, + data: getFarmsIdlMissingTypesInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/flashBorrowReserveLiquidity.ts b/clients/kamino-lending/src/generated/instructions/flashBorrowReserveLiquidity.ts new file mode 100644 index 00000000..1b306a03 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/flashBorrowReserveLiquidity.ts @@ -0,0 +1,390 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const FLASH_BORROW_RESERVE_LIQUIDITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([135, 231, 52, 167, 7, 52, 212, 193]); + +export function getFlashBorrowReserveLiquidityDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FLASH_BORROW_RESERVE_LIQUIDITY_DISCRIMINATOR, + ); +} + +export type FlashBorrowReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountUserTransferAuthority extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveSourceLiquidity extends string | AccountMeta = string, + TAccountUserDestinationLiquidity extends string | AccountMeta = string, + TAccountReserveLiquidityFeeReceiver extends string | AccountMeta = string, + TAccountReferrerTokenState extends string | AccountMeta = string, + TAccountReferrerAccount extends string | AccountMeta = string, + TAccountSysvarInfo extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountTokenProgram extends + | string + | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountUserTransferAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUserTransferAuthority, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveSourceLiquidity extends string + ? WritableAccount + : TAccountReserveSourceLiquidity, + TAccountUserDestinationLiquidity extends string + ? WritableAccount + : TAccountUserDestinationLiquidity, + TAccountReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState extends string + ? WritableAccount + : TAccountReferrerTokenState, + TAccountReferrerAccount extends string + ? WritableAccount + : TAccountReferrerAccount, + TAccountSysvarInfo extends string + ? ReadonlyAccount + : TAccountSysvarInfo, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface FlashBorrowReserveLiquidityInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface FlashBorrowReserveLiquidityInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getFlashBorrowReserveLiquidityInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: FLASH_BORROW_RESERVE_LIQUIDITY_DISCRIMINATOR, + }), + ); +} + +export function getFlashBorrowReserveLiquidityInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getFlashBorrowReserveLiquidityInstructionDataCodec(): FixedSizeCodec< + FlashBorrowReserveLiquidityInstructionDataArgs, + FlashBorrowReserveLiquidityInstructionData +> { + return combineCodec( + getFlashBorrowReserveLiquidityInstructionDataEncoder(), + getFlashBorrowReserveLiquidityInstructionDataDecoder(), + ); +} + +export interface FlashBorrowReserveLiquidityInput< + TAccountUserTransferAuthority extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveSourceLiquidity extends string = string, + TAccountUserDestinationLiquidity extends string = string, + TAccountReserveLiquidityFeeReceiver extends string = string, + TAccountReferrerTokenState extends string = string, + TAccountReferrerAccount extends string = string, + TAccountSysvarInfo extends string = string, + TAccountTokenProgram extends string = string, +> { + userTransferAuthority: TransactionSigner; + lendingMarketAuthority: Address; + lendingMarket: Address; + reserve: Address; + reserveLiquidityMint: Address; + reserveSourceLiquidity: Address; + userDestinationLiquidity: Address; + reserveLiquidityFeeReceiver: Address; + referrerTokenState?: Address; + referrerAccount?: Address; + sysvarInfo?: Address; + tokenProgram?: Address; + liquidityAmount: FlashBorrowReserveLiquidityInstructionDataArgs["liquidityAmount"]; +} + +export function getFlashBorrowReserveLiquidityInstruction< + TAccountUserTransferAuthority extends string, + TAccountLendingMarketAuthority extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveSourceLiquidity extends string, + TAccountUserDestinationLiquidity extends string, + TAccountReserveLiquidityFeeReceiver extends string, + TAccountReferrerTokenState extends string, + TAccountReferrerAccount extends string, + TAccountSysvarInfo extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: FlashBorrowReserveLiquidityInput< + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountUserDestinationLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): FlashBorrowReserveLiquidityInstruction< + TProgramAddress, + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountUserDestinationLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + userTransferAuthority: { + value: input.userTransferAuthority ?? null, + isWritable: false, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveSourceLiquidity: { + value: input.reserveSourceLiquidity ?? null, + isWritable: true, + }, + userDestinationLiquidity: { + value: input.userDestinationLiquidity ?? null, + isWritable: true, + }, + reserveLiquidityFeeReceiver: { + value: input.reserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + referrerTokenState: { + value: input.referrerTokenState ?? null, + isWritable: true, + }, + referrerAccount: { value: input.referrerAccount ?? null, isWritable: true }, + sysvarInfo: { value: input.sysvarInfo ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.sysvarInfo.value) { + accounts.sysvarInfo.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.userTransferAuthority), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveSourceLiquidity), + getAccountMeta(accounts.userDestinationLiquidity), + getAccountMeta(accounts.reserveLiquidityFeeReceiver), + getAccountMeta(accounts.referrerTokenState), + getAccountMeta(accounts.referrerAccount), + getAccountMeta(accounts.sysvarInfo), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getFlashBorrowReserveLiquidityInstructionDataEncoder().encode( + args as FlashBorrowReserveLiquidityInstructionDataArgs, + ), + } as FlashBorrowReserveLiquidityInstruction< + TProgramAddress, + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceLiquidity, + TAccountUserDestinationLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedFlashBorrowReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + userTransferAuthority: TAccountMetas[0]; + lendingMarketAuthority: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + reserve: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveSourceLiquidity: TAccountMetas[5]; + userDestinationLiquidity: TAccountMetas[6]; + reserveLiquidityFeeReceiver: TAccountMetas[7]; + referrerTokenState?: TAccountMetas[8] | undefined; + referrerAccount?: TAccountMetas[9] | undefined; + sysvarInfo: TAccountMetas[10]; + tokenProgram: TAccountMetas[11]; + }; + data: FlashBorrowReserveLiquidityInstructionData; +} + +export function parseFlashBorrowReserveLiquidityInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedFlashBorrowReserveLiquidityInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + userTransferAuthority: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveSourceLiquidity: getNextAccount(), + userDestinationLiquidity: getNextAccount(), + reserveLiquidityFeeReceiver: getNextAccount(), + referrerTokenState: getNextOptionalAccount(), + referrerAccount: getNextOptionalAccount(), + sysvarInfo: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getFlashBorrowReserveLiquidityInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/flashRepayReserveLiquidity.ts b/clients/kamino-lending/src/generated/instructions/flashRepayReserveLiquidity.ts new file mode 100644 index 00000000..c7263ebf --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/flashRepayReserveLiquidity.ts @@ -0,0 +1,391 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const FLASH_REPAY_RESERVE_LIQUIDITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([185, 117, 0, 203, 96, 245, 180, 186]); + +export function getFlashRepayReserveLiquidityDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FLASH_REPAY_RESERVE_LIQUIDITY_DISCRIMINATOR, + ); +} + +export type FlashRepayReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountUserTransferAuthority extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveDestinationLiquidity extends string | AccountMeta = string, + TAccountUserSourceLiquidity extends string | AccountMeta = string, + TAccountReserveLiquidityFeeReceiver extends string | AccountMeta = string, + TAccountReferrerTokenState extends string | AccountMeta = string, + TAccountReferrerAccount extends string | AccountMeta = string, + TAccountSysvarInfo extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountUserTransferAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUserTransferAuthority, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity extends string + ? WritableAccount + : TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity extends string + ? WritableAccount + : TAccountUserSourceLiquidity, + TAccountReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState extends string + ? WritableAccount + : TAccountReferrerTokenState, + TAccountReferrerAccount extends string + ? WritableAccount + : TAccountReferrerAccount, + TAccountSysvarInfo extends string + ? ReadonlyAccount + : TAccountSysvarInfo, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface FlashRepayReserveLiquidityInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; + borrowInstructionIndex: number; +} + +export interface FlashRepayReserveLiquidityInstructionDataArgs { + liquidityAmount: number | bigint; + borrowInstructionIndex: number; +} + +export function getFlashRepayReserveLiquidityInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ["borrowInstructionIndex", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: FLASH_REPAY_RESERVE_LIQUIDITY_DISCRIMINATOR, + }), + ); +} + +export function getFlashRepayReserveLiquidityInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ["borrowInstructionIndex", getU8Decoder()], + ]); +} + +export function getFlashRepayReserveLiquidityInstructionDataCodec(): FixedSizeCodec< + FlashRepayReserveLiquidityInstructionDataArgs, + FlashRepayReserveLiquidityInstructionData +> { + return combineCodec( + getFlashRepayReserveLiquidityInstructionDataEncoder(), + getFlashRepayReserveLiquidityInstructionDataDecoder(), + ); +} + +export interface FlashRepayReserveLiquidityInput< + TAccountUserTransferAuthority extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveDestinationLiquidity extends string = string, + TAccountUserSourceLiquidity extends string = string, + TAccountReserveLiquidityFeeReceiver extends string = string, + TAccountReferrerTokenState extends string = string, + TAccountReferrerAccount extends string = string, + TAccountSysvarInfo extends string = string, + TAccountTokenProgram extends string = string, +> { + userTransferAuthority: TransactionSigner; + lendingMarketAuthority: Address; + lendingMarket: Address; + reserve: Address; + reserveLiquidityMint: Address; + reserveDestinationLiquidity: Address; + userSourceLiquidity: Address; + reserveLiquidityFeeReceiver: Address; + referrerTokenState?: Address; + referrerAccount?: Address; + sysvarInfo?: Address; + tokenProgram: Address; + liquidityAmount: FlashRepayReserveLiquidityInstructionDataArgs["liquidityAmount"]; + borrowInstructionIndex: FlashRepayReserveLiquidityInstructionDataArgs["borrowInstructionIndex"]; +} + +export function getFlashRepayReserveLiquidityInstruction< + TAccountUserTransferAuthority extends string, + TAccountLendingMarketAuthority extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveDestinationLiquidity extends string, + TAccountUserSourceLiquidity extends string, + TAccountReserveLiquidityFeeReceiver extends string, + TAccountReferrerTokenState extends string, + TAccountReferrerAccount extends string, + TAccountSysvarInfo extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: FlashRepayReserveLiquidityInput< + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): FlashRepayReserveLiquidityInstruction< + TProgramAddress, + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + userTransferAuthority: { + value: input.userTransferAuthority ?? null, + isWritable: false, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveDestinationLiquidity: { + value: input.reserveDestinationLiquidity ?? null, + isWritable: true, + }, + userSourceLiquidity: { + value: input.userSourceLiquidity ?? null, + isWritable: true, + }, + reserveLiquidityFeeReceiver: { + value: input.reserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + referrerTokenState: { + value: input.referrerTokenState ?? null, + isWritable: true, + }, + referrerAccount: { value: input.referrerAccount ?? null, isWritable: true }, + sysvarInfo: { value: input.sysvarInfo ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.sysvarInfo.value) { + accounts.sysvarInfo.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.userTransferAuthority), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveDestinationLiquidity), + getAccountMeta(accounts.userSourceLiquidity), + getAccountMeta(accounts.reserveLiquidityFeeReceiver), + getAccountMeta(accounts.referrerTokenState), + getAccountMeta(accounts.referrerAccount), + getAccountMeta(accounts.sysvarInfo), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getFlashRepayReserveLiquidityInstructionDataEncoder().encode( + args as FlashRepayReserveLiquidityInstructionDataArgs, + ), + } as FlashRepayReserveLiquidityInstruction< + TProgramAddress, + TAccountUserTransferAuthority, + TAccountLendingMarketAuthority, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountReserveLiquidityFeeReceiver, + TAccountReferrerTokenState, + TAccountReferrerAccount, + TAccountSysvarInfo, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedFlashRepayReserveLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + userTransferAuthority: TAccountMetas[0]; + lendingMarketAuthority: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + reserve: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveDestinationLiquidity: TAccountMetas[5]; + userSourceLiquidity: TAccountMetas[6]; + reserveLiquidityFeeReceiver: TAccountMetas[7]; + referrerTokenState?: TAccountMetas[8] | undefined; + referrerAccount?: TAccountMetas[9] | undefined; + sysvarInfo: TAccountMetas[10]; + tokenProgram: TAccountMetas[11]; + }; + data: FlashRepayReserveLiquidityInstructionData; +} + +export function parseFlashRepayReserveLiquidityInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedFlashRepayReserveLiquidityInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + userTransferAuthority: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveDestinationLiquidity: getNextAccount(), + userSourceLiquidity: getNextAccount(), + reserveLiquidityFeeReceiver: getNextAccount(), + referrerTokenState: getNextOptionalAccount(), + referrerAccount: getNextOptionalAccount(), + sysvarInfo: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getFlashRepayReserveLiquidityInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/harvestReward.ts b/clients/kamino-lending/src/generated/instructions/harvestReward.ts new file mode 100644 index 00000000..fa813f26 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/harvestReward.ts @@ -0,0 +1,342 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const HARVEST_REWARD_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 68, 200, 228, 233, 184, 32, 226, 188, +]); + +export function getHarvestRewardDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HARVEST_REWARD_DISCRIMINATOR, + ); +} + +export type HarvestRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountRewardMint extends string | AccountMeta = string, + TAccountUserRewardAta extends string | AccountMeta = string, + TAccountRewardsVault extends string | AccountMeta = string, + TAccountRewardsTreasuryVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountGlobalConfig extends string + ? ReadonlyAccount + : TAccountGlobalConfig, + TAccountRewardMint extends string + ? ReadonlyAccount + : TAccountRewardMint, + TAccountUserRewardAta extends string + ? WritableAccount + : TAccountUserRewardAta, + TAccountRewardsVault extends string + ? WritableAccount + : TAccountRewardsVault, + TAccountRewardsTreasuryVault extends string + ? WritableAccount + : TAccountRewardsTreasuryVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface HarvestRewardInstructionData { + discriminator: ReadonlyUint8Array; + rewardIndex: bigint; +} + +export interface HarvestRewardInstructionDataArgs { + rewardIndex: number | bigint; +} + +export function getHarvestRewardInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["rewardIndex", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: HARVEST_REWARD_DISCRIMINATOR }), + ); +} + +export function getHarvestRewardInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["rewardIndex", getU64Decoder()], + ]); +} + +export function getHarvestRewardInstructionDataCodec(): FixedSizeCodec< + HarvestRewardInstructionDataArgs, + HarvestRewardInstructionData +> { + return combineCodec( + getHarvestRewardInstructionDataEncoder(), + getHarvestRewardInstructionDataDecoder(), + ); +} + +export interface HarvestRewardInput< + TAccountOwner extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountGlobalConfig extends string = string, + TAccountRewardMint extends string = string, + TAccountUserRewardAta extends string = string, + TAccountRewardsVault extends string = string, + TAccountRewardsTreasuryVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountScopePrices extends string = string, + TAccountTokenProgram extends string = string, +> { + owner: TransactionSigner; + userState: Address; + farmState: Address; + globalConfig: Address; + rewardMint: Address; + userRewardAta: Address; + rewardsVault: Address; + rewardsTreasuryVault: Address; + farmVaultsAuthority: Address; + scopePrices?: Address; + tokenProgram: Address; + rewardIndex: HarvestRewardInstructionDataArgs["rewardIndex"]; +} + +export function getHarvestRewardInstruction< + TAccountOwner extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountGlobalConfig extends string, + TAccountRewardMint extends string, + TAccountUserRewardAta extends string, + TAccountRewardsVault extends string, + TAccountRewardsTreasuryVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountScopePrices extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: HarvestRewardInput< + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountUserRewardAta, + TAccountRewardsVault, + TAccountRewardsTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountScopePrices, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): HarvestRewardInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountUserRewardAta, + TAccountRewardsVault, + TAccountRewardsTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountScopePrices, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: true }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: false }, + rewardMint: { value: input.rewardMint ?? null, isWritable: false }, + userRewardAta: { value: input.userRewardAta ?? null, isWritable: true }, + rewardsVault: { value: input.rewardsVault ?? null, isWritable: true }, + rewardsTreasuryVault: { + value: input.rewardsTreasuryVault ?? null, + isWritable: true, + }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.rewardMint), + getAccountMeta(accounts.userRewardAta), + getAccountMeta(accounts.rewardsVault), + getAccountMeta(accounts.rewardsTreasuryVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.scopePrices), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getHarvestRewardInstructionDataEncoder().encode( + args as HarvestRewardInstructionDataArgs, + ), + } as HarvestRewardInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountUserRewardAta, + TAccountRewardsVault, + TAccountRewardsTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountScopePrices, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedHarvestRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + userState: TAccountMetas[1]; + farmState: TAccountMetas[2]; + globalConfig: TAccountMetas[3]; + rewardMint: TAccountMetas[4]; + userRewardAta: TAccountMetas[5]; + rewardsVault: TAccountMetas[6]; + rewardsTreasuryVault: TAccountMetas[7]; + farmVaultsAuthority: TAccountMetas[8]; + scopePrices?: TAccountMetas[9] | undefined; + tokenProgram: TAccountMetas[10]; + }; + data: HarvestRewardInstructionData; +} + +export function parseHarvestRewardInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedHarvestRewardInstruction { + if (instruction.accounts.length < 11) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + globalConfig: getNextAccount(), + rewardMint: getNextAccount(), + userRewardAta: getNextAccount(), + rewardsVault: getNextAccount(), + rewardsTreasuryVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + scopePrices: getNextOptionalAccount(), + tokenProgram: getNextAccount(), + }, + data: getHarvestRewardInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/idlMissingTypes.ts b/clients/kamino-lending/src/generated/instructions/idlMissingTypes.ts new file mode 100644 index 00000000..220963fd --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/idlMissingTypes.ts @@ -0,0 +1,287 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + Codec, + Decoder, + Encoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; +import type { + AssetTier, + AssetTierArgs, + FeeCalculation, + FeeCalculationArgs, + ReserveFarmKind, + ReserveFarmKindArgs, + ReserveStatus, + ReserveStatusArgs, + UpdateConfigMode, + UpdateConfigModeArgs, + UpdateLendingMarketConfigValue, + UpdateLendingMarketConfigValueArgs, + UpdateLendingMarketMode, + UpdateLendingMarketModeArgs, +} from "../types/index.js"; +import { + getAssetTierDecoder, + getAssetTierEncoder, + getFeeCalculationDecoder, + getFeeCalculationEncoder, + getReserveFarmKindDecoder, + getReserveFarmKindEncoder, + getReserveStatusDecoder, + getReserveStatusEncoder, + getUpdateConfigModeDecoder, + getUpdateConfigModeEncoder, + getUpdateLendingMarketConfigValueDecoder, + getUpdateLendingMarketConfigValueEncoder, + getUpdateLendingMarketModeDecoder, + getUpdateLendingMarketModeEncoder, +} from "../types/index.js"; + +export const IDL_MISSING_TYPES_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([130, 80, 38, 153, 80, 212, 182, 253]); + +export function getIdlMissingTypesDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + IDL_MISSING_TYPES_DISCRIMINATOR, + ); +} + +export type IdlMissingTypesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + ...TRemainingAccounts, + ] + >; + +export interface IdlMissingTypesInstructionData { + discriminator: ReadonlyUint8Array; + reserveFarmKind: ReserveFarmKind; + assetTier: AssetTier; + feeCalculation: FeeCalculation; + reserveStatus: ReserveStatus; + updateConfigMode: UpdateConfigMode; + updateLendingMarketConfigValue: UpdateLendingMarketConfigValue; + updateLendingMarketConfigMode: UpdateLendingMarketMode; +} + +export interface IdlMissingTypesInstructionDataArgs { + reserveFarmKind: ReserveFarmKindArgs; + assetTier: AssetTierArgs; + feeCalculation: FeeCalculationArgs; + reserveStatus: ReserveStatusArgs; + updateConfigMode: UpdateConfigModeArgs; + updateLendingMarketConfigValue: UpdateLendingMarketConfigValueArgs; + updateLendingMarketConfigMode: UpdateLendingMarketModeArgs; +} + +export function getIdlMissingTypesInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["reserveFarmKind", getReserveFarmKindEncoder()], + ["assetTier", getAssetTierEncoder()], + ["feeCalculation", getFeeCalculationEncoder()], + ["reserveStatus", getReserveStatusEncoder()], + ["updateConfigMode", getUpdateConfigModeEncoder()], + [ + "updateLendingMarketConfigValue", + getUpdateLendingMarketConfigValueEncoder(), + ], + ["updateLendingMarketConfigMode", getUpdateLendingMarketModeEncoder()], + ]), + (value) => ({ ...value, discriminator: IDL_MISSING_TYPES_DISCRIMINATOR }), + ); +} + +export function getIdlMissingTypesInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["reserveFarmKind", getReserveFarmKindDecoder()], + ["assetTier", getAssetTierDecoder()], + ["feeCalculation", getFeeCalculationDecoder()], + ["reserveStatus", getReserveStatusDecoder()], + ["updateConfigMode", getUpdateConfigModeDecoder()], + [ + "updateLendingMarketConfigValue", + getUpdateLendingMarketConfigValueDecoder(), + ], + ["updateLendingMarketConfigMode", getUpdateLendingMarketModeDecoder()], + ]); +} + +export function getIdlMissingTypesInstructionDataCodec(): Codec< + IdlMissingTypesInstructionDataArgs, + IdlMissingTypesInstructionData +> { + return combineCodec( + getIdlMissingTypesInstructionDataEncoder(), + getIdlMissingTypesInstructionDataDecoder(), + ); +} + +export interface IdlMissingTypesInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + reserve: Address; + reserveFarmKind: IdlMissingTypesInstructionDataArgs["reserveFarmKind"]; + assetTier: IdlMissingTypesInstructionDataArgs["assetTier"]; + feeCalculation: IdlMissingTypesInstructionDataArgs["feeCalculation"]; + reserveStatus: IdlMissingTypesInstructionDataArgs["reserveStatus"]; + updateConfigMode: IdlMissingTypesInstructionDataArgs["updateConfigMode"]; + updateLendingMarketConfigValue: IdlMissingTypesInstructionDataArgs["updateLendingMarketConfigValue"]; + updateLendingMarketConfigMode: IdlMissingTypesInstructionDataArgs["updateLendingMarketConfigMode"]; +} + +export function getIdlMissingTypesInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: IdlMissingTypesInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve + >, + config?: { programAddress?: TProgramAddress }, +): IdlMissingTypesInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + ], + programAddress, + data: getIdlMissingTypesInstructionDataEncoder().encode( + args as IdlMissingTypesInstructionDataArgs, + ), + } as IdlMissingTypesInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve + >; + + return instruction; +} + +export interface ParsedIdlMissingTypesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + reserve: TAccountMetas[2]; + }; + data: IdlMissingTypesInstructionData; +} + +export function parseIdlMissingTypesInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedIdlMissingTypesInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + }, + data: getIdlMissingTypesInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/index.ts b/clients/kamino-lending/src/generated/instructions/index.ts new file mode 100644 index 00000000..5f46ed02 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/index.ts @@ -0,0 +1,77 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./addRewards.js"; +export * from "./borrowObligationLiquidity.js"; +export * from "./borrowObligationLiquidityV2.js"; +export * from "./deleteReferrerStateAndShortUrl.js"; +export * from "./depositAndWithdraw.js"; +export * from "./depositObligationCollateral.js"; +export * from "./depositObligationCollateralV2.js"; +export * from "./depositReserveLiquidity.js"; +export * from "./depositReserveLiquidityAndObligationCollateral.js"; +export * from "./depositReserveLiquidityAndObligationCollateralV2.js"; +export * from "./depositToFarmVault.js"; +export * from "./farmsIdlMissingTypes.js"; +export * from "./flashBorrowReserveLiquidity.js"; +export * from "./flashRepayReserveLiquidity.js"; +export * from "./harvestReward.js"; +export * from "./idlMissingTypes.js"; +export * from "./initFarmsForReserve.js"; +export * from "./initializeFarm.js"; +export * from "./initializeFarmDelegated.js"; +export * from "./initializeGlobalConfig.js"; +export * from "./initializeReward.js"; +export * from "./initializeUser.js"; +export * from "./initLendingMarket.js"; +export * from "./initObligation.js"; +export * from "./initObligationFarmsForReserve.js"; +export * from "./initReferrerStateAndShortUrl.js"; +export * from "./initReferrerTokenState.js"; +export * from "./initReserve.js"; +export * from "./initUserMetadata.js"; +export * from "./liquidateObligationAndRedeemReserveCollateral.js"; +export * from "./liquidateObligationAndRedeemReserveCollateralV2.js"; +export * from "./markObligationForDeleveraging.js"; +export * from "./redeemFees.js"; +export * from "./redeemReserveCollateral.js"; +export * from "./refreshFarm.js"; +export * from "./refreshObligation.js"; +export * from "./refreshObligationFarmsForReserve.js"; +export * from "./refreshReserve.js"; +export * from "./refreshReservesBatch.js"; +export * from "./refreshUserState.js"; +export * from "./repayAndWithdrawAndRedeem.js"; +export * from "./repayObligationLiquidity.js"; +export * from "./repayObligationLiquidityV2.js"; +export * from "./requestElevationGroup.js"; +export * from "./rewardUserOnce.js"; +export * from "./setStakeDelegated.js"; +export * from "./socializeLoss.js"; +export * from "./socializeLossV2.js"; +export * from "./stake.js"; +export * from "./transferOwnership.js"; +export * from "./unstake.js"; +export * from "./updateFarmAdmin.js"; +export * from "./updateFarmConfig.js"; +export * from "./updateGlobalConfig.js"; +export * from "./updateGlobalConfigAdmin.js"; +export * from "./updateLendingMarket.js"; +export * from "./updateLendingMarketOwner.js"; +export * from "./updateReserveConfig.js"; +export * from "./withdrawFromFarmVault.js"; +export * from "./withdrawObligationCollateral.js"; +export * from "./withdrawObligationCollateralAndRedeemReserveCollateral.js"; +export * from "./withdrawObligationCollateralAndRedeemReserveCollateralV2.js"; +export * from "./withdrawObligationCollateralV2.js"; +export * from "./withdrawProtocolFee.js"; +export * from "./withdrawReferrerFees.js"; +export * from "./withdrawReward.js"; +export * from "./withdrawSlashedAmount.js"; +export * from "./withdrawTreasury.js"; +export * from "./withdrawUnstakedDeposits.js"; diff --git a/clients/kamino-lending/src/generated/instructions/initFarmsForReserve.ts b/clients/kamino-lending/src/generated/instructions/initFarmsForReserve.ts new file mode 100644 index 00000000..da6da2a4 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initFarmsForReserve.ts @@ -0,0 +1,333 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_FARMS_FOR_RESERVE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([218, 6, 62, 233, 1, 33, 232, 82]); + +export function getInitFarmsForReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_FARMS_FOR_RESERVE_DISCRIMINATOR, + ); +} + +export type InitFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TAccountFarmsGlobalConfig extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountFarmsVaultAuthority extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + TAccountFarmsGlobalConfig extends string + ? ReadonlyAccount + : TAccountFarmsGlobalConfig, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountFarmsVaultAuthority extends string + ? ReadonlyAccount + : TAccountFarmsVaultAuthority, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitFarmsForReserveInstructionData { + discriminator: ReadonlyUint8Array; + mode: number; +} + +export interface InitFarmsForReserveInstructionDataArgs { + mode: number; +} + +export function getInitFarmsForReserveInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: INIT_FARMS_FOR_RESERVE_DISCRIMINATOR, + }), + ); +} + +export function getInitFarmsForReserveInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU8Decoder()], + ]); +} + +export function getInitFarmsForReserveInstructionDataCodec(): FixedSizeCodec< + InitFarmsForReserveInstructionDataArgs, + InitFarmsForReserveInstructionData +> { + return combineCodec( + getInitFarmsForReserveInstructionDataEncoder(), + getInitFarmsForReserveInstructionDataDecoder(), + ); +} + +export interface InitFarmsForReserveInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserve extends string = string, + TAccountFarmsProgram extends string = string, + TAccountFarmsGlobalConfig extends string = string, + TAccountFarmState extends string = string, + TAccountFarmsVaultAuthority extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + lendingMarketAuthority: Address; + reserve: Address; + farmsProgram: Address; + farmsGlobalConfig: Address; + farmState: Address; + farmsVaultAuthority: Address; + rent: Address; + systemProgram: Address; + mode: InitFarmsForReserveInstructionDataArgs["mode"]; +} + +export function getInitFarmsForReserveInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserve extends string, + TAccountFarmsProgram extends string, + TAccountFarmsGlobalConfig extends string, + TAccountFarmState extends string, + TAccountFarmsVaultAuthority extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitFarmsForReserveInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountFarmsProgram, + TAccountFarmsGlobalConfig, + TAccountFarmState, + TAccountFarmsVaultAuthority, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitFarmsForReserveInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountFarmsProgram, + TAccountFarmsGlobalConfig, + TAccountFarmState, + TAccountFarmsVaultAuthority, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: true, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserve: { value: input.reserve ?? null, isWritable: true }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + farmsGlobalConfig: { + value: input.farmsGlobalConfig ?? null, + isWritable: false, + }, + farmState: { value: input.farmState ?? null, isWritable: true }, + farmsVaultAuthority: { + value: input.farmsVaultAuthority ?? null, + isWritable: false, + }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.farmsProgram), + getAccountMeta(accounts.farmsGlobalConfig), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.farmsVaultAuthority), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitFarmsForReserveInstructionDataEncoder().encode( + args as InitFarmsForReserveInstructionDataArgs, + ), + } as InitFarmsForReserveInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountFarmsProgram, + TAccountFarmsGlobalConfig, + TAccountFarmState, + TAccountFarmsVaultAuthority, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + lendingMarketAuthority: TAccountMetas[2]; + reserve: TAccountMetas[3]; + farmsProgram: TAccountMetas[4]; + farmsGlobalConfig: TAccountMetas[5]; + farmState: TAccountMetas[6]; + farmsVaultAuthority: TAccountMetas[7]; + rent: TAccountMetas[8]; + systemProgram: TAccountMetas[9]; + }; + data: InitFarmsForReserveInstructionData; +} + +export function parseInitFarmsForReserveInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitFarmsForReserveInstruction { + if (instruction.accounts.length < 10) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserve: getNextAccount(), + farmsProgram: getNextAccount(), + farmsGlobalConfig: getNextAccount(), + farmState: getNextAccount(), + farmsVaultAuthority: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitFarmsForReserveInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initLendingMarket.ts b/clients/kamino-lending/src/generated/instructions/initLendingMarket.ts new file mode 100644 index 00000000..c4faee88 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initLendingMarket.ts @@ -0,0 +1,254 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_LENDING_MARKET_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([34, 162, 116, 14, 101, 137, 94, 239]); + +export function getInitLendingMarketDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_LENDING_MARKET_DISCRIMINATOR, + ); +} + +export type InitLendingMarketInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? WritableAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + ...TRemainingAccounts, + ] + >; + +export interface InitLendingMarketInstructionData { + discriminator: ReadonlyUint8Array; + quoteCurrency: number[]; +} + +export interface InitLendingMarketInstructionDataArgs { + quoteCurrency: number[]; +} + +export function getInitLendingMarketInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["quoteCurrency", getArrayEncoder(getU8Encoder(), { size: 32 })], + ]), + (value) => ({ ...value, discriminator: INIT_LENDING_MARKET_DISCRIMINATOR }), + ); +} + +export function getInitLendingMarketInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["quoteCurrency", getArrayDecoder(getU8Decoder(), { size: 32 })], + ]); +} + +export function getInitLendingMarketInstructionDataCodec(): FixedSizeCodec< + InitLendingMarketInstructionDataArgs, + InitLendingMarketInstructionData +> { + return combineCodec( + getInitLendingMarketInstructionDataEncoder(), + getInitLendingMarketInstructionDataDecoder(), + ); +} + +export interface InitLendingMarketInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountSystemProgram extends string = string, + TAccountRent extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + lendingMarketAuthority: Address; + systemProgram: Address; + rent: Address; + quoteCurrency: InitLendingMarketInstructionDataArgs["quoteCurrency"]; +} + +export function getInitLendingMarketInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountSystemProgram extends string, + TAccountRent extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitLendingMarketInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountSystemProgram, + TAccountRent + >, + config?: { programAddress?: TProgramAddress }, +): InitLendingMarketInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountSystemProgram, + TAccountRent +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: true, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: true }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.rent), + ], + programAddress, + data: getInitLendingMarketInstructionDataEncoder().encode( + args as InitLendingMarketInstructionDataArgs, + ), + } as InitLendingMarketInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountSystemProgram, + TAccountRent + >; + + return instruction; +} + +export interface ParsedInitLendingMarketInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + lendingMarketAuthority: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + rent: TAccountMetas[4]; + }; + data: InitLendingMarketInstructionData; +} + +export function parseInitLendingMarketInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitLendingMarketInstruction { + if (instruction.accounts.length < 5) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + systemProgram: getNextAccount(), + rent: getNextAccount(), + }, + data: getInitLendingMarketInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initObligation.ts b/clients/kamino-lending/src/generated/instructions/initObligation.ts new file mode 100644 index 00000000..cb04bd21 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initObligation.ts @@ -0,0 +1,317 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; +import type { + InitObligationArgs, + InitObligationArgsArgs, +} from "../types/index.js"; +import { + getInitObligationArgsDecoder, + getInitObligationArgsEncoder, +} from "../types/index.js"; + +export const INIT_OBLIGATION_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [251, 10, 231, 76, 27, 11, 159, 96], +); + +export function getInitObligationDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_OBLIGATION_DISCRIMINATOR, + ); +} + +export type InitObligationInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountObligationOwner extends string | AccountMeta = string, + TAccountFeePayer extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountSeed1Account extends string | AccountMeta = string, + TAccountSeed2Account extends string | AccountMeta = string, + TAccountOwnerUserMetadata extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountObligationOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountObligationOwner, + TAccountFeePayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFeePayer, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountSeed1Account extends string + ? ReadonlyAccount + : TAccountSeed1Account, + TAccountSeed2Account extends string + ? ReadonlyAccount + : TAccountSeed2Account, + TAccountOwnerUserMetadata extends string + ? ReadonlyAccount + : TAccountOwnerUserMetadata, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitObligationInstructionData { + discriminator: ReadonlyUint8Array; + args: InitObligationArgs; +} + +export interface InitObligationInstructionDataArgs { + args: InitObligationArgsArgs; +} + +export function getInitObligationInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["args", getInitObligationArgsEncoder()], + ]), + (value) => ({ ...value, discriminator: INIT_OBLIGATION_DISCRIMINATOR }), + ); +} + +export function getInitObligationInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["args", getInitObligationArgsDecoder()], + ]); +} + +export function getInitObligationInstructionDataCodec(): FixedSizeCodec< + InitObligationInstructionDataArgs, + InitObligationInstructionData +> { + return combineCodec( + getInitObligationInstructionDataEncoder(), + getInitObligationInstructionDataDecoder(), + ); +} + +export interface InitObligationInput< + TAccountObligationOwner extends string = string, + TAccountFeePayer extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountSeed1Account extends string = string, + TAccountSeed2Account extends string = string, + TAccountOwnerUserMetadata extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + obligationOwner: TransactionSigner; + feePayer: TransactionSigner; + obligation: Address; + lendingMarket: Address; + seed1Account: Address; + seed2Account: Address; + ownerUserMetadata: Address; + rent: Address; + systemProgram: Address; + args: InitObligationInstructionDataArgs["args"]; +} + +export function getInitObligationInstruction< + TAccountObligationOwner extends string, + TAccountFeePayer extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountSeed1Account extends string, + TAccountSeed2Account extends string, + TAccountOwnerUserMetadata extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitObligationInput< + TAccountObligationOwner, + TAccountFeePayer, + TAccountObligation, + TAccountLendingMarket, + TAccountSeed1Account, + TAccountSeed2Account, + TAccountOwnerUserMetadata, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitObligationInstruction< + TProgramAddress, + TAccountObligationOwner, + TAccountFeePayer, + TAccountObligation, + TAccountLendingMarket, + TAccountSeed1Account, + TAccountSeed2Account, + TAccountOwnerUserMetadata, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + obligationOwner: { + value: input.obligationOwner ?? null, + isWritable: false, + }, + feePayer: { value: input.feePayer ?? null, isWritable: true }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + seed1Account: { value: input.seed1Account ?? null, isWritable: false }, + seed2Account: { value: input.seed2Account ?? null, isWritable: false }, + ownerUserMetadata: { + value: input.ownerUserMetadata ?? null, + isWritable: false, + }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.obligationOwner), + getAccountMeta(accounts.feePayer), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.seed1Account), + getAccountMeta(accounts.seed2Account), + getAccountMeta(accounts.ownerUserMetadata), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitObligationInstructionDataEncoder().encode( + args as InitObligationInstructionDataArgs, + ), + } as InitObligationInstruction< + TProgramAddress, + TAccountObligationOwner, + TAccountFeePayer, + TAccountObligation, + TAccountLendingMarket, + TAccountSeed1Account, + TAccountSeed2Account, + TAccountOwnerUserMetadata, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitObligationInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + obligationOwner: TAccountMetas[0]; + feePayer: TAccountMetas[1]; + obligation: TAccountMetas[2]; + lendingMarket: TAccountMetas[3]; + seed1Account: TAccountMetas[4]; + seed2Account: TAccountMetas[5]; + ownerUserMetadata: TAccountMetas[6]; + rent: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + }; + data: InitObligationInstructionData; +} + +export function parseInitObligationInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitObligationInstruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + obligationOwner: getNextAccount(), + feePayer: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + seed1Account: getNextAccount(), + seed2Account: getNextAccount(), + ownerUserMetadata: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitObligationInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initObligationFarmsForReserve.ts b/clients/kamino-lending/src/generated/instructions/initObligationFarmsForReserve.ts new file mode 100644 index 00000000..754b4218 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initObligationFarmsForReserve.ts @@ -0,0 +1,341 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([136, 63, 15, 186, 211, 152, 168, 164]); + +export function getInitObligationFarmsForReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR, + ); +} + +export type InitObligationFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveFarmState extends string | AccountMeta = string, + TAccountObligationFarm extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountOwner extends string + ? ReadonlyAccount + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveFarmState extends string + ? WritableAccount + : TAccountReserveFarmState, + TAccountObligationFarm extends string + ? WritableAccount + : TAccountObligationFarm, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitObligationFarmsForReserveInstructionData { + discriminator: ReadonlyUint8Array; + mode: number; +} + +export interface InitObligationFarmsForReserveInstructionDataArgs { + mode: number; +} + +export function getInitObligationFarmsForReserveInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: INIT_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR, + }), + ); +} + +export function getInitObligationFarmsForReserveInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU8Decoder()], + ]); +} + +export function getInitObligationFarmsForReserveInstructionDataCodec(): FixedSizeCodec< + InitObligationFarmsForReserveInstructionDataArgs, + InitObligationFarmsForReserveInstructionData +> { + return combineCodec( + getInitObligationFarmsForReserveInstructionDataEncoder(), + getInitObligationFarmsForReserveInstructionDataDecoder(), + ); +} + +export interface InitObligationFarmsForReserveInput< + TAccountPayer extends string = string, + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserve extends string = string, + TAccountReserveFarmState extends string = string, + TAccountObligationFarm extends string = string, + TAccountLendingMarket extends string = string, + TAccountFarmsProgram extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + payer: TransactionSigner; + owner: Address; + obligation: Address; + lendingMarketAuthority: Address; + reserve: Address; + reserveFarmState: Address; + obligationFarm: Address; + lendingMarket: Address; + farmsProgram: Address; + rent: Address; + systemProgram: Address; + mode: InitObligationFarmsForReserveInstructionDataArgs["mode"]; +} + +export function getInitObligationFarmsForReserveInstruction< + TAccountPayer extends string, + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserve extends string, + TAccountReserveFarmState extends string, + TAccountObligationFarm extends string, + TAccountLendingMarket extends string, + TAccountFarmsProgram extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitObligationFarmsForReserveInput< + TAccountPayer, + TAccountOwner, + TAccountObligation, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveFarmState, + TAccountObligationFarm, + TAccountLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitObligationFarmsForReserveInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountObligation, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveFarmState, + TAccountObligationFarm, + TAccountLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveFarmState: { + value: input.reserveFarmState ?? null, + isWritable: true, + }, + obligationFarm: { value: input.obligationFarm ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveFarmState), + getAccountMeta(accounts.obligationFarm), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.farmsProgram), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitObligationFarmsForReserveInstructionDataEncoder().encode( + args as InitObligationFarmsForReserveInstructionDataArgs, + ), + } as InitObligationFarmsForReserveInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountObligation, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveFarmState, + TAccountObligationFarm, + TAccountLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitObligationFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + owner: TAccountMetas[1]; + obligation: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + reserve: TAccountMetas[4]; + reserveFarmState: TAccountMetas[5]; + obligationFarm: TAccountMetas[6]; + lendingMarket: TAccountMetas[7]; + farmsProgram: TAccountMetas[8]; + rent: TAccountMetas[9]; + systemProgram: TAccountMetas[10]; + }; + data: InitObligationFarmsForReserveInstructionData; +} + +export function parseInitObligationFarmsForReserveInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitObligationFarmsForReserveInstruction { + if (instruction.accounts.length < 11) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + payer: getNextAccount(), + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserve: getNextAccount(), + reserveFarmState: getNextAccount(), + obligationFarm: getNextAccount(), + lendingMarket: getNextAccount(), + farmsProgram: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitObligationFarmsForReserveInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initReferrerStateAndShortUrl.ts b/clients/kamino-lending/src/generated/instructions/initReferrerStateAndShortUrl.ts new file mode 100644 index 00000000..4c103d81 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initReferrerStateAndShortUrl.ts @@ -0,0 +1,275 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + Codec, + Decoder, + Encoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getUtf8Decoder, + getUtf8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([165, 19, 25, 127, 100, 55, 31, 90]); + +export function getInitReferrerStateAndShortUrlDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR, + ); +} + +export type InitReferrerStateAndShortUrlInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountReferrer extends string | AccountMeta = string, + TAccountReferrerState extends string | AccountMeta = string, + TAccountReferrerShortUrl extends string | AccountMeta = string, + TAccountReferrerUserMetadata extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountReferrer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountReferrer, + TAccountReferrerState extends string + ? WritableAccount + : TAccountReferrerState, + TAccountReferrerShortUrl extends string + ? WritableAccount + : TAccountReferrerShortUrl, + TAccountReferrerUserMetadata extends string + ? ReadonlyAccount + : TAccountReferrerUserMetadata, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitReferrerStateAndShortUrlInstructionData { + discriminator: ReadonlyUint8Array; + shortUrl: string; +} + +export interface InitReferrerStateAndShortUrlInstructionDataArgs { + shortUrl: string; +} + +export function getInitReferrerStateAndShortUrlInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["shortUrl", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())], + ]), + (value) => ({ + ...value, + discriminator: INIT_REFERRER_STATE_AND_SHORT_URL_DISCRIMINATOR, + }), + ); +} + +export function getInitReferrerStateAndShortUrlInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["shortUrl", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], + ]); +} + +export function getInitReferrerStateAndShortUrlInstructionDataCodec(): Codec< + InitReferrerStateAndShortUrlInstructionDataArgs, + InitReferrerStateAndShortUrlInstructionData +> { + return combineCodec( + getInitReferrerStateAndShortUrlInstructionDataEncoder(), + getInitReferrerStateAndShortUrlInstructionDataDecoder(), + ); +} + +export interface InitReferrerStateAndShortUrlInput< + TAccountReferrer extends string = string, + TAccountReferrerState extends string = string, + TAccountReferrerShortUrl extends string = string, + TAccountReferrerUserMetadata extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + referrer: TransactionSigner; + referrerState: Address; + referrerShortUrl: Address; + referrerUserMetadata: Address; + rent: Address; + systemProgram: Address; + shortUrl: InitReferrerStateAndShortUrlInstructionDataArgs["shortUrl"]; +} + +export function getInitReferrerStateAndShortUrlInstruction< + TAccountReferrer extends string, + TAccountReferrerState extends string, + TAccountReferrerShortUrl extends string, + TAccountReferrerUserMetadata extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitReferrerStateAndShortUrlInput< + TAccountReferrer, + TAccountReferrerState, + TAccountReferrerShortUrl, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitReferrerStateAndShortUrlInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerState, + TAccountReferrerShortUrl, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + referrer: { value: input.referrer ?? null, isWritable: true }, + referrerState: { value: input.referrerState ?? null, isWritable: true }, + referrerShortUrl: { + value: input.referrerShortUrl ?? null, + isWritable: true, + }, + referrerUserMetadata: { + value: input.referrerUserMetadata ?? null, + isWritable: false, + }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.referrer), + getAccountMeta(accounts.referrerState), + getAccountMeta(accounts.referrerShortUrl), + getAccountMeta(accounts.referrerUserMetadata), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitReferrerStateAndShortUrlInstructionDataEncoder().encode( + args as InitReferrerStateAndShortUrlInstructionDataArgs, + ), + } as InitReferrerStateAndShortUrlInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerState, + TAccountReferrerShortUrl, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitReferrerStateAndShortUrlInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + referrer: TAccountMetas[0]; + referrerState: TAccountMetas[1]; + referrerShortUrl: TAccountMetas[2]; + referrerUserMetadata: TAccountMetas[3]; + rent: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: InitReferrerStateAndShortUrlInstructionData; +} + +export function parseInitReferrerStateAndShortUrlInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitReferrerStateAndShortUrlInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + referrer: getNextAccount(), + referrerState: getNextAccount(), + referrerShortUrl: getNextAccount(), + referrerUserMetadata: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitReferrerStateAndShortUrlInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initReferrerTokenState.ts b/clients/kamino-lending/src/generated/instructions/initReferrerTokenState.ts new file mode 100644 index 00000000..1b81a82f --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initReferrerTokenState.ts @@ -0,0 +1,267 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_REFERRER_TOKEN_STATE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([116, 45, 66, 148, 58, 13, 218, 115]); + +export function getInitReferrerTokenStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_REFERRER_TOKEN_STATE_DISCRIMINATOR, + ); +} + +export type InitReferrerTokenStateInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReferrer extends string | AccountMeta = string, + TAccountReferrerTokenState extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? ReadonlyAccount + : TAccountReserve, + TAccountReferrer extends string + ? ReadonlyAccount + : TAccountReferrer, + TAccountReferrerTokenState extends string + ? WritableAccount + : TAccountReferrerTokenState, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitReferrerTokenStateInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitReferrerTokenStateInstructionDataArgs {} + +export function getInitReferrerTokenStateInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: INIT_REFERRER_TOKEN_STATE_DISCRIMINATOR, + }), + ); +} + +export function getInitReferrerTokenStateInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitReferrerTokenStateInstructionDataCodec(): FixedSizeCodec< + InitReferrerTokenStateInstructionDataArgs, + InitReferrerTokenStateInstructionData +> { + return combineCodec( + getInitReferrerTokenStateInstructionDataEncoder(), + getInitReferrerTokenStateInstructionDataDecoder(), + ); +} + +export interface InitReferrerTokenStateInput< + TAccountPayer extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountReferrer extends string = string, + TAccountReferrerTokenState extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + payer: TransactionSigner; + lendingMarket: Address; + reserve: Address; + referrer: Address; + referrerTokenState: Address; + rent: Address; + systemProgram: Address; +} + +export function getInitReferrerTokenStateInstruction< + TAccountPayer extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountReferrer extends string, + TAccountReferrerTokenState extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitReferrerTokenStateInput< + TAccountPayer, + TAccountLendingMarket, + TAccountReserve, + TAccountReferrer, + TAccountReferrerTokenState, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitReferrerTokenStateInstruction< + TProgramAddress, + TAccountPayer, + TAccountLendingMarket, + TAccountReserve, + TAccountReferrer, + TAccountReferrerTokenState, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: false }, + referrer: { value: input.referrer ?? null, isWritable: false }, + referrerTokenState: { + value: input.referrerTokenState ?? null, + isWritable: true, + }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.referrer), + getAccountMeta(accounts.referrerTokenState), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitReferrerTokenStateInstructionDataEncoder().encode({}), + } as InitReferrerTokenStateInstruction< + TProgramAddress, + TAccountPayer, + TAccountLendingMarket, + TAccountReserve, + TAccountReferrer, + TAccountReferrerTokenState, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitReferrerTokenStateInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + reserve: TAccountMetas[2]; + referrer: TAccountMetas[3]; + referrerTokenState: TAccountMetas[4]; + rent: TAccountMetas[5]; + systemProgram: TAccountMetas[6]; + }; + data: InitReferrerTokenStateInstructionData; +} + +export function parseInitReferrerTokenStateInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitReferrerTokenStateInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + payer: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + referrer: getNextAccount(), + referrerTokenState: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitReferrerTokenStateInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initReserve.ts b/clients/kamino-lending/src/generated/instructions/initReserve.ts new file mode 100644 index 00000000..ad39d9bd --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initReserve.ts @@ -0,0 +1,385 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_RESERVE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 138, 245, 71, 225, 153, 4, 3, 43, +]); + +export function getInitReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_RESERVE_DISCRIMINATOR, + ); +} + +export type InitReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveLiquiditySupply extends string | AccountMeta = string, + TAccountFeeReceiver extends string | AccountMeta = string, + TAccountReserveCollateralMint extends string | AccountMeta = string, + TAccountReserveCollateralSupply extends string | AccountMeta = string, + TAccountInitialLiquiditySource extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountLiquidityTokenProgram extends string | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply extends string + ? WritableAccount + : TAccountReserveLiquiditySupply, + TAccountFeeReceiver extends string + ? WritableAccount + : TAccountFeeReceiver, + TAccountReserveCollateralMint extends string + ? WritableAccount + : TAccountReserveCollateralMint, + TAccountReserveCollateralSupply extends string + ? WritableAccount + : TAccountReserveCollateralSupply, + TAccountInitialLiquiditySource extends string + ? WritableAccount + : TAccountInitialLiquiditySource, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidityTokenProgram, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitReserveInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitReserveInstructionDataArgs {} + +export function getInitReserveInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: INIT_RESERVE_DISCRIMINATOR }), + ); +} + +export function getInitReserveInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitReserveInstructionDataCodec(): FixedSizeCodec< + InitReserveInstructionDataArgs, + InitReserveInstructionData +> { + return combineCodec( + getInitReserveInstructionDataEncoder(), + getInitReserveInstructionDataDecoder(), + ); +} + +export interface InitReserveInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveLiquiditySupply extends string = string, + TAccountFeeReceiver extends string = string, + TAccountReserveCollateralMint extends string = string, + TAccountReserveCollateralSupply extends string = string, + TAccountInitialLiquiditySource extends string = string, + TAccountRent extends string = string, + TAccountLiquidityTokenProgram extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountSystemProgram extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + lendingMarketAuthority: Address; + reserve: Address; + reserveLiquidityMint: Address; + reserveLiquiditySupply: Address; + feeReceiver: Address; + reserveCollateralMint: Address; + reserveCollateralSupply: Address; + initialLiquiditySource: Address; + rent: Address; + liquidityTokenProgram: Address; + collateralTokenProgram: Address; + systemProgram: Address; +} + +export function getInitReserveInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveLiquiditySupply extends string, + TAccountFeeReceiver extends string, + TAccountReserveCollateralMint extends string, + TAccountReserveCollateralSupply extends string, + TAccountInitialLiquiditySource extends string, + TAccountRent extends string, + TAccountLiquidityTokenProgram extends string, + TAccountCollateralTokenProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitReserveInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountFeeReceiver, + TAccountReserveCollateralMint, + TAccountReserveCollateralSupply, + TAccountInitialLiquiditySource, + TAccountRent, + TAccountLiquidityTokenProgram, + TAccountCollateralTokenProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitReserveInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountFeeReceiver, + TAccountReserveCollateralMint, + TAccountReserveCollateralSupply, + TAccountInitialLiquiditySource, + TAccountRent, + TAccountLiquidityTokenProgram, + TAccountCollateralTokenProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: true, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveLiquiditySupply: { + value: input.reserveLiquiditySupply ?? null, + isWritable: true, + }, + feeReceiver: { value: input.feeReceiver ?? null, isWritable: true }, + reserveCollateralMint: { + value: input.reserveCollateralMint ?? null, + isWritable: true, + }, + reserveCollateralSupply: { + value: input.reserveCollateralSupply ?? null, + isWritable: true, + }, + initialLiquiditySource: { + value: input.initialLiquiditySource ?? null, + isWritable: true, + }, + rent: { value: input.rent ?? null, isWritable: false }, + liquidityTokenProgram: { + value: input.liquidityTokenProgram ?? null, + isWritable: false, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveLiquiditySupply), + getAccountMeta(accounts.feeReceiver), + getAccountMeta(accounts.reserveCollateralMint), + getAccountMeta(accounts.reserveCollateralSupply), + getAccountMeta(accounts.initialLiquiditySource), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.liquidityTokenProgram), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitReserveInstructionDataEncoder().encode({}), + } as InitReserveInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquiditySupply, + TAccountFeeReceiver, + TAccountReserveCollateralMint, + TAccountReserveCollateralSupply, + TAccountInitialLiquiditySource, + TAccountRent, + TAccountLiquidityTokenProgram, + TAccountCollateralTokenProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + lendingMarketAuthority: TAccountMetas[2]; + reserve: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveLiquiditySupply: TAccountMetas[5]; + feeReceiver: TAccountMetas[6]; + reserveCollateralMint: TAccountMetas[7]; + reserveCollateralSupply: TAccountMetas[8]; + initialLiquiditySource: TAccountMetas[9]; + rent: TAccountMetas[10]; + liquidityTokenProgram: TAccountMetas[11]; + collateralTokenProgram: TAccountMetas[12]; + systemProgram: TAccountMetas[13]; + }; + data: InitReserveInstructionData; +} + +export function parseInitReserveInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitReserveInstruction { + if (instruction.accounts.length < 14) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveLiquiditySupply: getNextAccount(), + feeReceiver: getNextAccount(), + reserveCollateralMint: getNextAccount(), + reserveCollateralSupply: getNextAccount(), + initialLiquiditySource: getNextAccount(), + rent: getNextAccount(), + liquidityTokenProgram: getNextAccount(), + collateralTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitReserveInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initUserMetadata.ts b/clients/kamino-lending/src/generated/instructions/initUserMetadata.ts new file mode 100644 index 00000000..0422b0fa --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initUserMetadata.ts @@ -0,0 +1,271 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INIT_USER_METADATA_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([117, 169, 176, 69, 197, 23, 15, 162]); + +export function getInitUserMetadataDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INIT_USER_METADATA_DISCRIMINATOR, + ); +} + +export type InitUserMetadataInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountFeePayer extends string | AccountMeta = string, + TAccountUserMetadata extends string | AccountMeta = string, + TAccountReferrerUserMetadata extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountFeePayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFeePayer, + TAccountUserMetadata extends string + ? WritableAccount + : TAccountUserMetadata, + TAccountReferrerUserMetadata extends string + ? ReadonlyAccount + : TAccountReferrerUserMetadata, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitUserMetadataInstructionData { + discriminator: ReadonlyUint8Array; + userLookupTable: Address; +} + +export interface InitUserMetadataInstructionDataArgs { + userLookupTable: Address; +} + +export function getInitUserMetadataInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["userLookupTable", getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: INIT_USER_METADATA_DISCRIMINATOR }), + ); +} + +export function getInitUserMetadataInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["userLookupTable", getAddressDecoder()], + ]); +} + +export function getInitUserMetadataInstructionDataCodec(): FixedSizeCodec< + InitUserMetadataInstructionDataArgs, + InitUserMetadataInstructionData +> { + return combineCodec( + getInitUserMetadataInstructionDataEncoder(), + getInitUserMetadataInstructionDataDecoder(), + ); +} + +export interface InitUserMetadataInput< + TAccountOwner extends string = string, + TAccountFeePayer extends string = string, + TAccountUserMetadata extends string = string, + TAccountReferrerUserMetadata extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + owner: TransactionSigner; + feePayer: TransactionSigner; + userMetadata: Address; + referrerUserMetadata?: Address; + rent: Address; + systemProgram: Address; + userLookupTable: InitUserMetadataInstructionDataArgs["userLookupTable"]; +} + +export function getInitUserMetadataInstruction< + TAccountOwner extends string, + TAccountFeePayer extends string, + TAccountUserMetadata extends string, + TAccountReferrerUserMetadata extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: InitUserMetadataInput< + TAccountOwner, + TAccountFeePayer, + TAccountUserMetadata, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitUserMetadataInstruction< + TProgramAddress, + TAccountOwner, + TAccountFeePayer, + TAccountUserMetadata, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + feePayer: { value: input.feePayer ?? null, isWritable: true }, + userMetadata: { value: input.userMetadata ?? null, isWritable: true }, + referrerUserMetadata: { + value: input.referrerUserMetadata ?? null, + isWritable: false, + }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.feePayer), + getAccountMeta(accounts.userMetadata), + getAccountMeta(accounts.referrerUserMetadata), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitUserMetadataInstructionDataEncoder().encode( + args as InitUserMetadataInstructionDataArgs, + ), + } as InitUserMetadataInstruction< + TProgramAddress, + TAccountOwner, + TAccountFeePayer, + TAccountUserMetadata, + TAccountReferrerUserMetadata, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitUserMetadataInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + feePayer: TAccountMetas[1]; + userMetadata: TAccountMetas[2]; + referrerUserMetadata?: TAccountMetas[3] | undefined; + rent: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: InitUserMetadataInstructionData; +} + +export function parseInitUserMetadataInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitUserMetadataInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + feePayer: getNextAccount(), + userMetadata: getNextAccount(), + referrerUserMetadata: getNextOptionalAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitUserMetadataInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initializeFarm.ts b/clients/kamino-lending/src/generated/instructions/initializeFarm.ts new file mode 100644 index 00000000..c9e2d1e1 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initializeFarm.ts @@ -0,0 +1,290 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INITIALIZE_FARM_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [252, 28, 185, 172, 244, 74, 117, 165], +); + +export function getInitializeFarmDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_FARM_DISCRIMINATOR, + ); +} + +export type InitializeFarmInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmAdmin extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFarmAdmin, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountGlobalConfig extends string + ? ReadonlyAccount + : TAccountGlobalConfig, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountTokenMint extends string + ? ReadonlyAccount + : TAccountTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + ...TRemainingAccounts, + ] + >; + +export interface InitializeFarmInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitializeFarmInstructionDataArgs {} + +export function getInitializeFarmInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: INITIALIZE_FARM_DISCRIMINATOR }), + ); +} + +export function getInitializeFarmInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeFarmInstructionDataCodec(): FixedSizeCodec< + InitializeFarmInstructionDataArgs, + InitializeFarmInstructionData +> { + return combineCodec( + getInitializeFarmInstructionDataEncoder(), + getInitializeFarmInstructionDataDecoder(), + ); +} + +export interface InitializeFarmInput< + TAccountFarmAdmin extends string = string, + TAccountFarmState extends string = string, + TAccountGlobalConfig extends string = string, + TAccountFarmVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountRent extends string = string, +> { + farmAdmin: TransactionSigner; + farmState: Address; + globalConfig: Address; + farmVault: Address; + farmVaultsAuthority: Address; + tokenMint: Address; + tokenProgram: Address; + systemProgram: Address; + rent: Address; +} + +export function getInitializeFarmInstruction< + TAccountFarmAdmin extends string, + TAccountFarmState extends string, + TAccountGlobalConfig extends string, + TAccountFarmVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountTokenMint extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountRent extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: InitializeFarmInput< + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent + >, + config?: { programAddress?: TProgramAddress }, +): InitializeFarmInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmAdmin: { value: input.farmAdmin ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: false }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + tokenMint: { value: input.tokenMint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmAdmin), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.tokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.rent), + ], + programAddress, + data: getInitializeFarmInstructionDataEncoder().encode({}), + } as InitializeFarmInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent + >; + + return instruction; +} + +export interface ParsedInitializeFarmInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmAdmin: TAccountMetas[0]; + farmState: TAccountMetas[1]; + globalConfig: TAccountMetas[2]; + farmVault: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + tokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + systemProgram: TAccountMetas[7]; + rent: TAccountMetas[8]; + }; + data: InitializeFarmInstructionData; +} + +export function parseInitializeFarmInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitializeFarmInstruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmAdmin: getNextAccount(), + farmState: getNextAccount(), + globalConfig: getNextAccount(), + farmVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + tokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + rent: getNextAccount(), + }, + data: getInitializeFarmInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initializeFarmDelegated.ts b/clients/kamino-lending/src/generated/instructions/initializeFarmDelegated.ts new file mode 100644 index 00000000..fbd5383e --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initializeFarmDelegated.ts @@ -0,0 +1,268 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INITIALIZE_FARM_DELEGATED_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([250, 84, 101, 25, 51, 77, 204, 91]); + +export function getInitializeFarmDelegatedDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_FARM_DELEGATED_DISCRIMINATOR, + ); +} + +export type InitializeFarmDelegatedInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmAdmin extends string | AccountMeta = string, + TAccountFarmDelegate extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFarmAdmin, + TAccountFarmDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountFarmDelegate, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountGlobalConfig extends string + ? ReadonlyAccount + : TAccountGlobalConfig, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + ...TRemainingAccounts, + ] + >; + +export interface InitializeFarmDelegatedInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitializeFarmDelegatedInstructionDataArgs {} + +export function getInitializeFarmDelegatedInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: INITIALIZE_FARM_DELEGATED_DISCRIMINATOR, + }), + ); +} + +export function getInitializeFarmDelegatedInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeFarmDelegatedInstructionDataCodec(): FixedSizeCodec< + InitializeFarmDelegatedInstructionDataArgs, + InitializeFarmDelegatedInstructionData +> { + return combineCodec( + getInitializeFarmDelegatedInstructionDataEncoder(), + getInitializeFarmDelegatedInstructionDataDecoder(), + ); +} + +export interface InitializeFarmDelegatedInput< + TAccountFarmAdmin extends string = string, + TAccountFarmDelegate extends string = string, + TAccountFarmState extends string = string, + TAccountGlobalConfig extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountSystemProgram extends string = string, + TAccountRent extends string = string, +> { + farmAdmin: TransactionSigner; + farmDelegate: TransactionSigner; + farmState: Address; + globalConfig: Address; + farmVaultsAuthority: Address; + systemProgram: Address; + rent: Address; +} + +export function getInitializeFarmDelegatedInstruction< + TAccountFarmAdmin extends string, + TAccountFarmDelegate extends string, + TAccountFarmState extends string, + TAccountGlobalConfig extends string, + TAccountFarmVaultsAuthority extends string, + TAccountSystemProgram extends string, + TAccountRent extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: InitializeFarmDelegatedInput< + TAccountFarmAdmin, + TAccountFarmDelegate, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVaultsAuthority, + TAccountSystemProgram, + TAccountRent + >, + config?: { programAddress?: TProgramAddress }, +): InitializeFarmDelegatedInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmDelegate, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVaultsAuthority, + TAccountSystemProgram, + TAccountRent +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmAdmin: { value: input.farmAdmin ?? null, isWritable: true }, + farmDelegate: { value: input.farmDelegate ?? null, isWritable: false }, + farmState: { value: input.farmState ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: false }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmAdmin), + getAccountMeta(accounts.farmDelegate), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.rent), + ], + programAddress, + data: getInitializeFarmDelegatedInstructionDataEncoder().encode({}), + } as InitializeFarmDelegatedInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmDelegate, + TAccountFarmState, + TAccountGlobalConfig, + TAccountFarmVaultsAuthority, + TAccountSystemProgram, + TAccountRent + >; + + return instruction; +} + +export interface ParsedInitializeFarmDelegatedInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmAdmin: TAccountMetas[0]; + farmDelegate: TAccountMetas[1]; + farmState: TAccountMetas[2]; + globalConfig: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + rent: TAccountMetas[6]; + }; + data: InitializeFarmDelegatedInstructionData; +} + +export function parseInitializeFarmDelegatedInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitializeFarmDelegatedInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmAdmin: getNextAccount(), + farmDelegate: getNextAccount(), + farmState: getNextAccount(), + globalConfig: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + systemProgram: getNextAccount(), + rent: getNextAccount(), + }, + data: getInitializeFarmDelegatedInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initializeGlobalConfig.ts b/clients/kamino-lending/src/generated/instructions/initializeGlobalConfig.ts new file mode 100644 index 00000000..665d5952 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initializeGlobalConfig.ts @@ -0,0 +1,224 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INITIALIZE_GLOBAL_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([113, 216, 122, 131, 225, 209, 22, 55]); + +export function getInitializeGlobalConfigDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_GLOBAL_CONFIG_DISCRIMINATOR, + ); +} + +export type InitializeGlobalConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountGlobalAdmin extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountTreasuryVaultsAuthority extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountGlobalAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountGlobalAdmin, + TAccountGlobalConfig extends string + ? WritableAccount + : TAccountGlobalConfig, + TAccountTreasuryVaultsAuthority extends string + ? ReadonlyAccount + : TAccountTreasuryVaultsAuthority, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface InitializeGlobalConfigInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitializeGlobalConfigInstructionDataArgs {} + +export function getInitializeGlobalConfigInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: INITIALIZE_GLOBAL_CONFIG_DISCRIMINATOR, + }), + ); +} + +export function getInitializeGlobalConfigInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeGlobalConfigInstructionDataCodec(): FixedSizeCodec< + InitializeGlobalConfigInstructionDataArgs, + InitializeGlobalConfigInstructionData +> { + return combineCodec( + getInitializeGlobalConfigInstructionDataEncoder(), + getInitializeGlobalConfigInstructionDataDecoder(), + ); +} + +export interface InitializeGlobalConfigInput< + TAccountGlobalAdmin extends string = string, + TAccountGlobalConfig extends string = string, + TAccountTreasuryVaultsAuthority extends string = string, + TAccountSystemProgram extends string = string, +> { + globalAdmin: TransactionSigner; + globalConfig: Address; + treasuryVaultsAuthority: Address; + systemProgram: Address; +} + +export function getInitializeGlobalConfigInstruction< + TAccountGlobalAdmin extends string, + TAccountGlobalConfig extends string, + TAccountTreasuryVaultsAuthority extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: InitializeGlobalConfigInput< + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountTreasuryVaultsAuthority, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): InitializeGlobalConfigInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountTreasuryVaultsAuthority, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + globalAdmin: { value: input.globalAdmin ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: true }, + treasuryVaultsAuthority: { + value: input.treasuryVaultsAuthority ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.globalAdmin), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.treasuryVaultsAuthority), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeGlobalConfigInstructionDataEncoder().encode({}), + } as InitializeGlobalConfigInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountTreasuryVaultsAuthority, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedInitializeGlobalConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + globalAdmin: TAccountMetas[0]; + globalConfig: TAccountMetas[1]; + treasuryVaultsAuthority: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + }; + data: InitializeGlobalConfigInstructionData; +} + +export function parseInitializeGlobalConfigInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitializeGlobalConfigInstruction { + if (instruction.accounts.length < 4) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + globalAdmin: getNextAccount(), + globalConfig: getNextAccount(), + treasuryVaultsAuthority: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeGlobalConfigInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initializeReward.ts b/clients/kamino-lending/src/generated/instructions/initializeReward.ts new file mode 100644 index 00000000..30479710 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initializeReward.ts @@ -0,0 +1,323 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INITIALIZE_REWARD_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([95, 135, 192, 196, 242, 129, 230, 68]); + +export function getInitializeRewardDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_REWARD_DISCRIMINATOR, + ); +} + +export type InitializeRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmAdmin extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountRewardMint extends string | AccountMeta = string, + TAccountRewardVault extends string | AccountMeta = string, + TAccountRewardTreasuryVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountTreasuryVaultsAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFarmAdmin, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountGlobalConfig extends string + ? ReadonlyAccount + : TAccountGlobalConfig, + TAccountRewardMint extends string + ? ReadonlyAccount + : TAccountRewardMint, + TAccountRewardVault extends string + ? WritableAccount + : TAccountRewardVault, + TAccountRewardTreasuryVault extends string + ? WritableAccount + : TAccountRewardTreasuryVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountTreasuryVaultsAuthority extends string + ? ReadonlyAccount + : TAccountTreasuryVaultsAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + ...TRemainingAccounts, + ] + >; + +export interface InitializeRewardInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitializeRewardInstructionDataArgs {} + +export function getInitializeRewardInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: INITIALIZE_REWARD_DISCRIMINATOR }), + ); +} + +export function getInitializeRewardInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeRewardInstructionDataCodec(): FixedSizeCodec< + InitializeRewardInstructionDataArgs, + InitializeRewardInstructionData +> { + return combineCodec( + getInitializeRewardInstructionDataEncoder(), + getInitializeRewardInstructionDataDecoder(), + ); +} + +export interface InitializeRewardInput< + TAccountFarmAdmin extends string = string, + TAccountFarmState extends string = string, + TAccountGlobalConfig extends string = string, + TAccountRewardMint extends string = string, + TAccountRewardVault extends string = string, + TAccountRewardTreasuryVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountTreasuryVaultsAuthority extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountRent extends string = string, +> { + farmAdmin: TransactionSigner; + farmState: Address; + globalConfig: Address; + rewardMint: Address; + rewardVault: Address; + rewardTreasuryVault: Address; + farmVaultsAuthority: Address; + treasuryVaultsAuthority: Address; + tokenProgram: Address; + systemProgram: Address; + rent: Address; +} + +export function getInitializeRewardInstruction< + TAccountFarmAdmin extends string, + TAccountFarmState extends string, + TAccountGlobalConfig extends string, + TAccountRewardMint extends string, + TAccountRewardVault extends string, + TAccountRewardTreasuryVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountTreasuryVaultsAuthority extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountRent extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: InitializeRewardInput< + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardVault, + TAccountRewardTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountTreasuryVaultsAuthority, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent + >, + config?: { programAddress?: TProgramAddress }, +): InitializeRewardInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardVault, + TAccountRewardTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountTreasuryVaultsAuthority, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmAdmin: { value: input.farmAdmin ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: false }, + rewardMint: { value: input.rewardMint ?? null, isWritable: false }, + rewardVault: { value: input.rewardVault ?? null, isWritable: true }, + rewardTreasuryVault: { + value: input.rewardTreasuryVault ?? null, + isWritable: true, + }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + treasuryVaultsAuthority: { + value: input.treasuryVaultsAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmAdmin), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.rewardMint), + getAccountMeta(accounts.rewardVault), + getAccountMeta(accounts.rewardTreasuryVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.treasuryVaultsAuthority), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.rent), + ], + programAddress, + data: getInitializeRewardInstructionDataEncoder().encode({}), + } as InitializeRewardInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardVault, + TAccountRewardTreasuryVault, + TAccountFarmVaultsAuthority, + TAccountTreasuryVaultsAuthority, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountRent + >; + + return instruction; +} + +export interface ParsedInitializeRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmAdmin: TAccountMetas[0]; + farmState: TAccountMetas[1]; + globalConfig: TAccountMetas[2]; + rewardMint: TAccountMetas[3]; + rewardVault: TAccountMetas[4]; + rewardTreasuryVault: TAccountMetas[5]; + farmVaultsAuthority: TAccountMetas[6]; + treasuryVaultsAuthority: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + systemProgram: TAccountMetas[9]; + rent: TAccountMetas[10]; + }; + data: InitializeRewardInstructionData; +} + +export function parseInitializeRewardInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitializeRewardInstruction { + if (instruction.accounts.length < 11) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmAdmin: getNextAccount(), + farmState: getNextAccount(), + globalConfig: getNextAccount(), + rewardMint: getNextAccount(), + rewardVault: getNextAccount(), + rewardTreasuryVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + treasuryVaultsAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + rent: getNextAccount(), + }, + data: getInitializeRewardInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/initializeUser.ts b/clients/kamino-lending/src/generated/instructions/initializeUser.ts new file mode 100644 index 00000000..ed120a14 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/initializeUser.ts @@ -0,0 +1,275 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const INITIALIZE_USER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [111, 17, 185, 250, 60, 122, 38, 254], +); + +export function getInitializeUserDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_USER_DISCRIMINATOR, + ); +} + +export type InitializeUserInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountAuthority extends string | AccountMeta = string, + TAccountPayer extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountDelegatee extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority, + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountOwner extends string + ? ReadonlyAccount + : TAccountOwner, + TAccountDelegatee extends string + ? ReadonlyAccount + : TAccountDelegatee, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + ...TRemainingAccounts, + ] + >; + +export interface InitializeUserInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface InitializeUserInstructionDataArgs {} + +export function getInitializeUserInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: INITIALIZE_USER_DISCRIMINATOR }), + ); +} + +export function getInitializeUserInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeUserInstructionDataCodec(): FixedSizeCodec< + InitializeUserInstructionDataArgs, + InitializeUserInstructionData +> { + return combineCodec( + getInitializeUserInstructionDataEncoder(), + getInitializeUserInstructionDataDecoder(), + ); +} + +export interface InitializeUserInput< + TAccountAuthority extends string = string, + TAccountPayer extends string = string, + TAccountOwner extends string = string, + TAccountDelegatee extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountSystemProgram extends string = string, + TAccountRent extends string = string, +> { + authority: TransactionSigner; + payer: TransactionSigner; + owner: Address; + delegatee: Address; + userState: Address; + farmState: Address; + systemProgram: Address; + rent: Address; +} + +export function getInitializeUserInstruction< + TAccountAuthority extends string, + TAccountPayer extends string, + TAccountOwner extends string, + TAccountDelegatee extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountSystemProgram extends string, + TAccountRent extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: InitializeUserInput< + TAccountAuthority, + TAccountPayer, + TAccountOwner, + TAccountDelegatee, + TAccountUserState, + TAccountFarmState, + TAccountSystemProgram, + TAccountRent + >, + config?: { programAddress?: TProgramAddress }, +): InitializeUserInstruction< + TProgramAddress, + TAccountAuthority, + TAccountPayer, + TAccountOwner, + TAccountDelegatee, + TAccountUserState, + TAccountFarmState, + TAccountSystemProgram, + TAccountRent +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authority: { value: input.authority ?? null, isWritable: false }, + payer: { value: input.payer ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + delegatee: { value: input.delegatee ?? null, isWritable: false }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.authority), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.delegatee), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.rent), + ], + programAddress, + data: getInitializeUserInstructionDataEncoder().encode({}), + } as InitializeUserInstruction< + TProgramAddress, + TAccountAuthority, + TAccountPayer, + TAccountOwner, + TAccountDelegatee, + TAccountUserState, + TAccountFarmState, + TAccountSystemProgram, + TAccountRent + >; + + return instruction; +} + +export interface ParsedInitializeUserInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + authority: TAccountMetas[0]; + payer: TAccountMetas[1]; + owner: TAccountMetas[2]; + delegatee: TAccountMetas[3]; + userState: TAccountMetas[4]; + farmState: TAccountMetas[5]; + systemProgram: TAccountMetas[6]; + rent: TAccountMetas[7]; + }; + data: InitializeUserInstructionData; +} + +export function parseInitializeUserInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedInitializeUserInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + authority: getNextAccount(), + payer: getNextAccount(), + owner: getNextAccount(), + delegatee: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + systemProgram: getNextAccount(), + rent: getNextAccount(), + }, + data: getInitializeUserInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateral.ts b/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateral.ts new file mode 100644 index 00000000..850f140e --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateral.ts @@ -0,0 +1,530 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([177, 71, 154, 188, 226, 133, 74, 55]); + +export function getLiquidateObligationAndRedeemReserveCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + ); +} + +export type LiquidateObligationAndRedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLiquidator extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountRepayReserve extends string | AccountMeta = string, + TAccountRepayReserveLiquidityMint extends string | AccountMeta = string, + TAccountRepayReserveLiquiditySupply extends string | AccountMeta = string, + TAccountWithdrawReserve extends string | AccountMeta = string, + TAccountWithdrawReserveLiquidityMint extends string | AccountMeta = string, + TAccountWithdrawReserveCollateralMint extends string | AccountMeta = string, + TAccountWithdrawReserveCollateralSupply extends string | AccountMeta = string, + TAccountWithdrawReserveLiquiditySupply extends string | AccountMeta = string, + TAccountWithdrawReserveLiquidityFeeReceiver extends + | string + | AccountMeta = string, + TAccountUserSourceLiquidity extends string | AccountMeta = string, + TAccountUserDestinationCollateral extends string | AccountMeta = string, + TAccountUserDestinationLiquidity extends string | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountRepayLiquidityTokenProgram extends string | AccountMeta = string, + TAccountWithdrawLiquidityTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLiquidator extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLiquidator, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountRepayReserve extends string + ? WritableAccount + : TAccountRepayReserve, + TAccountRepayReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountRepayReserveLiquidityMint, + TAccountRepayReserveLiquiditySupply extends string + ? WritableAccount + : TAccountRepayReserveLiquiditySupply, + TAccountWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawReserve, + TAccountWithdrawReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountWithdrawReserveLiquidityMint, + TAccountWithdrawReserveCollateralMint extends string + ? WritableAccount + : TAccountWithdrawReserveCollateralMint, + TAccountWithdrawReserveCollateralSupply extends string + ? WritableAccount + : TAccountWithdrawReserveCollateralSupply, + TAccountWithdrawReserveLiquiditySupply extends string + ? WritableAccount + : TAccountWithdrawReserveLiquiditySupply, + TAccountWithdrawReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountWithdrawReserveLiquidityFeeReceiver, + TAccountUserSourceLiquidity extends string + ? WritableAccount + : TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral extends string + ? WritableAccount + : TAccountUserDestinationCollateral, + TAccountUserDestinationLiquidity extends string + ? WritableAccount + : TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountRepayLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountRepayLiquidityTokenProgram, + TAccountWithdrawLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawLiquidityTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface LiquidateObligationAndRedeemReserveCollateralInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; + minAcceptableReceivedLiquidityAmount: bigint; + maxAllowedLtvOverridePercent: bigint; +} + +export interface LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs { + liquidityAmount: number | bigint; + minAcceptableReceivedLiquidityAmount: number | bigint; + maxAllowedLtvOverridePercent: number | bigint; +} + +export function getLiquidateObligationAndRedeemReserveCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ["minAcceptableReceivedLiquidityAmount", getU64Encoder()], + ["maxAllowedLtvOverridePercent", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getLiquidateObligationAndRedeemReserveCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ["minAcceptableReceivedLiquidityAmount", getU64Decoder()], + ["maxAllowedLtvOverridePercent", getU64Decoder()], + ]); +} + +export function getLiquidateObligationAndRedeemReserveCollateralInstructionDataCodec(): FixedSizeCodec< + LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs, + LiquidateObligationAndRedeemReserveCollateralInstructionData +> { + return combineCodec( + getLiquidateObligationAndRedeemReserveCollateralInstructionDataEncoder(), + getLiquidateObligationAndRedeemReserveCollateralInstructionDataDecoder(), + ); +} + +export interface LiquidateObligationAndRedeemReserveCollateralInput< + TAccountLiquidator extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountRepayReserve extends string = string, + TAccountRepayReserveLiquidityMint extends string = string, + TAccountRepayReserveLiquiditySupply extends string = string, + TAccountWithdrawReserve extends string = string, + TAccountWithdrawReserveLiquidityMint extends string = string, + TAccountWithdrawReserveCollateralMint extends string = string, + TAccountWithdrawReserveCollateralSupply extends string = string, + TAccountWithdrawReserveLiquiditySupply extends string = string, + TAccountWithdrawReserveLiquidityFeeReceiver extends string = string, + TAccountUserSourceLiquidity extends string = string, + TAccountUserDestinationCollateral extends string = string, + TAccountUserDestinationLiquidity extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountRepayLiquidityTokenProgram extends string = string, + TAccountWithdrawLiquidityTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + liquidator: TransactionSigner; + obligation: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + repayReserve: Address; + repayReserveLiquidityMint: Address; + repayReserveLiquiditySupply: Address; + withdrawReserve: Address; + withdrawReserveLiquidityMint: Address; + withdrawReserveCollateralMint: Address; + withdrawReserveCollateralSupply: Address; + withdrawReserveLiquiditySupply: Address; + withdrawReserveLiquidityFeeReceiver: Address; + userSourceLiquidity: Address; + userDestinationCollateral: Address; + userDestinationLiquidity: Address; + collateralTokenProgram: Address; + repayLiquidityTokenProgram: Address; + withdrawLiquidityTokenProgram: Address; + instructionSysvarAccount?: Address; + liquidityAmount: LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs["liquidityAmount"]; + minAcceptableReceivedLiquidityAmount: LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs["minAcceptableReceivedLiquidityAmount"]; + maxAllowedLtvOverridePercent: LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs["maxAllowedLtvOverridePercent"]; +} + +export function getLiquidateObligationAndRedeemReserveCollateralInstruction< + TAccountLiquidator extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountRepayReserve extends string, + TAccountRepayReserveLiquidityMint extends string, + TAccountRepayReserveLiquiditySupply extends string, + TAccountWithdrawReserve extends string, + TAccountWithdrawReserveLiquidityMint extends string, + TAccountWithdrawReserveCollateralMint extends string, + TAccountWithdrawReserveCollateralSupply extends string, + TAccountWithdrawReserveLiquiditySupply extends string, + TAccountWithdrawReserveLiquidityFeeReceiver extends string, + TAccountUserSourceLiquidity extends string, + TAccountUserDestinationCollateral extends string, + TAccountUserDestinationLiquidity extends string, + TAccountCollateralTokenProgram extends string, + TAccountRepayLiquidityTokenProgram extends string, + TAccountWithdrawLiquidityTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: LiquidateObligationAndRedeemReserveCollateralInput< + TAccountLiquidator, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountRepayReserve, + TAccountRepayReserveLiquidityMint, + TAccountRepayReserveLiquiditySupply, + TAccountWithdrawReserve, + TAccountWithdrawReserveLiquidityMint, + TAccountWithdrawReserveCollateralMint, + TAccountWithdrawReserveCollateralSupply, + TAccountWithdrawReserveLiquiditySupply, + TAccountWithdrawReserveLiquidityFeeReceiver, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountRepayLiquidityTokenProgram, + TAccountWithdrawLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): LiquidateObligationAndRedeemReserveCollateralInstruction< + TProgramAddress, + TAccountLiquidator, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountRepayReserve, + TAccountRepayReserveLiquidityMint, + TAccountRepayReserveLiquiditySupply, + TAccountWithdrawReserve, + TAccountWithdrawReserveLiquidityMint, + TAccountWithdrawReserveCollateralMint, + TAccountWithdrawReserveCollateralSupply, + TAccountWithdrawReserveLiquiditySupply, + TAccountWithdrawReserveLiquidityFeeReceiver, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountRepayLiquidityTokenProgram, + TAccountWithdrawLiquidityTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + liquidator: { value: input.liquidator ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + repayReserve: { value: input.repayReserve ?? null, isWritable: true }, + repayReserveLiquidityMint: { + value: input.repayReserveLiquidityMint ?? null, + isWritable: false, + }, + repayReserveLiquiditySupply: { + value: input.repayReserveLiquiditySupply ?? null, + isWritable: true, + }, + withdrawReserve: { value: input.withdrawReserve ?? null, isWritable: true }, + withdrawReserveLiquidityMint: { + value: input.withdrawReserveLiquidityMint ?? null, + isWritable: false, + }, + withdrawReserveCollateralMint: { + value: input.withdrawReserveCollateralMint ?? null, + isWritable: true, + }, + withdrawReserveCollateralSupply: { + value: input.withdrawReserveCollateralSupply ?? null, + isWritable: true, + }, + withdrawReserveLiquiditySupply: { + value: input.withdrawReserveLiquiditySupply ?? null, + isWritable: true, + }, + withdrawReserveLiquidityFeeReceiver: { + value: input.withdrawReserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + userSourceLiquidity: { + value: input.userSourceLiquidity ?? null, + isWritable: true, + }, + userDestinationCollateral: { + value: input.userDestinationCollateral ?? null, + isWritable: true, + }, + userDestinationLiquidity: { + value: input.userDestinationLiquidity ?? null, + isWritable: true, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + repayLiquidityTokenProgram: { + value: input.repayLiquidityTokenProgram ?? null, + isWritable: false, + }, + withdrawLiquidityTokenProgram: { + value: input.withdrawLiquidityTokenProgram ?? null, + isWritable: false, + }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.liquidator), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.repayReserve), + getAccountMeta(accounts.repayReserveLiquidityMint), + getAccountMeta(accounts.repayReserveLiquiditySupply), + getAccountMeta(accounts.withdrawReserve), + getAccountMeta(accounts.withdrawReserveLiquidityMint), + getAccountMeta(accounts.withdrawReserveCollateralMint), + getAccountMeta(accounts.withdrawReserveCollateralSupply), + getAccountMeta(accounts.withdrawReserveLiquiditySupply), + getAccountMeta(accounts.withdrawReserveLiquidityFeeReceiver), + getAccountMeta(accounts.userSourceLiquidity), + getAccountMeta(accounts.userDestinationCollateral), + getAccountMeta(accounts.userDestinationLiquidity), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.repayLiquidityTokenProgram), + getAccountMeta(accounts.withdrawLiquidityTokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getLiquidateObligationAndRedeemReserveCollateralInstructionDataEncoder().encode( + args as LiquidateObligationAndRedeemReserveCollateralInstructionDataArgs, + ), + } as LiquidateObligationAndRedeemReserveCollateralInstruction< + TProgramAddress, + TAccountLiquidator, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountRepayReserve, + TAccountRepayReserveLiquidityMint, + TAccountRepayReserveLiquiditySupply, + TAccountWithdrawReserve, + TAccountWithdrawReserveLiquidityMint, + TAccountWithdrawReserveCollateralMint, + TAccountWithdrawReserveCollateralSupply, + TAccountWithdrawReserveLiquiditySupply, + TAccountWithdrawReserveLiquidityFeeReceiver, + TAccountUserSourceLiquidity, + TAccountUserDestinationCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountRepayLiquidityTokenProgram, + TAccountWithdrawLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedLiquidateObligationAndRedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + liquidator: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + repayReserve: TAccountMetas[4]; + repayReserveLiquidityMint: TAccountMetas[5]; + repayReserveLiquiditySupply: TAccountMetas[6]; + withdrawReserve: TAccountMetas[7]; + withdrawReserveLiquidityMint: TAccountMetas[8]; + withdrawReserveCollateralMint: TAccountMetas[9]; + withdrawReserveCollateralSupply: TAccountMetas[10]; + withdrawReserveLiquiditySupply: TAccountMetas[11]; + withdrawReserveLiquidityFeeReceiver: TAccountMetas[12]; + userSourceLiquidity: TAccountMetas[13]; + userDestinationCollateral: TAccountMetas[14]; + userDestinationLiquidity: TAccountMetas[15]; + collateralTokenProgram: TAccountMetas[16]; + repayLiquidityTokenProgram: TAccountMetas[17]; + withdrawLiquidityTokenProgram: TAccountMetas[18]; + instructionSysvarAccount: TAccountMetas[19]; + }; + data: LiquidateObligationAndRedeemReserveCollateralInstructionData; +} + +export function parseLiquidateObligationAndRedeemReserveCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedLiquidateObligationAndRedeemReserveCollateralInstruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 20) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + liquidator: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + repayReserve: getNextAccount(), + repayReserveLiquidityMint: getNextAccount(), + repayReserveLiquiditySupply: getNextAccount(), + withdrawReserve: getNextAccount(), + withdrawReserveLiquidityMint: getNextAccount(), + withdrawReserveCollateralMint: getNextAccount(), + withdrawReserveCollateralSupply: getNextAccount(), + withdrawReserveLiquiditySupply: getNextAccount(), + withdrawReserveLiquidityFeeReceiver: getNextAccount(), + userSourceLiquidity: getNextAccount(), + userDestinationCollateral: getNextAccount(), + userDestinationLiquidity: getNextAccount(), + collateralTokenProgram: getNextAccount(), + repayLiquidityTokenProgram: getNextAccount(), + withdrawLiquidityTokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getLiquidateObligationAndRedeemReserveCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts b/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts new file mode 100644 index 00000000..f15bf254 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts @@ -0,0 +1,689 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([162, 161, 35, 143, 30, 187, 185, 103]); + +export function getLiquidateObligationAndRedeemReserveCollateralV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR, + ); +} + +export type LiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLiquidationAccountsLiquidator extends string | AccountMeta = string, + TAccountLiquidationAccountsObligation extends string | AccountMeta = string, + TAccountLiquidationAccountsLendingMarket extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsRepayReserve extends string | AccountMeta = string, + TAccountLiquidationAccountsRepayReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsRepayReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserve extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsUserSourceLiquidity extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsUserDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsRepayLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountLiquidationAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountCollateralFarmsAccountsV2ObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountCollateralFarmsAccountsV2ReserveFarmState extends + | string + | AccountMeta = string, + TAccountDebtFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountDebtFarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLiquidationAccountsLiquidator extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLiquidationAccountsLiquidator, + TAccountLiquidationAccountsObligation extends string + ? WritableAccount + : TAccountLiquidationAccountsObligation, + TAccountLiquidationAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsLendingMarket, + TAccountLiquidationAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsLendingMarketAuthority, + TAccountLiquidationAccountsRepayReserve extends string + ? WritableAccount + : TAccountLiquidationAccountsRepayReserve, + TAccountLiquidationAccountsRepayReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsRepayReserveLiquidityMint, + TAccountLiquidationAccountsRepayReserveLiquiditySupply extends string + ? WritableAccount + : TAccountLiquidationAccountsRepayReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserve extends string + ? WritableAccount + : TAccountLiquidationAccountsWithdrawReserve, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsWithdrawReserveLiquidityMint, + TAccountLiquidationAccountsWithdrawReserveCollateralMint extends string + ? WritableAccount + : TAccountLiquidationAccountsWithdrawReserveCollateralMint, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply extends string + ? WritableAccount + : TAccountLiquidationAccountsWithdrawReserveCollateralSupply, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply extends string + ? WritableAccount + : TAccountLiquidationAccountsWithdrawReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver, + TAccountLiquidationAccountsUserSourceLiquidity extends string + ? WritableAccount + : TAccountLiquidationAccountsUserSourceLiquidity, + TAccountLiquidationAccountsUserDestinationCollateral extends string + ? WritableAccount + : TAccountLiquidationAccountsUserDestinationCollateral, + TAccountLiquidationAccountsUserDestinationLiquidity extends string + ? WritableAccount + : TAccountLiquidationAccountsUserDestinationLiquidity, + TAccountLiquidationAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsCollateralTokenProgram, + TAccountLiquidationAccountsRepayLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsRepayLiquidityTokenProgram, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsWithdrawLiquidityTokenProgram, + TAccountLiquidationAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountLiquidationAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState extends string + ? WritableAccount + : TAccountCollateralFarmsAccountsV2ObligationFarmUserState, + TAccountCollateralFarmsAccountsV2ReserveFarmState extends string + ? WritableAccount + : TAccountCollateralFarmsAccountsV2ReserveFarmState, + TAccountDebtFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountDebtFarmsAccountsObligationFarmUserState, + TAccountDebtFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface LiquidateObligationAndRedeemReserveCollateralV2InstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; + minAcceptableReceivedLiquidityAmount: bigint; + maxAllowedLtvOverridePercent: bigint; +} + +export interface LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs { + liquidityAmount: number | bigint; + minAcceptableReceivedLiquidityAmount: number | bigint; + maxAllowedLtvOverridePercent: number | bigint; +} + +export function getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ["minAcceptableReceivedLiquidityAmount", getU64Encoder()], + ["maxAllowedLtvOverridePercent", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR, + }), + ); +} + +export function getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ["minAcceptableReceivedLiquidityAmount", getU64Decoder()], + ["maxAllowedLtvOverridePercent", getU64Decoder()], + ]); +} + +export function getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataCodec(): FixedSizeCodec< + LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs, + LiquidateObligationAndRedeemReserveCollateralV2InstructionData +> { + return combineCodec( + getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataEncoder(), + getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataDecoder(), + ); +} + +export interface LiquidateObligationAndRedeemReserveCollateralV2Input< + TAccountLiquidationAccountsLiquidator extends string = string, + TAccountLiquidationAccountsObligation extends string = string, + TAccountLiquidationAccountsLendingMarket extends string = string, + TAccountLiquidationAccountsLendingMarketAuthority extends string = string, + TAccountLiquidationAccountsRepayReserve extends string = string, + TAccountLiquidationAccountsRepayReserveLiquidityMint extends string = string, + TAccountLiquidationAccountsRepayReserveLiquiditySupply extends + string = string, + TAccountLiquidationAccountsWithdrawReserve extends string = string, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint extends + string = string, + TAccountLiquidationAccountsWithdrawReserveCollateralMint extends + string = string, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply extends + string = string, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply extends + string = string, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver extends + string = string, + TAccountLiquidationAccountsUserSourceLiquidity extends string = string, + TAccountLiquidationAccountsUserDestinationCollateral extends string = string, + TAccountLiquidationAccountsUserDestinationLiquidity extends string = string, + TAccountLiquidationAccountsCollateralTokenProgram extends string = string, + TAccountLiquidationAccountsRepayLiquidityTokenProgram extends string = string, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram extends + string = string, + TAccountLiquidationAccountsInstructionSysvarAccount extends string = string, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState extends + string = string, + TAccountCollateralFarmsAccountsV2ReserveFarmState extends string = string, + TAccountDebtFarmsAccountsObligationFarmUserState extends string = string, + TAccountDebtFarmsAccountsReserveFarmState extends string = string, + TAccountFarmsProgram extends string = string, +> { + liquidationAccountsLiquidator: TransactionSigner; + liquidationAccountsObligation: Address; + liquidationAccountsLendingMarket: Address; + liquidationAccountsLendingMarketAuthority: Address; + liquidationAccountsRepayReserve: Address; + liquidationAccountsRepayReserveLiquidityMint: Address; + liquidationAccountsRepayReserveLiquiditySupply: Address; + liquidationAccountsWithdrawReserve: Address; + liquidationAccountsWithdrawReserveLiquidityMint: Address; + liquidationAccountsWithdrawReserveCollateralMint: Address; + liquidationAccountsWithdrawReserveCollateralSupply: Address; + liquidationAccountsWithdrawReserveLiquiditySupply: Address; + liquidationAccountsWithdrawReserveLiquidityFeeReceiver: Address; + liquidationAccountsUserSourceLiquidity: Address; + liquidationAccountsUserDestinationCollateral: Address; + liquidationAccountsUserDestinationLiquidity: Address; + liquidationAccountsCollateralTokenProgram: Address; + liquidationAccountsRepayLiquidityTokenProgram: Address; + liquidationAccountsWithdrawLiquidityTokenProgram: Address; + liquidationAccountsInstructionSysvarAccount?: Address; + collateralFarmsAccountsV2ObligationFarmUserState?: Address; + collateralFarmsAccountsV2ReserveFarmState?: Address; + debtFarmsAccountsObligationFarmUserState?: Address; + debtFarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + liquidityAmount: LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs["liquidityAmount"]; + minAcceptableReceivedLiquidityAmount: LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs["minAcceptableReceivedLiquidityAmount"]; + maxAllowedLtvOverridePercent: LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs["maxAllowedLtvOverridePercent"]; +} + +export function getLiquidateObligationAndRedeemReserveCollateralV2Instruction< + TAccountLiquidationAccountsLiquidator extends string, + TAccountLiquidationAccountsObligation extends string, + TAccountLiquidationAccountsLendingMarket extends string, + TAccountLiquidationAccountsLendingMarketAuthority extends string, + TAccountLiquidationAccountsRepayReserve extends string, + TAccountLiquidationAccountsRepayReserveLiquidityMint extends string, + TAccountLiquidationAccountsRepayReserveLiquiditySupply extends string, + TAccountLiquidationAccountsWithdrawReserve extends string, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint extends string, + TAccountLiquidationAccountsWithdrawReserveCollateralMint extends string, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply extends string, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply extends string, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver extends string, + TAccountLiquidationAccountsUserSourceLiquidity extends string, + TAccountLiquidationAccountsUserDestinationCollateral extends string, + TAccountLiquidationAccountsUserDestinationLiquidity extends string, + TAccountLiquidationAccountsCollateralTokenProgram extends string, + TAccountLiquidationAccountsRepayLiquidityTokenProgram extends string, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram extends string, + TAccountLiquidationAccountsInstructionSysvarAccount extends string, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState extends string, + TAccountCollateralFarmsAccountsV2ReserveFarmState extends string, + TAccountDebtFarmsAccountsObligationFarmUserState extends string, + TAccountDebtFarmsAccountsReserveFarmState extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: LiquidateObligationAndRedeemReserveCollateralV2Input< + TAccountLiquidationAccountsLiquidator, + TAccountLiquidationAccountsObligation, + TAccountLiquidationAccountsLendingMarket, + TAccountLiquidationAccountsLendingMarketAuthority, + TAccountLiquidationAccountsRepayReserve, + TAccountLiquidationAccountsRepayReserveLiquidityMint, + TAccountLiquidationAccountsRepayReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserve, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint, + TAccountLiquidationAccountsWithdrawReserveCollateralMint, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver, + TAccountLiquidationAccountsUserSourceLiquidity, + TAccountLiquidationAccountsUserDestinationCollateral, + TAccountLiquidationAccountsUserDestinationLiquidity, + TAccountLiquidationAccountsCollateralTokenProgram, + TAccountLiquidationAccountsRepayLiquidityTokenProgram, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram, + TAccountLiquidationAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState, + TAccountCollateralFarmsAccountsV2ReserveFarmState, + TAccountDebtFarmsAccountsObligationFarmUserState, + TAccountDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): LiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgramAddress, + TAccountLiquidationAccountsLiquidator, + TAccountLiquidationAccountsObligation, + TAccountLiquidationAccountsLendingMarket, + TAccountLiquidationAccountsLendingMarketAuthority, + TAccountLiquidationAccountsRepayReserve, + TAccountLiquidationAccountsRepayReserveLiquidityMint, + TAccountLiquidationAccountsRepayReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserve, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint, + TAccountLiquidationAccountsWithdrawReserveCollateralMint, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver, + TAccountLiquidationAccountsUserSourceLiquidity, + TAccountLiquidationAccountsUserDestinationCollateral, + TAccountLiquidationAccountsUserDestinationLiquidity, + TAccountLiquidationAccountsCollateralTokenProgram, + TAccountLiquidationAccountsRepayLiquidityTokenProgram, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram, + TAccountLiquidationAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState, + TAccountCollateralFarmsAccountsV2ReserveFarmState, + TAccountDebtFarmsAccountsObligationFarmUserState, + TAccountDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + liquidationAccountsLiquidator: { + value: input.liquidationAccountsLiquidator ?? null, + isWritable: false, + }, + liquidationAccountsObligation: { + value: input.liquidationAccountsObligation ?? null, + isWritable: true, + }, + liquidationAccountsLendingMarket: { + value: input.liquidationAccountsLendingMarket ?? null, + isWritable: false, + }, + liquidationAccountsLendingMarketAuthority: { + value: input.liquidationAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + liquidationAccountsRepayReserve: { + value: input.liquidationAccountsRepayReserve ?? null, + isWritable: true, + }, + liquidationAccountsRepayReserveLiquidityMint: { + value: input.liquidationAccountsRepayReserveLiquidityMint ?? null, + isWritable: false, + }, + liquidationAccountsRepayReserveLiquiditySupply: { + value: input.liquidationAccountsRepayReserveLiquiditySupply ?? null, + isWritable: true, + }, + liquidationAccountsWithdrawReserve: { + value: input.liquidationAccountsWithdrawReserve ?? null, + isWritable: true, + }, + liquidationAccountsWithdrawReserveLiquidityMint: { + value: input.liquidationAccountsWithdrawReserveLiquidityMint ?? null, + isWritable: false, + }, + liquidationAccountsWithdrawReserveCollateralMint: { + value: input.liquidationAccountsWithdrawReserveCollateralMint ?? null, + isWritable: true, + }, + liquidationAccountsWithdrawReserveCollateralSupply: { + value: input.liquidationAccountsWithdrawReserveCollateralSupply ?? null, + isWritable: true, + }, + liquidationAccountsWithdrawReserveLiquiditySupply: { + value: input.liquidationAccountsWithdrawReserveLiquiditySupply ?? null, + isWritable: true, + }, + liquidationAccountsWithdrawReserveLiquidityFeeReceiver: { + value: + input.liquidationAccountsWithdrawReserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + liquidationAccountsUserSourceLiquidity: { + value: input.liquidationAccountsUserSourceLiquidity ?? null, + isWritable: true, + }, + liquidationAccountsUserDestinationCollateral: { + value: input.liquidationAccountsUserDestinationCollateral ?? null, + isWritable: true, + }, + liquidationAccountsUserDestinationLiquidity: { + value: input.liquidationAccountsUserDestinationLiquidity ?? null, + isWritable: true, + }, + liquidationAccountsCollateralTokenProgram: { + value: input.liquidationAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + liquidationAccountsRepayLiquidityTokenProgram: { + value: input.liquidationAccountsRepayLiquidityTokenProgram ?? null, + isWritable: false, + }, + liquidationAccountsWithdrawLiquidityTokenProgram: { + value: input.liquidationAccountsWithdrawLiquidityTokenProgram ?? null, + isWritable: false, + }, + liquidationAccountsInstructionSysvarAccount: { + value: input.liquidationAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + collateralFarmsAccountsV2ObligationFarmUserState: { + value: input.collateralFarmsAccountsV2ObligationFarmUserState ?? null, + isWritable: true, + }, + collateralFarmsAccountsV2ReserveFarmState: { + value: input.collateralFarmsAccountsV2ReserveFarmState ?? null, + isWritable: true, + }, + debtFarmsAccountsObligationFarmUserState: { + value: input.debtFarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + debtFarmsAccountsReserveFarmState: { + value: input.debtFarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.liquidationAccountsInstructionSysvarAccount.value) { + accounts.liquidationAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.liquidationAccountsLiquidator), + getAccountMeta(accounts.liquidationAccountsObligation), + getAccountMeta(accounts.liquidationAccountsLendingMarket), + getAccountMeta(accounts.liquidationAccountsLendingMarketAuthority), + getAccountMeta(accounts.liquidationAccountsRepayReserve), + getAccountMeta(accounts.liquidationAccountsRepayReserveLiquidityMint), + getAccountMeta(accounts.liquidationAccountsRepayReserveLiquiditySupply), + getAccountMeta(accounts.liquidationAccountsWithdrawReserve), + getAccountMeta(accounts.liquidationAccountsWithdrawReserveLiquidityMint), + getAccountMeta(accounts.liquidationAccountsWithdrawReserveCollateralMint), + getAccountMeta( + accounts.liquidationAccountsWithdrawReserveCollateralSupply, + ), + getAccountMeta( + accounts.liquidationAccountsWithdrawReserveLiquiditySupply, + ), + getAccountMeta( + accounts.liquidationAccountsWithdrawReserveLiquidityFeeReceiver, + ), + getAccountMeta(accounts.liquidationAccountsUserSourceLiquidity), + getAccountMeta(accounts.liquidationAccountsUserDestinationCollateral), + getAccountMeta(accounts.liquidationAccountsUserDestinationLiquidity), + getAccountMeta(accounts.liquidationAccountsCollateralTokenProgram), + getAccountMeta(accounts.liquidationAccountsRepayLiquidityTokenProgram), + getAccountMeta(accounts.liquidationAccountsWithdrawLiquidityTokenProgram), + getAccountMeta(accounts.liquidationAccountsInstructionSysvarAccount), + getAccountMeta(accounts.collateralFarmsAccountsV2ObligationFarmUserState), + getAccountMeta(accounts.collateralFarmsAccountsV2ReserveFarmState), + getAccountMeta(accounts.debtFarmsAccountsObligationFarmUserState), + getAccountMeta(accounts.debtFarmsAccountsReserveFarmState), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataEncoder().encode( + args as LiquidateObligationAndRedeemReserveCollateralV2InstructionDataArgs, + ), + } as LiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgramAddress, + TAccountLiquidationAccountsLiquidator, + TAccountLiquidationAccountsObligation, + TAccountLiquidationAccountsLendingMarket, + TAccountLiquidationAccountsLendingMarketAuthority, + TAccountLiquidationAccountsRepayReserve, + TAccountLiquidationAccountsRepayReserveLiquidityMint, + TAccountLiquidationAccountsRepayReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserve, + TAccountLiquidationAccountsWithdrawReserveLiquidityMint, + TAccountLiquidationAccountsWithdrawReserveCollateralMint, + TAccountLiquidationAccountsWithdrawReserveCollateralSupply, + TAccountLiquidationAccountsWithdrawReserveLiquiditySupply, + TAccountLiquidationAccountsWithdrawReserveLiquidityFeeReceiver, + TAccountLiquidationAccountsUserSourceLiquidity, + TAccountLiquidationAccountsUserDestinationCollateral, + TAccountLiquidationAccountsUserDestinationLiquidity, + TAccountLiquidationAccountsCollateralTokenProgram, + TAccountLiquidationAccountsRepayLiquidityTokenProgram, + TAccountLiquidationAccountsWithdrawLiquidityTokenProgram, + TAccountLiquidationAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsV2ObligationFarmUserState, + TAccountCollateralFarmsAccountsV2ReserveFarmState, + TAccountDebtFarmsAccountsObligationFarmUserState, + TAccountDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedLiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + liquidationAccountsLiquidator: TAccountMetas[0]; + liquidationAccountsObligation: TAccountMetas[1]; + liquidationAccountsLendingMarket: TAccountMetas[2]; + liquidationAccountsLendingMarketAuthority: TAccountMetas[3]; + liquidationAccountsRepayReserve: TAccountMetas[4]; + liquidationAccountsRepayReserveLiquidityMint: TAccountMetas[5]; + liquidationAccountsRepayReserveLiquiditySupply: TAccountMetas[6]; + liquidationAccountsWithdrawReserve: TAccountMetas[7]; + liquidationAccountsWithdrawReserveLiquidityMint: TAccountMetas[8]; + liquidationAccountsWithdrawReserveCollateralMint: TAccountMetas[9]; + liquidationAccountsWithdrawReserveCollateralSupply: TAccountMetas[10]; + liquidationAccountsWithdrawReserveLiquiditySupply: TAccountMetas[11]; + liquidationAccountsWithdrawReserveLiquidityFeeReceiver: TAccountMetas[12]; + liquidationAccountsUserSourceLiquidity: TAccountMetas[13]; + liquidationAccountsUserDestinationCollateral: TAccountMetas[14]; + liquidationAccountsUserDestinationLiquidity: TAccountMetas[15]; + liquidationAccountsCollateralTokenProgram: TAccountMetas[16]; + liquidationAccountsRepayLiquidityTokenProgram: TAccountMetas[17]; + liquidationAccountsWithdrawLiquidityTokenProgram: TAccountMetas[18]; + liquidationAccountsInstructionSysvarAccount: TAccountMetas[19]; + collateralFarmsAccountsV2ObligationFarmUserState?: + | TAccountMetas[20] + | undefined; + collateralFarmsAccountsV2ReserveFarmState?: TAccountMetas[21] | undefined; + debtFarmsAccountsObligationFarmUserState?: TAccountMetas[22] | undefined; + debtFarmsAccountsReserveFarmState?: TAccountMetas[23] | undefined; + farmsProgram: TAccountMetas[24]; + }; + data: LiquidateObligationAndRedeemReserveCollateralV2InstructionData; +} + +export function parseLiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedLiquidateObligationAndRedeemReserveCollateralV2Instruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 25) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + liquidationAccountsLiquidator: getNextAccount(), + liquidationAccountsObligation: getNextAccount(), + liquidationAccountsLendingMarket: getNextAccount(), + liquidationAccountsLendingMarketAuthority: getNextAccount(), + liquidationAccountsRepayReserve: getNextAccount(), + liquidationAccountsRepayReserveLiquidityMint: getNextAccount(), + liquidationAccountsRepayReserveLiquiditySupply: getNextAccount(), + liquidationAccountsWithdrawReserve: getNextAccount(), + liquidationAccountsWithdrawReserveLiquidityMint: getNextAccount(), + liquidationAccountsWithdrawReserveCollateralMint: getNextAccount(), + liquidationAccountsWithdrawReserveCollateralSupply: getNextAccount(), + liquidationAccountsWithdrawReserveLiquiditySupply: getNextAccount(), + liquidationAccountsWithdrawReserveLiquidityFeeReceiver: getNextAccount(), + liquidationAccountsUserSourceLiquidity: getNextAccount(), + liquidationAccountsUserDestinationCollateral: getNextAccount(), + liquidationAccountsUserDestinationLiquidity: getNextAccount(), + liquidationAccountsCollateralTokenProgram: getNextAccount(), + liquidationAccountsRepayLiquidityTokenProgram: getNextAccount(), + liquidationAccountsWithdrawLiquidityTokenProgram: getNextAccount(), + liquidationAccountsInstructionSysvarAccount: getNextAccount(), + collateralFarmsAccountsV2ObligationFarmUserState: + getNextOptionalAccount(), + collateralFarmsAccountsV2ReserveFarmState: getNextOptionalAccount(), + debtFarmsAccountsObligationFarmUserState: getNextOptionalAccount(), + debtFarmsAccountsReserveFarmState: getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getLiquidateObligationAndRedeemReserveCollateralV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/markObligationForDeleveraging.ts b/clients/kamino-lending/src/generated/instructions/markObligationForDeleveraging.ts new file mode 100644 index 00000000..9ba9287b --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/markObligationForDeleveraging.ts @@ -0,0 +1,223 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const MARK_OBLIGATION_FOR_DELEVERAGING_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([164, 35, 182, 19, 0, 116, 243, 127]); + +export function getMarkObligationForDeleveragingDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MARK_OBLIGATION_FOR_DELEVERAGING_DISCRIMINATOR, + ); +} + +export type MarkObligationForDeleveragingInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountRiskCouncil extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRiskCouncil extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountRiskCouncil, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + ...TRemainingAccounts, + ] + >; + +export interface MarkObligationForDeleveragingInstructionData { + discriminator: ReadonlyUint8Array; + autodeleverageTargetLtvPct: number; +} + +export interface MarkObligationForDeleveragingInstructionDataArgs { + autodeleverageTargetLtvPct: number; +} + +export function getMarkObligationForDeleveragingInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["autodeleverageTargetLtvPct", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: MARK_OBLIGATION_FOR_DELEVERAGING_DISCRIMINATOR, + }), + ); +} + +export function getMarkObligationForDeleveragingInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["autodeleverageTargetLtvPct", getU8Decoder()], + ]); +} + +export function getMarkObligationForDeleveragingInstructionDataCodec(): FixedSizeCodec< + MarkObligationForDeleveragingInstructionDataArgs, + MarkObligationForDeleveragingInstructionData +> { + return combineCodec( + getMarkObligationForDeleveragingInstructionDataEncoder(), + getMarkObligationForDeleveragingInstructionDataDecoder(), + ); +} + +export interface MarkObligationForDeleveragingInput< + TAccountRiskCouncil extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, +> { + riskCouncil: TransactionSigner; + obligation: Address; + lendingMarket: Address; + autodeleverageTargetLtvPct: MarkObligationForDeleveragingInstructionDataArgs["autodeleverageTargetLtvPct"]; +} + +export function getMarkObligationForDeleveragingInstruction< + TAccountRiskCouncil extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: MarkObligationForDeleveragingInput< + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket + >, + config?: { programAddress?: TProgramAddress }, +): MarkObligationForDeleveragingInstruction< + TProgramAddress, + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + riskCouncil: { value: input.riskCouncil ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.riskCouncil), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + ], + programAddress, + data: getMarkObligationForDeleveragingInstructionDataEncoder().encode( + args as MarkObligationForDeleveragingInstructionDataArgs, + ), + } as MarkObligationForDeleveragingInstruction< + TProgramAddress, + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket + >; + + return instruction; +} + +export interface ParsedMarkObligationForDeleveragingInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + riskCouncil: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + }; + data: MarkObligationForDeleveragingInstructionData; +} + +export function parseMarkObligationForDeleveragingInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedMarkObligationForDeleveragingInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + riskCouncil: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + }, + data: getMarkObligationForDeleveragingInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/redeemFees.ts b/clients/kamino-lending/src/generated/instructions/redeemFees.ts new file mode 100644 index 00000000..898b16ac --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/redeemFees.ts @@ -0,0 +1,266 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REDEEM_FEES_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 215, 39, 180, 41, 173, 46, 248, 220, +]); + +export function getRedeemFeesDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(REDEEM_FEES_DISCRIMINATOR); +} + +export type RedeemFeesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveLiquidityFeeReceiver extends string | AccountMeta = string, + TAccountReserveSupplyLiquidity extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveLiquidityFeeReceiver extends string + ? WritableAccount + : TAccountReserveLiquidityFeeReceiver, + TAccountReserveSupplyLiquidity extends string + ? WritableAccount + : TAccountReserveSupplyLiquidity, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface RedeemFeesInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface RedeemFeesInstructionDataArgs {} + +export function getRedeemFeesInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REDEEM_FEES_DISCRIMINATOR }), + ); +} + +export function getRedeemFeesInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRedeemFeesInstructionDataCodec(): FixedSizeCodec< + RedeemFeesInstructionDataArgs, + RedeemFeesInstructionData +> { + return combineCodec( + getRedeemFeesInstructionDataEncoder(), + getRedeemFeesInstructionDataDecoder(), + ); +} + +export interface RedeemFeesInput< + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveLiquidityFeeReceiver extends string = string, + TAccountReserveSupplyLiquidity extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountTokenProgram extends string = string, +> { + reserve: Address; + reserveLiquidityMint: Address; + reserveLiquidityFeeReceiver: Address; + reserveSupplyLiquidity: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + tokenProgram: Address; +} + +export function getRedeemFeesInstruction< + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveLiquidityFeeReceiver extends string, + TAccountReserveSupplyLiquidity extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RedeemFeesInput< + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquidityFeeReceiver, + TAccountReserveSupplyLiquidity, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): RedeemFeesInstruction< + TProgramAddress, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquidityFeeReceiver, + TAccountReserveSupplyLiquidity, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveLiquidityFeeReceiver: { + value: input.reserveLiquidityFeeReceiver ?? null, + isWritable: true, + }, + reserveSupplyLiquidity: { + value: input.reserveSupplyLiquidity ?? null, + isWritable: true, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveLiquidityFeeReceiver), + getAccountMeta(accounts.reserveSupplyLiquidity), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getRedeemFeesInstructionDataEncoder().encode({}), + } as RedeemFeesInstruction< + TProgramAddress, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveLiquidityFeeReceiver, + TAccountReserveSupplyLiquidity, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedRedeemFeesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + reserve: TAccountMetas[0]; + reserveLiquidityMint: TAccountMetas[1]; + reserveLiquidityFeeReceiver: TAccountMetas[2]; + reserveSupplyLiquidity: TAccountMetas[3]; + lendingMarket: TAccountMetas[4]; + lendingMarketAuthority: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + }; + data: RedeemFeesInstructionData; +} + +export function parseRedeemFeesInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRedeemFeesInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveLiquidityFeeReceiver: getNextAccount(), + reserveSupplyLiquidity: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getRedeemFeesInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/redeemReserveCollateral.ts b/clients/kamino-lending/src/generated/instructions/redeemReserveCollateral.ts new file mode 100644 index 00000000..60c76d15 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/redeemReserveCollateral.ts @@ -0,0 +1,384 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([234, 117, 181, 125, 185, 142, 220, 29]); + +export function getRedeemReserveCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + ); +} + +export type RedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveCollateralMint extends string | AccountMeta = string, + TAccountReserveLiquiditySupply extends string | AccountMeta = string, + TAccountUserSourceCollateral extends string | AccountMeta = string, + TAccountUserDestinationLiquidity extends string | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountLiquidityTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveCollateralMint extends string + ? WritableAccount + : TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply extends string + ? WritableAccount + : TAccountReserveLiquiditySupply, + TAccountUserSourceCollateral extends string + ? WritableAccount + : TAccountUserSourceCollateral, + TAccountUserDestinationLiquidity extends string + ? WritableAccount + : TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface RedeemReserveCollateralInstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface RedeemReserveCollateralInstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getRedeemReserveCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getRedeemReserveCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getRedeemReserveCollateralInstructionDataCodec(): FixedSizeCodec< + RedeemReserveCollateralInstructionDataArgs, + RedeemReserveCollateralInstructionData +> { + return combineCodec( + getRedeemReserveCollateralInstructionDataEncoder(), + getRedeemReserveCollateralInstructionDataDecoder(), + ); +} + +export interface RedeemReserveCollateralInput< + TAccountOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveCollateralMint extends string = string, + TAccountReserveLiquiditySupply extends string = string, + TAccountUserSourceCollateral extends string = string, + TAccountUserDestinationLiquidity extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountLiquidityTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + lendingMarket: Address; + reserve: Address; + lendingMarketAuthority: Address; + reserveLiquidityMint: Address; + reserveCollateralMint: Address; + reserveLiquiditySupply: Address; + userSourceCollateral: Address; + userDestinationLiquidity: Address; + collateralTokenProgram: Address; + liquidityTokenProgram: Address; + instructionSysvarAccount?: Address; + collateralAmount: RedeemReserveCollateralInstructionDataArgs["collateralAmount"]; +} + +export function getRedeemReserveCollateralInstruction< + TAccountOwner extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountLendingMarketAuthority extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveCollateralMint extends string, + TAccountReserveLiquiditySupply extends string, + TAccountUserSourceCollateral extends string, + TAccountUserDestinationLiquidity extends string, + TAccountCollateralTokenProgram extends string, + TAccountLiquidityTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RedeemReserveCollateralInput< + TAccountOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserSourceCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): RedeemReserveCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserSourceCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveCollateralMint: { + value: input.reserveCollateralMint ?? null, + isWritable: true, + }, + reserveLiquiditySupply: { + value: input.reserveLiquiditySupply ?? null, + isWritable: true, + }, + userSourceCollateral: { + value: input.userSourceCollateral ?? null, + isWritable: true, + }, + userDestinationLiquidity: { + value: input.userDestinationLiquidity ?? null, + isWritable: true, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + liquidityTokenProgram: { + value: input.liquidityTokenProgram ?? null, + isWritable: false, + }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveCollateralMint), + getAccountMeta(accounts.reserveLiquiditySupply), + getAccountMeta(accounts.userSourceCollateral), + getAccountMeta(accounts.userDestinationLiquidity), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.liquidityTokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getRedeemReserveCollateralInstructionDataEncoder().encode( + args as RedeemReserveCollateralInstructionDataArgs, + ), + } as RedeemReserveCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountLendingMarketAuthority, + TAccountReserveLiquidityMint, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserSourceCollateral, + TAccountUserDestinationLiquidity, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedRedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + reserve: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveCollateralMint: TAccountMetas[5]; + reserveLiquiditySupply: TAccountMetas[6]; + userSourceCollateral: TAccountMetas[7]; + userDestinationLiquidity: TAccountMetas[8]; + collateralTokenProgram: TAccountMetas[9]; + liquidityTokenProgram: TAccountMetas[10]; + instructionSysvarAccount: TAccountMetas[11]; + }; + data: RedeemReserveCollateralInstructionData; +} + +export function parseRedeemReserveCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRedeemReserveCollateralInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveCollateralMint: getNextAccount(), + reserveLiquiditySupply: getNextAccount(), + userSourceCollateral: getNextAccount(), + userDestinationLiquidity: getNextAccount(), + collateralTokenProgram: getNextAccount(), + liquidityTokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getRedeemReserveCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshFarm.ts b/clients/kamino-lending/src/generated/instructions/refreshFarm.ts new file mode 100644 index 00000000..deabda03 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshFarm.ts @@ -0,0 +1,188 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REFRESH_FARM_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 214, 131, 138, 183, 144, 194, 172, 42, +]); + +export function getRefreshFarmDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_FARM_DISCRIMINATOR, + ); +} + +export type RefreshFarmInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmState extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + ...TRemainingAccounts, + ] + >; + +export interface RefreshFarmInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface RefreshFarmInstructionDataArgs {} + +export function getRefreshFarmInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REFRESH_FARM_DISCRIMINATOR }), + ); +} + +export function getRefreshFarmInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRefreshFarmInstructionDataCodec(): FixedSizeCodec< + RefreshFarmInstructionDataArgs, + RefreshFarmInstructionData +> { + return combineCodec( + getRefreshFarmInstructionDataEncoder(), + getRefreshFarmInstructionDataDecoder(), + ); +} + +export interface RefreshFarmInput< + TAccountFarmState extends string = string, + TAccountScopePrices extends string = string, +> { + farmState: Address; + scopePrices?: Address; +} + +export function getRefreshFarmInstruction< + TAccountFarmState extends string, + TAccountScopePrices extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: RefreshFarmInput, + config?: { programAddress?: TProgramAddress }, +): RefreshFarmInstruction< + TProgramAddress, + TAccountFarmState, + TAccountScopePrices +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmState: { value: input.farmState ?? null, isWritable: true }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.scopePrices), + ], + programAddress, + data: getRefreshFarmInstructionDataEncoder().encode({}), + } as RefreshFarmInstruction< + TProgramAddress, + TAccountFarmState, + TAccountScopePrices + >; + + return instruction; +} + +export interface ParsedRefreshFarmInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmState: TAccountMetas[0]; + scopePrices?: TAccountMetas[1] | undefined; + }; + data: RefreshFarmInstructionData; +} + +export function parseRefreshFarmInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRefreshFarmInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmState: getNextAccount(), + scopePrices: getNextOptionalAccount(), + }, + data: getRefreshFarmInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshObligation.ts b/clients/kamino-lending/src/generated/instructions/refreshObligation.ts new file mode 100644 index 00000000..ca2b5c0b --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshObligation.ts @@ -0,0 +1,182 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REFRESH_OBLIGATION_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([33, 132, 147, 228, 151, 192, 72, 89]); + +export function getRefreshObligationDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_OBLIGATION_DISCRIMINATOR, + ); +} + +export type RefreshObligationInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + ...TRemainingAccounts, + ] + >; + +export interface RefreshObligationInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface RefreshObligationInstructionDataArgs {} + +export function getRefreshObligationInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REFRESH_OBLIGATION_DISCRIMINATOR }), + ); +} + +export function getRefreshObligationInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRefreshObligationInstructionDataCodec(): FixedSizeCodec< + RefreshObligationInstructionDataArgs, + RefreshObligationInstructionData +> { + return combineCodec( + getRefreshObligationInstructionDataEncoder(), + getRefreshObligationInstructionDataDecoder(), + ); +} + +export interface RefreshObligationInput< + TAccountLendingMarket extends string = string, + TAccountObligation extends string = string, +> { + lendingMarket: Address; + obligation: Address; +} + +export function getRefreshObligationInstruction< + TAccountLendingMarket extends string, + TAccountObligation extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RefreshObligationInput, + config?: { programAddress?: TProgramAddress }, +): RefreshObligationInstruction< + TProgramAddress, + TAccountLendingMarket, + TAccountObligation +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.obligation), + ], + programAddress, + data: getRefreshObligationInstructionDataEncoder().encode({}), + } as RefreshObligationInstruction< + TProgramAddress, + TAccountLendingMarket, + TAccountObligation + >; + + return instruction; +} + +export interface ParsedRefreshObligationInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarket: TAccountMetas[0]; + obligation: TAccountMetas[1]; + }; + data: RefreshObligationInstructionData; +} + +export function parseRefreshObligationInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRefreshObligationInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarket: getNextAccount(), + obligation: getNextAccount(), + }, + data: getRefreshObligationInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshObligationFarmsForReserve.ts b/clients/kamino-lending/src/generated/instructions/refreshObligationFarmsForReserve.ts new file mode 100644 index 00000000..e06b4eec --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshObligationFarmsForReserve.ts @@ -0,0 +1,343 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REFRESH_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([140, 144, 253, 21, 10, 74, 248, 3]); + +export function getRefreshObligationFarmsForReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR, + ); +} + +export type RefreshObligationFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountCrank extends string | AccountMeta = string, + TAccountBaseAccountsObligation extends string | AccountMeta = string, + TAccountBaseAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountBaseAccountsReserve extends string | AccountMeta = string, + TAccountBaseAccountsReserveFarmState extends string | AccountMeta = string, + TAccountBaseAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountBaseAccountsLendingMarket extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TAccountRent extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountCrank extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountCrank, + TAccountBaseAccountsObligation extends string + ? ReadonlyAccount + : TAccountBaseAccountsObligation, + TAccountBaseAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountBaseAccountsLendingMarketAuthority, + TAccountBaseAccountsReserve extends string + ? ReadonlyAccount + : TAccountBaseAccountsReserve, + TAccountBaseAccountsReserveFarmState extends string + ? WritableAccount + : TAccountBaseAccountsReserveFarmState, + TAccountBaseAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountBaseAccountsObligationFarmUserState, + TAccountBaseAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountBaseAccountsLendingMarket, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + TAccountRent extends string + ? ReadonlyAccount + : TAccountRent, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export interface RefreshObligationFarmsForReserveInstructionData { + discriminator: ReadonlyUint8Array; + mode: number; +} + +export interface RefreshObligationFarmsForReserveInstructionDataArgs { + mode: number; +} + +export function getRefreshObligationFarmsForReserveInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REFRESH_OBLIGATION_FARMS_FOR_RESERVE_DISCRIMINATOR, + }), + ); +} + +export function getRefreshObligationFarmsForReserveInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU8Decoder()], + ]); +} + +export function getRefreshObligationFarmsForReserveInstructionDataCodec(): FixedSizeCodec< + RefreshObligationFarmsForReserveInstructionDataArgs, + RefreshObligationFarmsForReserveInstructionData +> { + return combineCodec( + getRefreshObligationFarmsForReserveInstructionDataEncoder(), + getRefreshObligationFarmsForReserveInstructionDataDecoder(), + ); +} + +export interface RefreshObligationFarmsForReserveInput< + TAccountCrank extends string = string, + TAccountBaseAccountsObligation extends string = string, + TAccountBaseAccountsLendingMarketAuthority extends string = string, + TAccountBaseAccountsReserve extends string = string, + TAccountBaseAccountsReserveFarmState extends string = string, + TAccountBaseAccountsObligationFarmUserState extends string = string, + TAccountBaseAccountsLendingMarket extends string = string, + TAccountFarmsProgram extends string = string, + TAccountRent extends string = string, + TAccountSystemProgram extends string = string, +> { + crank: TransactionSigner; + baseAccountsObligation: Address; + baseAccountsLendingMarketAuthority: Address; + baseAccountsReserve: Address; + baseAccountsReserveFarmState: Address; + baseAccountsObligationFarmUserState: Address; + baseAccountsLendingMarket: Address; + farmsProgram: Address; + rent: Address; + systemProgram: Address; + mode: RefreshObligationFarmsForReserveInstructionDataArgs["mode"]; +} + +export function getRefreshObligationFarmsForReserveInstruction< + TAccountCrank extends string, + TAccountBaseAccountsObligation extends string, + TAccountBaseAccountsLendingMarketAuthority extends string, + TAccountBaseAccountsReserve extends string, + TAccountBaseAccountsReserveFarmState extends string, + TAccountBaseAccountsObligationFarmUserState extends string, + TAccountBaseAccountsLendingMarket extends string, + TAccountFarmsProgram extends string, + TAccountRent extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RefreshObligationFarmsForReserveInput< + TAccountCrank, + TAccountBaseAccountsObligation, + TAccountBaseAccountsLendingMarketAuthority, + TAccountBaseAccountsReserve, + TAccountBaseAccountsReserveFarmState, + TAccountBaseAccountsObligationFarmUserState, + TAccountBaseAccountsLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress }, +): RefreshObligationFarmsForReserveInstruction< + TProgramAddress, + TAccountCrank, + TAccountBaseAccountsObligation, + TAccountBaseAccountsLendingMarketAuthority, + TAccountBaseAccountsReserve, + TAccountBaseAccountsReserveFarmState, + TAccountBaseAccountsObligationFarmUserState, + TAccountBaseAccountsLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + crank: { value: input.crank ?? null, isWritable: false }, + baseAccountsObligation: { + value: input.baseAccountsObligation ?? null, + isWritable: false, + }, + baseAccountsLendingMarketAuthority: { + value: input.baseAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + baseAccountsReserve: { + value: input.baseAccountsReserve ?? null, + isWritable: false, + }, + baseAccountsReserveFarmState: { + value: input.baseAccountsReserveFarmState ?? null, + isWritable: true, + }, + baseAccountsObligationFarmUserState: { + value: input.baseAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + baseAccountsLendingMarket: { + value: input.baseAccountsLendingMarket ?? null, + isWritable: false, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + rent: { value: input.rent ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.crank), + getAccountMeta(accounts.baseAccountsObligation), + getAccountMeta(accounts.baseAccountsLendingMarketAuthority), + getAccountMeta(accounts.baseAccountsReserve), + getAccountMeta(accounts.baseAccountsReserveFarmState), + getAccountMeta(accounts.baseAccountsObligationFarmUserState), + getAccountMeta(accounts.baseAccountsLendingMarket), + getAccountMeta(accounts.farmsProgram), + getAccountMeta(accounts.rent), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getRefreshObligationFarmsForReserveInstructionDataEncoder().encode( + args as RefreshObligationFarmsForReserveInstructionDataArgs, + ), + } as RefreshObligationFarmsForReserveInstruction< + TProgramAddress, + TAccountCrank, + TAccountBaseAccountsObligation, + TAccountBaseAccountsLendingMarketAuthority, + TAccountBaseAccountsReserve, + TAccountBaseAccountsReserveFarmState, + TAccountBaseAccountsObligationFarmUserState, + TAccountBaseAccountsLendingMarket, + TAccountFarmsProgram, + TAccountRent, + TAccountSystemProgram + >; + + return instruction; +} + +export interface ParsedRefreshObligationFarmsForReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + crank: TAccountMetas[0]; + baseAccountsObligation: TAccountMetas[1]; + baseAccountsLendingMarketAuthority: TAccountMetas[2]; + baseAccountsReserve: TAccountMetas[3]; + baseAccountsReserveFarmState: TAccountMetas[4]; + baseAccountsObligationFarmUserState: TAccountMetas[5]; + baseAccountsLendingMarket: TAccountMetas[6]; + farmsProgram: TAccountMetas[7]; + rent: TAccountMetas[8]; + systemProgram: TAccountMetas[9]; + }; + data: RefreshObligationFarmsForReserveInstructionData; +} + +export function parseRefreshObligationFarmsForReserveInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRefreshObligationFarmsForReserveInstruction { + if (instruction.accounts.length < 10) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + crank: getNextAccount(), + baseAccountsObligation: getNextAccount(), + baseAccountsLendingMarketAuthority: getNextAccount(), + baseAccountsReserve: getNextAccount(), + baseAccountsReserveFarmState: getNextAccount(), + baseAccountsObligationFarmUserState: getNextAccount(), + baseAccountsLendingMarket: getNextAccount(), + farmsProgram: getNextAccount(), + rent: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getRefreshObligationFarmsForReserveInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshReserve.ts b/clients/kamino-lending/src/generated/instructions/refreshReserve.ts new file mode 100644 index 00000000..c756b992 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshReserve.ts @@ -0,0 +1,254 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REFRESH_RESERVE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [2, 218, 138, 235, 79, 201, 25, 102], +); + +export function getRefreshReserveDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_RESERVE_DISCRIMINATOR, + ); +} + +export type RefreshReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountReserve extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountPythOracle extends string | AccountMeta = string, + TAccountSwitchboardPriceOracle extends string | AccountMeta = string, + TAccountSwitchboardTwapOracle extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountPythOracle extends string + ? ReadonlyAccount + : TAccountPythOracle, + TAccountSwitchboardPriceOracle extends string + ? ReadonlyAccount + : TAccountSwitchboardPriceOracle, + TAccountSwitchboardTwapOracle extends string + ? ReadonlyAccount + : TAccountSwitchboardTwapOracle, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + ...TRemainingAccounts, + ] + >; + +export interface RefreshReserveInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface RefreshReserveInstructionDataArgs {} + +export function getRefreshReserveInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REFRESH_RESERVE_DISCRIMINATOR }), + ); +} + +export function getRefreshReserveInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRefreshReserveInstructionDataCodec(): FixedSizeCodec< + RefreshReserveInstructionDataArgs, + RefreshReserveInstructionData +> { + return combineCodec( + getRefreshReserveInstructionDataEncoder(), + getRefreshReserveInstructionDataDecoder(), + ); +} + +export interface RefreshReserveInput< + TAccountReserve extends string = string, + TAccountLendingMarket extends string = string, + TAccountPythOracle extends string = string, + TAccountSwitchboardPriceOracle extends string = string, + TAccountSwitchboardTwapOracle extends string = string, + TAccountScopePrices extends string = string, +> { + reserve: Address; + lendingMarket: Address; + pythOracle?: Address; + switchboardPriceOracle?: Address; + switchboardTwapOracle?: Address; + scopePrices?: Address; +} + +export function getRefreshReserveInstruction< + TAccountReserve extends string, + TAccountLendingMarket extends string, + TAccountPythOracle extends string, + TAccountSwitchboardPriceOracle extends string, + TAccountSwitchboardTwapOracle extends string, + TAccountScopePrices extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RefreshReserveInput< + TAccountReserve, + TAccountLendingMarket, + TAccountPythOracle, + TAccountSwitchboardPriceOracle, + TAccountSwitchboardTwapOracle, + TAccountScopePrices + >, + config?: { programAddress?: TProgramAddress }, +): RefreshReserveInstruction< + TProgramAddress, + TAccountReserve, + TAccountLendingMarket, + TAccountPythOracle, + TAccountSwitchboardPriceOracle, + TAccountSwitchboardTwapOracle, + TAccountScopePrices +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + reserve: { value: input.reserve ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + pythOracle: { value: input.pythOracle ?? null, isWritable: false }, + switchboardPriceOracle: { + value: input.switchboardPriceOracle ?? null, + isWritable: false, + }, + switchboardTwapOracle: { + value: input.switchboardTwapOracle ?? null, + isWritable: false, + }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.pythOracle), + getAccountMeta(accounts.switchboardPriceOracle), + getAccountMeta(accounts.switchboardTwapOracle), + getAccountMeta(accounts.scopePrices), + ], + programAddress, + data: getRefreshReserveInstructionDataEncoder().encode({}), + } as RefreshReserveInstruction< + TProgramAddress, + TAccountReserve, + TAccountLendingMarket, + TAccountPythOracle, + TAccountSwitchboardPriceOracle, + TAccountSwitchboardTwapOracle, + TAccountScopePrices + >; + + return instruction; +} + +export interface ParsedRefreshReserveInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + reserve: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + pythOracle?: TAccountMetas[2] | undefined; + switchboardPriceOracle?: TAccountMetas[3] | undefined; + switchboardTwapOracle?: TAccountMetas[4] | undefined; + scopePrices?: TAccountMetas[5] | undefined; + }; + data: RefreshReserveInstructionData; +} + +export function parseRefreshReserveInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRefreshReserveInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + reserve: getNextAccount(), + lendingMarket: getNextAccount(), + pythOracle: getNextOptionalAccount(), + switchboardPriceOracle: getNextOptionalAccount(), + switchboardTwapOracle: getNextOptionalAccount(), + scopePrices: getNextOptionalAccount(), + }, + data: getRefreshReserveInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshReservesBatch.ts b/clients/kamino-lending/src/generated/instructions/refreshReservesBatch.ts new file mode 100644 index 00000000..8ad458ae --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshReservesBatch.ts @@ -0,0 +1,132 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyUint8Array, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; + +export const REFRESH_RESERVES_BATCH_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([144, 110, 26, 103, 162, 204, 252, 147]); + +export function getRefreshReservesBatchDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_RESERVES_BATCH_DISCRIMINATOR, + ); +} + +export type RefreshReservesBatchInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts; + +export interface RefreshReservesBatchInstructionData { + discriminator: ReadonlyUint8Array; + skipPriceUpdates: boolean; +} + +export interface RefreshReservesBatchInstructionDataArgs { + skipPriceUpdates: boolean; +} + +export function getRefreshReservesBatchInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["skipPriceUpdates", getBooleanEncoder()], + ]), + (value) => ({ + ...value, + discriminator: REFRESH_RESERVES_BATCH_DISCRIMINATOR, + }), + ); +} + +export function getRefreshReservesBatchInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["skipPriceUpdates", getBooleanDecoder()], + ]); +} + +export function getRefreshReservesBatchInstructionDataCodec(): FixedSizeCodec< + RefreshReservesBatchInstructionDataArgs, + RefreshReservesBatchInstructionData +> { + return combineCodec( + getRefreshReservesBatchInstructionDataEncoder(), + getRefreshReservesBatchInstructionDataDecoder(), + ); +} + +export interface RefreshReservesBatchInput { + skipPriceUpdates: RefreshReservesBatchInstructionDataArgs["skipPriceUpdates"]; +} + +export function getRefreshReservesBatchInstruction< + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RefreshReservesBatchInput, + config?: { programAddress?: TProgramAddress }, +): RefreshReservesBatchInstruction { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original args. + const args = { ...input }; + + const instruction = { + programAddress, + data: getRefreshReservesBatchInstructionDataEncoder().encode( + args as RefreshReservesBatchInstructionDataArgs, + ), + } as RefreshReservesBatchInstruction; + + return instruction; +} + +export interface ParsedRefreshReservesBatchInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +> { + programAddress: Address; + data: RefreshReservesBatchInstructionData; +} + +export function parseRefreshReservesBatchInstruction( + instruction: Instruction & InstructionWithData, +): ParsedRefreshReservesBatchInstruction { + return { + programAddress: instruction.programAddress, + data: getRefreshReservesBatchInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/refreshUserState.ts b/clients/kamino-lending/src/generated/instructions/refreshUserState.ts new file mode 100644 index 00000000..fc119f0c --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/refreshUserState.ts @@ -0,0 +1,204 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REFRESH_USER_STATE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([1, 135, 12, 62, 243, 140, 77, 108]); + +export function getRefreshUserStateDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REFRESH_USER_STATE_DISCRIMINATOR, + ); +} + +export type RefreshUserStateInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + ...TRemainingAccounts, + ] + >; + +export interface RefreshUserStateInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface RefreshUserStateInstructionDataArgs {} + +export function getRefreshUserStateInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REFRESH_USER_STATE_DISCRIMINATOR }), + ); +} + +export function getRefreshUserStateInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRefreshUserStateInstructionDataCodec(): FixedSizeCodec< + RefreshUserStateInstructionDataArgs, + RefreshUserStateInstructionData +> { + return combineCodec( + getRefreshUserStateInstructionDataEncoder(), + getRefreshUserStateInstructionDataDecoder(), + ); +} + +export interface RefreshUserStateInput< + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountScopePrices extends string = string, +> { + userState: Address; + farmState: Address; + scopePrices?: Address; +} + +export function getRefreshUserStateInstruction< + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountScopePrices extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: RefreshUserStateInput< + TAccountUserState, + TAccountFarmState, + TAccountScopePrices + >, + config?: { programAddress?: TProgramAddress }, +): RefreshUserStateInstruction< + TProgramAddress, + TAccountUserState, + TAccountFarmState, + TAccountScopePrices +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.scopePrices), + ], + programAddress, + data: getRefreshUserStateInstructionDataEncoder().encode({}), + } as RefreshUserStateInstruction< + TProgramAddress, + TAccountUserState, + TAccountFarmState, + TAccountScopePrices + >; + + return instruction; +} + +export interface ParsedRefreshUserStateInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + userState: TAccountMetas[0]; + farmState: TAccountMetas[1]; + scopePrices?: TAccountMetas[2] | undefined; + }; + data: RefreshUserStateInstructionData; +} + +export function parseRefreshUserStateInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRefreshUserStateInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + userState: getNextAccount(), + farmState: getNextAccount(), + scopePrices: getNextOptionalAccount(), + }, + data: getRefreshUserStateInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/repayAndWithdrawAndRedeem.ts b/clients/kamino-lending/src/generated/instructions/repayAndWithdrawAndRedeem.ts new file mode 100644 index 00000000..379bb147 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/repayAndWithdrawAndRedeem.ts @@ -0,0 +1,724 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REPAY_AND_WITHDRAW_AND_REDEEM_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([2, 54, 152, 3, 148, 96, 109, 218]); + +export function getRepayAndWithdrawAndRedeemDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPAY_AND_WITHDRAW_AND_REDEEM_DISCRIMINATOR, + ); +} + +export type RepayAndWithdrawAndRedeemInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountRepayAccountsOwner extends string | AccountMeta = string, + TAccountRepayAccountsObligation extends string | AccountMeta = string, + TAccountRepayAccountsLendingMarket extends string | AccountMeta = string, + TAccountRepayAccountsRepayReserve extends string | AccountMeta = string, + TAccountRepayAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountRepayAccountsReserveDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountRepayAccountsUserSourceLiquidity extends + | string + | AccountMeta = string, + TAccountRepayAccountsTokenProgram extends string | AccountMeta = string, + TAccountRepayAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountWithdrawAccountsOwner extends string | AccountMeta = string, + TAccountWithdrawAccountsObligation extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarket extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsWithdrawReserve extends string | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveSourceCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountCollateralFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountCollateralFarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountRepayDebtFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountRepayDebtFarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRepayAccountsOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation extends string + ? WritableAccount + : TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve extends string + ? WritableAccount + : TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity extends string + ? WritableAccount + : TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity extends string + ? WritableAccount + : TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram extends string + ? ReadonlyAccount + : TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountRepayAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation extends string + ? WritableAccount + : TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity extends string + ? WritableAccount + : TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountCollateralFarmsAccountsObligationFarmUserState, + TAccountCollateralFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountCollateralFarmsAccountsReserveFarmState, + TAccountRepayDebtFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountRepayDebtFarmsAccountsObligationFarmUserState, + TAccountRepayDebtFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountRepayDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface RepayAndWithdrawAndRedeemInstructionData { + discriminator: ReadonlyUint8Array; + repayAmount: bigint; + withdrawCollateralAmount: bigint; +} + +export interface RepayAndWithdrawAndRedeemInstructionDataArgs { + repayAmount: number | bigint; + withdrawCollateralAmount: number | bigint; +} + +export function getRepayAndWithdrawAndRedeemInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["repayAmount", getU64Encoder()], + ["withdrawCollateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REPAY_AND_WITHDRAW_AND_REDEEM_DISCRIMINATOR, + }), + ); +} + +export function getRepayAndWithdrawAndRedeemInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["repayAmount", getU64Decoder()], + ["withdrawCollateralAmount", getU64Decoder()], + ]); +} + +export function getRepayAndWithdrawAndRedeemInstructionDataCodec(): FixedSizeCodec< + RepayAndWithdrawAndRedeemInstructionDataArgs, + RepayAndWithdrawAndRedeemInstructionData +> { + return combineCodec( + getRepayAndWithdrawAndRedeemInstructionDataEncoder(), + getRepayAndWithdrawAndRedeemInstructionDataDecoder(), + ); +} + +export interface RepayAndWithdrawAndRedeemInput< + TAccountRepayAccountsOwner extends string = string, + TAccountRepayAccountsObligation extends string = string, + TAccountRepayAccountsLendingMarket extends string = string, + TAccountRepayAccountsRepayReserve extends string = string, + TAccountRepayAccountsReserveLiquidityMint extends string = string, + TAccountRepayAccountsReserveDestinationLiquidity extends string = string, + TAccountRepayAccountsUserSourceLiquidity extends string = string, + TAccountRepayAccountsTokenProgram extends string = string, + TAccountRepayAccountsInstructionSysvarAccount extends string = string, + TAccountWithdrawAccountsOwner extends string = string, + TAccountWithdrawAccountsObligation extends string = string, + TAccountWithdrawAccountsLendingMarket extends string = string, + TAccountWithdrawAccountsLendingMarketAuthority extends string = string, + TAccountWithdrawAccountsWithdrawReserve extends string = string, + TAccountWithdrawAccountsReserveLiquidityMint extends string = string, + TAccountWithdrawAccountsReserveSourceCollateral extends string = string, + TAccountWithdrawAccountsReserveCollateralMint extends string = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + string = string, + TAccountWithdrawAccountsCollateralTokenProgram extends string = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string = string, + TAccountCollateralFarmsAccountsObligationFarmUserState extends + string = string, + TAccountCollateralFarmsAccountsReserveFarmState extends string = string, + TAccountRepayDebtFarmsAccountsObligationFarmUserState extends string = string, + TAccountRepayDebtFarmsAccountsReserveFarmState extends string = string, + TAccountFarmsProgram extends string = string, +> { + repayAccountsOwner: TransactionSigner; + repayAccountsObligation: Address; + repayAccountsLendingMarket: Address; + repayAccountsRepayReserve: Address; + repayAccountsReserveLiquidityMint: Address; + repayAccountsReserveDestinationLiquidity: Address; + repayAccountsUserSourceLiquidity: Address; + repayAccountsTokenProgram: Address; + repayAccountsInstructionSysvarAccount?: Address; + withdrawAccountsOwner: TransactionSigner; + withdrawAccountsObligation: Address; + withdrawAccountsLendingMarket: Address; + withdrawAccountsLendingMarketAuthority: Address; + withdrawAccountsWithdrawReserve: Address; + withdrawAccountsReserveLiquidityMint: Address; + withdrawAccountsReserveSourceCollateral: Address; + withdrawAccountsReserveCollateralMint: Address; + withdrawAccountsReserveLiquiditySupply: Address; + withdrawAccountsUserDestinationLiquidity: Address; + withdrawAccountsPlaceholderUserDestinationCollateral?: Address; + withdrawAccountsCollateralTokenProgram: Address; + withdrawAccountsLiquidityTokenProgram: Address; + withdrawAccountsInstructionSysvarAccount?: Address; + collateralFarmsAccountsObligationFarmUserState?: Address; + collateralFarmsAccountsReserveFarmState?: Address; + repayDebtFarmsAccountsObligationFarmUserState?: Address; + repayDebtFarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + repayAmount: RepayAndWithdrawAndRedeemInstructionDataArgs["repayAmount"]; + withdrawCollateralAmount: RepayAndWithdrawAndRedeemInstructionDataArgs["withdrawCollateralAmount"]; +} + +export function getRepayAndWithdrawAndRedeemInstruction< + TAccountRepayAccountsOwner extends string, + TAccountRepayAccountsObligation extends string, + TAccountRepayAccountsLendingMarket extends string, + TAccountRepayAccountsRepayReserve extends string, + TAccountRepayAccountsReserveLiquidityMint extends string, + TAccountRepayAccountsReserveDestinationLiquidity extends string, + TAccountRepayAccountsUserSourceLiquidity extends string, + TAccountRepayAccountsTokenProgram extends string, + TAccountRepayAccountsInstructionSysvarAccount extends string, + TAccountWithdrawAccountsOwner extends string, + TAccountWithdrawAccountsObligation extends string, + TAccountWithdrawAccountsLendingMarket extends string, + TAccountWithdrawAccountsLendingMarketAuthority extends string, + TAccountWithdrawAccountsWithdrawReserve extends string, + TAccountWithdrawAccountsReserveLiquidityMint extends string, + TAccountWithdrawAccountsReserveSourceCollateral extends string, + TAccountWithdrawAccountsReserveCollateralMint extends string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string, + TAccountWithdrawAccountsCollateralTokenProgram extends string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string, + TAccountCollateralFarmsAccountsObligationFarmUserState extends string, + TAccountCollateralFarmsAccountsReserveFarmState extends string, + TAccountRepayDebtFarmsAccountsObligationFarmUserState extends string, + TAccountRepayDebtFarmsAccountsReserveFarmState extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RepayAndWithdrawAndRedeemInput< + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsObligationFarmUserState, + TAccountCollateralFarmsAccountsReserveFarmState, + TAccountRepayDebtFarmsAccountsObligationFarmUserState, + TAccountRepayDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): RepayAndWithdrawAndRedeemInstruction< + TProgramAddress, + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsObligationFarmUserState, + TAccountCollateralFarmsAccountsReserveFarmState, + TAccountRepayDebtFarmsAccountsObligationFarmUserState, + TAccountRepayDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + repayAccountsOwner: { + value: input.repayAccountsOwner ?? null, + isWritable: false, + }, + repayAccountsObligation: { + value: input.repayAccountsObligation ?? null, + isWritable: true, + }, + repayAccountsLendingMarket: { + value: input.repayAccountsLendingMarket ?? null, + isWritable: false, + }, + repayAccountsRepayReserve: { + value: input.repayAccountsRepayReserve ?? null, + isWritable: true, + }, + repayAccountsReserveLiquidityMint: { + value: input.repayAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + repayAccountsReserveDestinationLiquidity: { + value: input.repayAccountsReserveDestinationLiquidity ?? null, + isWritable: true, + }, + repayAccountsUserSourceLiquidity: { + value: input.repayAccountsUserSourceLiquidity ?? null, + isWritable: true, + }, + repayAccountsTokenProgram: { + value: input.repayAccountsTokenProgram ?? null, + isWritable: false, + }, + repayAccountsInstructionSysvarAccount: { + value: input.repayAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + withdrawAccountsOwner: { + value: input.withdrawAccountsOwner ?? null, + isWritable: true, + }, + withdrawAccountsObligation: { + value: input.withdrawAccountsObligation ?? null, + isWritable: true, + }, + withdrawAccountsLendingMarket: { + value: input.withdrawAccountsLendingMarket ?? null, + isWritable: false, + }, + withdrawAccountsLendingMarketAuthority: { + value: input.withdrawAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawAccountsWithdrawReserve: { + value: input.withdrawAccountsWithdrawReserve ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquidityMint: { + value: input.withdrawAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + withdrawAccountsReserveSourceCollateral: { + value: input.withdrawAccountsReserveSourceCollateral ?? null, + isWritable: true, + }, + withdrawAccountsReserveCollateralMint: { + value: input.withdrawAccountsReserveCollateralMint ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquiditySupply: { + value: input.withdrawAccountsReserveLiquiditySupply ?? null, + isWritable: true, + }, + withdrawAccountsUserDestinationLiquidity: { + value: input.withdrawAccountsUserDestinationLiquidity ?? null, + isWritable: true, + }, + withdrawAccountsPlaceholderUserDestinationCollateral: { + value: input.withdrawAccountsPlaceholderUserDestinationCollateral ?? null, + isWritable: false, + }, + withdrawAccountsCollateralTokenProgram: { + value: input.withdrawAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsLiquidityTokenProgram: { + value: input.withdrawAccountsLiquidityTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsInstructionSysvarAccount: { + value: input.withdrawAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + collateralFarmsAccountsObligationFarmUserState: { + value: input.collateralFarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + collateralFarmsAccountsReserveFarmState: { + value: input.collateralFarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + repayDebtFarmsAccountsObligationFarmUserState: { + value: input.repayDebtFarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + repayDebtFarmsAccountsReserveFarmState: { + value: input.repayDebtFarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.repayAccountsInstructionSysvarAccount.value) { + accounts.repayAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + if (!accounts.withdrawAccountsInstructionSysvarAccount.value) { + accounts.withdrawAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.repayAccountsOwner), + getAccountMeta(accounts.repayAccountsObligation), + getAccountMeta(accounts.repayAccountsLendingMarket), + getAccountMeta(accounts.repayAccountsRepayReserve), + getAccountMeta(accounts.repayAccountsReserveLiquidityMint), + getAccountMeta(accounts.repayAccountsReserveDestinationLiquidity), + getAccountMeta(accounts.repayAccountsUserSourceLiquidity), + getAccountMeta(accounts.repayAccountsTokenProgram), + getAccountMeta(accounts.repayAccountsInstructionSysvarAccount), + getAccountMeta(accounts.withdrawAccountsOwner), + getAccountMeta(accounts.withdrawAccountsObligation), + getAccountMeta(accounts.withdrawAccountsLendingMarket), + getAccountMeta(accounts.withdrawAccountsLendingMarketAuthority), + getAccountMeta(accounts.withdrawAccountsWithdrawReserve), + getAccountMeta(accounts.withdrawAccountsReserveLiquidityMint), + getAccountMeta(accounts.withdrawAccountsReserveSourceCollateral), + getAccountMeta(accounts.withdrawAccountsReserveCollateralMint), + getAccountMeta(accounts.withdrawAccountsReserveLiquiditySupply), + getAccountMeta(accounts.withdrawAccountsUserDestinationLiquidity), + getAccountMeta( + accounts.withdrawAccountsPlaceholderUserDestinationCollateral, + ), + getAccountMeta(accounts.withdrawAccountsCollateralTokenProgram), + getAccountMeta(accounts.withdrawAccountsLiquidityTokenProgram), + getAccountMeta(accounts.withdrawAccountsInstructionSysvarAccount), + getAccountMeta(accounts.collateralFarmsAccountsObligationFarmUserState), + getAccountMeta(accounts.collateralFarmsAccountsReserveFarmState), + getAccountMeta(accounts.repayDebtFarmsAccountsObligationFarmUserState), + getAccountMeta(accounts.repayDebtFarmsAccountsReserveFarmState), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getRepayAndWithdrawAndRedeemInstructionDataEncoder().encode( + args as RepayAndWithdrawAndRedeemInstructionDataArgs, + ), + } as RepayAndWithdrawAndRedeemInstruction< + TProgramAddress, + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountCollateralFarmsAccountsObligationFarmUserState, + TAccountCollateralFarmsAccountsReserveFarmState, + TAccountRepayDebtFarmsAccountsObligationFarmUserState, + TAccountRepayDebtFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedRepayAndWithdrawAndRedeemInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + repayAccountsOwner: TAccountMetas[0]; + repayAccountsObligation: TAccountMetas[1]; + repayAccountsLendingMarket: TAccountMetas[2]; + repayAccountsRepayReserve: TAccountMetas[3]; + repayAccountsReserveLiquidityMint: TAccountMetas[4]; + repayAccountsReserveDestinationLiquidity: TAccountMetas[5]; + repayAccountsUserSourceLiquidity: TAccountMetas[6]; + repayAccountsTokenProgram: TAccountMetas[7]; + repayAccountsInstructionSysvarAccount: TAccountMetas[8]; + withdrawAccountsOwner: TAccountMetas[9]; + withdrawAccountsObligation: TAccountMetas[10]; + withdrawAccountsLendingMarket: TAccountMetas[11]; + withdrawAccountsLendingMarketAuthority: TAccountMetas[12]; + withdrawAccountsWithdrawReserve: TAccountMetas[13]; + withdrawAccountsReserveLiquidityMint: TAccountMetas[14]; + withdrawAccountsReserveSourceCollateral: TAccountMetas[15]; + withdrawAccountsReserveCollateralMint: TAccountMetas[16]; + withdrawAccountsReserveLiquiditySupply: TAccountMetas[17]; + withdrawAccountsUserDestinationLiquidity: TAccountMetas[18]; + withdrawAccountsPlaceholderUserDestinationCollateral?: + | TAccountMetas[19] + | undefined; + withdrawAccountsCollateralTokenProgram: TAccountMetas[20]; + withdrawAccountsLiquidityTokenProgram: TAccountMetas[21]; + withdrawAccountsInstructionSysvarAccount: TAccountMetas[22]; + collateralFarmsAccountsObligationFarmUserState?: + | TAccountMetas[23] + | undefined; + collateralFarmsAccountsReserveFarmState?: TAccountMetas[24] | undefined; + repayDebtFarmsAccountsObligationFarmUserState?: + | TAccountMetas[25] + | undefined; + repayDebtFarmsAccountsReserveFarmState?: TAccountMetas[26] | undefined; + farmsProgram: TAccountMetas[27]; + }; + data: RepayAndWithdrawAndRedeemInstructionData; +} + +export function parseRepayAndWithdrawAndRedeemInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRepayAndWithdrawAndRedeemInstruction { + if (instruction.accounts.length < 28) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + repayAccountsOwner: getNextAccount(), + repayAccountsObligation: getNextAccount(), + repayAccountsLendingMarket: getNextAccount(), + repayAccountsRepayReserve: getNextAccount(), + repayAccountsReserveLiquidityMint: getNextAccount(), + repayAccountsReserveDestinationLiquidity: getNextAccount(), + repayAccountsUserSourceLiquidity: getNextAccount(), + repayAccountsTokenProgram: getNextAccount(), + repayAccountsInstructionSysvarAccount: getNextAccount(), + withdrawAccountsOwner: getNextAccount(), + withdrawAccountsObligation: getNextAccount(), + withdrawAccountsLendingMarket: getNextAccount(), + withdrawAccountsLendingMarketAuthority: getNextAccount(), + withdrawAccountsWithdrawReserve: getNextAccount(), + withdrawAccountsReserveLiquidityMint: getNextAccount(), + withdrawAccountsReserveSourceCollateral: getNextAccount(), + withdrawAccountsReserveCollateralMint: getNextAccount(), + withdrawAccountsReserveLiquiditySupply: getNextAccount(), + withdrawAccountsUserDestinationLiquidity: getNextAccount(), + withdrawAccountsPlaceholderUserDestinationCollateral: + getNextOptionalAccount(), + withdrawAccountsCollateralTokenProgram: getNextAccount(), + withdrawAccountsLiquidityTokenProgram: getNextAccount(), + withdrawAccountsInstructionSysvarAccount: getNextAccount(), + collateralFarmsAccountsObligationFarmUserState: getNextOptionalAccount(), + collateralFarmsAccountsReserveFarmState: getNextOptionalAccount(), + repayDebtFarmsAccountsObligationFarmUserState: getNextOptionalAccount(), + repayDebtFarmsAccountsReserveFarmState: getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getRepayAndWithdrawAndRedeemInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/repayObligationLiquidity.ts b/clients/kamino-lending/src/generated/instructions/repayObligationLiquidity.ts new file mode 100644 index 00000000..b167642d --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/repayObligationLiquidity.ts @@ -0,0 +1,327 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REPAY_OBLIGATION_LIQUIDITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([145, 178, 13, 225, 76, 240, 147, 72]); + +export function getRepayObligationLiquidityDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPAY_OBLIGATION_LIQUIDITY_DISCRIMINATOR, + ); +} + +export type RepayObligationLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountRepayReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveDestinationLiquidity extends string | AccountMeta = string, + TAccountUserSourceLiquidity extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountRepayReserve extends string + ? WritableAccount + : TAccountRepayReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity extends string + ? WritableAccount + : TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity extends string + ? WritableAccount + : TAccountUserSourceLiquidity, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface RepayObligationLiquidityInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface RepayObligationLiquidityInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getRepayObligationLiquidityInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REPAY_OBLIGATION_LIQUIDITY_DISCRIMINATOR, + }), + ); +} + +export function getRepayObligationLiquidityInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getRepayObligationLiquidityInstructionDataCodec(): FixedSizeCodec< + RepayObligationLiquidityInstructionDataArgs, + RepayObligationLiquidityInstructionData +> { + return combineCodec( + getRepayObligationLiquidityInstructionDataEncoder(), + getRepayObligationLiquidityInstructionDataDecoder(), + ); +} + +export interface RepayObligationLiquidityInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountRepayReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveDestinationLiquidity extends string = string, + TAccountUserSourceLiquidity extends string = string, + TAccountTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + repayReserve: Address; + reserveLiquidityMint: Address; + reserveDestinationLiquidity: Address; + userSourceLiquidity: Address; + tokenProgram: Address; + instructionSysvarAccount?: Address; + liquidityAmount: RepayObligationLiquidityInstructionDataArgs["liquidityAmount"]; +} + +export function getRepayObligationLiquidityInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountRepayReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveDestinationLiquidity extends string, + TAccountUserSourceLiquidity extends string, + TAccountTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RepayObligationLiquidityInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountRepayReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): RepayObligationLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountRepayReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + repayReserve: { value: input.repayReserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveDestinationLiquidity: { + value: input.reserveDestinationLiquidity ?? null, + isWritable: true, + }, + userSourceLiquidity: { + value: input.userSourceLiquidity ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.repayReserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveDestinationLiquidity), + getAccountMeta(accounts.userSourceLiquidity), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getRepayObligationLiquidityInstructionDataEncoder().encode( + args as RepayObligationLiquidityInstructionDataArgs, + ), + } as RepayObligationLiquidityInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountRepayReserve, + TAccountReserveLiquidityMint, + TAccountReserveDestinationLiquidity, + TAccountUserSourceLiquidity, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedRepayObligationLiquidityInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + repayReserve: TAccountMetas[3]; + reserveLiquidityMint: TAccountMetas[4]; + reserveDestinationLiquidity: TAccountMetas[5]; + userSourceLiquidity: TAccountMetas[6]; + tokenProgram: TAccountMetas[7]; + instructionSysvarAccount: TAccountMetas[8]; + }; + data: RepayObligationLiquidityInstructionData; +} + +export function parseRepayObligationLiquidityInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRepayObligationLiquidityInstruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + repayReserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveDestinationLiquidity: getNextAccount(), + userSourceLiquidity: getNextAccount(), + tokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getRepayObligationLiquidityInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/repayObligationLiquidityV2.ts b/clients/kamino-lending/src/generated/instructions/repayObligationLiquidityV2.ts new file mode 100644 index 00000000..f3619767 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/repayObligationLiquidityV2.ts @@ -0,0 +1,440 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REPAY_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([116, 174, 213, 76, 180, 53, 210, 144]); + +export function getRepayObligationLiquidityV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPAY_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR, + ); +} + +export type RepayObligationLiquidityV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountRepayAccountsOwner extends string | AccountMeta = string, + TAccountRepayAccountsObligation extends string | AccountMeta = string, + TAccountRepayAccountsLendingMarket extends string | AccountMeta = string, + TAccountRepayAccountsRepayReserve extends string | AccountMeta = string, + TAccountRepayAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountRepayAccountsReserveDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountRepayAccountsUserSourceLiquidity extends + | string + | AccountMeta = string, + TAccountRepayAccountsTokenProgram extends string | AccountMeta = string, + TAccountRepayAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRepayAccountsOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation extends string + ? WritableAccount + : TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve extends string + ? WritableAccount + : TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity extends string + ? WritableAccount + : TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity extends string + ? WritableAccount + : TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram extends string + ? ReadonlyAccount + : TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountRepayAccountsInstructionSysvarAccount, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface RepayObligationLiquidityV2InstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface RepayObligationLiquidityV2InstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getRepayObligationLiquidityV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REPAY_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR, + }), + ); +} + +export function getRepayObligationLiquidityV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getRepayObligationLiquidityV2InstructionDataCodec(): FixedSizeCodec< + RepayObligationLiquidityV2InstructionDataArgs, + RepayObligationLiquidityV2InstructionData +> { + return combineCodec( + getRepayObligationLiquidityV2InstructionDataEncoder(), + getRepayObligationLiquidityV2InstructionDataDecoder(), + ); +} + +export interface RepayObligationLiquidityV2Input< + TAccountRepayAccountsOwner extends string = string, + TAccountRepayAccountsObligation extends string = string, + TAccountRepayAccountsLendingMarket extends string = string, + TAccountRepayAccountsRepayReserve extends string = string, + TAccountRepayAccountsReserveLiquidityMint extends string = string, + TAccountRepayAccountsReserveDestinationLiquidity extends string = string, + TAccountRepayAccountsUserSourceLiquidity extends string = string, + TAccountRepayAccountsTokenProgram extends string = string, + TAccountRepayAccountsInstructionSysvarAccount extends string = string, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState extends + string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountFarmsProgram extends string = string, +> { + repayAccountsOwner: TransactionSigner; + repayAccountsObligation: Address; + repayAccountsLendingMarket: Address; + repayAccountsRepayReserve: Address; + repayAccountsReserveLiquidityMint: Address; + repayAccountsReserveDestinationLiquidity: Address; + repayAccountsUserSourceLiquidity: Address; + repayAccountsTokenProgram: Address; + repayAccountsInstructionSysvarAccount?: Address; + repayObligationLiquidityV2FarmsAccountsObligationFarmUserState?: Address; + repayObligationLiquidityV2FarmsAccountsReserveFarmState?: Address; + lendingMarketAuthority: Address; + farmsProgram: Address; + liquidityAmount: RepayObligationLiquidityV2InstructionDataArgs["liquidityAmount"]; +} + +export function getRepayObligationLiquidityV2Instruction< + TAccountRepayAccountsOwner extends string, + TAccountRepayAccountsObligation extends string, + TAccountRepayAccountsLendingMarket extends string, + TAccountRepayAccountsRepayReserve extends string, + TAccountRepayAccountsReserveLiquidityMint extends string, + TAccountRepayAccountsReserveDestinationLiquidity extends string, + TAccountRepayAccountsUserSourceLiquidity extends string, + TAccountRepayAccountsTokenProgram extends string, + TAccountRepayAccountsInstructionSysvarAccount extends string, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState extends + string, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState extends + string, + TAccountLendingMarketAuthority extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RepayObligationLiquidityV2Input< + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): RepayObligationLiquidityV2Instruction< + TProgramAddress, + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + repayAccountsOwner: { + value: input.repayAccountsOwner ?? null, + isWritable: false, + }, + repayAccountsObligation: { + value: input.repayAccountsObligation ?? null, + isWritable: true, + }, + repayAccountsLendingMarket: { + value: input.repayAccountsLendingMarket ?? null, + isWritable: false, + }, + repayAccountsRepayReserve: { + value: input.repayAccountsRepayReserve ?? null, + isWritable: true, + }, + repayAccountsReserveLiquidityMint: { + value: input.repayAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + repayAccountsReserveDestinationLiquidity: { + value: input.repayAccountsReserveDestinationLiquidity ?? null, + isWritable: true, + }, + repayAccountsUserSourceLiquidity: { + value: input.repayAccountsUserSourceLiquidity ?? null, + isWritable: true, + }, + repayAccountsTokenProgram: { + value: input.repayAccountsTokenProgram ?? null, + isWritable: false, + }, + repayAccountsInstructionSysvarAccount: { + value: input.repayAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + repayObligationLiquidityV2FarmsAccountsObligationFarmUserState: { + value: + input.repayObligationLiquidityV2FarmsAccountsObligationFarmUserState ?? + null, + isWritable: true, + }, + repayObligationLiquidityV2FarmsAccountsReserveFarmState: { + value: + input.repayObligationLiquidityV2FarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.repayAccountsInstructionSysvarAccount.value) { + accounts.repayAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.repayAccountsOwner), + getAccountMeta(accounts.repayAccountsObligation), + getAccountMeta(accounts.repayAccountsLendingMarket), + getAccountMeta(accounts.repayAccountsRepayReserve), + getAccountMeta(accounts.repayAccountsReserveLiquidityMint), + getAccountMeta(accounts.repayAccountsReserveDestinationLiquidity), + getAccountMeta(accounts.repayAccountsUserSourceLiquidity), + getAccountMeta(accounts.repayAccountsTokenProgram), + getAccountMeta(accounts.repayAccountsInstructionSysvarAccount), + getAccountMeta( + accounts.repayObligationLiquidityV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta( + accounts.repayObligationLiquidityV2FarmsAccountsReserveFarmState, + ), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getRepayObligationLiquidityV2InstructionDataEncoder().encode( + args as RepayObligationLiquidityV2InstructionDataArgs, + ), + } as RepayObligationLiquidityV2Instruction< + TProgramAddress, + TAccountRepayAccountsOwner, + TAccountRepayAccountsObligation, + TAccountRepayAccountsLendingMarket, + TAccountRepayAccountsRepayReserve, + TAccountRepayAccountsReserveLiquidityMint, + TAccountRepayAccountsReserveDestinationLiquidity, + TAccountRepayAccountsUserSourceLiquidity, + TAccountRepayAccountsTokenProgram, + TAccountRepayAccountsInstructionSysvarAccount, + TAccountRepayObligationLiquidityV2FarmsAccountsObligationFarmUserState, + TAccountRepayObligationLiquidityV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedRepayObligationLiquidityV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + repayAccountsOwner: TAccountMetas[0]; + repayAccountsObligation: TAccountMetas[1]; + repayAccountsLendingMarket: TAccountMetas[2]; + repayAccountsRepayReserve: TAccountMetas[3]; + repayAccountsReserveLiquidityMint: TAccountMetas[4]; + repayAccountsReserveDestinationLiquidity: TAccountMetas[5]; + repayAccountsUserSourceLiquidity: TAccountMetas[6]; + repayAccountsTokenProgram: TAccountMetas[7]; + repayAccountsInstructionSysvarAccount: TAccountMetas[8]; + repayObligationLiquidityV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[9] + | undefined; + repayObligationLiquidityV2FarmsAccountsReserveFarmState?: + | TAccountMetas[10] + | undefined; + lendingMarketAuthority: TAccountMetas[11]; + farmsProgram: TAccountMetas[12]; + }; + data: RepayObligationLiquidityV2InstructionData; +} + +export function parseRepayObligationLiquidityV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRepayObligationLiquidityV2Instruction { + if (instruction.accounts.length < 13) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + repayAccountsOwner: getNextAccount(), + repayAccountsObligation: getNextAccount(), + repayAccountsLendingMarket: getNextAccount(), + repayAccountsRepayReserve: getNextAccount(), + repayAccountsReserveLiquidityMint: getNextAccount(), + repayAccountsReserveDestinationLiquidity: getNextAccount(), + repayAccountsUserSourceLiquidity: getNextAccount(), + repayAccountsTokenProgram: getNextAccount(), + repayAccountsInstructionSysvarAccount: getNextAccount(), + repayObligationLiquidityV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + repayObligationLiquidityV2FarmsAccountsReserveFarmState: + getNextOptionalAccount(), + lendingMarketAuthority: getNextAccount(), + farmsProgram: getNextAccount(), + }, + data: getRepayObligationLiquidityV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/requestElevationGroup.ts b/clients/kamino-lending/src/generated/instructions/requestElevationGroup.ts new file mode 100644 index 00000000..5b02d7b1 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/requestElevationGroup.ts @@ -0,0 +1,223 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REQUEST_ELEVATION_GROUP_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([36, 119, 251, 129, 34, 240, 7, 147]); + +export function getRequestElevationGroupDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REQUEST_ELEVATION_GROUP_DISCRIMINATOR, + ); +} + +export type RequestElevationGroupInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + ...TRemainingAccounts, + ] + >; + +export interface RequestElevationGroupInstructionData { + discriminator: ReadonlyUint8Array; + elevationGroup: number; +} + +export interface RequestElevationGroupInstructionDataArgs { + elevationGroup: number; +} + +export function getRequestElevationGroupInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["elevationGroup", getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: REQUEST_ELEVATION_GROUP_DISCRIMINATOR, + }), + ); +} + +export function getRequestElevationGroupInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["elevationGroup", getU8Decoder()], + ]); +} + +export function getRequestElevationGroupInstructionDataCodec(): FixedSizeCodec< + RequestElevationGroupInstructionDataArgs, + RequestElevationGroupInstructionData +> { + return combineCodec( + getRequestElevationGroupInstructionDataEncoder(), + getRequestElevationGroupInstructionDataDecoder(), + ); +} + +export interface RequestElevationGroupInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + elevationGroup: RequestElevationGroupInstructionDataArgs["elevationGroup"]; +} + +export function getRequestElevationGroupInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: RequestElevationGroupInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket + >, + config?: { programAddress?: TProgramAddress }, +): RequestElevationGroupInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + ], + programAddress, + data: getRequestElevationGroupInstructionDataEncoder().encode( + args as RequestElevationGroupInstructionDataArgs, + ), + } as RequestElevationGroupInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket + >; + + return instruction; +} + +export interface ParsedRequestElevationGroupInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + }; + data: RequestElevationGroupInstructionData; +} + +export function parseRequestElevationGroupInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRequestElevationGroupInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + }, + data: getRequestElevationGroupInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/rewardUserOnce.ts b/clients/kamino-lending/src/generated/instructions/rewardUserOnce.ts new file mode 100644 index 00000000..61483779 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/rewardUserOnce.ts @@ -0,0 +1,221 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const REWARD_USER_ONCE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([219, 137, 57, 22, 94, 186, 96, 114]); + +export function getRewardUserOnceDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REWARD_USER_ONCE_DISCRIMINATOR, + ); +} + +export type RewardUserOnceInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmAdmin extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFarmAdmin, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + ...TRemainingAccounts, + ] + >; + +export interface RewardUserOnceInstructionData { + discriminator: ReadonlyUint8Array; + rewardIndex: bigint; + amount: bigint; +} + +export interface RewardUserOnceInstructionDataArgs { + rewardIndex: number | bigint; + amount: number | bigint; +} + +export function getRewardUserOnceInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["rewardIndex", getU64Encoder()], + ["amount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: REWARD_USER_ONCE_DISCRIMINATOR }), + ); +} + +export function getRewardUserOnceInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["rewardIndex", getU64Decoder()], + ["amount", getU64Decoder()], + ]); +} + +export function getRewardUserOnceInstructionDataCodec(): FixedSizeCodec< + RewardUserOnceInstructionDataArgs, + RewardUserOnceInstructionData +> { + return combineCodec( + getRewardUserOnceInstructionDataEncoder(), + getRewardUserOnceInstructionDataDecoder(), + ); +} + +export interface RewardUserOnceInput< + TAccountFarmAdmin extends string = string, + TAccountFarmState extends string = string, + TAccountUserState extends string = string, +> { + farmAdmin: TransactionSigner; + farmState: Address; + userState: Address; + rewardIndex: RewardUserOnceInstructionDataArgs["rewardIndex"]; + amount: RewardUserOnceInstructionDataArgs["amount"]; +} + +export function getRewardUserOnceInstruction< + TAccountFarmAdmin extends string, + TAccountFarmState extends string, + TAccountUserState extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: RewardUserOnceInput< + TAccountFarmAdmin, + TAccountFarmState, + TAccountUserState + >, + config?: { programAddress?: TProgramAddress }, +): RewardUserOnceInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountUserState +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmAdmin: { value: input.farmAdmin ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + userState: { value: input.userState ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmAdmin), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.userState), + ], + programAddress, + data: getRewardUserOnceInstructionDataEncoder().encode( + args as RewardUserOnceInstructionDataArgs, + ), + } as RewardUserOnceInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountUserState + >; + + return instruction; +} + +export interface ParsedRewardUserOnceInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmAdmin: TAccountMetas[0]; + farmState: TAccountMetas[1]; + userState: TAccountMetas[2]; + }; + data: RewardUserOnceInstructionData; +} + +export function parseRewardUserOnceInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedRewardUserOnceInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmAdmin: getNextAccount(), + farmState: getNextAccount(), + userState: getNextAccount(), + }, + data: getRewardUserOnceInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/setStakeDelegated.ts b/clients/kamino-lending/src/generated/instructions/setStakeDelegated.ts new file mode 100644 index 00000000..b32cfbcf --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/setStakeDelegated.ts @@ -0,0 +1,219 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const SET_STAKE_DELEGATED_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([73, 171, 184, 75, 30, 56, 198, 223]); + +export function getSetStakeDelegatedDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_STAKE_DELEGATED_DISCRIMINATOR, + ); +} + +export type SetStakeDelegatedInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountDelegateAuthority extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountDelegateAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountDelegateAuthority, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + ...TRemainingAccounts, + ] + >; + +export interface SetStakeDelegatedInstructionData { + discriminator: ReadonlyUint8Array; + newAmount: bigint; +} + +export interface SetStakeDelegatedInstructionDataArgs { + newAmount: number | bigint; +} + +export function getSetStakeDelegatedInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["newAmount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: SET_STAKE_DELEGATED_DISCRIMINATOR }), + ); +} + +export function getSetStakeDelegatedInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["newAmount", getU64Decoder()], + ]); +} + +export function getSetStakeDelegatedInstructionDataCodec(): FixedSizeCodec< + SetStakeDelegatedInstructionDataArgs, + SetStakeDelegatedInstructionData +> { + return combineCodec( + getSetStakeDelegatedInstructionDataEncoder(), + getSetStakeDelegatedInstructionDataDecoder(), + ); +} + +export interface SetStakeDelegatedInput< + TAccountDelegateAuthority extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, +> { + delegateAuthority: TransactionSigner; + userState: Address; + farmState: Address; + newAmount: SetStakeDelegatedInstructionDataArgs["newAmount"]; +} + +export function getSetStakeDelegatedInstruction< + TAccountDelegateAuthority extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: SetStakeDelegatedInput< + TAccountDelegateAuthority, + TAccountUserState, + TAccountFarmState + >, + config?: { programAddress?: TProgramAddress }, +): SetStakeDelegatedInstruction< + TProgramAddress, + TAccountDelegateAuthority, + TAccountUserState, + TAccountFarmState +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + delegateAuthority: { + value: input.delegateAuthority ?? null, + isWritable: false, + }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.delegateAuthority), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + ], + programAddress, + data: getSetStakeDelegatedInstructionDataEncoder().encode( + args as SetStakeDelegatedInstructionDataArgs, + ), + } as SetStakeDelegatedInstruction< + TProgramAddress, + TAccountDelegateAuthority, + TAccountUserState, + TAccountFarmState + >; + + return instruction; +} + +export interface ParsedSetStakeDelegatedInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + delegateAuthority: TAccountMetas[0]; + userState: TAccountMetas[1]; + farmState: TAccountMetas[2]; + }; + data: SetStakeDelegatedInstructionData; +} + +export function parseSetStakeDelegatedInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedSetStakeDelegatedInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + delegateAuthority: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + }, + data: getSetStakeDelegatedInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/socializeLoss.ts b/clients/kamino-lending/src/generated/instructions/socializeLoss.ts new file mode 100644 index 00000000..08bb536e --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/socializeLoss.ts @@ -0,0 +1,258 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const SOCIALIZE_LOSS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 245, 75, 91, 0, 236, 97, 19, 3, +]); + +export function getSocializeLossDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SOCIALIZE_LOSS_DISCRIMINATOR, + ); +} + +export type SocializeLossInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountRiskCouncil extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRiskCouncil extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountRiskCouncil, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface SocializeLossInstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface SocializeLossInstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getSocializeLossInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: SOCIALIZE_LOSS_DISCRIMINATOR }), + ); +} + +export function getSocializeLossInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getSocializeLossInstructionDataCodec(): FixedSizeCodec< + SocializeLossInstructionDataArgs, + SocializeLossInstructionData +> { + return combineCodec( + getSocializeLossInstructionDataEncoder(), + getSocializeLossInstructionDataDecoder(), + ); +} + +export interface SocializeLossInput< + TAccountRiskCouncil extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + riskCouncil: TransactionSigner; + obligation: Address; + lendingMarket: Address; + reserve: Address; + instructionSysvarAccount?: Address; + liquidityAmount: SocializeLossInstructionDataArgs["liquidityAmount"]; +} + +export function getSocializeLossInstruction< + TAccountRiskCouncil extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: SocializeLossInput< + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket, + TAccountReserve, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): SocializeLossInstruction< + TProgramAddress, + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket, + TAccountReserve, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + riskCouncil: { value: input.riskCouncil ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.riskCouncil), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getSocializeLossInstructionDataEncoder().encode( + args as SocializeLossInstructionDataArgs, + ), + } as SocializeLossInstruction< + TProgramAddress, + TAccountRiskCouncil, + TAccountObligation, + TAccountLendingMarket, + TAccountReserve, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedSocializeLossInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + riskCouncil: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + reserve: TAccountMetas[3]; + instructionSysvarAccount: TAccountMetas[4]; + }; + data: SocializeLossInstructionData; +} + +export function parseSocializeLossInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedSocializeLossInstruction { + if (instruction.accounts.length < 5) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + riskCouncil: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getSocializeLossInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/socializeLossV2.ts b/clients/kamino-lending/src/generated/instructions/socializeLossV2.ts new file mode 100644 index 00000000..8c95bd2d --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/socializeLossV2.ts @@ -0,0 +1,354 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const SOCIALIZE_LOSS_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([238, 95, 98, 220, 187, 40, 204, 154]); + +export function getSocializeLossV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SOCIALIZE_LOSS_V2_DISCRIMINATOR, + ); +} + +export type SocializeLossV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountSocializeLossAccountsRiskCouncil extends + | string + | AccountMeta = string, + TAccountSocializeLossAccountsObligation extends string | AccountMeta = string, + TAccountSocializeLossAccountsLendingMarket extends + | string + | AccountMeta = string, + TAccountSocializeLossAccountsReserve extends string | AccountMeta = string, + TAccountSocializeLossAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountSocializeLossV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSocializeLossAccountsRiskCouncil extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSocializeLossAccountsRiskCouncil, + TAccountSocializeLossAccountsObligation extends string + ? WritableAccount + : TAccountSocializeLossAccountsObligation, + TAccountSocializeLossAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountSocializeLossAccountsLendingMarket, + TAccountSocializeLossAccountsReserve extends string + ? WritableAccount + : TAccountSocializeLossAccountsReserve, + TAccountSocializeLossAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountSocializeLossAccountsInstructionSysvarAccount, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountSocializeLossV2FarmsAccountsObligationFarmUserState, + TAccountSocializeLossV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountSocializeLossV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface SocializeLossV2InstructionData { + discriminator: ReadonlyUint8Array; + liquidityAmount: bigint; +} + +export interface SocializeLossV2InstructionDataArgs { + liquidityAmount: number | bigint; +} + +export function getSocializeLossV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["liquidityAmount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: SOCIALIZE_LOSS_V2_DISCRIMINATOR }), + ); +} + +export function getSocializeLossV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["liquidityAmount", getU64Decoder()], + ]); +} + +export function getSocializeLossV2InstructionDataCodec(): FixedSizeCodec< + SocializeLossV2InstructionDataArgs, + SocializeLossV2InstructionData +> { + return combineCodec( + getSocializeLossV2InstructionDataEncoder(), + getSocializeLossV2InstructionDataDecoder(), + ); +} + +export interface SocializeLossV2Input< + TAccountSocializeLossAccountsRiskCouncil extends string = string, + TAccountSocializeLossAccountsObligation extends string = string, + TAccountSocializeLossAccountsLendingMarket extends string = string, + TAccountSocializeLossAccountsReserve extends string = string, + TAccountSocializeLossAccountsInstructionSysvarAccount extends string = string, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountSocializeLossV2FarmsAccountsReserveFarmState extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountFarmsProgram extends string = string, +> { + socializeLossAccountsRiskCouncil: TransactionSigner; + socializeLossAccountsObligation: Address; + socializeLossAccountsLendingMarket: Address; + socializeLossAccountsReserve: Address; + socializeLossAccountsInstructionSysvarAccount?: Address; + socializeLossV2FarmsAccountsObligationFarmUserState?: Address; + socializeLossV2FarmsAccountsReserveFarmState?: Address; + lendingMarketAuthority: Address; + farmsProgram: Address; + liquidityAmount: SocializeLossV2InstructionDataArgs["liquidityAmount"]; +} + +export function getSocializeLossV2Instruction< + TAccountSocializeLossAccountsRiskCouncil extends string, + TAccountSocializeLossAccountsObligation extends string, + TAccountSocializeLossAccountsLendingMarket extends string, + TAccountSocializeLossAccountsReserve extends string, + TAccountSocializeLossAccountsInstructionSysvarAccount extends string, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState extends string, + TAccountSocializeLossV2FarmsAccountsReserveFarmState extends string, + TAccountLendingMarketAuthority extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: SocializeLossV2Input< + TAccountSocializeLossAccountsRiskCouncil, + TAccountSocializeLossAccountsObligation, + TAccountSocializeLossAccountsLendingMarket, + TAccountSocializeLossAccountsReserve, + TAccountSocializeLossAccountsInstructionSysvarAccount, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState, + TAccountSocializeLossV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): SocializeLossV2Instruction< + TProgramAddress, + TAccountSocializeLossAccountsRiskCouncil, + TAccountSocializeLossAccountsObligation, + TAccountSocializeLossAccountsLendingMarket, + TAccountSocializeLossAccountsReserve, + TAccountSocializeLossAccountsInstructionSysvarAccount, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState, + TAccountSocializeLossV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + socializeLossAccountsRiskCouncil: { + value: input.socializeLossAccountsRiskCouncil ?? null, + isWritable: false, + }, + socializeLossAccountsObligation: { + value: input.socializeLossAccountsObligation ?? null, + isWritable: true, + }, + socializeLossAccountsLendingMarket: { + value: input.socializeLossAccountsLendingMarket ?? null, + isWritable: false, + }, + socializeLossAccountsReserve: { + value: input.socializeLossAccountsReserve ?? null, + isWritable: true, + }, + socializeLossAccountsInstructionSysvarAccount: { + value: input.socializeLossAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + socializeLossV2FarmsAccountsObligationFarmUserState: { + value: input.socializeLossV2FarmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + socializeLossV2FarmsAccountsReserveFarmState: { + value: input.socializeLossV2FarmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.socializeLossAccountsInstructionSysvarAccount.value) { + accounts.socializeLossAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.socializeLossAccountsRiskCouncil), + getAccountMeta(accounts.socializeLossAccountsObligation), + getAccountMeta(accounts.socializeLossAccountsLendingMarket), + getAccountMeta(accounts.socializeLossAccountsReserve), + getAccountMeta(accounts.socializeLossAccountsInstructionSysvarAccount), + getAccountMeta( + accounts.socializeLossV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta(accounts.socializeLossV2FarmsAccountsReserveFarmState), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getSocializeLossV2InstructionDataEncoder().encode( + args as SocializeLossV2InstructionDataArgs, + ), + } as SocializeLossV2Instruction< + TProgramAddress, + TAccountSocializeLossAccountsRiskCouncil, + TAccountSocializeLossAccountsObligation, + TAccountSocializeLossAccountsLendingMarket, + TAccountSocializeLossAccountsReserve, + TAccountSocializeLossAccountsInstructionSysvarAccount, + TAccountSocializeLossV2FarmsAccountsObligationFarmUserState, + TAccountSocializeLossV2FarmsAccountsReserveFarmState, + TAccountLendingMarketAuthority, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedSocializeLossV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + socializeLossAccountsRiskCouncil: TAccountMetas[0]; + socializeLossAccountsObligation: TAccountMetas[1]; + socializeLossAccountsLendingMarket: TAccountMetas[2]; + socializeLossAccountsReserve: TAccountMetas[3]; + socializeLossAccountsInstructionSysvarAccount: TAccountMetas[4]; + socializeLossV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[5] + | undefined; + socializeLossV2FarmsAccountsReserveFarmState?: TAccountMetas[6] | undefined; + lendingMarketAuthority: TAccountMetas[7]; + farmsProgram: TAccountMetas[8]; + }; + data: SocializeLossV2InstructionData; +} + +export function parseSocializeLossV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedSocializeLossV2Instruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + socializeLossAccountsRiskCouncil: getNextAccount(), + socializeLossAccountsObligation: getNextAccount(), + socializeLossAccountsLendingMarket: getNextAccount(), + socializeLossAccountsReserve: getNextAccount(), + socializeLossAccountsInstructionSysvarAccount: getNextAccount(), + socializeLossV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + socializeLossV2FarmsAccountsReserveFarmState: getNextOptionalAccount(), + lendingMarketAuthority: getNextAccount(), + farmsProgram: getNextAccount(), + }, + data: getSocializeLossV2InstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/stake.ts b/clients/kamino-lending/src/generated/instructions/stake.ts new file mode 100644 index 00000000..68518288 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/stake.ts @@ -0,0 +1,292 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const STAKE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 206, 176, 202, 18, 200, 209, 179, 108, +]); + +export function getStakeDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(STAKE_DISCRIMINATOR); +} + +export type StakeInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountUserAta extends string | AccountMeta = string, + TAccountTokenMint extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountUserAta extends string + ? WritableAccount + : TAccountUserAta, + TAccountTokenMint extends string + ? ReadonlyAccount + : TAccountTokenMint, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface StakeInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; +} + +export interface StakeInstructionDataArgs { + amount: number | bigint; +} + +export function getStakeInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: STAKE_DISCRIMINATOR }), + ); +} + +export function getStakeInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ]); +} + +export function getStakeInstructionDataCodec(): FixedSizeCodec< + StakeInstructionDataArgs, + StakeInstructionData +> { + return combineCodec( + getStakeInstructionDataEncoder(), + getStakeInstructionDataDecoder(), + ); +} + +export interface StakeInput< + TAccountOwner extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountFarmVault extends string = string, + TAccountUserAta extends string = string, + TAccountTokenMint extends string = string, + TAccountScopePrices extends string = string, + TAccountTokenProgram extends string = string, +> { + owner: TransactionSigner; + userState: Address; + farmState: Address; + farmVault: Address; + userAta: Address; + tokenMint: Address; + scopePrices?: Address; + tokenProgram: Address; + amount: StakeInstructionDataArgs["amount"]; +} + +export function getStakeInstruction< + TAccountOwner extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountFarmVault extends string, + TAccountUserAta extends string, + TAccountTokenMint extends string, + TAccountScopePrices extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: StakeInput< + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountFarmVault, + TAccountUserAta, + TAccountTokenMint, + TAccountScopePrices, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): StakeInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountFarmVault, + TAccountUserAta, + TAccountTokenMint, + TAccountScopePrices, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + userAta: { value: input.userAta ?? null, isWritable: true }, + tokenMint: { value: input.tokenMint ?? null, isWritable: false }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.userAta), + getAccountMeta(accounts.tokenMint), + getAccountMeta(accounts.scopePrices), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getStakeInstructionDataEncoder().encode( + args as StakeInstructionDataArgs, + ), + } as StakeInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountFarmVault, + TAccountUserAta, + TAccountTokenMint, + TAccountScopePrices, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedStakeInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + userState: TAccountMetas[1]; + farmState: TAccountMetas[2]; + farmVault: TAccountMetas[3]; + userAta: TAccountMetas[4]; + tokenMint: TAccountMetas[5]; + scopePrices?: TAccountMetas[6] | undefined; + tokenProgram: TAccountMetas[7]; + }; + data: StakeInstructionData; +} + +export function parseStakeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedStakeInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + farmVault: getNextAccount(), + userAta: getNextAccount(), + tokenMint: getNextAccount(), + scopePrices: getNextOptionalAccount(), + tokenProgram: getNextAccount(), + }, + data: getStakeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/transferOwnership.ts b/clients/kamino-lending/src/generated/instructions/transferOwnership.ts new file mode 100644 index 00000000..6647b783 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/transferOwnership.ts @@ -0,0 +1,199 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]); + +export function getTransferOwnershipDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR, + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + ...TRemainingAccounts, + ] + >; + +export interface TransferOwnershipInstructionData { + discriminator: ReadonlyUint8Array; + newOwner: Address; +} + +export interface TransferOwnershipInstructionDataArgs { + newOwner: Address; +} + +export function getTransferOwnershipInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["newOwner", getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }), + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["newOwner", getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): FixedSizeCodec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder(), + ); +} + +export interface TransferOwnershipInput< + TAccountOwner extends string = string, + TAccountUserState extends string = string, +> { + owner: TransactionSigner; + userState: Address; + newOwner: TransferOwnershipInstructionDataArgs["newOwner"]; +} + +export function getTransferOwnershipInstruction< + TAccountOwner extends string, + TAccountUserState extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput, + config?: { programAddress?: TProgramAddress }, +): TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + userState: { value: input.userState ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.userState), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs, + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState + >; + + return instruction; +} + +export interface ParsedTransferOwnershipInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + userState: TAccountMetas[1]; + }; + data: TransferOwnershipInstructionData; +} + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + userState: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/unstake.ts b/clients/kamino-lending/src/generated/instructions/unstake.ts new file mode 100644 index 00000000..9df1a105 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/unstake.ts @@ -0,0 +1,236 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU128Decoder, + getU128Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UNSTAKE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ + 90, 95, 107, 42, 205, 124, 50, 225, +]); + +export function getUnstakeDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode(UNSTAKE_DISCRIMINATOR); +} + +export type UnstakeInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + ...TRemainingAccounts, + ] + >; + +export interface UnstakeInstructionData { + discriminator: ReadonlyUint8Array; + stakeSharesScaled: bigint; +} + +export interface UnstakeInstructionDataArgs { + stakeSharesScaled: number | bigint; +} + +export function getUnstakeInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["stakeSharesScaled", getU128Encoder()], + ]), + (value) => ({ ...value, discriminator: UNSTAKE_DISCRIMINATOR }), + ); +} + +export function getUnstakeInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["stakeSharesScaled", getU128Decoder()], + ]); +} + +export function getUnstakeInstructionDataCodec(): FixedSizeCodec< + UnstakeInstructionDataArgs, + UnstakeInstructionData +> { + return combineCodec( + getUnstakeInstructionDataEncoder(), + getUnstakeInstructionDataDecoder(), + ); +} + +export interface UnstakeInput< + TAccountOwner extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountScopePrices extends string = string, +> { + owner: TransactionSigner; + userState: Address; + farmState: Address; + scopePrices?: Address; + stakeSharesScaled: UnstakeInstructionDataArgs["stakeSharesScaled"]; +} + +export function getUnstakeInstruction< + TAccountOwner extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountScopePrices extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: UnstakeInput< + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountScopePrices + >, + config?: { programAddress?: TProgramAddress }, +): UnstakeInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountScopePrices +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: true }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.scopePrices), + ], + programAddress, + data: getUnstakeInstructionDataEncoder().encode( + args as UnstakeInstructionDataArgs, + ), + } as UnstakeInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountScopePrices + >; + + return instruction; +} + +export interface ParsedUnstakeInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + userState: TAccountMetas[1]; + farmState: TAccountMetas[2]; + scopePrices?: TAccountMetas[3] | undefined; + }; + data: UnstakeInstructionData; +} + +export function parseUnstakeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUnstakeInstruction { + if (instruction.accounts.length < 4) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + scopePrices: getNextOptionalAccount(), + }, + data: getUnstakeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateFarmAdmin.ts b/clients/kamino-lending/src/generated/instructions/updateFarmAdmin.ts new file mode 100644 index 00000000..86065c29 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateFarmAdmin.ts @@ -0,0 +1,187 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_FARM_ADMIN_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([20, 37, 136, 19, 122, 239, 36, 130]); + +export function getUpdateFarmAdminDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_FARM_ADMIN_DISCRIMINATOR, + ); +} + +export type UpdateFarmAdminInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountPendingFarmAdmin extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPendingFarmAdmin, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + ...TRemainingAccounts, + ] + >; + +export interface UpdateFarmAdminInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface UpdateFarmAdminInstructionDataArgs {} + +export function getUpdateFarmAdminInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UPDATE_FARM_ADMIN_DISCRIMINATOR }), + ); +} + +export function getUpdateFarmAdminInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUpdateFarmAdminInstructionDataCodec(): FixedSizeCodec< + UpdateFarmAdminInstructionDataArgs, + UpdateFarmAdminInstructionData +> { + return combineCodec( + getUpdateFarmAdminInstructionDataEncoder(), + getUpdateFarmAdminInstructionDataDecoder(), + ); +} + +export interface UpdateFarmAdminInput< + TAccountPendingFarmAdmin extends string = string, + TAccountFarmState extends string = string, +> { + pendingFarmAdmin: TransactionSigner; + farmState: Address; +} + +export function getUpdateFarmAdminInstruction< + TAccountPendingFarmAdmin extends string, + TAccountFarmState extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: UpdateFarmAdminInput, + config?: { programAddress?: TProgramAddress }, +): UpdateFarmAdminInstruction< + TProgramAddress, + TAccountPendingFarmAdmin, + TAccountFarmState +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingFarmAdmin: { + value: input.pendingFarmAdmin ?? null, + isWritable: true, + }, + farmState: { value: input.farmState ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingFarmAdmin), + getAccountMeta(accounts.farmState), + ], + programAddress, + data: getUpdateFarmAdminInstructionDataEncoder().encode({}), + } as UpdateFarmAdminInstruction< + TProgramAddress, + TAccountPendingFarmAdmin, + TAccountFarmState + >; + + return instruction; +} + +export interface ParsedUpdateFarmAdminInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + pendingFarmAdmin: TAccountMetas[0]; + farmState: TAccountMetas[1]; + }; + data: UpdateFarmAdminInstructionData; +} + +export function parseUpdateFarmAdminInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateFarmAdminInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + pendingFarmAdmin: getNextAccount(), + farmState: getNextAccount(), + }, + data: getUpdateFarmAdminInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateFarmConfig.ts b/clients/kamino-lending/src/generated/instructions/updateFarmConfig.ts new file mode 100644 index 00000000..ad48cee7 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateFarmConfig.ts @@ -0,0 +1,232 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + Codec, + Decoder, + Encoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU16Decoder, + getU16Encoder, + getU32Decoder, + getU32Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_FARM_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([214, 176, 188, 244, 203, 59, 230, 207]); + +export function getUpdateFarmConfigDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_FARM_CONFIG_DISCRIMINATOR, + ); +} + +export type UpdateFarmConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + ...TRemainingAccounts, + ] + >; + +export interface UpdateFarmConfigInstructionData { + discriminator: ReadonlyUint8Array; + mode: number; + data: ReadonlyUint8Array; +} + +export interface UpdateFarmConfigInstructionDataArgs { + mode: number; + data: ReadonlyUint8Array; +} + +export function getUpdateFarmConfigInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU16Encoder()], + ["data", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: UPDATE_FARM_CONFIG_DISCRIMINATOR }), + ); +} + +export function getUpdateFarmConfigInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU16Decoder()], + ["data", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getUpdateFarmConfigInstructionDataCodec(): Codec< + UpdateFarmConfigInstructionDataArgs, + UpdateFarmConfigInstructionData +> { + return combineCodec( + getUpdateFarmConfigInstructionDataEncoder(), + getUpdateFarmConfigInstructionDataDecoder(), + ); +} + +export interface UpdateFarmConfigInput< + TAccountSigner extends string = string, + TAccountFarmState extends string = string, + TAccountScopePrices extends string = string, +> { + signer: TransactionSigner; + farmState: Address; + scopePrices?: Address; + mode: UpdateFarmConfigInstructionDataArgs["mode"]; + data: UpdateFarmConfigInstructionDataArgs["data"]; +} + +export function getUpdateFarmConfigInstruction< + TAccountSigner extends string, + TAccountFarmState extends string, + TAccountScopePrices extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: UpdateFarmConfigInput< + TAccountSigner, + TAccountFarmState, + TAccountScopePrices + >, + config?: { programAddress?: TProgramAddress }, +): UpdateFarmConfigInstruction< + TProgramAddress, + TAccountSigner, + TAccountFarmState, + TAccountScopePrices +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.scopePrices), + ], + programAddress, + data: getUpdateFarmConfigInstructionDataEncoder().encode( + args as UpdateFarmConfigInstructionDataArgs, + ), + } as UpdateFarmConfigInstruction< + TProgramAddress, + TAccountSigner, + TAccountFarmState, + TAccountScopePrices + >; + + return instruction; +} + +export interface ParsedUpdateFarmConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + farmState: TAccountMetas[1]; + scopePrices?: TAccountMetas[2] | undefined; + }; + data: UpdateFarmConfigInstructionData; +} + +export function parseUpdateFarmConfigInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateFarmConfigInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + signer: getNextAccount(), + farmState: getNextAccount(), + scopePrices: getNextOptionalAccount(), + }, + data: getUpdateFarmConfigInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateGlobalConfig.ts b/clients/kamino-lending/src/generated/instructions/updateGlobalConfig.ts new file mode 100644 index 00000000..bef43aea --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateGlobalConfig.ts @@ -0,0 +1,211 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_GLOBAL_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([164, 84, 130, 189, 111, 58, 250, 200]); + +export function getUpdateGlobalConfigDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_GLOBAL_CONFIG_DISCRIMINATOR, + ); +} + +export type UpdateGlobalConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountGlobalAdmin extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountGlobalAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountGlobalAdmin, + TAccountGlobalConfig extends string + ? WritableAccount + : TAccountGlobalConfig, + ...TRemainingAccounts, + ] + >; + +export interface UpdateGlobalConfigInstructionData { + discriminator: ReadonlyUint8Array; + mode: number; + value: number[]; +} + +export interface UpdateGlobalConfigInstructionDataArgs { + mode: number; + value: number[]; +} + +export function getUpdateGlobalConfigInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU8Encoder()], + ["value", getArrayEncoder(getU8Encoder(), { size: 32 })], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_GLOBAL_CONFIG_DISCRIMINATOR, + }), + ); +} + +export function getUpdateGlobalConfigInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU8Decoder()], + ["value", getArrayDecoder(getU8Decoder(), { size: 32 })], + ]); +} + +export function getUpdateGlobalConfigInstructionDataCodec(): FixedSizeCodec< + UpdateGlobalConfigInstructionDataArgs, + UpdateGlobalConfigInstructionData +> { + return combineCodec( + getUpdateGlobalConfigInstructionDataEncoder(), + getUpdateGlobalConfigInstructionDataDecoder(), + ); +} + +export interface UpdateGlobalConfigInput< + TAccountGlobalAdmin extends string = string, + TAccountGlobalConfig extends string = string, +> { + globalAdmin: TransactionSigner; + globalConfig: Address; + mode: UpdateGlobalConfigInstructionDataArgs["mode"]; + value: UpdateGlobalConfigInstructionDataArgs["value"]; +} + +export function getUpdateGlobalConfigInstruction< + TAccountGlobalAdmin extends string, + TAccountGlobalConfig extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: UpdateGlobalConfigInput, + config?: { programAddress?: TProgramAddress }, +): UpdateGlobalConfigInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + globalAdmin: { value: input.globalAdmin ?? null, isWritable: false }, + globalConfig: { value: input.globalConfig ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.globalAdmin), + getAccountMeta(accounts.globalConfig), + ], + programAddress, + data: getUpdateGlobalConfigInstructionDataEncoder().encode( + args as UpdateGlobalConfigInstructionDataArgs, + ), + } as UpdateGlobalConfigInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig + >; + + return instruction; +} + +export interface ParsedUpdateGlobalConfigInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + globalAdmin: TAccountMetas[0]; + globalConfig: TAccountMetas[1]; + }; + data: UpdateGlobalConfigInstructionData; +} + +export function parseUpdateGlobalConfigInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateGlobalConfigInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + globalAdmin: getNextAccount(), + globalConfig: getNextAccount(), + }, + data: getUpdateGlobalConfigInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateGlobalConfigAdmin.ts b/clients/kamino-lending/src/generated/instructions/updateGlobalConfigAdmin.ts new file mode 100644 index 00000000..a56003f5 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateGlobalConfigAdmin.ts @@ -0,0 +1,195 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_GLOBAL_CONFIG_ADMIN_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([184, 87, 23, 193, 156, 238, 175, 119]); + +export function getUpdateGlobalConfigAdminDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_GLOBAL_CONFIG_ADMIN_DISCRIMINATOR, + ); +} + +export type UpdateGlobalConfigAdminInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountPendingGlobalAdmin extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingGlobalAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPendingGlobalAdmin, + TAccountGlobalConfig extends string + ? WritableAccount + : TAccountGlobalConfig, + ...TRemainingAccounts, + ] + >; + +export interface UpdateGlobalConfigAdminInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface UpdateGlobalConfigAdminInstructionDataArgs {} + +export function getUpdateGlobalConfigAdminInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: UPDATE_GLOBAL_CONFIG_ADMIN_DISCRIMINATOR, + }), + ); +} + +export function getUpdateGlobalConfigAdminInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUpdateGlobalConfigAdminInstructionDataCodec(): FixedSizeCodec< + UpdateGlobalConfigAdminInstructionDataArgs, + UpdateGlobalConfigAdminInstructionData +> { + return combineCodec( + getUpdateGlobalConfigAdminInstructionDataEncoder(), + getUpdateGlobalConfigAdminInstructionDataDecoder(), + ); +} + +export interface UpdateGlobalConfigAdminInput< + TAccountPendingGlobalAdmin extends string = string, + TAccountGlobalConfig extends string = string, +> { + pendingGlobalAdmin: TransactionSigner; + globalConfig: Address; +} + +export function getUpdateGlobalConfigAdminInstruction< + TAccountPendingGlobalAdmin extends string, + TAccountGlobalConfig extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: UpdateGlobalConfigAdminInput< + TAccountPendingGlobalAdmin, + TAccountGlobalConfig + >, + config?: { programAddress?: TProgramAddress }, +): UpdateGlobalConfigAdminInstruction< + TProgramAddress, + TAccountPendingGlobalAdmin, + TAccountGlobalConfig +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingGlobalAdmin: { + value: input.pendingGlobalAdmin ?? null, + isWritable: false, + }, + globalConfig: { value: input.globalConfig ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingGlobalAdmin), + getAccountMeta(accounts.globalConfig), + ], + programAddress, + data: getUpdateGlobalConfigAdminInstructionDataEncoder().encode({}), + } as UpdateGlobalConfigAdminInstruction< + TProgramAddress, + TAccountPendingGlobalAdmin, + TAccountGlobalConfig + >; + + return instruction; +} + +export interface ParsedUpdateGlobalConfigAdminInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + pendingGlobalAdmin: TAccountMetas[0]; + globalConfig: TAccountMetas[1]; + }; + data: UpdateGlobalConfigAdminInstructionData; +} + +export function parseUpdateGlobalConfigAdminInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateGlobalConfigAdminInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + pendingGlobalAdmin: getNextAccount(), + globalConfig: getNextAccount(), + }, + data: getUpdateGlobalConfigAdminInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateLendingMarket.ts b/clients/kamino-lending/src/generated/instructions/updateLendingMarket.ts new file mode 100644 index 00000000..54cfe12c --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateLendingMarket.ts @@ -0,0 +1,220 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_LENDING_MARKET_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([209, 157, 53, 210, 97, 180, 31, 45]); + +export function getUpdateLendingMarketDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_LENDING_MARKET_DISCRIMINATOR, + ); +} + +export type UpdateLendingMarketInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? WritableAccount + : TAccountLendingMarket, + ...TRemainingAccounts, + ] + >; + +export interface UpdateLendingMarketInstructionData { + discriminator: ReadonlyUint8Array; + mode: bigint; + value: number[]; +} + +export interface UpdateLendingMarketInstructionDataArgs { + mode: number | bigint; + value: number[]; +} + +export function getUpdateLendingMarketInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU64Encoder()], + ["value", getArrayEncoder(getU8Encoder(), { size: 72 })], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_LENDING_MARKET_DISCRIMINATOR, + }), + ); +} + +export function getUpdateLendingMarketInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU64Decoder()], + ["value", getArrayDecoder(getU8Decoder(), { size: 72 })], + ]); +} + +export function getUpdateLendingMarketInstructionDataCodec(): FixedSizeCodec< + UpdateLendingMarketInstructionDataArgs, + UpdateLendingMarketInstructionData +> { + return combineCodec( + getUpdateLendingMarketInstructionDataEncoder(), + getUpdateLendingMarketInstructionDataDecoder(), + ); +} + +export interface UpdateLendingMarketInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + mode: UpdateLendingMarketInstructionDataArgs["mode"]; + value: UpdateLendingMarketInstructionDataArgs["value"]; +} + +export function getUpdateLendingMarketInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: UpdateLendingMarketInput< + TAccountLendingMarketOwner, + TAccountLendingMarket + >, + config?: { programAddress?: TProgramAddress }, +): UpdateLendingMarketInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + ], + programAddress, + data: getUpdateLendingMarketInstructionDataEncoder().encode( + args as UpdateLendingMarketInstructionDataArgs, + ), + } as UpdateLendingMarketInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket + >; + + return instruction; +} + +export interface ParsedUpdateLendingMarketInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + }; + data: UpdateLendingMarketInstructionData; +} + +export function parseUpdateLendingMarketInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateLendingMarketInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + }, + data: getUpdateLendingMarketInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateLendingMarketOwner.ts b/clients/kamino-lending/src/generated/instructions/updateLendingMarketOwner.ts new file mode 100644 index 00000000..da240da8 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateLendingMarketOwner.ts @@ -0,0 +1,196 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_LENDING_MARKET_OWNER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([118, 224, 10, 62, 196, 230, 184, 89]); + +export function getUpdateLendingMarketOwnerDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_LENDING_MARKET_OWNER_DISCRIMINATOR, + ); +} + +export type UpdateLendingMarketOwnerInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwnerCached extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwnerCached extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwnerCached, + TAccountLendingMarket extends string + ? WritableAccount + : TAccountLendingMarket, + ...TRemainingAccounts, + ] + >; + +export interface UpdateLendingMarketOwnerInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface UpdateLendingMarketOwnerInstructionDataArgs {} + +export function getUpdateLendingMarketOwnerInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: UPDATE_LENDING_MARKET_OWNER_DISCRIMINATOR, + }), + ); +} + +export function getUpdateLendingMarketOwnerInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUpdateLendingMarketOwnerInstructionDataCodec(): FixedSizeCodec< + UpdateLendingMarketOwnerInstructionDataArgs, + UpdateLendingMarketOwnerInstructionData +> { + return combineCodec( + getUpdateLendingMarketOwnerInstructionDataEncoder(), + getUpdateLendingMarketOwnerInstructionDataDecoder(), + ); +} + +export interface UpdateLendingMarketOwnerInput< + TAccountLendingMarketOwnerCached extends string = string, + TAccountLendingMarket extends string = string, +> { + lendingMarketOwnerCached: TransactionSigner; + lendingMarket: Address; +} + +export function getUpdateLendingMarketOwnerInstruction< + TAccountLendingMarketOwnerCached extends string, + TAccountLendingMarket extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: UpdateLendingMarketOwnerInput< + TAccountLendingMarketOwnerCached, + TAccountLendingMarket + >, + config?: { programAddress?: TProgramAddress }, +): UpdateLendingMarketOwnerInstruction< + TProgramAddress, + TAccountLendingMarketOwnerCached, + TAccountLendingMarket +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwnerCached: { + value: input.lendingMarketOwnerCached ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwnerCached), + getAccountMeta(accounts.lendingMarket), + ], + programAddress, + data: getUpdateLendingMarketOwnerInstructionDataEncoder().encode({}), + } as UpdateLendingMarketOwnerInstruction< + TProgramAddress, + TAccountLendingMarketOwnerCached, + TAccountLendingMarket + >; + + return instruction; +} + +export interface ParsedUpdateLendingMarketOwnerInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwnerCached: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + }; + data: UpdateLendingMarketOwnerInstructionData; +} + +export function parseUpdateLendingMarketOwnerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateLendingMarketOwnerInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwnerCached: getNextAccount(), + lendingMarket: getNextAccount(), + }, + data: getUpdateLendingMarketOwnerInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/updateReserveConfig.ts b/clients/kamino-lending/src/generated/instructions/updateReserveConfig.ts new file mode 100644 index 00000000..6d7dd61f --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/updateReserveConfig.ts @@ -0,0 +1,242 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + Codec, + Decoder, + Encoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const UPDATE_RESERVE_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([61, 148, 100, 70, 143, 107, 17, 13]); + +export function getUpdateReserveConfigDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_RESERVE_CONFIG_DISCRIMINATOR, + ); +} + +export type UpdateReserveConfigInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + ...TRemainingAccounts, + ] + >; + +export interface UpdateReserveConfigInstructionData { + discriminator: ReadonlyUint8Array; + mode: bigint; + value: ReadonlyUint8Array; + skipValidation: boolean; +} + +export interface UpdateReserveConfigInstructionDataArgs { + mode: number | bigint; + value: ReadonlyUint8Array; + skipValidation: boolean; +} + +export function getUpdateReserveConfigInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["mode", getU64Encoder()], + ["value", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ["skipValidation", getBooleanEncoder()], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_RESERVE_CONFIG_DISCRIMINATOR, + }), + ); +} + +export function getUpdateReserveConfigInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["mode", getU64Decoder()], + ["value", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ["skipValidation", getBooleanDecoder()], + ]); +} + +export function getUpdateReserveConfigInstructionDataCodec(): Codec< + UpdateReserveConfigInstructionDataArgs, + UpdateReserveConfigInstructionData +> { + return combineCodec( + getUpdateReserveConfigInstructionDataEncoder(), + getUpdateReserveConfigInstructionDataDecoder(), + ); +} + +export interface UpdateReserveConfigInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + reserve: Address; + mode: UpdateReserveConfigInstructionDataArgs["mode"]; + value: UpdateReserveConfigInstructionDataArgs["value"]; + skipValidation: UpdateReserveConfigInstructionDataArgs["skipValidation"]; +} + +export function getUpdateReserveConfigInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: UpdateReserveConfigInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve + >, + config?: { programAddress?: TProgramAddress }, +): UpdateReserveConfigInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + ], + programAddress, + data: getUpdateReserveConfigInstructionDataEncoder().encode( + args as UpdateReserveConfigInstructionDataArgs, + ), + } as UpdateReserveConfigInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve + >; + + return instruction; +} + +export interface ParsedUpdateReserveConfigInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + reserve: TAccountMetas[2]; + }; + data: UpdateReserveConfigInstructionData; +} + +export function parseUpdateReserveConfigInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedUpdateReserveConfigInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + }, + data: getUpdateReserveConfigInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawFromFarmVault.ts b/clients/kamino-lending/src/generated/instructions/withdrawFromFarmVault.ts new file mode 100644 index 00000000..267658e2 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawFromFarmVault.ts @@ -0,0 +1,273 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_FROM_FARM_VAULT_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([22, 82, 128, 250, 86, 79, 124, 78]); + +export function getWithdrawFromFarmVaultDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_FROM_FARM_VAULT_DISCRIMINATOR, + ); +} + +export type WithdrawFromFarmVaultInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountWithdrawAuthority extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountWithdrawerTokenAccount extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountWithdrawAuthority extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountWithdrawAuthority, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountWithdrawerTokenAccount extends string + ? WritableAccount + : TAccountWithdrawerTokenAccount, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawFromFarmVaultInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; +} + +export interface WithdrawFromFarmVaultInstructionDataArgs { + amount: number | bigint; +} + +export function getWithdrawFromFarmVaultInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: WITHDRAW_FROM_FARM_VAULT_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawFromFarmVaultInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ]); +} + +export function getWithdrawFromFarmVaultInstructionDataCodec(): FixedSizeCodec< + WithdrawFromFarmVaultInstructionDataArgs, + WithdrawFromFarmVaultInstructionData +> { + return combineCodec( + getWithdrawFromFarmVaultInstructionDataEncoder(), + getWithdrawFromFarmVaultInstructionDataDecoder(), + ); +} + +export interface WithdrawFromFarmVaultInput< + TAccountWithdrawAuthority extends string = string, + TAccountFarmState extends string = string, + TAccountWithdrawerTokenAccount extends string = string, + TAccountFarmVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountTokenProgram extends string = string, +> { + withdrawAuthority: TransactionSigner; + farmState: Address; + withdrawerTokenAccount: Address; + farmVault: Address; + farmVaultsAuthority: Address; + tokenProgram: Address; + amount: WithdrawFromFarmVaultInstructionDataArgs["amount"]; +} + +export function getWithdrawFromFarmVaultInstruction< + TAccountWithdrawAuthority extends string, + TAccountFarmState extends string, + TAccountWithdrawerTokenAccount extends string, + TAccountFarmVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: WithdrawFromFarmVaultInput< + TAccountWithdrawAuthority, + TAccountFarmState, + TAccountWithdrawerTokenAccount, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawFromFarmVaultInstruction< + TProgramAddress, + TAccountWithdrawAuthority, + TAccountFarmState, + TAccountWithdrawerTokenAccount, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + withdrawAuthority: { + value: input.withdrawAuthority ?? null, + isWritable: true, + }, + farmState: { value: input.farmState ?? null, isWritable: true }, + withdrawerTokenAccount: { + value: input.withdrawerTokenAccount ?? null, + isWritable: true, + }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.withdrawAuthority), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.withdrawerTokenAccount), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawFromFarmVaultInstructionDataEncoder().encode( + args as WithdrawFromFarmVaultInstructionDataArgs, + ), + } as WithdrawFromFarmVaultInstruction< + TProgramAddress, + TAccountWithdrawAuthority, + TAccountFarmState, + TAccountWithdrawerTokenAccount, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawFromFarmVaultInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + withdrawAuthority: TAccountMetas[0]; + farmState: TAccountMetas[1]; + withdrawerTokenAccount: TAccountMetas[2]; + farmVault: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + tokenProgram: TAccountMetas[5]; + }; + data: WithdrawFromFarmVaultInstructionData; +} + +export function parseWithdrawFromFarmVaultInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawFromFarmVaultInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + withdrawAuthority: getNextAccount(), + farmState: getNextAccount(), + withdrawerTokenAccount: getNextAccount(), + farmVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawFromFarmVaultInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateral.ts b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateral.ts new file mode 100644 index 00000000..82f15aee --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateral.ts @@ -0,0 +1,327 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_OBLIGATION_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([37, 116, 205, 103, 243, 192, 92, 198]); + +export function getWithdrawObligationCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_OBLIGATION_COLLATERAL_DISCRIMINATOR, + ); +} + +export type WithdrawObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountWithdrawReserve extends string | AccountMeta = string, + TAccountReserveSourceCollateral extends string | AccountMeta = string, + TAccountUserDestinationCollateral extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawReserve, + TAccountReserveSourceCollateral extends string + ? WritableAccount + : TAccountReserveSourceCollateral, + TAccountUserDestinationCollateral extends string + ? WritableAccount + : TAccountUserDestinationCollateral, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawObligationCollateralInstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface WithdrawObligationCollateralInstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getWithdrawObligationCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: WITHDRAW_OBLIGATION_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawObligationCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getWithdrawObligationCollateralInstructionDataCodec(): FixedSizeCodec< + WithdrawObligationCollateralInstructionDataArgs, + WithdrawObligationCollateralInstructionData +> { + return combineCodec( + getWithdrawObligationCollateralInstructionDataEncoder(), + getWithdrawObligationCollateralInstructionDataDecoder(), + ); +} + +export interface WithdrawObligationCollateralInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountWithdrawReserve extends string = string, + TAccountReserveSourceCollateral extends string = string, + TAccountUserDestinationCollateral extends string = string, + TAccountTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + withdrawReserve: Address; + reserveSourceCollateral: Address; + userDestinationCollateral: Address; + tokenProgram: Address; + instructionSysvarAccount?: Address; + collateralAmount: WithdrawObligationCollateralInstructionDataArgs["collateralAmount"]; +} + +export function getWithdrawObligationCollateralInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountWithdrawReserve extends string, + TAccountReserveSourceCollateral extends string, + TAccountUserDestinationCollateral extends string, + TAccountTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawObligationCollateralInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveSourceCollateral, + TAccountUserDestinationCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveSourceCollateral, + TAccountUserDestinationCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawReserve: { value: input.withdrawReserve ?? null, isWritable: true }, + reserveSourceCollateral: { + value: input.reserveSourceCollateral ?? null, + isWritable: true, + }, + userDestinationCollateral: { + value: input.userDestinationCollateral ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.withdrawReserve), + getAccountMeta(accounts.reserveSourceCollateral), + getAccountMeta(accounts.userDestinationCollateral), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getWithdrawObligationCollateralInstructionDataEncoder().encode( + args as WithdrawObligationCollateralInstructionDataArgs, + ), + } as WithdrawObligationCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveSourceCollateral, + TAccountUserDestinationCollateral, + TAccountTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedWithdrawObligationCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + withdrawReserve: TAccountMetas[4]; + reserveSourceCollateral: TAccountMetas[5]; + userDestinationCollateral: TAccountMetas[6]; + tokenProgram: TAccountMetas[7]; + instructionSysvarAccount: TAccountMetas[8]; + }; + data: WithdrawObligationCollateralInstructionData; +} + +export function parseWithdrawObligationCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawObligationCollateralInstruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + withdrawReserve: getNextAccount(), + reserveSourceCollateral: getNextAccount(), + userDestinationCollateral: getNextAccount(), + tokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getWithdrawObligationCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts new file mode 100644 index 00000000..c05f4a18 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts @@ -0,0 +1,427 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([75, 93, 93, 220, 34, 150, 218, 196]); + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + ); +} + +export type WithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountObligation extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountWithdrawReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveSourceCollateral extends string | AccountMeta = string, + TAccountReserveCollateralMint extends string | AccountMeta = string, + TAccountReserveLiquiditySupply extends string | AccountMeta = string, + TAccountUserDestinationLiquidity extends string | AccountMeta = string, + TAccountPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountCollateralTokenProgram extends string | AccountMeta = string, + TAccountLiquidityTokenProgram extends string | AccountMeta = string, + TAccountInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountObligation extends string + ? WritableAccount + : TAccountObligation, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveSourceCollateral extends string + ? WritableAccount + : TAccountReserveSourceCollateral, + TAccountReserveCollateralMint extends string + ? WritableAccount + : TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply extends string + ? WritableAccount + : TAccountReserveLiquiditySupply, + TAccountUserDestinationLiquidity extends string + ? WritableAccount + : TAccountUserDestinationLiquidity, + TAccountPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountInstructionSysvarAccount, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralInstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataCodec(): FixedSizeCodec< + WithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataArgs, + WithdrawObligationCollateralAndRedeemReserveCollateralInstructionData +> { + return combineCodec( + getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataEncoder(), + getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataDecoder(), + ); +} + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralInput< + TAccountOwner extends string = string, + TAccountObligation extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountWithdrawReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveSourceCollateral extends string = string, + TAccountReserveCollateralMint extends string = string, + TAccountReserveLiquiditySupply extends string = string, + TAccountUserDestinationLiquidity extends string = string, + TAccountPlaceholderUserDestinationCollateral extends string = string, + TAccountCollateralTokenProgram extends string = string, + TAccountLiquidityTokenProgram extends string = string, + TAccountInstructionSysvarAccount extends string = string, +> { + owner: TransactionSigner; + obligation: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + withdrawReserve: Address; + reserveLiquidityMint: Address; + reserveSourceCollateral: Address; + reserveCollateralMint: Address; + reserveLiquiditySupply: Address; + userDestinationLiquidity: Address; + placeholderUserDestinationCollateral?: Address; + collateralTokenProgram: Address; + liquidityTokenProgram: Address; + instructionSysvarAccount?: Address; + collateralAmount: WithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataArgs["collateralAmount"]; +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TAccountOwner extends string, + TAccountObligation extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountWithdrawReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveSourceCollateral extends string, + TAccountReserveCollateralMint extends string, + TAccountReserveLiquiditySupply extends string, + TAccountUserDestinationLiquidity extends string, + TAccountPlaceholderUserDestinationCollateral extends string, + TAccountCollateralTokenProgram extends string, + TAccountLiquidityTokenProgram extends string, + TAccountInstructionSysvarAccount extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawObligationCollateralAndRedeemReserveCollateralInput< + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceCollateral, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserDestinationLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceCollateral, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserDestinationLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: true }, + obligation: { value: input.obligation ?? null, isWritable: true }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawReserve: { value: input.withdrawReserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveSourceCollateral: { + value: input.reserveSourceCollateral ?? null, + isWritable: true, + }, + reserveCollateralMint: { + value: input.reserveCollateralMint ?? null, + isWritable: true, + }, + reserveLiquiditySupply: { + value: input.reserveLiquiditySupply ?? null, + isWritable: true, + }, + userDestinationLiquidity: { + value: input.userDestinationLiquidity ?? null, + isWritable: true, + }, + placeholderUserDestinationCollateral: { + value: input.placeholderUserDestinationCollateral ?? null, + isWritable: false, + }, + collateralTokenProgram: { + value: input.collateralTokenProgram ?? null, + isWritable: false, + }, + liquidityTokenProgram: { + value: input.liquidityTokenProgram ?? null, + isWritable: false, + }, + instructionSysvarAccount: { + value: input.instructionSysvarAccount ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionSysvarAccount.value) { + accounts.instructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.obligation), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.withdrawReserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveSourceCollateral), + getAccountMeta(accounts.reserveCollateralMint), + getAccountMeta(accounts.reserveLiquiditySupply), + getAccountMeta(accounts.userDestinationLiquidity), + getAccountMeta(accounts.placeholderUserDestinationCollateral), + getAccountMeta(accounts.collateralTokenProgram), + getAccountMeta(accounts.liquidityTokenProgram), + getAccountMeta(accounts.instructionSysvarAccount), + ], + programAddress, + data: getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataEncoder().encode( + args as WithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataArgs, + ), + } as WithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgramAddress, + TAccountOwner, + TAccountObligation, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountWithdrawReserve, + TAccountReserveLiquidityMint, + TAccountReserveSourceCollateral, + TAccountReserveCollateralMint, + TAccountReserveLiquiditySupply, + TAccountUserDestinationLiquidity, + TAccountPlaceholderUserDestinationCollateral, + TAccountCollateralTokenProgram, + TAccountLiquidityTokenProgram, + TAccountInstructionSysvarAccount + >; + + return instruction; +} + +export interface ParsedWithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + obligation: TAccountMetas[1]; + lendingMarket: TAccountMetas[2]; + lendingMarketAuthority: TAccountMetas[3]; + withdrawReserve: TAccountMetas[4]; + reserveLiquidityMint: TAccountMetas[5]; + reserveSourceCollateral: TAccountMetas[6]; + reserveCollateralMint: TAccountMetas[7]; + reserveLiquiditySupply: TAccountMetas[8]; + userDestinationLiquidity: TAccountMetas[9]; + placeholderUserDestinationCollateral?: TAccountMetas[10] | undefined; + collateralTokenProgram: TAccountMetas[11]; + liquidityTokenProgram: TAccountMetas[12]; + instructionSysvarAccount: TAccountMetas[13]; + }; + data: WithdrawObligationCollateralAndRedeemReserveCollateralInstructionData; +} + +export function parseWithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawObligationCollateralAndRedeemReserveCollateralInstruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 14) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + obligation: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + withdrawReserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveSourceCollateral: getNextAccount(), + reserveCollateralMint: getNextAccount(), + reserveLiquiditySupply: getNextAccount(), + userDestinationLiquidity: getNextAccount(), + placeholderUserDestinationCollateral: getNextOptionalAccount(), + collateralTokenProgram: getNextAccount(), + liquidityTokenProgram: getNextAccount(), + instructionSysvarAccount: getNextAccount(), + }, + data: getWithdrawObligationCollateralAndRedeemReserveCollateralInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts new file mode 100644 index 00000000..eb7d4f8a --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts @@ -0,0 +1,533 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([235, 52, 119, 152, 149, 197, 20, 7]); + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR, + ); +} + +export type WithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountWithdrawAccountsOwner extends string | AccountMeta = string, + TAccountWithdrawAccountsObligation extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarket extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsWithdrawReserve extends string | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquidityMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveSourceCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveCollateralMint extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsCollateralTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState extends + | string + | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountWithdrawAccountsOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation extends string + ? WritableAccount + : TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity extends string + ? WritableAccount + : TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: + WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL_V2_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataCodec(): FixedSizeCodec< + WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataArgs, + WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionData +> { + return combineCodec( + getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataEncoder(), + getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataDecoder(), + ); +} + +export interface WithdrawObligationCollateralAndRedeemReserveCollateralV2Input< + TAccountWithdrawAccountsOwner extends string = string, + TAccountWithdrawAccountsObligation extends string = string, + TAccountWithdrawAccountsLendingMarket extends string = string, + TAccountWithdrawAccountsLendingMarketAuthority extends string = string, + TAccountWithdrawAccountsWithdrawReserve extends string = string, + TAccountWithdrawAccountsReserveLiquidityMint extends string = string, + TAccountWithdrawAccountsReserveSourceCollateral extends string = string, + TAccountWithdrawAccountsReserveCollateralMint extends string = string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string = string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string = string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends + string = string, + TAccountWithdrawAccountsCollateralTokenProgram extends string = string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string = string, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState extends + string = string, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState extends + string = string, + TAccountFarmsProgram extends string = string, +> { + withdrawAccountsOwner: TransactionSigner; + withdrawAccountsObligation: Address; + withdrawAccountsLendingMarket: Address; + withdrawAccountsLendingMarketAuthority: Address; + withdrawAccountsWithdrawReserve: Address; + withdrawAccountsReserveLiquidityMint: Address; + withdrawAccountsReserveSourceCollateral: Address; + withdrawAccountsReserveCollateralMint: Address; + withdrawAccountsReserveLiquiditySupply: Address; + withdrawAccountsUserDestinationLiquidity: Address; + withdrawAccountsPlaceholderUserDestinationCollateral?: Address; + withdrawAccountsCollateralTokenProgram: Address; + withdrawAccountsLiquidityTokenProgram: Address; + withdrawAccountsInstructionSysvarAccount?: Address; + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState?: Address; + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + collateralAmount: WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataArgs["collateralAmount"]; +} + +export function getWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TAccountWithdrawAccountsOwner extends string, + TAccountWithdrawAccountsObligation extends string, + TAccountWithdrawAccountsLendingMarket extends string, + TAccountWithdrawAccountsLendingMarketAuthority extends string, + TAccountWithdrawAccountsWithdrawReserve extends string, + TAccountWithdrawAccountsReserveLiquidityMint extends string, + TAccountWithdrawAccountsReserveSourceCollateral extends string, + TAccountWithdrawAccountsReserveCollateralMint extends string, + TAccountWithdrawAccountsReserveLiquiditySupply extends string, + TAccountWithdrawAccountsUserDestinationLiquidity extends string, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral extends string, + TAccountWithdrawAccountsCollateralTokenProgram extends string, + TAccountWithdrawAccountsLiquidityTokenProgram extends string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState extends + string, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState extends + string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawObligationCollateralAndRedeemReserveCollateralV2Input< + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgramAddress, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + withdrawAccountsOwner: { + value: input.withdrawAccountsOwner ?? null, + isWritable: true, + }, + withdrawAccountsObligation: { + value: input.withdrawAccountsObligation ?? null, + isWritable: true, + }, + withdrawAccountsLendingMarket: { + value: input.withdrawAccountsLendingMarket ?? null, + isWritable: false, + }, + withdrawAccountsLendingMarketAuthority: { + value: input.withdrawAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawAccountsWithdrawReserve: { + value: input.withdrawAccountsWithdrawReserve ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquidityMint: { + value: input.withdrawAccountsReserveLiquidityMint ?? null, + isWritable: false, + }, + withdrawAccountsReserveSourceCollateral: { + value: input.withdrawAccountsReserveSourceCollateral ?? null, + isWritable: true, + }, + withdrawAccountsReserveCollateralMint: { + value: input.withdrawAccountsReserveCollateralMint ?? null, + isWritable: true, + }, + withdrawAccountsReserveLiquiditySupply: { + value: input.withdrawAccountsReserveLiquiditySupply ?? null, + isWritable: true, + }, + withdrawAccountsUserDestinationLiquidity: { + value: input.withdrawAccountsUserDestinationLiquidity ?? null, + isWritable: true, + }, + withdrawAccountsPlaceholderUserDestinationCollateral: { + value: input.withdrawAccountsPlaceholderUserDestinationCollateral ?? null, + isWritable: false, + }, + withdrawAccountsCollateralTokenProgram: { + value: input.withdrawAccountsCollateralTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsLiquidityTokenProgram: { + value: input.withdrawAccountsLiquidityTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsInstructionSysvarAccount: { + value: input.withdrawAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState: + { + value: + input.withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState ?? + null, + isWritable: true, + }, + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState: + { + value: + input.withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState ?? + null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.withdrawAccountsInstructionSysvarAccount.value) { + accounts.withdrawAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.withdrawAccountsOwner), + getAccountMeta(accounts.withdrawAccountsObligation), + getAccountMeta(accounts.withdrawAccountsLendingMarket), + getAccountMeta(accounts.withdrawAccountsLendingMarketAuthority), + getAccountMeta(accounts.withdrawAccountsWithdrawReserve), + getAccountMeta(accounts.withdrawAccountsReserveLiquidityMint), + getAccountMeta(accounts.withdrawAccountsReserveSourceCollateral), + getAccountMeta(accounts.withdrawAccountsReserveCollateralMint), + getAccountMeta(accounts.withdrawAccountsReserveLiquiditySupply), + getAccountMeta(accounts.withdrawAccountsUserDestinationLiquidity), + getAccountMeta( + accounts.withdrawAccountsPlaceholderUserDestinationCollateral, + ), + getAccountMeta(accounts.withdrawAccountsCollateralTokenProgram), + getAccountMeta(accounts.withdrawAccountsLiquidityTokenProgram), + getAccountMeta(accounts.withdrawAccountsInstructionSysvarAccount), + getAccountMeta( + accounts.withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState, + ), + getAccountMeta( + accounts.withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState, + ), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataEncoder().encode( + args as WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataArgs, + ), + } as WithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgramAddress, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveLiquidityMint, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsReserveCollateralMint, + TAccountWithdrawAccountsReserveLiquiditySupply, + TAccountWithdrawAccountsUserDestinationLiquidity, + TAccountWithdrawAccountsPlaceholderUserDestinationCollateral, + TAccountWithdrawAccountsCollateralTokenProgram, + TAccountWithdrawAccountsLiquidityTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState, + TAccountWithdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + withdrawAccountsOwner: TAccountMetas[0]; + withdrawAccountsObligation: TAccountMetas[1]; + withdrawAccountsLendingMarket: TAccountMetas[2]; + withdrawAccountsLendingMarketAuthority: TAccountMetas[3]; + withdrawAccountsWithdrawReserve: TAccountMetas[4]; + withdrawAccountsReserveLiquidityMint: TAccountMetas[5]; + withdrawAccountsReserveSourceCollateral: TAccountMetas[6]; + withdrawAccountsReserveCollateralMint: TAccountMetas[7]; + withdrawAccountsReserveLiquiditySupply: TAccountMetas[8]; + withdrawAccountsUserDestinationLiquidity: TAccountMetas[9]; + withdrawAccountsPlaceholderUserDestinationCollateral?: + | TAccountMetas[10] + | undefined; + withdrawAccountsCollateralTokenProgram: TAccountMetas[11]; + withdrawAccountsLiquidityTokenProgram: TAccountMetas[12]; + withdrawAccountsInstructionSysvarAccount: TAccountMetas[13]; + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState?: + | TAccountMetas[14] + | undefined; + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState?: + | TAccountMetas[15] + | undefined; + farmsProgram: TAccountMetas[16]; + }; + data: WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionData; +} + +export function parseWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction< + TProgram, + TAccountMetas +> { + if (instruction.accounts.length < 17) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + withdrawAccountsOwner: getNextAccount(), + withdrawAccountsObligation: getNextAccount(), + withdrawAccountsLendingMarket: getNextAccount(), + withdrawAccountsLendingMarketAuthority: getNextAccount(), + withdrawAccountsWithdrawReserve: getNextAccount(), + withdrawAccountsReserveLiquidityMint: getNextAccount(), + withdrawAccountsReserveSourceCollateral: getNextAccount(), + withdrawAccountsReserveCollateralMint: getNextAccount(), + withdrawAccountsReserveLiquiditySupply: getNextAccount(), + withdrawAccountsUserDestinationLiquidity: getNextAccount(), + withdrawAccountsPlaceholderUserDestinationCollateral: + getNextOptionalAccount(), + withdrawAccountsCollateralTokenProgram: getNextAccount(), + withdrawAccountsLiquidityTokenProgram: getNextAccount(), + withdrawAccountsInstructionSysvarAccount: getNextAccount(), + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsObligationFarmUserState: + getNextOptionalAccount(), + withdrawObligationCollateralAndRedeemReserveCollateralV2FarmsAccountsReserveFarmState: + getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getWithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralV2.ts b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralV2.ts new file mode 100644 index 00000000..455721bd --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawObligationCollateralV2.ts @@ -0,0 +1,404 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([202, 249, 117, 114, 231, 192, 47, 138]); + +export function getWithdrawObligationCollateralV2DiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + ); +} + +export type WithdrawObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountWithdrawAccountsOwner extends string | AccountMeta = string, + TAccountWithdrawAccountsObligation extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarket extends string | AccountMeta = string, + TAccountWithdrawAccountsLendingMarketAuthority extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsWithdrawReserve extends string | AccountMeta = string, + TAccountWithdrawAccountsReserveSourceCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsUserDestinationCollateral extends + | string + | AccountMeta = string, + TAccountWithdrawAccountsTokenProgram extends string | AccountMeta = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends + | string + | AccountMeta = "Sysvar1nstructions1111111111111111111111111", + TAccountFarmsAccountsObligationFarmUserState extends + | string + | AccountMeta = string, + TAccountFarmsAccountsReserveFarmState extends string | AccountMeta = string, + TAccountFarmsProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountWithdrawAccountsOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation extends string + ? WritableAccount + : TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve extends string + ? WritableAccount + : TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveSourceCollateral extends string + ? WritableAccount + : TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsUserDestinationCollateral extends string + ? WritableAccount + : TAccountWithdrawAccountsUserDestinationCollateral, + TAccountWithdrawAccountsTokenProgram extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount extends string + ? ReadonlyAccount + : TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountFarmsAccountsObligationFarmUserState extends string + ? WritableAccount + : TAccountFarmsAccountsObligationFarmUserState, + TAccountFarmsAccountsReserveFarmState extends string + ? WritableAccount + : TAccountFarmsAccountsReserveFarmState, + TAccountFarmsProgram extends string + ? ReadonlyAccount + : TAccountFarmsProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawObligationCollateralV2InstructionData { + discriminator: ReadonlyUint8Array; + collateralAmount: bigint; +} + +export interface WithdrawObligationCollateralV2InstructionDataArgs { + collateralAmount: number | bigint; +} + +export function getWithdrawObligationCollateralV2InstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["collateralAmount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: WITHDRAW_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawObligationCollateralV2InstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["collateralAmount", getU64Decoder()], + ]); +} + +export function getWithdrawObligationCollateralV2InstructionDataCodec(): FixedSizeCodec< + WithdrawObligationCollateralV2InstructionDataArgs, + WithdrawObligationCollateralV2InstructionData +> { + return combineCodec( + getWithdrawObligationCollateralV2InstructionDataEncoder(), + getWithdrawObligationCollateralV2InstructionDataDecoder(), + ); +} + +export interface WithdrawObligationCollateralV2Input< + TAccountWithdrawAccountsOwner extends string = string, + TAccountWithdrawAccountsObligation extends string = string, + TAccountWithdrawAccountsLendingMarket extends string = string, + TAccountWithdrawAccountsLendingMarketAuthority extends string = string, + TAccountWithdrawAccountsWithdrawReserve extends string = string, + TAccountWithdrawAccountsReserveSourceCollateral extends string = string, + TAccountWithdrawAccountsUserDestinationCollateral extends string = string, + TAccountWithdrawAccountsTokenProgram extends string = string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string = string, + TAccountFarmsAccountsObligationFarmUserState extends string = string, + TAccountFarmsAccountsReserveFarmState extends string = string, + TAccountFarmsProgram extends string = string, +> { + withdrawAccountsOwner: TransactionSigner; + withdrawAccountsObligation: Address; + withdrawAccountsLendingMarket: Address; + withdrawAccountsLendingMarketAuthority: Address; + withdrawAccountsWithdrawReserve: Address; + withdrawAccountsReserveSourceCollateral: Address; + withdrawAccountsUserDestinationCollateral: Address; + withdrawAccountsTokenProgram: Address; + withdrawAccountsInstructionSysvarAccount?: Address; + farmsAccountsObligationFarmUserState?: Address; + farmsAccountsReserveFarmState?: Address; + farmsProgram: Address; + collateralAmount: WithdrawObligationCollateralV2InstructionDataArgs["collateralAmount"]; +} + +export function getWithdrawObligationCollateralV2Instruction< + TAccountWithdrawAccountsOwner extends string, + TAccountWithdrawAccountsObligation extends string, + TAccountWithdrawAccountsLendingMarket extends string, + TAccountWithdrawAccountsLendingMarketAuthority extends string, + TAccountWithdrawAccountsWithdrawReserve extends string, + TAccountWithdrawAccountsReserveSourceCollateral extends string, + TAccountWithdrawAccountsUserDestinationCollateral extends string, + TAccountWithdrawAccountsTokenProgram extends string, + TAccountWithdrawAccountsInstructionSysvarAccount extends string, + TAccountFarmsAccountsObligationFarmUserState extends string, + TAccountFarmsAccountsReserveFarmState extends string, + TAccountFarmsProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawObligationCollateralV2Input< + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsUserDestinationCollateral, + TAccountWithdrawAccountsTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountFarmsAccountsObligationFarmUserState, + TAccountFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawObligationCollateralV2Instruction< + TProgramAddress, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsUserDestinationCollateral, + TAccountWithdrawAccountsTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountFarmsAccountsObligationFarmUserState, + TAccountFarmsAccountsReserveFarmState, + TAccountFarmsProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + withdrawAccountsOwner: { + value: input.withdrawAccountsOwner ?? null, + isWritable: false, + }, + withdrawAccountsObligation: { + value: input.withdrawAccountsObligation ?? null, + isWritable: true, + }, + withdrawAccountsLendingMarket: { + value: input.withdrawAccountsLendingMarket ?? null, + isWritable: false, + }, + withdrawAccountsLendingMarketAuthority: { + value: input.withdrawAccountsLendingMarketAuthority ?? null, + isWritable: false, + }, + withdrawAccountsWithdrawReserve: { + value: input.withdrawAccountsWithdrawReserve ?? null, + isWritable: true, + }, + withdrawAccountsReserveSourceCollateral: { + value: input.withdrawAccountsReserveSourceCollateral ?? null, + isWritable: true, + }, + withdrawAccountsUserDestinationCollateral: { + value: input.withdrawAccountsUserDestinationCollateral ?? null, + isWritable: true, + }, + withdrawAccountsTokenProgram: { + value: input.withdrawAccountsTokenProgram ?? null, + isWritable: false, + }, + withdrawAccountsInstructionSysvarAccount: { + value: input.withdrawAccountsInstructionSysvarAccount ?? null, + isWritable: false, + }, + farmsAccountsObligationFarmUserState: { + value: input.farmsAccountsObligationFarmUserState ?? null, + isWritable: true, + }, + farmsAccountsReserveFarmState: { + value: input.farmsAccountsReserveFarmState ?? null, + isWritable: true, + }, + farmsProgram: { value: input.farmsProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.withdrawAccountsInstructionSysvarAccount.value) { + accounts.withdrawAccountsInstructionSysvarAccount.value = + "Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.withdrawAccountsOwner), + getAccountMeta(accounts.withdrawAccountsObligation), + getAccountMeta(accounts.withdrawAccountsLendingMarket), + getAccountMeta(accounts.withdrawAccountsLendingMarketAuthority), + getAccountMeta(accounts.withdrawAccountsWithdrawReserve), + getAccountMeta(accounts.withdrawAccountsReserveSourceCollateral), + getAccountMeta(accounts.withdrawAccountsUserDestinationCollateral), + getAccountMeta(accounts.withdrawAccountsTokenProgram), + getAccountMeta(accounts.withdrawAccountsInstructionSysvarAccount), + getAccountMeta(accounts.farmsAccountsObligationFarmUserState), + getAccountMeta(accounts.farmsAccountsReserveFarmState), + getAccountMeta(accounts.farmsProgram), + ], + programAddress, + data: getWithdrawObligationCollateralV2InstructionDataEncoder().encode( + args as WithdrawObligationCollateralV2InstructionDataArgs, + ), + } as WithdrawObligationCollateralV2Instruction< + TProgramAddress, + TAccountWithdrawAccountsOwner, + TAccountWithdrawAccountsObligation, + TAccountWithdrawAccountsLendingMarket, + TAccountWithdrawAccountsLendingMarketAuthority, + TAccountWithdrawAccountsWithdrawReserve, + TAccountWithdrawAccountsReserveSourceCollateral, + TAccountWithdrawAccountsUserDestinationCollateral, + TAccountWithdrawAccountsTokenProgram, + TAccountWithdrawAccountsInstructionSysvarAccount, + TAccountFarmsAccountsObligationFarmUserState, + TAccountFarmsAccountsReserveFarmState, + TAccountFarmsProgram + >; + + return instruction; +} + +export interface ParsedWithdrawObligationCollateralV2Instruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + withdrawAccountsOwner: TAccountMetas[0]; + withdrawAccountsObligation: TAccountMetas[1]; + withdrawAccountsLendingMarket: TAccountMetas[2]; + withdrawAccountsLendingMarketAuthority: TAccountMetas[3]; + withdrawAccountsWithdrawReserve: TAccountMetas[4]; + withdrawAccountsReserveSourceCollateral: TAccountMetas[5]; + withdrawAccountsUserDestinationCollateral: TAccountMetas[6]; + withdrawAccountsTokenProgram: TAccountMetas[7]; + withdrawAccountsInstructionSysvarAccount: TAccountMetas[8]; + farmsAccountsObligationFarmUserState?: TAccountMetas[9] | undefined; + farmsAccountsReserveFarmState?: TAccountMetas[10] | undefined; + farmsProgram: TAccountMetas[11]; + }; + data: WithdrawObligationCollateralV2InstructionData; +} + +export function parseWithdrawObligationCollateralV2Instruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawObligationCollateralV2Instruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === KAMINO_LENDING_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + withdrawAccountsOwner: getNextAccount(), + withdrawAccountsObligation: getNextAccount(), + withdrawAccountsLendingMarket: getNextAccount(), + withdrawAccountsLendingMarketAuthority: getNextAccount(), + withdrawAccountsWithdrawReserve: getNextAccount(), + withdrawAccountsReserveSourceCollateral: getNextAccount(), + withdrawAccountsUserDestinationCollateral: getNextAccount(), + withdrawAccountsTokenProgram: getNextAccount(), + withdrawAccountsInstructionSysvarAccount: getNextAccount(), + farmsAccountsObligationFarmUserState: getNextOptionalAccount(), + farmsAccountsReserveFarmState: getNextOptionalAccount(), + farmsProgram: getNextAccount(), + }, + data: getWithdrawObligationCollateralV2InstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawProtocolFee.ts b/clients/kamino-lending/src/generated/instructions/withdrawProtocolFee.ts new file mode 100644 index 00000000..cb02da66 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawProtocolFee.ts @@ -0,0 +1,313 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlySignerAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_PROTOCOL_FEE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([158, 201, 158, 189, 33, 93, 162, 103]); + +export function getWithdrawProtocolFeeDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_PROTOCOL_FEE_DISCRIMINATOR, + ); +} + +export type WithdrawProtocolFeeInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountLendingMarketOwner extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountFeeVault extends string | AccountMeta = string, + TAccountLendingMarketOwnerAta extends string | AccountMeta = string, + TAccountTokenProgram extends + | string + | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountLendingMarketOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountLendingMarketOwner, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountReserve extends string + ? ReadonlyAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountFeeVault extends string + ? WritableAccount + : TAccountFeeVault, + TAccountLendingMarketOwnerAta extends string + ? WritableAccount + : TAccountLendingMarketOwnerAta, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawProtocolFeeInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; +} + +export interface WithdrawProtocolFeeInstructionDataArgs { + amount: number | bigint; +} + +export function getWithdrawProtocolFeeInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: WITHDRAW_PROTOCOL_FEE_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawProtocolFeeInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ]); +} + +export function getWithdrawProtocolFeeInstructionDataCodec(): FixedSizeCodec< + WithdrawProtocolFeeInstructionDataArgs, + WithdrawProtocolFeeInstructionData +> { + return combineCodec( + getWithdrawProtocolFeeInstructionDataEncoder(), + getWithdrawProtocolFeeInstructionDataDecoder(), + ); +} + +export interface WithdrawProtocolFeeInput< + TAccountLendingMarketOwner extends string = string, + TAccountLendingMarket extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountFeeVault extends string = string, + TAccountLendingMarketOwnerAta extends string = string, + TAccountTokenProgram extends string = string, +> { + lendingMarketOwner: TransactionSigner; + lendingMarket: Address; + reserve: Address; + reserveLiquidityMint: Address; + lendingMarketAuthority: Address; + feeVault: Address; + lendingMarketOwnerAta: Address; + tokenProgram?: Address; + amount: WithdrawProtocolFeeInstructionDataArgs["amount"]; +} + +export function getWithdrawProtocolFeeInstruction< + TAccountLendingMarketOwner extends string, + TAccountLendingMarket extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountLendingMarketAuthority extends string, + TAccountFeeVault extends string, + TAccountLendingMarketOwnerAta extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawProtocolFeeInput< + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountLendingMarketAuthority, + TAccountFeeVault, + TAccountLendingMarketOwnerAta, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawProtocolFeeInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountLendingMarketAuthority, + TAccountFeeVault, + TAccountLendingMarketOwnerAta, + TAccountTokenProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + lendingMarketOwner: { + value: input.lendingMarketOwner ?? null, + isWritable: false, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + reserve: { value: input.reserve ?? null, isWritable: false }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + feeVault: { value: input.feeVault ?? null, isWritable: true }, + lendingMarketOwnerAta: { + value: input.lendingMarketOwnerAta ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.lendingMarketOwner), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.feeVault), + getAccountMeta(accounts.lendingMarketOwnerAta), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawProtocolFeeInstructionDataEncoder().encode( + args as WithdrawProtocolFeeInstructionDataArgs, + ), + } as WithdrawProtocolFeeInstruction< + TProgramAddress, + TAccountLendingMarketOwner, + TAccountLendingMarket, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountLendingMarketAuthority, + TAccountFeeVault, + TAccountLendingMarketOwnerAta, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawProtocolFeeInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + lendingMarketOwner: TAccountMetas[0]; + lendingMarket: TAccountMetas[1]; + reserve: TAccountMetas[2]; + reserveLiquidityMint: TAccountMetas[3]; + lendingMarketAuthority: TAccountMetas[4]; + feeVault: TAccountMetas[5]; + lendingMarketOwnerAta: TAccountMetas[6]; + tokenProgram: TAccountMetas[7]; + }; + data: WithdrawProtocolFeeInstructionData; +} + +export function parseWithdrawProtocolFeeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawProtocolFeeInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + lendingMarketOwner: getNextAccount(), + lendingMarket: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + feeVault: getNextAccount(), + lendingMarketOwnerAta: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawProtocolFeeInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawReferrerFees.ts b/clients/kamino-lending/src/generated/instructions/withdrawReferrerFees.ts new file mode 100644 index 00000000..d910324e --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawReferrerFees.ts @@ -0,0 +1,307 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_REFERRER_FEES_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([171, 118, 121, 201, 233, 140, 23, 228]); + +export function getWithdrawReferrerFeesDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_REFERRER_FEES_DISCRIMINATOR, + ); +} + +export type WithdrawReferrerFeesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountReferrer extends string | AccountMeta = string, + TAccountReferrerTokenState extends string | AccountMeta = string, + TAccountReserve extends string | AccountMeta = string, + TAccountReserveLiquidityMint extends string | AccountMeta = string, + TAccountReserveSupplyLiquidity extends string | AccountMeta = string, + TAccountReferrerTokenAccount extends string | AccountMeta = string, + TAccountLendingMarket extends string | AccountMeta = string, + TAccountLendingMarketAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountReferrer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountReferrer, + TAccountReferrerTokenState extends string + ? WritableAccount + : TAccountReferrerTokenState, + TAccountReserve extends string + ? WritableAccount + : TAccountReserve, + TAccountReserveLiquidityMint extends string + ? ReadonlyAccount + : TAccountReserveLiquidityMint, + TAccountReserveSupplyLiquidity extends string + ? WritableAccount + : TAccountReserveSupplyLiquidity, + TAccountReferrerTokenAccount extends string + ? WritableAccount + : TAccountReferrerTokenAccount, + TAccountLendingMarket extends string + ? ReadonlyAccount + : TAccountLendingMarket, + TAccountLendingMarketAuthority extends string + ? ReadonlyAccount + : TAccountLendingMarketAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawReferrerFeesInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface WithdrawReferrerFeesInstructionDataArgs {} + +export function getWithdrawReferrerFeesInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: WITHDRAW_REFERRER_FEES_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawReferrerFeesInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getWithdrawReferrerFeesInstructionDataCodec(): FixedSizeCodec< + WithdrawReferrerFeesInstructionDataArgs, + WithdrawReferrerFeesInstructionData +> { + return combineCodec( + getWithdrawReferrerFeesInstructionDataEncoder(), + getWithdrawReferrerFeesInstructionDataDecoder(), + ); +} + +export interface WithdrawReferrerFeesInput< + TAccountReferrer extends string = string, + TAccountReferrerTokenState extends string = string, + TAccountReserve extends string = string, + TAccountReserveLiquidityMint extends string = string, + TAccountReserveSupplyLiquidity extends string = string, + TAccountReferrerTokenAccount extends string = string, + TAccountLendingMarket extends string = string, + TAccountLendingMarketAuthority extends string = string, + TAccountTokenProgram extends string = string, +> { + referrer: TransactionSigner; + referrerTokenState: Address; + reserve: Address; + reserveLiquidityMint: Address; + reserveSupplyLiquidity: Address; + referrerTokenAccount: Address; + lendingMarket: Address; + lendingMarketAuthority: Address; + tokenProgram: Address; +} + +export function getWithdrawReferrerFeesInstruction< + TAccountReferrer extends string, + TAccountReferrerTokenState extends string, + TAccountReserve extends string, + TAccountReserveLiquidityMint extends string, + TAccountReserveSupplyLiquidity extends string, + TAccountReferrerTokenAccount extends string, + TAccountLendingMarket extends string, + TAccountLendingMarketAuthority extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof KAMINO_LENDING_PROGRAM_ADDRESS, +>( + input: WithdrawReferrerFeesInput< + TAccountReferrer, + TAccountReferrerTokenState, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSupplyLiquidity, + TAccountReferrerTokenAccount, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawReferrerFeesInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerTokenState, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSupplyLiquidity, + TAccountReferrerTokenAccount, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? KAMINO_LENDING_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + referrer: { value: input.referrer ?? null, isWritable: true }, + referrerTokenState: { + value: input.referrerTokenState ?? null, + isWritable: true, + }, + reserve: { value: input.reserve ?? null, isWritable: true }, + reserveLiquidityMint: { + value: input.reserveLiquidityMint ?? null, + isWritable: false, + }, + reserveSupplyLiquidity: { + value: input.reserveSupplyLiquidity ?? null, + isWritable: true, + }, + referrerTokenAccount: { + value: input.referrerTokenAccount ?? null, + isWritable: true, + }, + lendingMarket: { value: input.lendingMarket ?? null, isWritable: false }, + lendingMarketAuthority: { + value: input.lendingMarketAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.referrer), + getAccountMeta(accounts.referrerTokenState), + getAccountMeta(accounts.reserve), + getAccountMeta(accounts.reserveLiquidityMint), + getAccountMeta(accounts.reserveSupplyLiquidity), + getAccountMeta(accounts.referrerTokenAccount), + getAccountMeta(accounts.lendingMarket), + getAccountMeta(accounts.lendingMarketAuthority), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawReferrerFeesInstructionDataEncoder().encode({}), + } as WithdrawReferrerFeesInstruction< + TProgramAddress, + TAccountReferrer, + TAccountReferrerTokenState, + TAccountReserve, + TAccountReserveLiquidityMint, + TAccountReserveSupplyLiquidity, + TAccountReferrerTokenAccount, + TAccountLendingMarket, + TAccountLendingMarketAuthority, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawReferrerFeesInstruction< + TProgram extends string = typeof KAMINO_LENDING_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + referrer: TAccountMetas[0]; + referrerTokenState: TAccountMetas[1]; + reserve: TAccountMetas[2]; + reserveLiquidityMint: TAccountMetas[3]; + reserveSupplyLiquidity: TAccountMetas[4]; + referrerTokenAccount: TAccountMetas[5]; + lendingMarket: TAccountMetas[6]; + lendingMarketAuthority: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + }; + data: WithdrawReferrerFeesInstructionData; +} + +export function parseWithdrawReferrerFeesInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawReferrerFeesInstruction { + if (instruction.accounts.length < 9) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + referrer: getNextAccount(), + referrerTokenState: getNextAccount(), + reserve: getNextAccount(), + reserveLiquidityMint: getNextAccount(), + reserveSupplyLiquidity: getNextAccount(), + referrerTokenAccount: getNextAccount(), + lendingMarket: getNextAccount(), + lendingMarketAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawReferrerFeesInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawReward.ts b/clients/kamino-lending/src/generated/instructions/withdrawReward.ts new file mode 100644 index 00000000..f5315f75 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawReward.ts @@ -0,0 +1,305 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_REWARD_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [191, 187, 176, 137, 9, 25, 187, 244], +); + +export function getWithdrawRewardDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_REWARD_DISCRIMINATOR, + ); +} + +export type WithdrawRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountFarmAdmin extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountRewardMint extends string | AccountMeta = string, + TAccountRewardVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountAdminRewardTokenAta extends string | AccountMeta = string, + TAccountScopePrices extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountFarmAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountFarmAdmin, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountRewardMint extends string + ? ReadonlyAccount + : TAccountRewardMint, + TAccountRewardVault extends string + ? WritableAccount + : TAccountRewardVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountAdminRewardTokenAta extends string + ? WritableAccount + : TAccountAdminRewardTokenAta, + TAccountScopePrices extends string + ? ReadonlyAccount + : TAccountScopePrices, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawRewardInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; + rewardIndex: bigint; +} + +export interface WithdrawRewardInstructionDataArgs { + amount: number | bigint; + rewardIndex: number | bigint; +} + +export function getWithdrawRewardInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ["rewardIndex", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: WITHDRAW_REWARD_DISCRIMINATOR }), + ); +} + +export function getWithdrawRewardInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ["rewardIndex", getU64Decoder()], + ]); +} + +export function getWithdrawRewardInstructionDataCodec(): FixedSizeCodec< + WithdrawRewardInstructionDataArgs, + WithdrawRewardInstructionData +> { + return combineCodec( + getWithdrawRewardInstructionDataEncoder(), + getWithdrawRewardInstructionDataDecoder(), + ); +} + +export interface WithdrawRewardInput< + TAccountFarmAdmin extends string = string, + TAccountFarmState extends string = string, + TAccountRewardMint extends string = string, + TAccountRewardVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountAdminRewardTokenAta extends string = string, + TAccountScopePrices extends string = string, + TAccountTokenProgram extends string = string, +> { + farmAdmin: TransactionSigner; + farmState: Address; + rewardMint: Address; + rewardVault: Address; + farmVaultsAuthority: Address; + adminRewardTokenAta: Address; + scopePrices?: Address; + tokenProgram: Address; + amount: WithdrawRewardInstructionDataArgs["amount"]; + rewardIndex: WithdrawRewardInstructionDataArgs["rewardIndex"]; +} + +export function getWithdrawRewardInstruction< + TAccountFarmAdmin extends string, + TAccountFarmState extends string, + TAccountRewardMint extends string, + TAccountRewardVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountAdminRewardTokenAta extends string, + TAccountScopePrices extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: WithdrawRewardInput< + TAccountFarmAdmin, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountAdminRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawRewardInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountAdminRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + farmAdmin: { value: input.farmAdmin ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + rewardMint: { value: input.rewardMint ?? null, isWritable: false }, + rewardVault: { value: input.rewardVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + adminRewardTokenAta: { + value: input.adminRewardTokenAta ?? null, + isWritable: true, + }, + scopePrices: { value: input.scopePrices ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.farmAdmin), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.rewardMint), + getAccountMeta(accounts.rewardVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.adminRewardTokenAta), + getAccountMeta(accounts.scopePrices), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawRewardInstructionDataEncoder().encode( + args as WithdrawRewardInstructionDataArgs, + ), + } as WithdrawRewardInstruction< + TProgramAddress, + TAccountFarmAdmin, + TAccountFarmState, + TAccountRewardMint, + TAccountRewardVault, + TAccountFarmVaultsAuthority, + TAccountAdminRewardTokenAta, + TAccountScopePrices, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawRewardInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + farmAdmin: TAccountMetas[0]; + farmState: TAccountMetas[1]; + rewardMint: TAccountMetas[2]; + rewardVault: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + adminRewardTokenAta: TAccountMetas[5]; + scopePrices?: TAccountMetas[6] | undefined; + tokenProgram: TAccountMetas[7]; + }; + data: WithdrawRewardInstructionData; +} + +export function parseWithdrawRewardInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawRewardInstruction { + if (instruction.accounts.length < 8) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === FARMS_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + farmAdmin: getNextAccount(), + farmState: getNextAccount(), + rewardMint: getNextAccount(), + rewardVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + adminRewardTokenAta: getNextAccount(), + scopePrices: getNextOptionalAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawRewardInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawSlashedAmount.ts b/clients/kamino-lending/src/generated/instructions/withdrawSlashedAmount.ts new file mode 100644 index 00000000..2a42ab0a --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawSlashedAmount.ts @@ -0,0 +1,255 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_SLASHED_AMOUNT_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([202, 217, 67, 74, 172, 22, 140, 216]); + +export function getWithdrawSlashedAmountDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_SLASHED_AMOUNT_DISCRIMINATOR, + ); +} + +export type WithdrawSlashedAmountInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountCrank extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountSlashedAmountSpillAddress extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountCrank extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountCrank, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountSlashedAmountSpillAddress extends string + ? WritableAccount + : TAccountSlashedAmountSpillAddress, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawSlashedAmountInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface WithdrawSlashedAmountInstructionDataArgs {} + +export function getWithdrawSlashedAmountInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: WITHDRAW_SLASHED_AMOUNT_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawSlashedAmountInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getWithdrawSlashedAmountInstructionDataCodec(): FixedSizeCodec< + WithdrawSlashedAmountInstructionDataArgs, + WithdrawSlashedAmountInstructionData +> { + return combineCodec( + getWithdrawSlashedAmountInstructionDataEncoder(), + getWithdrawSlashedAmountInstructionDataDecoder(), + ); +} + +export interface WithdrawSlashedAmountInput< + TAccountCrank extends string = string, + TAccountFarmState extends string = string, + TAccountSlashedAmountSpillAddress extends string = string, + TAccountFarmVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountTokenProgram extends string = string, +> { + crank: TransactionSigner; + farmState: Address; + slashedAmountSpillAddress: Address; + farmVault: Address; + farmVaultsAuthority: Address; + tokenProgram: Address; +} + +export function getWithdrawSlashedAmountInstruction< + TAccountCrank extends string, + TAccountFarmState extends string, + TAccountSlashedAmountSpillAddress extends string, + TAccountFarmVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: WithdrawSlashedAmountInput< + TAccountCrank, + TAccountFarmState, + TAccountSlashedAmountSpillAddress, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawSlashedAmountInstruction< + TProgramAddress, + TAccountCrank, + TAccountFarmState, + TAccountSlashedAmountSpillAddress, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + crank: { value: input.crank ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + slashedAmountSpillAddress: { + value: input.slashedAmountSpillAddress ?? null, + isWritable: true, + }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.crank), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.slashedAmountSpillAddress), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawSlashedAmountInstructionDataEncoder().encode({}), + } as WithdrawSlashedAmountInstruction< + TProgramAddress, + TAccountCrank, + TAccountFarmState, + TAccountSlashedAmountSpillAddress, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawSlashedAmountInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + crank: TAccountMetas[0]; + farmState: TAccountMetas[1]; + slashedAmountSpillAddress: TAccountMetas[2]; + farmVault: TAccountMetas[3]; + farmVaultsAuthority: TAccountMetas[4]; + tokenProgram: TAccountMetas[5]; + }; + data: WithdrawSlashedAmountInstructionData; +} + +export function parseWithdrawSlashedAmountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawSlashedAmountInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + crank: getNextAccount(), + farmState: getNextAccount(), + slashedAmountSpillAddress: getNextAccount(), + farmVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawSlashedAmountInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawTreasury.ts b/clients/kamino-lending/src/generated/instructions/withdrawTreasury.ts new file mode 100644 index 00000000..de33a756 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawTreasury.ts @@ -0,0 +1,282 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_TREASURY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([40, 63, 122, 158, 144, 216, 83, 96]); + +export function getWithdrawTreasuryDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_TREASURY_DISCRIMINATOR, + ); +} + +export type WithdrawTreasuryInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountGlobalAdmin extends string | AccountMeta = string, + TAccountGlobalConfig extends string | AccountMeta = string, + TAccountRewardMint extends string | AccountMeta = string, + TAccountRewardTreasuryVault extends string | AccountMeta = string, + TAccountTreasuryVaultAuthority extends string | AccountMeta = string, + TAccountWithdrawDestinationTokenAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountGlobalAdmin extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountGlobalAdmin, + TAccountGlobalConfig extends string + ? ReadonlyAccount + : TAccountGlobalConfig, + TAccountRewardMint extends string + ? ReadonlyAccount + : TAccountRewardMint, + TAccountRewardTreasuryVault extends string + ? WritableAccount + : TAccountRewardTreasuryVault, + TAccountTreasuryVaultAuthority extends string + ? ReadonlyAccount + : TAccountTreasuryVaultAuthority, + TAccountWithdrawDestinationTokenAccount extends string + ? WritableAccount + : TAccountWithdrawDestinationTokenAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawTreasuryInstructionData { + discriminator: ReadonlyUint8Array; + amount: bigint; +} + +export interface WithdrawTreasuryInstructionDataArgs { + amount: number | bigint; +} + +export function getWithdrawTreasuryInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], + ["amount", getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: WITHDRAW_TREASURY_DISCRIMINATOR }), + ); +} + +export function getWithdrawTreasuryInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ["amount", getU64Decoder()], + ]); +} + +export function getWithdrawTreasuryInstructionDataCodec(): FixedSizeCodec< + WithdrawTreasuryInstructionDataArgs, + WithdrawTreasuryInstructionData +> { + return combineCodec( + getWithdrawTreasuryInstructionDataEncoder(), + getWithdrawTreasuryInstructionDataDecoder(), + ); +} + +export interface WithdrawTreasuryInput< + TAccountGlobalAdmin extends string = string, + TAccountGlobalConfig extends string = string, + TAccountRewardMint extends string = string, + TAccountRewardTreasuryVault extends string = string, + TAccountTreasuryVaultAuthority extends string = string, + TAccountWithdrawDestinationTokenAccount extends string = string, + TAccountTokenProgram extends string = string, +> { + globalAdmin: TransactionSigner; + globalConfig: Address; + rewardMint: Address; + rewardTreasuryVault: Address; + treasuryVaultAuthority: Address; + withdrawDestinationTokenAccount: Address; + tokenProgram: Address; + amount: WithdrawTreasuryInstructionDataArgs["amount"]; +} + +export function getWithdrawTreasuryInstruction< + TAccountGlobalAdmin extends string, + TAccountGlobalConfig extends string, + TAccountRewardMint extends string, + TAccountRewardTreasuryVault extends string, + TAccountTreasuryVaultAuthority extends string, + TAccountWithdrawDestinationTokenAccount extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: WithdrawTreasuryInput< + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardTreasuryVault, + TAccountTreasuryVaultAuthority, + TAccountWithdrawDestinationTokenAccount, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawTreasuryInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardTreasuryVault, + TAccountTreasuryVaultAuthority, + TAccountWithdrawDestinationTokenAccount, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + globalAdmin: { value: input.globalAdmin ?? null, isWritable: true }, + globalConfig: { value: input.globalConfig ?? null, isWritable: false }, + rewardMint: { value: input.rewardMint ?? null, isWritable: false }, + rewardTreasuryVault: { + value: input.rewardTreasuryVault ?? null, + isWritable: true, + }, + treasuryVaultAuthority: { + value: input.treasuryVaultAuthority ?? null, + isWritable: false, + }, + withdrawDestinationTokenAccount: { + value: input.withdrawDestinationTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.globalAdmin), + getAccountMeta(accounts.globalConfig), + getAccountMeta(accounts.rewardMint), + getAccountMeta(accounts.rewardTreasuryVault), + getAccountMeta(accounts.treasuryVaultAuthority), + getAccountMeta(accounts.withdrawDestinationTokenAccount), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawTreasuryInstructionDataEncoder().encode( + args as WithdrawTreasuryInstructionDataArgs, + ), + } as WithdrawTreasuryInstruction< + TProgramAddress, + TAccountGlobalAdmin, + TAccountGlobalConfig, + TAccountRewardMint, + TAccountRewardTreasuryVault, + TAccountTreasuryVaultAuthority, + TAccountWithdrawDestinationTokenAccount, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawTreasuryInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + globalAdmin: TAccountMetas[0]; + globalConfig: TAccountMetas[1]; + rewardMint: TAccountMetas[2]; + rewardTreasuryVault: TAccountMetas[3]; + treasuryVaultAuthority: TAccountMetas[4]; + withdrawDestinationTokenAccount: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + }; + data: WithdrawTreasuryInstructionData; +} + +export function parseWithdrawTreasuryInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawTreasuryInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + globalAdmin: getNextAccount(), + globalConfig: getNextAccount(), + rewardMint: getNextAccount(), + rewardTreasuryVault: getNextAccount(), + treasuryVaultAuthority: getNextAccount(), + withdrawDestinationTokenAccount: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawTreasuryInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/kamino-lending/src/generated/instructions/withdrawUnstakedDeposits.ts b/clients/kamino-lending/src/generated/instructions/withdrawUnstakedDeposits.ts new file mode 100644 index 00000000..c0cf5a64 --- /dev/null +++ b/clients/kamino-lending/src/generated/instructions/withdrawUnstakedDeposits.ts @@ -0,0 +1,266 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, + Instruction, + InstructionWithAccounts, + InstructionWithData, + ReadonlyAccount, + ReadonlyUint8Array, + TransactionSigner, + WritableAccount, + WritableSignerAccount, +} from "@solana/kit"; +import { + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, +} from "@solana/kit"; +import { FARMS_PROGRAM_ADDRESS } from "../programs/index.js"; +import type { ResolvedAccount } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; + +export const WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([36, 102, 187, 49, 220, 36, 132, 67]); + +export function getWithdrawUnstakedDepositsDiscriminatorBytes(): ReadonlyUint8Array { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR, + ); +} + +export type WithdrawUnstakedDepositsInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountUserState extends string | AccountMeta = string, + TAccountFarmState extends string | AccountMeta = string, + TAccountUserAta extends string | AccountMeta = string, + TAccountFarmVault extends string | AccountMeta = string, + TAccountFarmVaultsAuthority extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountUserState extends string + ? WritableAccount + : TAccountUserState, + TAccountFarmState extends string + ? WritableAccount + : TAccountFarmState, + TAccountUserAta extends string + ? WritableAccount + : TAccountUserAta, + TAccountFarmVault extends string + ? WritableAccount + : TAccountFarmVault, + TAccountFarmVaultsAuthority extends string + ? ReadonlyAccount + : TAccountFarmVaultsAuthority, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + ...TRemainingAccounts, + ] + >; + +export interface WithdrawUnstakedDepositsInstructionData { + discriminator: ReadonlyUint8Array; +} + +export interface WithdrawUnstakedDepositsInstructionDataArgs {} + +export function getWithdrawUnstakedDepositsInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: WITHDRAW_UNSTAKED_DEPOSITS_DISCRIMINATOR, + }), + ); +} + +export function getWithdrawUnstakedDepositsInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getWithdrawUnstakedDepositsInstructionDataCodec(): FixedSizeCodec< + WithdrawUnstakedDepositsInstructionDataArgs, + WithdrawUnstakedDepositsInstructionData +> { + return combineCodec( + getWithdrawUnstakedDepositsInstructionDataEncoder(), + getWithdrawUnstakedDepositsInstructionDataDecoder(), + ); +} + +export interface WithdrawUnstakedDepositsInput< + TAccountOwner extends string = string, + TAccountUserState extends string = string, + TAccountFarmState extends string = string, + TAccountUserAta extends string = string, + TAccountFarmVault extends string = string, + TAccountFarmVaultsAuthority extends string = string, + TAccountTokenProgram extends string = string, +> { + owner: TransactionSigner; + userState: Address; + farmState: Address; + userAta: Address; + farmVault: Address; + farmVaultsAuthority: Address; + tokenProgram: Address; +} + +export function getWithdrawUnstakedDepositsInstruction< + TAccountOwner extends string, + TAccountUserState extends string, + TAccountFarmState extends string, + TAccountUserAta extends string, + TAccountFarmVault extends string, + TAccountFarmVaultsAuthority extends string, + TAccountTokenProgram extends string, + TProgramAddress extends Address = typeof FARMS_PROGRAM_ADDRESS, +>( + input: WithdrawUnstakedDepositsInput< + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountUserAta, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >, + config?: { programAddress?: TProgramAddress }, +): WithdrawUnstakedDepositsInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountUserAta, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram +> { + // Program address. + const programAddress = config?.programAddress ?? FARMS_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: true }, + userState: { value: input.userState ?? null, isWritable: true }, + farmState: { value: input.farmState ?? null, isWritable: true }, + userAta: { value: input.userAta ?? null, isWritable: true }, + farmVault: { value: input.farmVault ?? null, isWritable: true }, + farmVaultsAuthority: { + value: input.farmVaultsAuthority ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.userState), + getAccountMeta(accounts.farmState), + getAccountMeta(accounts.userAta), + getAccountMeta(accounts.farmVault), + getAccountMeta(accounts.farmVaultsAuthority), + getAccountMeta(accounts.tokenProgram), + ], + programAddress, + data: getWithdrawUnstakedDepositsInstructionDataEncoder().encode({}), + } as WithdrawUnstakedDepositsInstruction< + TProgramAddress, + TAccountOwner, + TAccountUserState, + TAccountFarmState, + TAccountUserAta, + TAccountFarmVault, + TAccountFarmVaultsAuthority, + TAccountTokenProgram + >; + + return instruction; +} + +export interface ParsedWithdrawUnstakedDepositsInstruction< + TProgram extends string = typeof FARMS_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + userState: TAccountMetas[1]; + farmState: TAccountMetas[2]; + userAta: TAccountMetas[3]; + farmVault: TAccountMetas[4]; + farmVaultsAuthority: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + }; + data: WithdrawUnstakedDepositsInstructionData; +} + +export function parseWithdrawUnstakedDepositsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData, +): ParsedWithdrawUnstakedDepositsInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error("Not enough accounts"); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + owner: getNextAccount(), + userState: getNextAccount(), + farmState: getNextAccount(), + userAta: getNextAccount(), + farmVault: getNextAccount(), + farmVaultsAuthority: getNextAccount(), + tokenProgram: getNextAccount(), + }, + data: getWithdrawUnstakedDepositsInstructionDataDecoder().decode( + instruction.data, + ), + }; +} diff --git a/clients/kamino-lending/src/generated/pdas/index.ts b/clients/kamino-lending/src/generated/pdas/index.ts new file mode 100644 index 00000000..cc400979 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/index.ts @@ -0,0 +1,19 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./lendingMarketAuth.js"; +export * from "./obligation.js"; +export * from "./obligationFarmState.js"; +export * from "./referrerState.js"; +export * from "./referrerTokenState.js"; +export * from "./reserveCollateralMint.js"; +export * from "./reserveCollateralSupply.js"; +export * from "./reserveFeeVault.js"; +export * from "./reserveLiquiditySupply.js"; +export * from "./shortUrl.js"; +export * from "./userMetadata.js"; diff --git a/clients/kamino-lending/src/generated/pdas/lendingMarketAuth.ts b/clients/kamino-lending/src/generated/pdas/lendingMarketAuth.ts new file mode 100644 index 00000000..5ba11cf9 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/lendingMarketAuth.ts @@ -0,0 +1,34 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface LendingMarketAuthSeeds { + lendingMarket: Address; +} + +export async function findLendingMarketAuthPda( + seeds: LendingMarketAuthSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("lma"), + getAddressEncoder().encode(seeds.lendingMarket), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/obligation.ts b/clients/kamino-lending/src/generated/pdas/obligation.ts new file mode 100644 index 00000000..92da9095 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/obligation.ts @@ -0,0 +1,48 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getU8Encoder, +} from "@solana/kit"; + +export interface ObligationSeeds { + tag: number; + + id: number; + + user: Address; + + market: Address; + + seed1Account: Address; + + seed2Account: Address; +} + +export async function findObligationPda( + seeds: ObligationSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getU8Encoder().encode(seeds.tag), + getU8Encoder().encode(seeds.id), + getAddressEncoder().encode(seeds.user), + getAddressEncoder().encode(seeds.market), + getAddressEncoder().encode(seeds.seed1Account), + getAddressEncoder().encode(seeds.seed2Account), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/obligationFarmState.ts b/clients/kamino-lending/src/generated/pdas/obligationFarmState.ts new file mode 100644 index 00000000..da64505b --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/obligationFarmState.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ObligationFarmStateSeeds { + farm: Address; + + obligation: Address; +} + +export async function findObligationFarmStatePda( + seeds: ObligationFarmStateSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" as Address<"FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("user"), + getAddressEncoder().encode(seeds.farm), + getAddressEncoder().encode(seeds.obligation), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/referrerState.ts b/clients/kamino-lending/src/generated/pdas/referrerState.ts new file mode 100644 index 00000000..bc2e42cb --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/referrerState.ts @@ -0,0 +1,34 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReferrerStateSeeds { + referrer: Address; +} + +export async function findReferrerStatePda( + seeds: ReferrerStateSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("ref_state"), + getAddressEncoder().encode(seeds.referrer), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/referrerTokenState.ts b/clients/kamino-lending/src/generated/pdas/referrerTokenState.ts new file mode 100644 index 00000000..837be128 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/referrerTokenState.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReferrerTokenStateSeeds { + referrer: Address; + + reserve: Address; +} + +export async function findReferrerTokenStatePda( + seeds: ReferrerTokenStateSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("referrer_acc"), + getAddressEncoder().encode(seeds.referrer), + getAddressEncoder().encode(seeds.reserve), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/reserveCollateralMint.ts b/clients/kamino-lending/src/generated/pdas/reserveCollateralMint.ts new file mode 100644 index 00000000..b019745f --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/reserveCollateralMint.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReserveCollateralMintSeeds { + lendingMarket: Address; + + mint: Address; +} + +export async function findReserveCollateralMintPda( + seeds: ReserveCollateralMintSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("reserve_coll_mint"), + getAddressEncoder().encode(seeds.lendingMarket), + getAddressEncoder().encode(seeds.mint), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/reserveCollateralSupply.ts b/clients/kamino-lending/src/generated/pdas/reserveCollateralSupply.ts new file mode 100644 index 00000000..5ad8ee54 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/reserveCollateralSupply.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReserveCollateralSupplySeeds { + lendingMarket: Address; + + mint: Address; +} + +export async function findReserveCollateralSupplyPda( + seeds: ReserveCollateralSupplySeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("reserve_coll_supply"), + getAddressEncoder().encode(seeds.lendingMarket), + getAddressEncoder().encode(seeds.mint), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/reserveFeeVault.ts b/clients/kamino-lending/src/generated/pdas/reserveFeeVault.ts new file mode 100644 index 00000000..d16f2b5a --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/reserveFeeVault.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReserveFeeVaultSeeds { + lendingMarket: Address; + + mint: Address; +} + +export async function findReserveFeeVaultPda( + seeds: ReserveFeeVaultSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("fee_receiver"), + getAddressEncoder().encode(seeds.lendingMarket), + getAddressEncoder().encode(seeds.mint), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/reserveLiquiditySupply.ts b/clients/kamino-lending/src/generated/pdas/reserveLiquiditySupply.ts new file mode 100644 index 00000000..ef76a318 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/reserveLiquiditySupply.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface ReserveLiquiditySupplySeeds { + lendingMarket: Address; + + mint: Address; +} + +export async function findReserveLiquiditySupplyPda( + seeds: ReserveLiquiditySupplySeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("reserve_liq_supply"), + getAddressEncoder().encode(seeds.lendingMarket), + getAddressEncoder().encode(seeds.mint), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/shortUrl.ts b/clients/kamino-lending/src/generated/pdas/shortUrl.ts new file mode 100644 index 00000000..ce2f2385 --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/shortUrl.ts @@ -0,0 +1,30 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { getProgramDerivedAddress, getUtf8Encoder } from "@solana/kit"; + +export interface ShortUrlSeeds { + shortUrl: string; +} + +export async function findShortUrlPda( + seeds: ShortUrlSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("short_url"), + getUtf8Encoder().encode(seeds.shortUrl), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/pdas/userMetadata.ts b/clients/kamino-lending/src/generated/pdas/userMetadata.ts new file mode 100644 index 00000000..cb0361bb --- /dev/null +++ b/clients/kamino-lending/src/generated/pdas/userMetadata.ts @@ -0,0 +1,34 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface UserMetadataSeeds { + user: Address; +} + +export async function findUserMetadataPda( + seeds: UserMetadataSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("user_meta"), + getAddressEncoder().encode(seeds.user), + ], + }); +} diff --git a/clients/kamino-lending/src/generated/programs/farms.ts b/clients/kamino-lending/src/generated/programs/farms.ts new file mode 100644 index 00000000..96cfc69f --- /dev/null +++ b/clients/kamino-lending/src/generated/programs/farms.ts @@ -0,0 +1,491 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ReadonlyUint8Array } from "@solana/kit"; +import { containsBytes, fixEncoderSize, getBytesEncoder } from "@solana/kit"; +import type { + ParsedAddRewardsInstruction, + ParsedDepositToFarmVaultInstruction, + ParsedFarmsIdlMissingTypesInstruction, + ParsedHarvestRewardInstruction, + ParsedInitializeFarmDelegatedInstruction, + ParsedInitializeFarmInstruction, + ParsedInitializeGlobalConfigInstruction, + ParsedInitializeRewardInstruction, + ParsedInitializeUserInstruction, + ParsedRefreshFarmInstruction, + ParsedRefreshUserStateInstruction, + ParsedRewardUserOnceInstruction, + ParsedSetStakeDelegatedInstruction, + ParsedStakeInstruction, + ParsedTransferOwnershipInstruction, + ParsedUnstakeInstruction, + ParsedUpdateFarmAdminInstruction, + ParsedUpdateFarmConfigInstruction, + ParsedUpdateGlobalConfigAdminInstruction, + ParsedUpdateGlobalConfigInstruction, + ParsedWithdrawFromFarmVaultInstruction, + ParsedWithdrawRewardInstruction, + ParsedWithdrawSlashedAmountInstruction, + ParsedWithdrawTreasuryInstruction, + ParsedWithdrawUnstakedDepositsInstruction, +} from "../instructions/index.js"; + +export const FARMS_PROGRAM_ADDRESS = + "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" as Address<"FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr">; + +export enum FarmsAccount { + FarmState = 0, + GlobalConfig = 1, + FarmsUserState = 2, + OraclePrices = 3, +} + +export function identifyFarmsAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, +): FarmsAccount { + const data = "data" in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([198, 102, 216, 74, 63, 66, 163, 190]), + ), + 0, + ) + ) { + return FarmsAccount.FarmState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([149, 8, 156, 202, 160, 252, 176, 217]), + ), + 0, + ) + ) { + return FarmsAccount.GlobalConfig; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([72, 177, 85, 249, 76, 167, 186, 126]), + ), + 0, + ) + ) { + return FarmsAccount.FarmsUserState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([89, 128, 118, 221, 6, 72, 180, 146]), + ), + 0, + ) + ) { + return FarmsAccount.OraclePrices; + } + throw new Error( + "The provided account could not be identified as a farms account.", + ); +} + +export enum FarmsInstruction { + InitializeGlobalConfig = 0, + UpdateGlobalConfig = 1, + InitializeFarm = 2, + InitializeFarmDelegated = 3, + InitializeReward = 4, + AddRewards = 5, + UpdateFarmConfig = 6, + InitializeUser = 7, + TransferOwnership = 8, + RewardUserOnce = 9, + RefreshFarm = 10, + Stake = 11, + SetStakeDelegated = 12, + HarvestReward = 13, + Unstake = 14, + RefreshUserState = 15, + WithdrawUnstakedDeposits = 16, + WithdrawTreasury = 17, + DepositToFarmVault = 18, + WithdrawFromFarmVault = 19, + WithdrawSlashedAmount = 20, + UpdateFarmAdmin = 21, + UpdateGlobalConfigAdmin = 22, + WithdrawReward = 23, + FarmsIdlMissingTypes = 24, +} + +export function identifyFarmsInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, +): FarmsInstruction { + const data = "data" in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([113, 216, 122, 131, 225, 209, 22, 55]), + ), + 0, + ) + ) { + return FarmsInstruction.InitializeGlobalConfig; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([164, 84, 130, 189, 111, 58, 250, 200]), + ), + 0, + ) + ) { + return FarmsInstruction.UpdateGlobalConfig; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([252, 28, 185, 172, 244, 74, 117, 165]), + ), + 0, + ) + ) { + return FarmsInstruction.InitializeFarm; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([250, 84, 101, 25, 51, 77, 204, 91]), + ), + 0, + ) + ) { + return FarmsInstruction.InitializeFarmDelegated; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([95, 135, 192, 196, 242, 129, 230, 68]), + ), + 0, + ) + ) { + return FarmsInstruction.InitializeReward; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([88, 186, 25, 227, 38, 137, 81, 23]), + ), + 0, + ) + ) { + return FarmsInstruction.AddRewards; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([214, 176, 188, 244, 203, 59, 230, 207]), + ), + 0, + ) + ) { + return FarmsInstruction.UpdateFarmConfig; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([111, 17, 185, 250, 60, 122, 38, 254]), + ), + 0, + ) + ) { + return FarmsInstruction.InitializeUser; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]), + ), + 0, + ) + ) { + return FarmsInstruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([219, 137, 57, 22, 94, 186, 96, 114]), + ), + 0, + ) + ) { + return FarmsInstruction.RewardUserOnce; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([214, 131, 138, 183, 144, 194, 172, 42]), + ), + 0, + ) + ) { + return FarmsInstruction.RefreshFarm; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([206, 176, 202, 18, 200, 209, 179, 108]), + ), + 0, + ) + ) { + return FarmsInstruction.Stake; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([73, 171, 184, 75, 30, 56, 198, 223]), + ), + 0, + ) + ) { + return FarmsInstruction.SetStakeDelegated; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([68, 200, 228, 233, 184, 32, 226, 188]), + ), + 0, + ) + ) { + return FarmsInstruction.HarvestReward; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([90, 95, 107, 42, 205, 124, 50, 225]), + ), + 0, + ) + ) { + return FarmsInstruction.Unstake; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([1, 135, 12, 62, 243, 140, 77, 108]), + ), + 0, + ) + ) { + return FarmsInstruction.RefreshUserState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([36, 102, 187, 49, 220, 36, 132, 67]), + ), + 0, + ) + ) { + return FarmsInstruction.WithdrawUnstakedDeposits; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([40, 63, 122, 158, 144, 216, 83, 96]), + ), + 0, + ) + ) { + return FarmsInstruction.WithdrawTreasury; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([131, 166, 64, 94, 108, 213, 114, 183]), + ), + 0, + ) + ) { + return FarmsInstruction.DepositToFarmVault; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([22, 82, 128, 250, 86, 79, 124, 78]), + ), + 0, + ) + ) { + return FarmsInstruction.WithdrawFromFarmVault; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([202, 217, 67, 74, 172, 22, 140, 216]), + ), + 0, + ) + ) { + return FarmsInstruction.WithdrawSlashedAmount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([20, 37, 136, 19, 122, 239, 36, 130]), + ), + 0, + ) + ) { + return FarmsInstruction.UpdateFarmAdmin; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([184, 87, 23, 193, 156, 238, 175, 119]), + ), + 0, + ) + ) { + return FarmsInstruction.UpdateGlobalConfigAdmin; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([191, 187, 176, 137, 9, 25, 187, 244]), + ), + 0, + ) + ) { + return FarmsInstruction.WithdrawReward; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([130, 80, 38, 153, 80, 212, 182, 253]), + ), + 0, + ) + ) { + return FarmsInstruction.FarmsIdlMissingTypes; + } + throw new Error( + "The provided instruction could not be identified as a farms instruction.", + ); +} + +export type ParsedFarmsInstruction< + TProgram extends string = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr", +> = + | ({ + instructionType: FarmsInstruction.InitializeGlobalConfig; + } & ParsedInitializeGlobalConfigInstruction) + | ({ + instructionType: FarmsInstruction.UpdateGlobalConfig; + } & ParsedUpdateGlobalConfigInstruction) + | ({ + instructionType: FarmsInstruction.InitializeFarm; + } & ParsedInitializeFarmInstruction) + | ({ + instructionType: FarmsInstruction.InitializeFarmDelegated; + } & ParsedInitializeFarmDelegatedInstruction) + | ({ + instructionType: FarmsInstruction.InitializeReward; + } & ParsedInitializeRewardInstruction) + | ({ + instructionType: FarmsInstruction.AddRewards; + } & ParsedAddRewardsInstruction) + | ({ + instructionType: FarmsInstruction.UpdateFarmConfig; + } & ParsedUpdateFarmConfigInstruction) + | ({ + instructionType: FarmsInstruction.InitializeUser; + } & ParsedInitializeUserInstruction) + | ({ + instructionType: FarmsInstruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: FarmsInstruction.RewardUserOnce; + } & ParsedRewardUserOnceInstruction) + | ({ + instructionType: FarmsInstruction.RefreshFarm; + } & ParsedRefreshFarmInstruction) + | ({ + instructionType: FarmsInstruction.Stake; + } & ParsedStakeInstruction) + | ({ + instructionType: FarmsInstruction.SetStakeDelegated; + } & ParsedSetStakeDelegatedInstruction) + | ({ + instructionType: FarmsInstruction.HarvestReward; + } & ParsedHarvestRewardInstruction) + | ({ + instructionType: FarmsInstruction.Unstake; + } & ParsedUnstakeInstruction) + | ({ + instructionType: FarmsInstruction.RefreshUserState; + } & ParsedRefreshUserStateInstruction) + | ({ + instructionType: FarmsInstruction.WithdrawUnstakedDeposits; + } & ParsedWithdrawUnstakedDepositsInstruction) + | ({ + instructionType: FarmsInstruction.WithdrawTreasury; + } & ParsedWithdrawTreasuryInstruction) + | ({ + instructionType: FarmsInstruction.DepositToFarmVault; + } & ParsedDepositToFarmVaultInstruction) + | ({ + instructionType: FarmsInstruction.WithdrawFromFarmVault; + } & ParsedWithdrawFromFarmVaultInstruction) + | ({ + instructionType: FarmsInstruction.WithdrawSlashedAmount; + } & ParsedWithdrawSlashedAmountInstruction) + | ({ + instructionType: FarmsInstruction.UpdateFarmAdmin; + } & ParsedUpdateFarmAdminInstruction) + | ({ + instructionType: FarmsInstruction.UpdateGlobalConfigAdmin; + } & ParsedUpdateGlobalConfigAdminInstruction) + | ({ + instructionType: FarmsInstruction.WithdrawReward; + } & ParsedWithdrawRewardInstruction) + | ({ + instructionType: FarmsInstruction.FarmsIdlMissingTypes; + } & ParsedFarmsIdlMissingTypesInstruction); diff --git a/clients/kamino-lending/src/generated/programs/index.ts b/clients/kamino-lending/src/generated/programs/index.ts new file mode 100644 index 00000000..7ec4a2ee --- /dev/null +++ b/clients/kamino-lending/src/generated/programs/index.ts @@ -0,0 +1,10 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./farms.js"; +export * from "./kaminoLending.js"; diff --git a/clients/kamino-lending/src/generated/programs/kaminoLending.ts b/clients/kamino-lending/src/generated/programs/kaminoLending.ts new file mode 100644 index 00000000..84228ff6 --- /dev/null +++ b/clients/kamino-lending/src/generated/programs/kaminoLending.ts @@ -0,0 +1,843 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ReadonlyUint8Array } from "@solana/kit"; +import { containsBytes, fixEncoderSize, getBytesEncoder } from "@solana/kit"; +import type { + ParsedBorrowObligationLiquidityInstruction, + ParsedBorrowObligationLiquidityV2Instruction, + ParsedDeleteReferrerStateAndShortUrlInstruction, + ParsedDepositAndWithdrawInstruction, + ParsedDepositObligationCollateralInstruction, + ParsedDepositObligationCollateralV2Instruction, + ParsedDepositReserveLiquidityAndObligationCollateralInstruction, + ParsedDepositReserveLiquidityAndObligationCollateralV2Instruction, + ParsedDepositReserveLiquidityInstruction, + ParsedFlashBorrowReserveLiquidityInstruction, + ParsedFlashRepayReserveLiquidityInstruction, + ParsedIdlMissingTypesInstruction, + ParsedInitFarmsForReserveInstruction, + ParsedInitLendingMarketInstruction, + ParsedInitObligationFarmsForReserveInstruction, + ParsedInitObligationInstruction, + ParsedInitReferrerStateAndShortUrlInstruction, + ParsedInitReferrerTokenStateInstruction, + ParsedInitReserveInstruction, + ParsedInitUserMetadataInstruction, + ParsedLiquidateObligationAndRedeemReserveCollateralInstruction, + ParsedLiquidateObligationAndRedeemReserveCollateralV2Instruction, + ParsedMarkObligationForDeleveragingInstruction, + ParsedRedeemFeesInstruction, + ParsedRedeemReserveCollateralInstruction, + ParsedRefreshObligationFarmsForReserveInstruction, + ParsedRefreshObligationInstruction, + ParsedRefreshReserveInstruction, + ParsedRefreshReservesBatchInstruction, + ParsedRepayAndWithdrawAndRedeemInstruction, + ParsedRepayObligationLiquidityInstruction, + ParsedRepayObligationLiquidityV2Instruction, + ParsedRequestElevationGroupInstruction, + ParsedSocializeLossInstruction, + ParsedSocializeLossV2Instruction, + ParsedUpdateLendingMarketInstruction, + ParsedUpdateLendingMarketOwnerInstruction, + ParsedUpdateReserveConfigInstruction, + ParsedWithdrawObligationCollateralAndRedeemReserveCollateralInstruction, + ParsedWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction, + ParsedWithdrawObligationCollateralInstruction, + ParsedWithdrawObligationCollateralV2Instruction, + ParsedWithdrawProtocolFeeInstruction, + ParsedWithdrawReferrerFeesInstruction, +} from "../instructions/index.js"; + +export const KAMINO_LENDING_PROGRAM_ADDRESS = + "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" as Address<"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD">; + +export enum KaminoLendingAccount { + UserState = 0, + LendingMarket = 1, + Obligation = 2, + ReferrerState = 3, + ReferrerTokenState = 4, + ShortUrl = 5, + UserMetadata = 6, + Reserve = 7, +} + +export function identifyKaminoLendingAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, +): KaminoLendingAccount { + const data = "data" in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([72, 177, 85, 249, 76, 167, 186, 126]), + ), + 0, + ) + ) { + return KaminoLendingAccount.UserState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([246, 114, 50, 98, 72, 157, 28, 120]), + ), + 0, + ) + ) { + return KaminoLendingAccount.LendingMarket; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([168, 206, 141, 106, 88, 76, 172, 167]), + ), + 0, + ) + ) { + return KaminoLendingAccount.Obligation; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([194, 81, 217, 103, 12, 19, 12, 66]), + ), + 0, + ) + ) { + return KaminoLendingAccount.ReferrerState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([39, 15, 208, 77, 32, 195, 105, 56]), + ), + 0, + ) + ) { + return KaminoLendingAccount.ReferrerTokenState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([28, 89, 174, 25, 226, 124, 126, 212]), + ), + 0, + ) + ) { + return KaminoLendingAccount.ShortUrl; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([157, 214, 220, 235, 98, 135, 171, 28]), + ), + 0, + ) + ) { + return KaminoLendingAccount.UserMetadata; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([43, 242, 204, 202, 26, 247, 59, 127]), + ), + 0, + ) + ) { + return KaminoLendingAccount.Reserve; + } + throw new Error( + "The provided account could not be identified as a kaminoLending account.", + ); +} + +export enum KaminoLendingInstruction { + InitLendingMarket = 0, + UpdateLendingMarket = 1, + UpdateLendingMarketOwner = 2, + InitReserve = 3, + InitFarmsForReserve = 4, + UpdateReserveConfig = 5, + RedeemFees = 6, + WithdrawProtocolFee = 7, + SocializeLoss = 8, + SocializeLossV2 = 9, + MarkObligationForDeleveraging = 10, + RefreshReservesBatch = 11, + RefreshReserve = 12, + DepositReserveLiquidity = 13, + RedeemReserveCollateral = 14, + InitObligation = 15, + InitObligationFarmsForReserve = 16, + RefreshObligationFarmsForReserve = 17, + RefreshObligation = 18, + DepositObligationCollateral = 19, + DepositObligationCollateralV2 = 20, + WithdrawObligationCollateral = 21, + WithdrawObligationCollateralV2 = 22, + BorrowObligationLiquidity = 23, + BorrowObligationLiquidityV2 = 24, + RepayObligationLiquidity = 25, + RepayObligationLiquidityV2 = 26, + RepayAndWithdrawAndRedeem = 27, + DepositAndWithdraw = 28, + DepositReserveLiquidityAndObligationCollateral = 29, + DepositReserveLiquidityAndObligationCollateralV2 = 30, + WithdrawObligationCollateralAndRedeemReserveCollateral = 31, + WithdrawObligationCollateralAndRedeemReserveCollateralV2 = 32, + LiquidateObligationAndRedeemReserveCollateral = 33, + LiquidateObligationAndRedeemReserveCollateralV2 = 34, + FlashRepayReserveLiquidity = 35, + FlashBorrowReserveLiquidity = 36, + RequestElevationGroup = 37, + InitReferrerTokenState = 38, + InitUserMetadata = 39, + WithdrawReferrerFees = 40, + InitReferrerStateAndShortUrl = 41, + DeleteReferrerStateAndShortUrl = 42, + IdlMissingTypes = 43, +} + +export function identifyKaminoLendingInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, +): KaminoLendingInstruction { + const data = "data" in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([34, 162, 116, 14, 101, 137, 94, 239]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitLendingMarket; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([209, 157, 53, 210, 97, 180, 31, 45]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.UpdateLendingMarket; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([118, 224, 10, 62, 196, 230, 184, 89]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.UpdateLendingMarketOwner; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([138, 245, 71, 225, 153, 4, 3, 43]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitReserve; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([218, 6, 62, 233, 1, 33, 232, 82]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitFarmsForReserve; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([61, 148, 100, 70, 143, 107, 17, 13]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.UpdateReserveConfig; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([215, 39, 180, 41, 173, 46, 248, 220]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RedeemFees; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([158, 201, 158, 189, 33, 93, 162, 103]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawProtocolFee; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([245, 75, 91, 0, 236, 97, 19, 3]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.SocializeLoss; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([238, 95, 98, 220, 187, 40, 204, 154]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.SocializeLossV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([164, 35, 182, 19, 0, 116, 243, 127]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.MarkObligationForDeleveraging; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([144, 110, 26, 103, 162, 204, 252, 147]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RefreshReservesBatch; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([2, 218, 138, 235, 79, 201, 25, 102]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RefreshReserve; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([169, 201, 30, 126, 6, 205, 102, 68]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositReserveLiquidity; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([234, 117, 181, 125, 185, 142, 220, 29]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RedeemReserveCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([251, 10, 231, 76, 27, 11, 159, 96]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitObligation; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([136, 63, 15, 186, 211, 152, 168, 164]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitObligationFarmsForReserve; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([140, 144, 253, 21, 10, 74, 248, 3]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RefreshObligationFarmsForReserve; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([33, 132, 147, 228, 151, 192, 72, 89]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RefreshObligation; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([108, 209, 4, 72, 21, 22, 118, 133]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositObligationCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([137, 145, 151, 94, 167, 113, 4, 145]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositObligationCollateralV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([37, 116, 205, 103, 243, 192, 92, 198]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawObligationCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([202, 249, 117, 114, 231, 192, 47, 138]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawObligationCollateralV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([121, 127, 18, 204, 73, 245, 225, 65]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.BorrowObligationLiquidity; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([161, 128, 143, 245, 171, 199, 194, 6]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.BorrowObligationLiquidityV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([145, 178, 13, 225, 76, 240, 147, 72]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RepayObligationLiquidity; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([116, 174, 213, 76, 180, 53, 210, 144]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RepayObligationLiquidityV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([2, 54, 152, 3, 148, 96, 109, 218]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RepayAndWithdrawAndRedeem; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([141, 153, 39, 15, 64, 61, 88, 84]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositAndWithdraw; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([129, 199, 4, 2, 222, 39, 26, 46]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositReserveLiquidityAndObligationCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([216, 224, 191, 27, 204, 151, 102, 175]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DepositReserveLiquidityAndObligationCollateralV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([75, 93, 93, 220, 34, 150, 218, 196]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawObligationCollateralAndRedeemReserveCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([235, 52, 119, 152, 149, 197, 20, 7]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawObligationCollateralAndRedeemReserveCollateralV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([177, 71, 154, 188, 226, 133, 74, 55]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.LiquidateObligationAndRedeemReserveCollateral; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([162, 161, 35, 143, 30, 187, 185, 103]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.LiquidateObligationAndRedeemReserveCollateralV2; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([185, 117, 0, 203, 96, 245, 180, 186]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.FlashRepayReserveLiquidity; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([135, 231, 52, 167, 7, 52, 212, 193]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.FlashBorrowReserveLiquidity; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([36, 119, 251, 129, 34, 240, 7, 147]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.RequestElevationGroup; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([116, 45, 66, 148, 58, 13, 218, 115]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitReferrerTokenState; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([117, 169, 176, 69, 197, 23, 15, 162]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitUserMetadata; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([171, 118, 121, 201, 233, 140, 23, 228]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.WithdrawReferrerFees; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([165, 19, 25, 127, 100, 55, 31, 90]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.InitReferrerStateAndShortUrl; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([153, 185, 99, 28, 228, 179, 187, 150]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.DeleteReferrerStateAndShortUrl; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([130, 80, 38, 153, 80, 212, 182, 253]), + ), + 0, + ) + ) { + return KaminoLendingInstruction.IdlMissingTypes; + } + throw new Error( + "The provided instruction could not be identified as a kaminoLending instruction.", + ); +} + +export type ParsedKaminoLendingInstruction< + TProgram extends string = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD", +> = + | ({ + instructionType: KaminoLendingInstruction.InitLendingMarket; + } & ParsedInitLendingMarketInstruction) + | ({ + instructionType: KaminoLendingInstruction.UpdateLendingMarket; + } & ParsedUpdateLendingMarketInstruction) + | ({ + instructionType: KaminoLendingInstruction.UpdateLendingMarketOwner; + } & ParsedUpdateLendingMarketOwnerInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitReserve; + } & ParsedInitReserveInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitFarmsForReserve; + } & ParsedInitFarmsForReserveInstruction) + | ({ + instructionType: KaminoLendingInstruction.UpdateReserveConfig; + } & ParsedUpdateReserveConfigInstruction) + | ({ + instructionType: KaminoLendingInstruction.RedeemFees; + } & ParsedRedeemFeesInstruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawProtocolFee; + } & ParsedWithdrawProtocolFeeInstruction) + | ({ + instructionType: KaminoLendingInstruction.SocializeLoss; + } & ParsedSocializeLossInstruction) + | ({ + instructionType: KaminoLendingInstruction.SocializeLossV2; + } & ParsedSocializeLossV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.MarkObligationForDeleveraging; + } & ParsedMarkObligationForDeleveragingInstruction) + | ({ + instructionType: KaminoLendingInstruction.RefreshReservesBatch; + } & ParsedRefreshReservesBatchInstruction) + | ({ + instructionType: KaminoLendingInstruction.RefreshReserve; + } & ParsedRefreshReserveInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositReserveLiquidity; + } & ParsedDepositReserveLiquidityInstruction) + | ({ + instructionType: KaminoLendingInstruction.RedeemReserveCollateral; + } & ParsedRedeemReserveCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitObligation; + } & ParsedInitObligationInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitObligationFarmsForReserve; + } & ParsedInitObligationFarmsForReserveInstruction) + | ({ + instructionType: KaminoLendingInstruction.RefreshObligationFarmsForReserve; + } & ParsedRefreshObligationFarmsForReserveInstruction) + | ({ + instructionType: KaminoLendingInstruction.RefreshObligation; + } & ParsedRefreshObligationInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositObligationCollateral; + } & ParsedDepositObligationCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositObligationCollateralV2; + } & ParsedDepositObligationCollateralV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawObligationCollateral; + } & ParsedWithdrawObligationCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawObligationCollateralV2; + } & ParsedWithdrawObligationCollateralV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.BorrowObligationLiquidity; + } & ParsedBorrowObligationLiquidityInstruction) + | ({ + instructionType: KaminoLendingInstruction.BorrowObligationLiquidityV2; + } & ParsedBorrowObligationLiquidityV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.RepayObligationLiquidity; + } & ParsedRepayObligationLiquidityInstruction) + | ({ + instructionType: KaminoLendingInstruction.RepayObligationLiquidityV2; + } & ParsedRepayObligationLiquidityV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.RepayAndWithdrawAndRedeem; + } & ParsedRepayAndWithdrawAndRedeemInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositAndWithdraw; + } & ParsedDepositAndWithdrawInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositReserveLiquidityAndObligationCollateral; + } & ParsedDepositReserveLiquidityAndObligationCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.DepositReserveLiquidityAndObligationCollateralV2; + } & ParsedDepositReserveLiquidityAndObligationCollateralV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawObligationCollateralAndRedeemReserveCollateral; + } & ParsedWithdrawObligationCollateralAndRedeemReserveCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawObligationCollateralAndRedeemReserveCollateralV2; + } & ParsedWithdrawObligationCollateralAndRedeemReserveCollateralV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.LiquidateObligationAndRedeemReserveCollateral; + } & ParsedLiquidateObligationAndRedeemReserveCollateralInstruction) + | ({ + instructionType: KaminoLendingInstruction.LiquidateObligationAndRedeemReserveCollateralV2; + } & ParsedLiquidateObligationAndRedeemReserveCollateralV2Instruction) + | ({ + instructionType: KaminoLendingInstruction.FlashRepayReserveLiquidity; + } & ParsedFlashRepayReserveLiquidityInstruction) + | ({ + instructionType: KaminoLendingInstruction.FlashBorrowReserveLiquidity; + } & ParsedFlashBorrowReserveLiquidityInstruction) + | ({ + instructionType: KaminoLendingInstruction.RequestElevationGroup; + } & ParsedRequestElevationGroupInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitReferrerTokenState; + } & ParsedInitReferrerTokenStateInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitUserMetadata; + } & ParsedInitUserMetadataInstruction) + | ({ + instructionType: KaminoLendingInstruction.WithdrawReferrerFees; + } & ParsedWithdrawReferrerFeesInstruction) + | ({ + instructionType: KaminoLendingInstruction.InitReferrerStateAndShortUrl; + } & ParsedInitReferrerStateAndShortUrlInstruction) + | ({ + instructionType: KaminoLendingInstruction.DeleteReferrerStateAndShortUrl; + } & ParsedDeleteReferrerStateAndShortUrlInstruction) + | ({ + instructionType: KaminoLendingInstruction.IdlMissingTypes; + } & ParsedIdlMissingTypesInstruction); diff --git a/clients/kamino-lending/src/generated/shared/index.ts b/clients/kamino-lending/src/generated/shared/index.ts new file mode 100644 index 00000000..7d911d4a --- /dev/null +++ b/clients/kamino-lending/src/generated/shared/index.ts @@ -0,0 +1,168 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + AccountMeta, + AccountSignerMeta, + Address, + ProgramDerivedAddress, + TransactionSigner, +} from "@solana/kit"; +import { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + upgradeRoleToSigner, +} from "@solana/kit"; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value === null || value === undefined) { + throw new Error("Expected a value but received null or undefined."); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined, +): Address { + if (!value) { + throw new Error("Expected a Address."); + } + if (typeof value === "object" && "address" in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0] as Address; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined, +): ProgramDerivedAddress { + if (!(value && Array.isArray(value) && isProgramDerivedAddress(value))) { + throw new Error("Expected a ProgramDerivedAddress."); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined, +): TransactionSigner { + if (!(value && isTransactionSigner(value))) { + throw new Error("Expected a TransactionSigner."); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export interface ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> { + isWritable: boolean; + value: U; +} + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export interface InstructionWithByteDelta { + byteDelta: number; +} + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: "omitted" | "programId", +) { + return ( + account: ResolvedAccount, + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === "omitted") { + return; + } + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner, +): value is TransactionSigner { + return ( + !!value && + typeof value === "object" && + "address" in value && + kitIsTransactionSigner(value) + ); +} diff --git a/clients/kamino-lending/src/generated/types/assetTier.ts b/clients/kamino-lending/src/generated/types/assetTier.ts new file mode 100644 index 00000000..cf728b6d --- /dev/null +++ b/clients/kamino-lending/src/generated/types/assetTier.ts @@ -0,0 +1,34 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum AssetTier { + Regular = 0, + IsolatedCollateral = 1, + IsolatedDebt = 2, +} + +export type AssetTierArgs = AssetTier; + +export function getAssetTierEncoder(): FixedSizeEncoder { + return getEnumEncoder(AssetTier); +} + +export function getAssetTierDecoder(): FixedSizeDecoder { + return getEnumDecoder(AssetTier); +} + +export function getAssetTierCodec(): FixedSizeCodec { + return combineCodec(getAssetTierEncoder(), getAssetTierDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/bigFractionBytes.ts b/clients/kamino-lending/src/generated/types/bigFractionBytes.ts new file mode 100644 index 00000000..64259aff --- /dev/null +++ b/clients/kamino-lending/src/generated/types/bigFractionBytes.ts @@ -0,0 +1,56 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface BigFractionBytes { + value: bigint[]; + padding: bigint[]; +} + +export interface BigFractionBytesArgs { + value: (number | bigint)[]; + padding: (number | bigint)[]; +} + +export function getBigFractionBytesEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["value", getArrayEncoder(getU64Encoder(), { size: 4 })], + ["padding", getArrayEncoder(getU64Encoder(), { size: 2 })], + ]); +} + +export function getBigFractionBytesDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["value", getArrayDecoder(getU64Decoder(), { size: 4 })], + ["padding", getArrayDecoder(getU64Decoder(), { size: 2 })], + ]); +} + +export function getBigFractionBytesCodec(): FixedSizeCodec< + BigFractionBytesArgs, + BigFractionBytes +> { + return combineCodec( + getBigFractionBytesEncoder(), + getBigFractionBytesDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/borrowRateCurve.ts b/clients/kamino-lending/src/generated/types/borrowRateCurve.ts new file mode 100644 index 00000000..64081047 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/borrowRateCurve.ts @@ -0,0 +1,49 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, +} from "@solana/kit"; +import type { CurvePoint, CurvePointArgs } from "./index.js"; +import { getCurvePointDecoder, getCurvePointEncoder } from "./index.js"; + +export interface BorrowRateCurve { + points: CurvePoint[]; +} + +export interface BorrowRateCurveArgs { + points: CurvePointArgs[]; +} + +export function getBorrowRateCurveEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["points", getArrayEncoder(getCurvePointEncoder(), { size: 11 })], + ]); +} + +export function getBorrowRateCurveDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["points", getArrayDecoder(getCurvePointDecoder(), { size: 11 })], + ]); +} + +export function getBorrowRateCurveCodec(): FixedSizeCodec< + BorrowRateCurveArgs, + BorrowRateCurve +> { + return combineCodec(getBorrowRateCurveEncoder(), getBorrowRateCurveDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/curvePoint.ts b/clients/kamino-lending/src/generated/types/curvePoint.ts new file mode 100644 index 00000000..c6197836 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/curvePoint.ts @@ -0,0 +1,48 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, +} from "@solana/kit"; + +export interface CurvePoint { + utilizationRateBps: number; + borrowRateBps: number; +} + +export type CurvePointArgs = CurvePoint; + +export function getCurvePointEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["utilizationRateBps", getU32Encoder()], + ["borrowRateBps", getU32Encoder()], + ]); +} + +export function getCurvePointDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["utilizationRateBps", getU32Decoder()], + ["borrowRateBps", getU32Decoder()], + ]); +} + +export function getCurvePointCodec(): FixedSizeCodec< + CurvePointArgs, + CurvePoint +> { + return combineCodec(getCurvePointEncoder(), getCurvePointDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/datedPrice.ts b/clients/kamino-lending/src/generated/types/datedPrice.ts new file mode 100644 index 00000000..c2ea7db6 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/datedPrice.ts @@ -0,0 +1,73 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; +import type { Price, PriceArgs } from "./index.js"; +import { getPriceDecoder, getPriceEncoder } from "./index.js"; + +export interface DatedPrice { + price: Price; + lastUpdatedSlot: bigint; + unixTimestamp: bigint; + reserved: bigint[]; + reserved2: number[]; + index: number; +} + +export interface DatedPriceArgs { + price: PriceArgs; + lastUpdatedSlot: number | bigint; + unixTimestamp: number | bigint; + reserved: (number | bigint)[]; + reserved2: number[]; + index: number; +} + +export function getDatedPriceEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["price", getPriceEncoder()], + ["lastUpdatedSlot", getU64Encoder()], + ["unixTimestamp", getU64Encoder()], + ["reserved", getArrayEncoder(getU64Encoder(), { size: 2 })], + ["reserved2", getArrayEncoder(getU16Encoder(), { size: 3 })], + ["index", getU16Encoder()], + ]); +} + +export function getDatedPriceDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["price", getPriceDecoder()], + ["lastUpdatedSlot", getU64Decoder()], + ["unixTimestamp", getU64Decoder()], + ["reserved", getArrayDecoder(getU64Decoder(), { size: 2 })], + ["reserved2", getArrayDecoder(getU16Decoder(), { size: 3 })], + ["index", getU16Decoder()], + ]); +} + +export function getDatedPriceCodec(): FixedSizeCodec< + DatedPriceArgs, + DatedPrice +> { + return combineCodec(getDatedPriceEncoder(), getDatedPriceDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/elevationGroup.ts b/clients/kamino-lending/src/generated/types/elevationGroup.ts new file mode 100644 index 00000000..aeb48280 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/elevationGroup.ts @@ -0,0 +1,88 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface ElevationGroup { + maxLiquidationBonusBps: number; + id: number; + ltvPct: number; + liquidationThresholdPct: number; + allowNewLoans: number; + maxReservesAsCollateral: number; + padding0: number; + debtReserve: Address; + padding1: bigint[]; +} + +export interface ElevationGroupArgs { + maxLiquidationBonusBps: number; + id: number; + ltvPct: number; + liquidationThresholdPct: number; + allowNewLoans: number; + maxReservesAsCollateral: number; + padding0: number; + debtReserve: Address; + padding1: (number | bigint)[]; +} + +export function getElevationGroupEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["maxLiquidationBonusBps", getU16Encoder()], + ["id", getU8Encoder()], + ["ltvPct", getU8Encoder()], + ["liquidationThresholdPct", getU8Encoder()], + ["allowNewLoans", getU8Encoder()], + ["maxReservesAsCollateral", getU8Encoder()], + ["padding0", getU8Encoder()], + ["debtReserve", getAddressEncoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 4 })], + ]); +} + +export function getElevationGroupDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["maxLiquidationBonusBps", getU16Decoder()], + ["id", getU8Decoder()], + ["ltvPct", getU8Decoder()], + ["liquidationThresholdPct", getU8Decoder()], + ["allowNewLoans", getU8Decoder()], + ["maxReservesAsCollateral", getU8Decoder()], + ["padding0", getU8Decoder()], + ["debtReserve", getAddressDecoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 4 })], + ]); +} + +export function getElevationGroupCodec(): FixedSizeCodec< + ElevationGroupArgs, + ElevationGroup +> { + return combineCodec(getElevationGroupEncoder(), getElevationGroupDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/elevationGroupLendingMarket.ts b/clients/kamino-lending/src/generated/types/elevationGroupLendingMarket.ts new file mode 100644 index 00000000..901c02fe --- /dev/null +++ b/clients/kamino-lending/src/generated/types/elevationGroupLendingMarket.ts @@ -0,0 +1,91 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface ElevationGroupLendingMarket { + maxLiquidationBonusBps: number; + id: number; + ltvPct: number; + liquidationThresholdPct: number; + allowNewLoans: number; + maxReservesAsCollateral: number; + padding0: number; + debtReserve: Address; + padding1: bigint[]; +} + +export interface ElevationGroupLendingMarketArgs { + maxLiquidationBonusBps: number; + id: number; + ltvPct: number; + liquidationThresholdPct: number; + allowNewLoans: number; + maxReservesAsCollateral: number; + padding0: number; + debtReserve: Address; + padding1: (number | bigint)[]; +} + +export function getElevationGroupLendingMarketEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["maxLiquidationBonusBps", getU16Encoder()], + ["id", getU8Encoder()], + ["ltvPct", getU8Encoder()], + ["liquidationThresholdPct", getU8Encoder()], + ["allowNewLoans", getU8Encoder()], + ["maxReservesAsCollateral", getU8Encoder()], + ["padding0", getU8Encoder()], + ["debtReserve", getAddressEncoder()], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 4 })], + ]); +} + +export function getElevationGroupLendingMarketDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["maxLiquidationBonusBps", getU16Decoder()], + ["id", getU8Decoder()], + ["ltvPct", getU8Decoder()], + ["liquidationThresholdPct", getU8Decoder()], + ["allowNewLoans", getU8Decoder()], + ["maxReservesAsCollateral", getU8Decoder()], + ["padding0", getU8Decoder()], + ["debtReserve", getAddressDecoder()], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 4 })], + ]); +} + +export function getElevationGroupLendingMarketCodec(): FixedSizeCodec< + ElevationGroupLendingMarketArgs, + ElevationGroupLendingMarket +> { + return combineCodec( + getElevationGroupLendingMarketEncoder(), + getElevationGroupLendingMarketDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/farmConfigOption.ts b/clients/kamino-lending/src/generated/types/farmConfigOption.ts new file mode 100644 index 00000000..65f13dbc --- /dev/null +++ b/clients/kamino-lending/src/generated/types/farmConfigOption.ts @@ -0,0 +1,58 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum FarmConfigOption { + UpdateRewardRps = 0, + UpdateRewardMinClaimDuration = 1, + WithdrawAuthority = 2, + DepositWarmupPeriod = 3, + WithdrawCooldownPeriod = 4, + RewardType = 5, + RpsDecimals = 6, + LockingMode = 7, + LockingStartTimestamp = 8, + LockingDuration = 9, + LockingEarlyWithdrawalPenaltyBps = 10, + DepositCapAmount = 11, + SlashedAmountSpillAddress = 12, + ScopePricesAccount = 13, + ScopeOraclePriceId = 14, + ScopeOracleMaxAge = 15, + UpdateRewardScheduleCurvePoints = 16, + UpdatePendingFarmAdmin = 17, + UpdateStrategyId = 18, + UpdateDelegatedRpsAdmin = 19, + UpdateVaultId = 20, +} + +export type FarmConfigOptionArgs = FarmConfigOption; + +export function getFarmConfigOptionEncoder(): FixedSizeEncoder { + return getEnumEncoder(FarmConfigOption); +} + +export function getFarmConfigOptionDecoder(): FixedSizeDecoder { + return getEnumDecoder(FarmConfigOption); +} + +export function getFarmConfigOptionCodec(): FixedSizeCodec< + FarmConfigOptionArgs, + FarmConfigOption +> { + return combineCodec( + getFarmConfigOptionEncoder(), + getFarmConfigOptionDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/farmsTokenInfo.ts b/clients/kamino-lending/src/generated/types/farmsTokenInfo.ts new file mode 100644 index 00000000..bd3fbace --- /dev/null +++ b/clients/kamino-lending/src/generated/types/farmsTokenInfo.ts @@ -0,0 +1,64 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface FarmsTokenInfo { + mint: Address; + decimals: bigint; + tokenProgram: Address; + padding: bigint[]; +} + +export interface FarmsTokenInfoArgs { + mint: Address; + decimals: number | bigint; + tokenProgram: Address; + padding: (number | bigint)[]; +} + +export function getFarmsTokenInfoEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["mint", getAddressEncoder()], + ["decimals", getU64Encoder()], + ["tokenProgram", getAddressEncoder()], + ["padding", getArrayEncoder(getU64Encoder(), { size: 6 })], + ]); +} + +export function getFarmsTokenInfoDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["mint", getAddressDecoder()], + ["decimals", getU64Decoder()], + ["tokenProgram", getAddressDecoder()], + ["padding", getArrayDecoder(getU64Decoder(), { size: 6 })], + ]); +} + +export function getFarmsTokenInfoCodec(): FixedSizeCodec< + FarmsTokenInfoArgs, + FarmsTokenInfo +> { + return combineCodec(getFarmsTokenInfoEncoder(), getFarmsTokenInfoDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/feeCalculation.ts b/clients/kamino-lending/src/generated/types/feeCalculation.ts new file mode 100644 index 00000000..951aa7f8 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/feeCalculation.ts @@ -0,0 +1,36 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum FeeCalculation { + Exclusive = 0, + Inclusive = 1, +} + +export type FeeCalculationArgs = FeeCalculation; + +export function getFeeCalculationEncoder(): FixedSizeEncoder { + return getEnumEncoder(FeeCalculation); +} + +export function getFeeCalculationDecoder(): FixedSizeDecoder { + return getEnumDecoder(FeeCalculation); +} + +export function getFeeCalculationCodec(): FixedSizeCodec< + FeeCalculationArgs, + FeeCalculation +> { + return combineCodec(getFeeCalculationEncoder(), getFeeCalculationDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/globalConfigOption.ts b/clients/kamino-lending/src/generated/types/globalConfigOption.ts new file mode 100644 index 00000000..bf527b56 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/globalConfigOption.ts @@ -0,0 +1,39 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum GlobalConfigOption { + SetPendingGlobalAdmin = 0, + SetTreasuryFeeBps = 1, +} + +export type GlobalConfigOptionArgs = GlobalConfigOption; + +export function getGlobalConfigOptionEncoder(): FixedSizeEncoder { + return getEnumEncoder(GlobalConfigOption); +} + +export function getGlobalConfigOptionDecoder(): FixedSizeDecoder { + return getEnumDecoder(GlobalConfigOption); +} + +export function getGlobalConfigOptionCodec(): FixedSizeCodec< + GlobalConfigOptionArgs, + GlobalConfigOption +> { + return combineCodec( + getGlobalConfigOptionEncoder(), + getGlobalConfigOptionDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/index.ts b/clients/kamino-lending/src/generated/types/index.ts new file mode 100644 index 00000000..73b91501 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/index.ts @@ -0,0 +1,45 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from "./assetTier.js"; +export * from "./bigFractionBytes.js"; +export * from "./borrowRateCurve.js"; +export * from "./curvePoint.js"; +export * from "./datedPrice.js"; +export * from "./elevationGroup.js"; +export * from "./elevationGroupLendingMarket.js"; +export * from "./farmConfigOption.js"; +export * from "./farmsTokenInfo.js"; +export * from "./feeCalculation.js"; +export * from "./globalConfigOption.js"; +export * from "./initObligationArgs.js"; +export * from "./lastUpdate.js"; +export * from "./lockingMode.js"; +export * from "./obligationCollateral.js"; +export * from "./obligationLiquidity.js"; +export * from "./price.js"; +export * from "./priceHeuristic.js"; +export * from "./pythConfiguration.js"; +export * from "./reserveCollateral.js"; +export * from "./reserveConfig.js"; +export * from "./reserveFarmKind.js"; +export * from "./reserveFees.js"; +export * from "./reserveLiquidity.js"; +export * from "./reserveStatus.js"; +export * from "./rewardInfo.js"; +export * from "./rewardPerTimeUnitPoint.js"; +export * from "./rewardScheduleCurve.js"; +export * from "./rewardType.js"; +export * from "./scopeConfiguration.js"; +export * from "./switchboardConfiguration.js"; +export * from "./timeUnit.js"; +export * from "./tokenInfo.js"; +export * from "./updateConfigMode.js"; +export * from "./updateLendingMarketConfigValue.js"; +export * from "./updateLendingMarketMode.js"; +export * from "./withdrawalCaps.js"; diff --git a/clients/kamino-lending/src/generated/types/initObligationArgs.ts b/clients/kamino-lending/src/generated/types/initObligationArgs.ts new file mode 100644 index 00000000..a8fb99a0 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/initObligationArgs.ts @@ -0,0 +1,51 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, +} from "@solana/kit"; + +export interface InitObligationArgs { + tag: number; + id: number; +} + +export type InitObligationArgsArgs = InitObligationArgs; + +export function getInitObligationArgsEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["tag", getU8Encoder()], + ["id", getU8Encoder()], + ]); +} + +export function getInitObligationArgsDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["tag", getU8Decoder()], + ["id", getU8Decoder()], + ]); +} + +export function getInitObligationArgsCodec(): FixedSizeCodec< + InitObligationArgsArgs, + InitObligationArgs +> { + return combineCodec( + getInitObligationArgsEncoder(), + getInitObligationArgsDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/lastUpdate.ts b/clients/kamino-lending/src/generated/types/lastUpdate.ts new file mode 100644 index 00000000..03cd27c5 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/lastUpdate.ts @@ -0,0 +1,63 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface LastUpdate { + slot: bigint; + stale: number; + priceStatus: number; + placeholder: number[]; +} + +export interface LastUpdateArgs { + slot: number | bigint; + stale: number; + priceStatus: number; + placeholder: number[]; +} + +export function getLastUpdateEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["slot", getU64Encoder()], + ["stale", getU8Encoder()], + ["priceStatus", getU8Encoder()], + ["placeholder", getArrayEncoder(getU8Encoder(), { size: 6 })], + ]); +} + +export function getLastUpdateDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["slot", getU64Decoder()], + ["stale", getU8Decoder()], + ["priceStatus", getU8Decoder()], + ["placeholder", getArrayDecoder(getU8Decoder(), { size: 6 })], + ]); +} + +export function getLastUpdateCodec(): FixedSizeCodec< + LastUpdateArgs, + LastUpdate +> { + return combineCodec(getLastUpdateEncoder(), getLastUpdateDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/lockingMode.ts b/clients/kamino-lending/src/generated/types/lockingMode.ts new file mode 100644 index 00000000..6d5ce2c4 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/lockingMode.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum LockingMode { + None = 0, + Continuous = 1, + WithExpiry = 2, +} + +export type LockingModeArgs = LockingMode; + +export function getLockingModeEncoder(): FixedSizeEncoder { + return getEnumEncoder(LockingMode); +} + +export function getLockingModeDecoder(): FixedSizeDecoder { + return getEnumDecoder(LockingMode); +} + +export function getLockingModeCodec(): FixedSizeCodec< + LockingModeArgs, + LockingMode +> { + return combineCodec(getLockingModeEncoder(), getLockingModeDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/obligationCollateral.ts b/clients/kamino-lending/src/generated/types/obligationCollateral.ts new file mode 100644 index 00000000..9ddd7198 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/obligationCollateral.ts @@ -0,0 +1,73 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; + +export interface ObligationCollateral { + depositReserve: Address; + depositedAmount: bigint; + marketValueSf: bigint; + borrowedAmountAgainstThisCollateralInElevationGroup: bigint; + padding: bigint[]; +} + +export interface ObligationCollateralArgs { + depositReserve: Address; + depositedAmount: number | bigint; + marketValueSf: number | bigint; + borrowedAmountAgainstThisCollateralInElevationGroup: number | bigint; + padding: (number | bigint)[]; +} + +export function getObligationCollateralEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["depositReserve", getAddressEncoder()], + ["depositedAmount", getU64Encoder()], + ["marketValueSf", getU128Encoder()], + ["borrowedAmountAgainstThisCollateralInElevationGroup", getU64Encoder()], + ["padding", getArrayEncoder(getU64Encoder(), { size: 9 })], + ]); +} + +export function getObligationCollateralDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["depositReserve", getAddressDecoder()], + ["depositedAmount", getU64Decoder()], + ["marketValueSf", getU128Decoder()], + ["borrowedAmountAgainstThisCollateralInElevationGroup", getU64Decoder()], + ["padding", getArrayDecoder(getU64Decoder(), { size: 9 })], + ]); +} + +export function getObligationCollateralCodec(): FixedSizeCodec< + ObligationCollateralArgs, + ObligationCollateral +> { + return combineCodec( + getObligationCollateralEncoder(), + getObligationCollateralDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/obligationLiquidity.ts b/clients/kamino-lending/src/generated/types/obligationLiquidity.ts new file mode 100644 index 00000000..c0fea093 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/obligationLiquidity.ts @@ -0,0 +1,90 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; +import type { BigFractionBytes, BigFractionBytesArgs } from "./index.js"; +import { + getBigFractionBytesDecoder, + getBigFractionBytesEncoder, +} from "./index.js"; + +export interface ObligationLiquidity { + borrowReserve: Address; + cumulativeBorrowRateBsf: BigFractionBytes; + padding: bigint; + borrowedAmountSf: bigint; + marketValueSf: bigint; + borrowFactorAdjustedMarketValueSf: bigint; + borrowedAmountOutsideElevationGroups: bigint; + padding2: bigint[]; +} + +export interface ObligationLiquidityArgs { + borrowReserve: Address; + cumulativeBorrowRateBsf: BigFractionBytesArgs; + padding: number | bigint; + borrowedAmountSf: number | bigint; + marketValueSf: number | bigint; + borrowFactorAdjustedMarketValueSf: number | bigint; + borrowedAmountOutsideElevationGroups: number | bigint; + padding2: (number | bigint)[]; +} + +export function getObligationLiquidityEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["borrowReserve", getAddressEncoder()], + ["cumulativeBorrowRateBsf", getBigFractionBytesEncoder()], + ["padding", getU64Encoder()], + ["borrowedAmountSf", getU128Encoder()], + ["marketValueSf", getU128Encoder()], + ["borrowFactorAdjustedMarketValueSf", getU128Encoder()], + ["borrowedAmountOutsideElevationGroups", getU64Encoder()], + ["padding2", getArrayEncoder(getU64Encoder(), { size: 7 })], + ]); +} + +export function getObligationLiquidityDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["borrowReserve", getAddressDecoder()], + ["cumulativeBorrowRateBsf", getBigFractionBytesDecoder()], + ["padding", getU64Decoder()], + ["borrowedAmountSf", getU128Decoder()], + ["marketValueSf", getU128Decoder()], + ["borrowFactorAdjustedMarketValueSf", getU128Decoder()], + ["borrowedAmountOutsideElevationGroups", getU64Decoder()], + ["padding2", getArrayDecoder(getU64Decoder(), { size: 7 })], + ]); +} + +export function getObligationLiquidityCodec(): FixedSizeCodec< + ObligationLiquidityArgs, + ObligationLiquidity +> { + return combineCodec( + getObligationLiquidityEncoder(), + getObligationLiquidityDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/price.ts b/clients/kamino-lending/src/generated/types/price.ts new file mode 100644 index 00000000..c7f7915f --- /dev/null +++ b/clients/kamino-lending/src/generated/types/price.ts @@ -0,0 +1,48 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface Price { + value: bigint; + exp: bigint; +} + +export interface PriceArgs { + value: number | bigint; + exp: number | bigint; +} + +export function getPriceEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["value", getU64Encoder()], + ["exp", getU64Encoder()], + ]); +} + +export function getPriceDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["value", getU64Decoder()], + ["exp", getU64Decoder()], + ]); +} + +export function getPriceCodec(): FixedSizeCodec { + return combineCodec(getPriceEncoder(), getPriceDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/priceHeuristic.ts b/clients/kamino-lending/src/generated/types/priceHeuristic.ts new file mode 100644 index 00000000..ec126191 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/priceHeuristic.ts @@ -0,0 +1,55 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface PriceHeuristic { + lower: bigint; + upper: bigint; + exp: bigint; +} + +export interface PriceHeuristicArgs { + lower: number | bigint; + upper: number | bigint; + exp: number | bigint; +} + +export function getPriceHeuristicEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["lower", getU64Encoder()], + ["upper", getU64Encoder()], + ["exp", getU64Encoder()], + ]); +} + +export function getPriceHeuristicDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["lower", getU64Decoder()], + ["upper", getU64Decoder()], + ["exp", getU64Decoder()], + ]); +} + +export function getPriceHeuristicCodec(): FixedSizeCodec< + PriceHeuristicArgs, + PriceHeuristic +> { + return combineCodec(getPriceHeuristicEncoder(), getPriceHeuristicDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/pythConfiguration.ts b/clients/kamino-lending/src/generated/types/pythConfiguration.ts new file mode 100644 index 00000000..4ff0a5cd --- /dev/null +++ b/clients/kamino-lending/src/generated/types/pythConfiguration.ts @@ -0,0 +1,45 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, +} from "@solana/kit"; + +export interface PythConfiguration { + price: Address; +} + +export type PythConfigurationArgs = PythConfiguration; + +export function getPythConfigurationEncoder(): FixedSizeEncoder { + return getStructEncoder([["price", getAddressEncoder()]]); +} + +export function getPythConfigurationDecoder(): FixedSizeDecoder { + return getStructDecoder([["price", getAddressDecoder()]]); +} + +export function getPythConfigurationCodec(): FixedSizeCodec< + PythConfigurationArgs, + PythConfiguration +> { + return combineCodec( + getPythConfigurationEncoder(), + getPythConfigurationDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/reserveCollateral.ts b/clients/kamino-lending/src/generated/types/reserveCollateral.ts new file mode 100644 index 00000000..7b8334e4 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveCollateral.ts @@ -0,0 +1,73 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; + +export interface ReserveCollateral { + mintPubkey: Address; + mintTotalSupply: bigint; + supplyVault: Address; + padding1: bigint[]; + padding2: bigint[]; +} + +export interface ReserveCollateralArgs { + mintPubkey: Address; + mintTotalSupply: number | bigint; + supplyVault: Address; + padding1: (number | bigint)[]; + padding2: (number | bigint)[]; +} + +export function getReserveCollateralEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["mintPubkey", getAddressEncoder()], + ["mintTotalSupply", getU64Encoder()], + ["supplyVault", getAddressEncoder()], + ["padding1", getArrayEncoder(getU128Encoder(), { size: 32 })], + ["padding2", getArrayEncoder(getU128Encoder(), { size: 32 })], + ]); +} + +export function getReserveCollateralDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["mintPubkey", getAddressDecoder()], + ["mintTotalSupply", getU64Decoder()], + ["supplyVault", getAddressDecoder()], + ["padding1", getArrayDecoder(getU128Decoder(), { size: 32 })], + ["padding2", getArrayDecoder(getU128Decoder(), { size: 32 })], + ]); +} + +export function getReserveCollateralCodec(): FixedSizeCodec< + ReserveCollateralArgs, + ReserveCollateral +> { + return combineCodec( + getReserveCollateralEncoder(), + getReserveCollateralDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/reserveConfig.ts b/clients/kamino-lending/src/generated/types/reserveConfig.ts new file mode 100644 index 00000000..1f12c64c --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveConfig.ts @@ -0,0 +1,195 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; +import type { + BorrowRateCurve, + BorrowRateCurveArgs, + ReserveFees, + ReserveFeesArgs, + TokenInfo, + TokenInfoArgs, + WithdrawalCaps, + WithdrawalCapsArgs, +} from "./index.js"; +import { + getBorrowRateCurveDecoder, + getBorrowRateCurveEncoder, + getReserveFeesDecoder, + getReserveFeesEncoder, + getTokenInfoDecoder, + getTokenInfoEncoder, + getWithdrawalCapsDecoder, + getWithdrawalCapsEncoder, +} from "./index.js"; + +export interface ReserveConfig { + status: number; + assetTier: number; + hostFixedInterestRateBps: number; + reserved2: number[]; + reserved3: number[]; + protocolTakeRatePct: number; + protocolLiquidationFeePct: number; + loanToValuePct: number; + liquidationThresholdPct: number; + minLiquidationBonusBps: number; + maxLiquidationBonusBps: number; + badDebtLiquidationBonusBps: number; + deleveragingMarginCallPeriodSecs: bigint; + deleveragingThresholdDecreaseBpsPerDay: bigint; + fees: ReserveFees; + borrowRateCurve: BorrowRateCurve; + borrowFactorPct: bigint; + depositLimit: bigint; + borrowLimit: bigint; + tokenInfo: TokenInfo; + depositWithdrawalCap: WithdrawalCaps; + debtWithdrawalCap: WithdrawalCaps; + elevationGroups: number[]; + disableUsageAsCollOutsideEmode: number; + utilizationLimitBlockBorrowingAbovePct: number; + autodeleverageEnabled: number; + reserved1: number[]; + borrowLimitOutsideElevationGroup: bigint; + borrowLimitAgainstThisCollateralInElevationGroup: bigint[]; + deleveragingBonusIncreaseBpsPerDay: bigint; +} + +export interface ReserveConfigArgs { + status: number; + assetTier: number; + hostFixedInterestRateBps: number; + reserved2: number[]; + reserved3: number[]; + protocolTakeRatePct: number; + protocolLiquidationFeePct: number; + loanToValuePct: number; + liquidationThresholdPct: number; + minLiquidationBonusBps: number; + maxLiquidationBonusBps: number; + badDebtLiquidationBonusBps: number; + deleveragingMarginCallPeriodSecs: number | bigint; + deleveragingThresholdDecreaseBpsPerDay: number | bigint; + fees: ReserveFeesArgs; + borrowRateCurve: BorrowRateCurveArgs; + borrowFactorPct: number | bigint; + depositLimit: number | bigint; + borrowLimit: number | bigint; + tokenInfo: TokenInfoArgs; + depositWithdrawalCap: WithdrawalCapsArgs; + debtWithdrawalCap: WithdrawalCapsArgs; + elevationGroups: number[]; + disableUsageAsCollOutsideEmode: number; + utilizationLimitBlockBorrowingAbovePct: number; + autodeleverageEnabled: number; + reserved1: number[]; + borrowLimitOutsideElevationGroup: number | bigint; + borrowLimitAgainstThisCollateralInElevationGroup: (number | bigint)[]; + deleveragingBonusIncreaseBpsPerDay: number | bigint; +} + +export function getReserveConfigEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["status", getU8Encoder()], + ["assetTier", getU8Encoder()], + ["hostFixedInterestRateBps", getU16Encoder()], + ["reserved2", getArrayEncoder(getU8Encoder(), { size: 2 })], + ["reserved3", getArrayEncoder(getU8Encoder(), { size: 8 })], + ["protocolTakeRatePct", getU8Encoder()], + ["protocolLiquidationFeePct", getU8Encoder()], + ["loanToValuePct", getU8Encoder()], + ["liquidationThresholdPct", getU8Encoder()], + ["minLiquidationBonusBps", getU16Encoder()], + ["maxLiquidationBonusBps", getU16Encoder()], + ["badDebtLiquidationBonusBps", getU16Encoder()], + ["deleveragingMarginCallPeriodSecs", getU64Encoder()], + ["deleveragingThresholdDecreaseBpsPerDay", getU64Encoder()], + ["fees", getReserveFeesEncoder()], + ["borrowRateCurve", getBorrowRateCurveEncoder()], + ["borrowFactorPct", getU64Encoder()], + ["depositLimit", getU64Encoder()], + ["borrowLimit", getU64Encoder()], + ["tokenInfo", getTokenInfoEncoder()], + ["depositWithdrawalCap", getWithdrawalCapsEncoder()], + ["debtWithdrawalCap", getWithdrawalCapsEncoder()], + ["elevationGroups", getArrayEncoder(getU8Encoder(), { size: 20 })], + ["disableUsageAsCollOutsideEmode", getU8Encoder()], + ["utilizationLimitBlockBorrowingAbovePct", getU8Encoder()], + ["autodeleverageEnabled", getU8Encoder()], + ["reserved1", getArrayEncoder(getU8Encoder(), { size: 1 })], + ["borrowLimitOutsideElevationGroup", getU64Encoder()], + [ + "borrowLimitAgainstThisCollateralInElevationGroup", + getArrayEncoder(getU64Encoder(), { size: 32 }), + ], + ["deleveragingBonusIncreaseBpsPerDay", getU64Encoder()], + ]); +} + +export function getReserveConfigDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["status", getU8Decoder()], + ["assetTier", getU8Decoder()], + ["hostFixedInterestRateBps", getU16Decoder()], + ["reserved2", getArrayDecoder(getU8Decoder(), { size: 2 })], + ["reserved3", getArrayDecoder(getU8Decoder(), { size: 8 })], + ["protocolTakeRatePct", getU8Decoder()], + ["protocolLiquidationFeePct", getU8Decoder()], + ["loanToValuePct", getU8Decoder()], + ["liquidationThresholdPct", getU8Decoder()], + ["minLiquidationBonusBps", getU16Decoder()], + ["maxLiquidationBonusBps", getU16Decoder()], + ["badDebtLiquidationBonusBps", getU16Decoder()], + ["deleveragingMarginCallPeriodSecs", getU64Decoder()], + ["deleveragingThresholdDecreaseBpsPerDay", getU64Decoder()], + ["fees", getReserveFeesDecoder()], + ["borrowRateCurve", getBorrowRateCurveDecoder()], + ["borrowFactorPct", getU64Decoder()], + ["depositLimit", getU64Decoder()], + ["borrowLimit", getU64Decoder()], + ["tokenInfo", getTokenInfoDecoder()], + ["depositWithdrawalCap", getWithdrawalCapsDecoder()], + ["debtWithdrawalCap", getWithdrawalCapsDecoder()], + ["elevationGroups", getArrayDecoder(getU8Decoder(), { size: 20 })], + ["disableUsageAsCollOutsideEmode", getU8Decoder()], + ["utilizationLimitBlockBorrowingAbovePct", getU8Decoder()], + ["autodeleverageEnabled", getU8Decoder()], + ["reserved1", getArrayDecoder(getU8Decoder(), { size: 1 })], + ["borrowLimitOutsideElevationGroup", getU64Decoder()], + [ + "borrowLimitAgainstThisCollateralInElevationGroup", + getArrayDecoder(getU64Decoder(), { size: 32 }), + ], + ["deleveragingBonusIncreaseBpsPerDay", getU64Decoder()], + ]); +} + +export function getReserveConfigCodec(): FixedSizeCodec< + ReserveConfigArgs, + ReserveConfig +> { + return combineCodec(getReserveConfigEncoder(), getReserveConfigDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/reserveFarmKind.ts b/clients/kamino-lending/src/generated/types/reserveFarmKind.ts new file mode 100644 index 00000000..5607b963 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveFarmKind.ts @@ -0,0 +1,36 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum ReserveFarmKind { + Collateral = 0, + Debt = 1, +} + +export type ReserveFarmKindArgs = ReserveFarmKind; + +export function getReserveFarmKindEncoder(): FixedSizeEncoder { + return getEnumEncoder(ReserveFarmKind); +} + +export function getReserveFarmKindDecoder(): FixedSizeDecoder { + return getEnumDecoder(ReserveFarmKind); +} + +export function getReserveFarmKindCodec(): FixedSizeCodec< + ReserveFarmKindArgs, + ReserveFarmKind +> { + return combineCodec(getReserveFarmKindEncoder(), getReserveFarmKindDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/reserveFees.ts b/clients/kamino-lending/src/generated/types/reserveFees.ts new file mode 100644 index 00000000..5f4004e2 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveFees.ts @@ -0,0 +1,59 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface ReserveFees { + borrowFeeSf: bigint; + flashLoanFeeSf: bigint; + padding: number[]; +} + +export interface ReserveFeesArgs { + borrowFeeSf: number | bigint; + flashLoanFeeSf: number | bigint; + padding: number[]; +} + +export function getReserveFeesEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["borrowFeeSf", getU64Encoder()], + ["flashLoanFeeSf", getU64Encoder()], + ["padding", getArrayEncoder(getU8Encoder(), { size: 8 })], + ]); +} + +export function getReserveFeesDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["borrowFeeSf", getU64Decoder()], + ["flashLoanFeeSf", getU64Decoder()], + ["padding", getArrayDecoder(getU8Decoder(), { size: 8 })], + ]); +} + +export function getReserveFeesCodec(): FixedSizeCodec< + ReserveFeesArgs, + ReserveFees +> { + return combineCodec(getReserveFeesEncoder(), getReserveFeesDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/reserveLiquidity.ts b/clients/kamino-lending/src/generated/types/reserveLiquidity.ts new file mode 100644 index 00000000..eb94f907 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveLiquidity.ts @@ -0,0 +1,130 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; +import type { BigFractionBytes, BigFractionBytesArgs } from "./index.js"; +import { + getBigFractionBytesDecoder, + getBigFractionBytesEncoder, +} from "./index.js"; + +export interface ReserveLiquidity { + mintPubkey: Address; + supplyVault: Address; + feeVault: Address; + availableAmount: bigint; + borrowedAmountSf: bigint; + marketPriceSf: bigint; + marketPriceLastUpdatedTs: bigint; + mintDecimals: bigint; + depositLimitCrossedTimestamp: bigint; + borrowLimitCrossedTimestamp: bigint; + cumulativeBorrowRateBsf: BigFractionBytes; + accumulatedProtocolFeesSf: bigint; + accumulatedReferrerFeesSf: bigint; + pendingReferrerFeesSf: bigint; + absoluteReferralRateSf: bigint; + tokenProgram: Address; + padding2: bigint[]; + padding3: bigint[]; +} + +export interface ReserveLiquidityArgs { + mintPubkey: Address; + supplyVault: Address; + feeVault: Address; + availableAmount: number | bigint; + borrowedAmountSf: number | bigint; + marketPriceSf: number | bigint; + marketPriceLastUpdatedTs: number | bigint; + mintDecimals: number | bigint; + depositLimitCrossedTimestamp: number | bigint; + borrowLimitCrossedTimestamp: number | bigint; + cumulativeBorrowRateBsf: BigFractionBytesArgs; + accumulatedProtocolFeesSf: number | bigint; + accumulatedReferrerFeesSf: number | bigint; + pendingReferrerFeesSf: number | bigint; + absoluteReferralRateSf: number | bigint; + tokenProgram: Address; + padding2: (number | bigint)[]; + padding3: (number | bigint)[]; +} + +export function getReserveLiquidityEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["mintPubkey", getAddressEncoder()], + ["supplyVault", getAddressEncoder()], + ["feeVault", getAddressEncoder()], + ["availableAmount", getU64Encoder()], + ["borrowedAmountSf", getU128Encoder()], + ["marketPriceSf", getU128Encoder()], + ["marketPriceLastUpdatedTs", getU64Encoder()], + ["mintDecimals", getU64Encoder()], + ["depositLimitCrossedTimestamp", getU64Encoder()], + ["borrowLimitCrossedTimestamp", getU64Encoder()], + ["cumulativeBorrowRateBsf", getBigFractionBytesEncoder()], + ["accumulatedProtocolFeesSf", getU128Encoder()], + ["accumulatedReferrerFeesSf", getU128Encoder()], + ["pendingReferrerFeesSf", getU128Encoder()], + ["absoluteReferralRateSf", getU128Encoder()], + ["tokenProgram", getAddressEncoder()], + ["padding2", getArrayEncoder(getU64Encoder(), { size: 51 })], + ["padding3", getArrayEncoder(getU128Encoder(), { size: 32 })], + ]); +} + +export function getReserveLiquidityDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["mintPubkey", getAddressDecoder()], + ["supplyVault", getAddressDecoder()], + ["feeVault", getAddressDecoder()], + ["availableAmount", getU64Decoder()], + ["borrowedAmountSf", getU128Decoder()], + ["marketPriceSf", getU128Decoder()], + ["marketPriceLastUpdatedTs", getU64Decoder()], + ["mintDecimals", getU64Decoder()], + ["depositLimitCrossedTimestamp", getU64Decoder()], + ["borrowLimitCrossedTimestamp", getU64Decoder()], + ["cumulativeBorrowRateBsf", getBigFractionBytesDecoder()], + ["accumulatedProtocolFeesSf", getU128Decoder()], + ["accumulatedReferrerFeesSf", getU128Decoder()], + ["pendingReferrerFeesSf", getU128Decoder()], + ["absoluteReferralRateSf", getU128Decoder()], + ["tokenProgram", getAddressDecoder()], + ["padding2", getArrayDecoder(getU64Decoder(), { size: 51 })], + ["padding3", getArrayDecoder(getU128Decoder(), { size: 32 })], + ]); +} + +export function getReserveLiquidityCodec(): FixedSizeCodec< + ReserveLiquidityArgs, + ReserveLiquidity +> { + return combineCodec( + getReserveLiquidityEncoder(), + getReserveLiquidityDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/reserveStatus.ts b/clients/kamino-lending/src/generated/types/reserveStatus.ts new file mode 100644 index 00000000..eb3eeb5b --- /dev/null +++ b/clients/kamino-lending/src/generated/types/reserveStatus.ts @@ -0,0 +1,37 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum ReserveStatus { + Active = 0, + Obsolete = 1, + Hidden = 2, +} + +export type ReserveStatusArgs = ReserveStatus; + +export function getReserveStatusEncoder(): FixedSizeEncoder { + return getEnumEncoder(ReserveStatus); +} + +export function getReserveStatusDecoder(): FixedSizeDecoder { + return getEnumDecoder(ReserveStatus); +} + +export function getReserveStatusCodec(): FixedSizeCodec< + ReserveStatusArgs, + ReserveStatus +> { + return combineCodec(getReserveStatusEncoder(), getReserveStatusDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/rewardInfo.ts b/clients/kamino-lending/src/generated/types/rewardInfo.ts new file mode 100644 index 00000000..241b5c41 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/rewardInfo.ts @@ -0,0 +1,112 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, Codec, Decoder, Encoder } from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; +import type { + RewardScheduleCurve, + RewardScheduleCurveArgs, + TokenInfo, + TokenInfoArgs, +} from "./index.js"; +import { + getRewardScheduleCurveDecoder, + getRewardScheduleCurveEncoder, + getTokenInfoDecoder, + getTokenInfoEncoder, +} from "./index.js"; + +export interface RewardInfo { + token: TokenInfo; + rewardsVault: Address; + rewardsAvailable: bigint; + rewardScheduleCurve: RewardScheduleCurve; + minClaimDurationSeconds: bigint; + lastIssuanceTs: bigint; + rewardsIssuedUnclaimed: bigint; + rewardsIssuedCumulative: bigint; + rewardPerShareScaled: bigint; + placeholder0: bigint; + rewardType: number; + rewardsPerSecondDecimals: number; + padding0: number[]; + padding1: bigint[]; +} + +export interface RewardInfoArgs { + token: TokenInfoArgs; + rewardsVault: Address; + rewardsAvailable: number | bigint; + rewardScheduleCurve: RewardScheduleCurveArgs; + minClaimDurationSeconds: number | bigint; + lastIssuanceTs: number | bigint; + rewardsIssuedUnclaimed: number | bigint; + rewardsIssuedCumulative: number | bigint; + rewardPerShareScaled: number | bigint; + placeholder0: number | bigint; + rewardType: number; + rewardsPerSecondDecimals: number; + padding0: number[]; + padding1: (number | bigint)[]; +} + +export function getRewardInfoEncoder(): Encoder { + return getStructEncoder([ + ["token", getTokenInfoEncoder()], + ["rewardsVault", getAddressEncoder()], + ["rewardsAvailable", getU64Encoder()], + ["rewardScheduleCurve", getRewardScheduleCurveEncoder()], + ["minClaimDurationSeconds", getU64Encoder()], + ["lastIssuanceTs", getU64Encoder()], + ["rewardsIssuedUnclaimed", getU64Encoder()], + ["rewardsIssuedCumulative", getU64Encoder()], + ["rewardPerShareScaled", getU128Encoder()], + ["placeholder0", getU64Encoder()], + ["rewardType", getU8Encoder()], + ["rewardsPerSecondDecimals", getU8Encoder()], + ["padding0", getArrayEncoder(getU8Encoder(), { size: 6 })], + ["padding1", getArrayEncoder(getU64Encoder(), { size: 20 })], + ]); +} + +export function getRewardInfoDecoder(): Decoder { + return getStructDecoder([ + ["token", getTokenInfoDecoder()], + ["rewardsVault", getAddressDecoder()], + ["rewardsAvailable", getU64Decoder()], + ["rewardScheduleCurve", getRewardScheduleCurveDecoder()], + ["minClaimDurationSeconds", getU64Decoder()], + ["lastIssuanceTs", getU64Decoder()], + ["rewardsIssuedUnclaimed", getU64Decoder()], + ["rewardsIssuedCumulative", getU64Decoder()], + ["rewardPerShareScaled", getU128Decoder()], + ["placeholder0", getU64Decoder()], + ["rewardType", getU8Decoder()], + ["rewardsPerSecondDecimals", getU8Decoder()], + ["padding0", getArrayDecoder(getU8Decoder(), { size: 6 })], + ["padding1", getArrayDecoder(getU64Decoder(), { size: 20 })], + ]); +} + +export function getRewardInfoCodec(): Codec { + return combineCodec(getRewardInfoEncoder(), getRewardInfoDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/rewardPerTimeUnitPoint.ts b/clients/kamino-lending/src/generated/types/rewardPerTimeUnitPoint.ts new file mode 100644 index 00000000..11f23a0d --- /dev/null +++ b/clients/kamino-lending/src/generated/types/rewardPerTimeUnitPoint.ts @@ -0,0 +1,54 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface RewardPerTimeUnitPoint { + tsStart: bigint; + rewardPerTimeUnit: bigint; +} + +export interface RewardPerTimeUnitPointArgs { + tsStart: number | bigint; + rewardPerTimeUnit: number | bigint; +} + +export function getRewardPerTimeUnitPointEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["tsStart", getU64Encoder()], + ["rewardPerTimeUnit", getU64Encoder()], + ]); +} + +export function getRewardPerTimeUnitPointDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["tsStart", getU64Decoder()], + ["rewardPerTimeUnit", getU64Decoder()], + ]); +} + +export function getRewardPerTimeUnitPointCodec(): FixedSizeCodec< + RewardPerTimeUnitPointArgs, + RewardPerTimeUnitPoint +> { + return combineCodec( + getRewardPerTimeUnitPointEncoder(), + getRewardPerTimeUnitPointDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/rewardScheduleCurve.ts b/clients/kamino-lending/src/generated/types/rewardScheduleCurve.ts new file mode 100644 index 00000000..ab05b629 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/rewardScheduleCurve.ts @@ -0,0 +1,86 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, +} from "@solana/kit"; +import type { + RewardPerTimeUnitPoint, + RewardPerTimeUnitPointArgs, +} from "./index.js"; +import { + getRewardPerTimeUnitPointDecoder, + getRewardPerTimeUnitPointEncoder, +} from "./index.js"; + +export interface RewardScheduleCurve { + /** + * This is a stepwise function, meaning that each point represents + * how many rewards are issued per time unit since the beginning + * of that point until the beginning of the next point. + * This is not a linear curve, there is no interpolation going on. + * A curve can be [[t0, 100], [t1, 50], [t2, 0]] + * meaning that from t0 to t1, 100 rewards are issued per time unit, + * from t1 to t2, 50 rewards are issued per time unit, and after t2 it stops + * Another curve, can be [[t0, 100], [u64::max, 0]] + * meaning that from t0 to u64::max, 100 rewards are issued per time unit + */ + points: RewardPerTimeUnitPoint[]; +} + +export interface RewardScheduleCurveArgs { + /** + * This is a stepwise function, meaning that each point represents + * how many rewards are issued per time unit since the beginning + * of that point until the beginning of the next point. + * This is not a linear curve, there is no interpolation going on. + * A curve can be [[t0, 100], [t1, 50], [t2, 0]] + * meaning that from t0 to t1, 100 rewards are issued per time unit, + * from t1 to t2, 50 rewards are issued per time unit, and after t2 it stops + * Another curve, can be [[t0, 100], [u64::max, 0]] + * meaning that from t0 to u64::max, 100 rewards are issued per time unit + */ + points: RewardPerTimeUnitPointArgs[]; +} + +export function getRewardScheduleCurveEncoder(): FixedSizeEncoder { + return getStructEncoder([ + [ + "points", + getArrayEncoder(getRewardPerTimeUnitPointEncoder(), { size: 20 }), + ], + ]); +} + +export function getRewardScheduleCurveDecoder(): FixedSizeDecoder { + return getStructDecoder([ + [ + "points", + getArrayDecoder(getRewardPerTimeUnitPointDecoder(), { size: 20 }), + ], + ]); +} + +export function getRewardScheduleCurveCodec(): FixedSizeCodec< + RewardScheduleCurveArgs, + RewardScheduleCurve +> { + return combineCodec( + getRewardScheduleCurveEncoder(), + getRewardScheduleCurveDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/rewardType.ts b/clients/kamino-lending/src/generated/types/rewardType.ts new file mode 100644 index 00000000..a5d9b3b8 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/rewardType.ts @@ -0,0 +1,36 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum RewardType { + Proportional = 0, + Constant = 1, +} + +export type RewardTypeArgs = RewardType; + +export function getRewardTypeEncoder(): FixedSizeEncoder { + return getEnumEncoder(RewardType); +} + +export function getRewardTypeDecoder(): FixedSizeDecoder { + return getEnumDecoder(RewardType); +} + +export function getRewardTypeCodec(): FixedSizeCodec< + RewardTypeArgs, + RewardType +> { + return combineCodec(getRewardTypeEncoder(), getRewardTypeDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/scopeConfiguration.ts b/clients/kamino-lending/src/generated/types/scopeConfiguration.ts new file mode 100644 index 00000000..7ec3f89a --- /dev/null +++ b/clients/kamino-lending/src/generated/types/scopeConfiguration.ts @@ -0,0 +1,59 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU16Decoder, + getU16Encoder, +} from "@solana/kit"; + +export interface ScopeConfiguration { + priceFeed: Address; + priceChain: number[]; + twapChain: number[]; +} + +export type ScopeConfigurationArgs = ScopeConfiguration; + +export function getScopeConfigurationEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["priceFeed", getAddressEncoder()], + ["priceChain", getArrayEncoder(getU16Encoder(), { size: 4 })], + ["twapChain", getArrayEncoder(getU16Encoder(), { size: 4 })], + ]); +} + +export function getScopeConfigurationDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["priceFeed", getAddressDecoder()], + ["priceChain", getArrayDecoder(getU16Decoder(), { size: 4 })], + ["twapChain", getArrayDecoder(getU16Decoder(), { size: 4 })], + ]); +} + +export function getScopeConfigurationCodec(): FixedSizeCodec< + ScopeConfigurationArgs, + ScopeConfiguration +> { + return combineCodec( + getScopeConfigurationEncoder(), + getScopeConfigurationDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/switchboardConfiguration.ts b/clients/kamino-lending/src/generated/types/switchboardConfiguration.ts new file mode 100644 index 00000000..04abc76b --- /dev/null +++ b/clients/kamino-lending/src/generated/types/switchboardConfiguration.ts @@ -0,0 +1,52 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, +} from "@solana/kit"; + +export interface SwitchboardConfiguration { + priceAggregator: Address; + twapAggregator: Address; +} + +export type SwitchboardConfigurationArgs = SwitchboardConfiguration; + +export function getSwitchboardConfigurationEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["priceAggregator", getAddressEncoder()], + ["twapAggregator", getAddressEncoder()], + ]); +} + +export function getSwitchboardConfigurationDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["priceAggregator", getAddressDecoder()], + ["twapAggregator", getAddressDecoder()], + ]); +} + +export function getSwitchboardConfigurationCodec(): FixedSizeCodec< + SwitchboardConfigurationArgs, + SwitchboardConfiguration +> { + return combineCodec( + getSwitchboardConfigurationEncoder(), + getSwitchboardConfigurationDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/timeUnit.ts b/clients/kamino-lending/src/generated/types/timeUnit.ts new file mode 100644 index 00000000..efa32695 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/timeUnit.ts @@ -0,0 +1,33 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum TimeUnit { + Seconds = 0, + Slots = 1, +} + +export type TimeUnitArgs = TimeUnit; + +export function getTimeUnitEncoder(): FixedSizeEncoder { + return getEnumEncoder(TimeUnit); +} + +export function getTimeUnitDecoder(): FixedSizeDecoder { + return getEnumDecoder(TimeUnit); +} + +export function getTimeUnitCodec(): FixedSizeCodec { + return combineCodec(getTimeUnitEncoder(), getTimeUnitDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/tokenInfo.ts b/clients/kamino-lending/src/generated/types/tokenInfo.ts new file mode 100644 index 00000000..41e33a28 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/tokenInfo.ts @@ -0,0 +1,108 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; +import type { + PriceHeuristic, + PriceHeuristicArgs, + PythConfiguration, + PythConfigurationArgs, + ScopeConfiguration, + ScopeConfigurationArgs, + SwitchboardConfiguration, + SwitchboardConfigurationArgs, +} from "./index.js"; +import { + getPriceHeuristicDecoder, + getPriceHeuristicEncoder, + getPythConfigurationDecoder, + getPythConfigurationEncoder, + getScopeConfigurationDecoder, + getScopeConfigurationEncoder, + getSwitchboardConfigurationDecoder, + getSwitchboardConfigurationEncoder, +} from "./index.js"; + +export interface TokenInfo { + name: number[]; + heuristic: PriceHeuristic; + maxTwapDivergenceBps: bigint; + maxAgePriceSeconds: bigint; + maxAgeTwapSeconds: bigint; + scopeConfiguration: ScopeConfiguration; + switchboardConfiguration: SwitchboardConfiguration; + pythConfiguration: PythConfiguration; + blockPriceUsage: number; + reserved: number[]; + padding: bigint[]; +} + +export interface TokenInfoArgs { + name: number[]; + heuristic: PriceHeuristicArgs; + maxTwapDivergenceBps: number | bigint; + maxAgePriceSeconds: number | bigint; + maxAgeTwapSeconds: number | bigint; + scopeConfiguration: ScopeConfigurationArgs; + switchboardConfiguration: SwitchboardConfigurationArgs; + pythConfiguration: PythConfigurationArgs; + blockPriceUsage: number; + reserved: number[]; + padding: (number | bigint)[]; +} + +export function getTokenInfoEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["name", getArrayEncoder(getU8Encoder(), { size: 32 })], + ["heuristic", getPriceHeuristicEncoder()], + ["maxTwapDivergenceBps", getU64Encoder()], + ["maxAgePriceSeconds", getU64Encoder()], + ["maxAgeTwapSeconds", getU64Encoder()], + ["scopeConfiguration", getScopeConfigurationEncoder()], + ["switchboardConfiguration", getSwitchboardConfigurationEncoder()], + ["pythConfiguration", getPythConfigurationEncoder()], + ["blockPriceUsage", getU8Encoder()], + ["reserved", getArrayEncoder(getU8Encoder(), { size: 7 })], + ["padding", getArrayEncoder(getU64Encoder(), { size: 19 })], + ]); +} + +export function getTokenInfoDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["name", getArrayDecoder(getU8Decoder(), { size: 32 })], + ["heuristic", getPriceHeuristicDecoder()], + ["maxTwapDivergenceBps", getU64Decoder()], + ["maxAgePriceSeconds", getU64Decoder()], + ["maxAgeTwapSeconds", getU64Decoder()], + ["scopeConfiguration", getScopeConfigurationDecoder()], + ["switchboardConfiguration", getSwitchboardConfigurationDecoder()], + ["pythConfiguration", getPythConfigurationDecoder()], + ["blockPriceUsage", getU8Decoder()], + ["reserved", getArrayDecoder(getU8Decoder(), { size: 7 })], + ["padding", getArrayDecoder(getU64Decoder(), { size: 19 })], + ]); +} + +export function getTokenInfoCodec(): FixedSizeCodec { + return combineCodec(getTokenInfoEncoder(), getTokenInfoDecoder()); +} diff --git a/clients/kamino-lending/src/generated/types/updateConfigMode.ts b/clients/kamino-lending/src/generated/types/updateConfigMode.ts new file mode 100644 index 00000000..5be6a529 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/updateConfigMode.ts @@ -0,0 +1,86 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum UpdateConfigMode { + UpdateLoanToValuePct = 0, + UpdateMaxLiquidationBonusBps = 1, + UpdateLiquidationThresholdPct = 2, + UpdateProtocolLiquidationFee = 3, + UpdateProtocolTakeRate = 4, + UpdateFeesBorrowFee = 5, + UpdateFeesFlashLoanFee = 6, + UpdateFeesReferralFeeBps = 7, + UpdateDepositLimit = 8, + UpdateBorrowLimit = 9, + UpdateTokenInfoLowerHeuristic = 10, + UpdateTokenInfoUpperHeuristic = 11, + UpdateTokenInfoExpHeuristic = 12, + UpdateTokenInfoTwapDivergence = 13, + UpdateTokenInfoScopeTwap = 14, + UpdateTokenInfoScopeChain = 15, + UpdateTokenInfoName = 16, + UpdateTokenInfoPriceMaxAge = 17, + UpdateTokenInfoTwapMaxAge = 18, + UpdateScopePriceFeed = 19, + UpdatePythPrice = 20, + UpdateSwitchboardFeed = 21, + UpdateSwitchboardTwapFeed = 22, + UpdateBorrowRateCurve = 23, + UpdateEntireReserveConfig = 24, + UpdateDebtWithdrawalCap = 25, + UpdateDepositWithdrawalCap = 26, + UpdateDebtWithdrawalCapCurrentTotal = 27, + UpdateDepositWithdrawalCapCurrentTotal = 28, + UpdateBadDebtLiquidationBonusBps = 29, + UpdateMinLiquidationBonusBps = 30, + UpdateDeleveragingMarginCallPeriod = 31, + UpdateBorrowFactor = 32, + UpdateAssetTier = 33, + UpdateElevationGroup = 34, + UpdateDeleveragingThresholdDecreaseBpsPerDay = 35, + DeprecatedUpdateMultiplierSideBoost = 36, + DeprecatedUpdateMultiplierTagBoost = 37, + UpdateReserveStatus = 38, + UpdateFarmCollateral = 39, + UpdateFarmDebt = 40, + UpdateDisableUsageAsCollateralOutsideEmode = 41, + UpdateBlockBorrowingAboveUtilizationPct = 42, + UpdateBlockPriceUsage = 43, + UpdateBorrowLimitOutsideElevationGroup = 44, + UpdateBorrowLimitsInElevationGroupAgainstThisReserve = 45, + UpdateHostFixedInterestRateBps = 46, + UpdateAutodeleverageEnabled = 47, + UpdateDeleveragingBonusIncreaseBpsPerDay = 48, +} + +export type UpdateConfigModeArgs = UpdateConfigMode; + +export function getUpdateConfigModeEncoder(): FixedSizeEncoder { + return getEnumEncoder(UpdateConfigMode); +} + +export function getUpdateConfigModeDecoder(): FixedSizeDecoder { + return getEnumDecoder(UpdateConfigMode); +} + +export function getUpdateConfigModeCodec(): FixedSizeCodec< + UpdateConfigModeArgs, + UpdateConfigMode +> { + return combineCodec( + getUpdateConfigModeEncoder(), + getUpdateConfigModeDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/updateLendingMarketConfigValue.ts b/clients/kamino-lending/src/generated/types/updateLendingMarketConfigValue.ts new file mode 100644 index 00000000..73d232ef --- /dev/null +++ b/clients/kamino-lending/src/generated/types/updateLendingMarketConfigValue.ts @@ -0,0 +1,288 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + Address, + Codec, + Decoder, + Encoder, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, +} from "@solana/kit"; +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, + getStructDecoder, + getStructEncoder, + getTupleDecoder, + getTupleEncoder, + getU8Decoder, + getU8Encoder, + getU16Decoder, + getU16Encoder, + getU64Decoder, + getU64Encoder, + getU128Decoder, + getU128Encoder, +} from "@solana/kit"; +import type { ElevationGroup, ElevationGroupArgs } from "./index.js"; +import { getElevationGroupDecoder, getElevationGroupEncoder } from "./index.js"; + +export type UpdateLendingMarketConfigValue = + | { __kind: "Bool"; fields: readonly [boolean] } + | { __kind: "U8"; fields: readonly [number] } + | { __kind: "U8Array"; fields: readonly [number[]] } + | { __kind: "U16"; fields: readonly [number] } + | { __kind: "U64"; fields: readonly [bigint] } + | { __kind: "U128"; fields: readonly [bigint] } + | { __kind: "Pubkey"; fields: readonly [Address] } + | { __kind: "ElevationGroup"; fields: readonly [ElevationGroup] } + | { __kind: "Name"; fields: readonly [number[]] }; + +export type UpdateLendingMarketConfigValueArgs = + | { __kind: "Bool"; fields: readonly [boolean] } + | { __kind: "U8"; fields: readonly [number] } + | { __kind: "U8Array"; fields: readonly [number[]] } + | { __kind: "U16"; fields: readonly [number] } + | { __kind: "U64"; fields: readonly [number | bigint] } + | { __kind: "U128"; fields: readonly [number | bigint] } + | { __kind: "Pubkey"; fields: readonly [Address] } + | { __kind: "ElevationGroup"; fields: readonly [ElevationGroupArgs] } + | { __kind: "Name"; fields: readonly [number[]] }; + +export function getUpdateLendingMarketConfigValueEncoder(): Encoder { + return getDiscriminatedUnionEncoder([ + [ + "Bool", + getStructEncoder([["fields", getTupleEncoder([getBooleanEncoder()])]]), + ], + ["U8", getStructEncoder([["fields", getTupleEncoder([getU8Encoder()])]])], + [ + "U8Array", + getStructEncoder([ + [ + "fields", + getTupleEncoder([getArrayEncoder(getU8Encoder(), { size: 8 })]), + ], + ]), + ], + ["U16", getStructEncoder([["fields", getTupleEncoder([getU16Encoder()])]])], + ["U64", getStructEncoder([["fields", getTupleEncoder([getU64Encoder()])]])], + [ + "U128", + getStructEncoder([["fields", getTupleEncoder([getU128Encoder()])]]), + ], + [ + "Pubkey", + getStructEncoder([["fields", getTupleEncoder([getAddressEncoder()])]]), + ], + [ + "ElevationGroup", + getStructEncoder([ + ["fields", getTupleEncoder([getElevationGroupEncoder()])], + ]), + ], + [ + "Name", + getStructEncoder([ + [ + "fields", + getTupleEncoder([getArrayEncoder(getU8Encoder(), { size: 32 })]), + ], + ]), + ], + ]); +} + +export function getUpdateLendingMarketConfigValueDecoder(): Decoder { + return getDiscriminatedUnionDecoder([ + [ + "Bool", + getStructDecoder([["fields", getTupleDecoder([getBooleanDecoder()])]]), + ], + ["U8", getStructDecoder([["fields", getTupleDecoder([getU8Decoder()])]])], + [ + "U8Array", + getStructDecoder([ + [ + "fields", + getTupleDecoder([getArrayDecoder(getU8Decoder(), { size: 8 })]), + ], + ]), + ], + ["U16", getStructDecoder([["fields", getTupleDecoder([getU16Decoder()])]])], + ["U64", getStructDecoder([["fields", getTupleDecoder([getU64Decoder()])]])], + [ + "U128", + getStructDecoder([["fields", getTupleDecoder([getU128Decoder()])]]), + ], + [ + "Pubkey", + getStructDecoder([["fields", getTupleDecoder([getAddressDecoder()])]]), + ], + [ + "ElevationGroup", + getStructDecoder([ + ["fields", getTupleDecoder([getElevationGroupDecoder()])], + ]), + ], + [ + "Name", + getStructDecoder([ + [ + "fields", + getTupleDecoder([getArrayDecoder(getU8Decoder(), { size: 32 })]), + ], + ]), + ], + ]); +} + +export function getUpdateLendingMarketConfigValueCodec(): Codec< + UpdateLendingMarketConfigValueArgs, + UpdateLendingMarketConfigValue +> { + return combineCodec( + getUpdateLendingMarketConfigValueEncoder(), + getUpdateLendingMarketConfigValueDecoder(), + ); +} + +// Data Enum Helpers. +export function updateLendingMarketConfigValue( + kind: "Bool", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Bool" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Bool" +>; +export function updateLendingMarketConfigValue( + kind: "U8", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U8" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U8" +>; +export function updateLendingMarketConfigValue( + kind: "U8Array", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U8Array" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U8Array" +>; +export function updateLendingMarketConfigValue( + kind: "U16", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U16" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U16" +>; +export function updateLendingMarketConfigValue( + kind: "U64", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U64" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U64" +>; +export function updateLendingMarketConfigValue( + kind: "U128", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U128" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "U128" +>; +export function updateLendingMarketConfigValue( + kind: "Pubkey", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Pubkey" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Pubkey" +>; +export function updateLendingMarketConfigValue( + kind: "ElevationGroup", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "ElevationGroup" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "ElevationGroup" +>; +export function updateLendingMarketConfigValue( + kind: "Name", + data: GetDiscriminatedUnionVariantContent< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Name" + >["fields"], +): GetDiscriminatedUnionVariant< + UpdateLendingMarketConfigValueArgs, + "__kind", + "Name" +>; +export function updateLendingMarketConfigValue< + K extends UpdateLendingMarketConfigValueArgs["__kind"], + Data, +>(kind: K, data?: Data) { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} + +export function isUpdateLendingMarketConfigValue< + K extends UpdateLendingMarketConfigValue["__kind"], +>( + kind: K, + value: UpdateLendingMarketConfigValue, +): value is UpdateLendingMarketConfigValue & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/kamino-lending/src/generated/types/updateLendingMarketMode.ts b/clients/kamino-lending/src/generated/types/updateLendingMarketMode.ts new file mode 100644 index 00000000..6ba8c1d8 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/updateLendingMarketMode.ts @@ -0,0 +1,59 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { combineCodec, getEnumDecoder, getEnumEncoder } from "@solana/kit"; + +export enum UpdateLendingMarketMode { + UpdateOwner = 0, + UpdateEmergencyMode = 1, + UpdateLiquidationCloseFactor = 2, + UpdateLiquidationMaxValue = 3, + DeprecatedUpdateGlobalUnhealthyBorrow = 4, + UpdateGlobalAllowedBorrow = 5, + UpdateRiskCouncil = 6, + UpdateMinFullLiquidationThreshold = 7, + UpdateInsolvencyRiskLtv = 8, + UpdateElevationGroup = 9, + UpdateReferralFeeBps = 10, + DeprecatedUpdateMultiplierPoints = 11, + UpdatePriceRefreshTriggerToMaxAgePct = 12, + UpdateAutodeleverageEnabled = 13, + UpdateBorrowingDisabled = 14, + UpdateMinNetValueObligationPostAction = 15, + UpdateMinValueLtvSkipPriorityLiqCheck = 16, + UpdateMinValueBfSkipPriorityLiqCheck = 17, + UpdatePaddingFields = 18, + UpdateName = 19, + UpdateIndividualAutodeleverageMarginCallPeriodSecs = 20, + UpdateInitialDepositAmount = 21, +} + +export type UpdateLendingMarketModeArgs = UpdateLendingMarketMode; + +export function getUpdateLendingMarketModeEncoder(): FixedSizeEncoder { + return getEnumEncoder(UpdateLendingMarketMode); +} + +export function getUpdateLendingMarketModeDecoder(): FixedSizeDecoder { + return getEnumDecoder(UpdateLendingMarketMode); +} + +export function getUpdateLendingMarketModeCodec(): FixedSizeCodec< + UpdateLendingMarketModeArgs, + UpdateLendingMarketMode +> { + return combineCodec( + getUpdateLendingMarketModeEncoder(), + getUpdateLendingMarketModeDecoder(), + ); +} diff --git a/clients/kamino-lending/src/generated/types/withdrawalCaps.ts b/clients/kamino-lending/src/generated/types/withdrawalCaps.ts new file mode 100644 index 00000000..f6295d07 --- /dev/null +++ b/clients/kamino-lending/src/generated/types/withdrawalCaps.ts @@ -0,0 +1,61 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { + FixedSizeCodec, + FixedSizeDecoder, + FixedSizeEncoder, +} from "@solana/kit"; +import { + combineCodec, + getI64Decoder, + getI64Encoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, +} from "@solana/kit"; + +export interface WithdrawalCaps { + configCapacity: bigint; + currentTotal: bigint; + lastIntervalStartTimestamp: bigint; + configIntervalLengthSeconds: bigint; +} + +export interface WithdrawalCapsArgs { + configCapacity: number | bigint; + currentTotal: number | bigint; + lastIntervalStartTimestamp: number | bigint; + configIntervalLengthSeconds: number | bigint; +} + +export function getWithdrawalCapsEncoder(): FixedSizeEncoder { + return getStructEncoder([ + ["configCapacity", getI64Encoder()], + ["currentTotal", getI64Encoder()], + ["lastIntervalStartTimestamp", getU64Encoder()], + ["configIntervalLengthSeconds", getU64Encoder()], + ]); +} + +export function getWithdrawalCapsDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ["configCapacity", getI64Decoder()], + ["currentTotal", getI64Decoder()], + ["lastIntervalStartTimestamp", getU64Decoder()], + ["configIntervalLengthSeconds", getU64Decoder()], + ]); +} + +export function getWithdrawalCapsCodec(): FixedSizeCodec< + WithdrawalCapsArgs, + WithdrawalCaps +> { + return combineCodec(getWithdrawalCapsEncoder(), getWithdrawalCapsDecoder()); +} diff --git a/clients/kamino-lending/tsconfig.json b/clients/kamino-lending/tsconfig.json new file mode 100644 index 00000000..e528d933 --- /dev/null +++ b/clients/kamino-lending/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@macalinao/tsconfig/tsconfig.base.json" +} diff --git a/clients/quarry/docs/quarry-merge-mine.md b/clients/quarry/docs/quarry-merge-mine.md index 73b3a585..8d6977da 100644 --- a/clients/quarry/docs/quarry-merge-mine.md +++ b/clients/quarry/docs/quarry-merge-mine.md @@ -11,33 +11,33 @@ - [mergePool](#mergePool) - [mergeMiner](#mergeMiner) - [Instructions](#instructions) - - [newPool](#newPool-1) - - [newPoolV2](#newPoolV2-1) - - [initMergeMiner](#initMergeMiner-1) - - [initMergeMinerV2](#initMergeMinerV2-1) - - [initMinerMM](#initMinerMM-1) - - [initMinerMMV2](#initMinerMMV2-1) - - [stakePrimaryMiner](#stakePrimaryMiner-1) - - [stakeReplicaMiner](#stakeReplicaMiner-1) - - [unstakePrimaryMiner](#unstakePrimaryMiner-1) - - [unstakeAllReplicaMiner](#unstakeAllReplicaMiner-1) - - [withdrawTokensMM](#withdrawTokensMM-1) - - [rescueTokensMM](#rescueTokensMM-1) - - [claimRewardsMM](#claimRewardsMM-1) + - [newPool](#newPool) + - [newPoolV2](#newPoolV2) + - [initMergeMiner](#initMergeMiner) + - [initMergeMinerV2](#initMergeMinerV2) + - [initMinerMM](#initMinerMM) + - [initMinerMMV2](#initMinerMMV2) + - [stakePrimaryMiner](#stakePrimaryMiner) + - [stakeReplicaMiner](#stakeReplicaMiner) + - [unstakePrimaryMiner](#unstakePrimaryMiner) + - [unstakeAllReplicaMiner](#unstakeAllReplicaMiner) + - [withdrawTokensMM](#withdrawTokensMM) + - [rescueTokensMM](#rescueTokensMM) + - [claimRewardsMM](#claimRewardsMM) - [PDAs](#pdas) - - [mergePool](#mergePool-2) - - [replicaMint](#replicaMint-2) - - [mergeMiner](#mergeMiner-2) + - [mergePool](#mergePool) + - [replicaMint](#replicaMint) + - [mergeMiner](#mergeMiner) - [Types](#types) - - [newMergePoolEvent](#newMergePoolEvent-3) - - [initMergeMinerEvent](#initMergeMinerEvent-3) - - [initMinerEvent](#initMinerEvent-3) - - [stakePrimaryEvent](#stakePrimaryEvent-3) - - [stakeReplicaEvent](#stakeReplicaEvent-3) - - [unstakePrimaryEvent](#unstakePrimaryEvent-3) - - [unstakeReplicaEvent](#unstakeReplicaEvent-3) - - [withdrawTokensEvent](#withdrawTokensEvent-3) - - [claimEventMM](#claimEventMM-3) + - [newMergePoolEvent](#newMergePoolEvent) + - [initMergeMinerEvent](#initMergeMinerEvent) + - [initMinerEvent](#initMinerEvent) + - [stakePrimaryEvent](#stakePrimaryEvent) + - [stakeReplicaEvent](#stakeReplicaEvent) + - [unstakePrimaryEvent](#unstakePrimaryEvent) + - [unstakeReplicaEvent](#unstakeReplicaEvent) + - [withdrawTokensEvent](#withdrawTokensEvent) + - [claimEventMM](#claimEventMM) - [Errors](#errors) ## Accounts @@ -205,18 +205,18 @@ **Accounts:** -| Account | Type | Description | -| ----------------------- | -------- | ----------- | -| `mmOwner` | signer | | -| `mmPrimaryTokenAccount` | writable | | -| `pool` | writable | | -| `mm` | writable | | -| `rewarder` | readonly | | -| `quarry` | writable | | -| `miner` | writable | | -| `minerVault` | writable | | -| `tokenProgram` | readonly | | -| `mineProgram` | readonly | | +| Account | Type | Description | +| ------------------------------------ | -------- | ----------- | +| `mmOwner` | signer | | +| `mmPrimaryTokenAccount` | writable | | +| `stakePrimaryMinerStakePool` | writable | | +| `stakePrimaryMinerStakeMm` | writable | | +| `stakePrimaryMinerStakeRewarder` | readonly | | +| `stakePrimaryMinerStakeQuarry` | writable | | +| `stakePrimaryMinerStakeMiner` | writable | | +| `stakePrimaryMinerStakeMinerVault` | writable | | +| `stakePrimaryMinerStakeTokenProgram` | readonly | | +| `stakePrimaryMinerStakeMineProgram` | readonly | | **Arguments:** @@ -228,19 +228,19 @@ **Accounts:** -| Account | Type | Description | -| ------------------------- | -------- | ----------- | -| `mmOwner` | signer | | -| `replicaMint` | writable | | -| `replicaMintTokenAccount` | writable | | -| `pool` | writable | | -| `mm` | writable | | -| `rewarder` | readonly | | -| `quarry` | writable | | -| `miner` | writable | | -| `minerVault` | writable | | -| `tokenProgram` | readonly | | -| `mineProgram` | readonly | | +| Account | Type | Description | +| ------------------------------------ | -------- | ----------- | +| `mmOwner` | signer | | +| `replicaMint` | writable | | +| `replicaMintTokenAccount` | writable | | +| `stakeReplicaMinerStakePool` | writable | | +| `stakeReplicaMinerStakeMm` | writable | | +| `stakeReplicaMinerStakeRewarder` | readonly | | +| `stakeReplicaMinerStakeQuarry` | writable | | +| `stakeReplicaMinerStakeMiner` | writable | | +| `stakeReplicaMinerStakeMinerVault` | writable | | +| `stakeReplicaMinerStakeTokenProgram` | readonly | | +| `stakeReplicaMinerStakeMineProgram` | readonly | | **Arguments:** @@ -252,18 +252,18 @@ **Accounts:** -| Account | Type | Description | -| ----------------------- | -------- | ----------- | -| `mmOwner` | signer | | -| `mmPrimaryTokenAccount` | writable | | -| `pool` | writable | | -| `mm` | writable | | -| `rewarder` | readonly | | -| `quarry` | writable | | -| `miner` | writable | | -| `minerVault` | writable | | -| `tokenProgram` | readonly | | -| `mineProgram` | readonly | | +| Account | Type | Description | +| -------------------------------------- | -------- | ----------- | +| `mmOwner` | signer | | +| `mmPrimaryTokenAccount` | writable | | +| `unstakePrimaryMinerStakePool` | writable | | +| `unstakePrimaryMinerStakeMm` | writable | | +| `unstakePrimaryMinerStakeRewarder` | readonly | | +| `unstakePrimaryMinerStakeQuarry` | writable | | +| `unstakePrimaryMinerStakeMiner` | writable | | +| `unstakePrimaryMinerStakeMinerVault` | writable | | +| `unstakePrimaryMinerStakeTokenProgram` | readonly | | +| `unstakePrimaryMinerStakeMineProgram` | readonly | | **Arguments:** @@ -276,19 +276,19 @@ **Accounts:** -| Account | Type | Description | -| ------------------------- | -------- | ----------- | -| `mmOwner` | signer | | -| `replicaMint` | writable | | -| `replicaMintTokenAccount` | writable | | -| `pool` | writable | | -| `mm` | writable | | -| `rewarder` | readonly | | -| `quarry` | writable | | -| `miner` | writable | | -| `minerVault` | writable | | -| `tokenProgram` | readonly | | -| `mineProgram` | readonly | | +| Account | Type | Description | +| ----------------------------------------- | -------- | ----------- | +| `mmOwner` | signer | | +| `replicaMint` | writable | | +| `replicaMintTokenAccount` | writable | | +| `unstakeAllReplicaMinerStakePool` | writable | | +| `unstakeAllReplicaMinerStakeMm` | writable | | +| `unstakeAllReplicaMinerStakeRewarder` | readonly | | +| `unstakeAllReplicaMinerStakeQuarry` | writable | | +| `unstakeAllReplicaMinerStakeMiner` | writable | | +| `unstakeAllReplicaMinerStakeMinerVault` | writable | | +| `unstakeAllReplicaMinerStakeTokenProgram` | readonly | | +| `unstakeAllReplicaMinerStakeMineProgram` | readonly | | **Arguments:** @@ -341,23 +341,23 @@ **Accounts:** -| Account | Type | Description | -| ---------------------- | -------- | ----------- | -| `mintWrapper` | writable | | -| `mintWrapperProgram` | readonly | | -| `minter` | writable | | -| `rewardsTokenMint` | writable | | -| `rewardsTokenAccount` | writable | | -| `claimFeeTokenAccount` | writable | | -| `stakeTokenAccount` | writable | | -| `pool` | writable | | -| `mm` | writable | | -| `rewarder` | readonly | | -| `quarry` | writable | | -| `miner` | writable | | -| `minerVault` | writable | | -| `tokenProgram` | readonly | | -| `mineProgram` | readonly | | +| Account | Type | Description | +| ------------------------------- | -------- | ----------- | +| `mintWrapper` | writable | | +| `mintWrapperProgram` | readonly | | +| `minter` | writable | | +| `rewardsTokenMint` | writable | | +| `rewardsTokenAccount` | writable | | +| `claimFeeTokenAccount` | writable | | +| `stakeTokenAccount` | writable | | +| `claimRewardsStakePool` | writable | | +| `claimRewardsStakeMm` | writable | | +| `claimRewardsStakeRewarder` | readonly | | +| `claimRewardsStakeQuarry` | writable | | +| `claimRewardsStakeMiner` | writable | | +| `claimRewardsStakeMinerVault` | writable | | +| `claimRewardsStakeTokenProgram` | readonly | | +| `claimRewardsStakeMineProgram` | readonly | | **Arguments:** @@ -520,10 +520,10 @@ ## Errors -- **unauthorized** (Code: 6000 / `6000` / `0x1770`) -- Unauthorized. -- **insufficientBalance** (Code: 6001 / `6001` / `0x1771`) -- Insufficient balance. -- **invalidMiner** (Code: 6002 / `6002` / `0x1772`) -- Invalid miner for the given quarry. -- **cannotWithdrawReplicaMint** (Code: 6003 / `6003` / `0x1773`) -- Cannot withdraw a replica mint. -- **outstandingReplicaTokens** (Code: 6004 / `6004` / `0x1774`) -- User must first withdraw from all replica quarries. -- **replicaDecimalsMismatch** (Code: 6005 / `6005` / `0x1775`) -- The replica mint must have the same number of decimals as the primary mint. -- **replicaNonZeroSupply** (Code: 6006 / `6006` / `0x1776`) -- The replica mint must have zero supply. +- **6000 - Unauthorized**: Unauthorized. _(Hex: `0x1770`)_ +- **6001 - InsufficientBalance**: Insufficient balance. _(Hex: `0x1771`)_ +- **6002 - InvalidMiner**: Invalid miner for the given quarry. _(Hex: `0x1772`)_ +- **6003 - CannotWithdrawReplicaMint**: Cannot withdraw a replica mint. _(Hex: `0x1773`)_ +- **6004 - OutstandingReplicaTokens**: User must first withdraw from all replica quarries. _(Hex: `0x1774`)_ +- **6005 - ReplicaDecimalsMismatch**: The replica mint must have the same number of decimals as the primary mint. _(Hex: `0x1775`)_ +- **6006 - ReplicaNonZeroSupply**: The replica mint must have zero supply. _(Hex: `0x1776`)_ diff --git a/clients/quarry/docs/quarry-mine.md b/clients/quarry/docs/quarry-mine.md index 983adc77..5ae74966 100644 --- a/clients/quarry/docs/quarry-mine.md +++ b/clients/quarry/docs/quarry-mine.md @@ -12,41 +12,41 @@ - [quarry](#quarry) - [miner](#miner) - [Instructions](#instructions) - - [newRewarder](#newRewarder-1) - - [newRewarderV2](#newRewarderV2-1) - - [setPauseAuthority](#setPauseAuthority-1) - - [pause](#pause-1) - - [unpause](#unpause-1) - - [transferAuthority](#transferAuthority-1) - - [acceptAuthority](#acceptAuthority-1) - - [setAnnualRewards](#setAnnualRewards-1) - - [createQuarry](#createQuarry-1) - - [createQuarryV2](#createQuarryV2-1) - - [setRewardsShare](#setRewardsShare-1) - - [setFamine](#setFamine-1) - - [updateQuarryRewards](#updateQuarryRewards-1) - - [createMiner](#createMiner-1) - - [createMinerV2](#createMinerV2-1) - - [claimRewards](#claimRewards-1) - - [claimRewardsV2](#claimRewardsV2-1) - - [stakeTokens](#stakeTokens-1) - - [withdrawTokens](#withdrawTokens-1) - - [rescueTokens](#rescueTokens-1) - - [extractFees](#extractFees-1) + - [newRewarder](#newRewarder) + - [newRewarderV2](#newRewarderV2) + - [setPauseAuthority](#setPauseAuthority) + - [pause](#pause) + - [unpause](#unpause) + - [transferAuthority](#transferAuthority) + - [acceptAuthority](#acceptAuthority) + - [setAnnualRewards](#setAnnualRewards) + - [createQuarry](#createQuarry) + - [createQuarryV2](#createQuarryV2) + - [setRewardsShare](#setRewardsShare) + - [setFamine](#setFamine) + - [updateQuarryRewards](#updateQuarryRewards) + - [createMiner](#createMiner) + - [createMinerV2](#createMinerV2) + - [claimRewards](#claimRewards) + - [claimRewardsV2](#claimRewardsV2) + - [stakeTokens](#stakeTokens) + - [withdrawTokens](#withdrawTokens) + - [rescueTokens](#rescueTokens) + - [extractFees](#extractFees) - [PDAs](#pdas) - - [rewarder](#rewarder-2) - - [quarry](#quarry-2) - - [miner](#miner-2) + - [rewarder](#rewarder) + - [quarry](#quarry) + - [miner](#miner) - [Types](#types) - - [stakeAction](#stakeAction-3) - - [claimEvent](#claimEvent-3) - - [minerCreateEvent](#minerCreateEvent-3) - - [quarryCreateEvent](#quarryCreateEvent-3) - - [newRewarderEvent](#newRewarderEvent-3) - - [stakeEvent](#stakeEvent-3) - - [withdrawEvent](#withdrawEvent-3) - - [rewarderAnnualRewardsUpdateEvent](#rewarderAnnualRewardsUpdateEvent-3) - - [quarryRewardsUpdateEvent](#quarryRewardsUpdateEvent-3) + - [stakeAction](#stakeAction) + - [claimEvent](#claimEvent) + - [minerCreateEvent](#minerCreateEvent) + - [quarryCreateEvent](#quarryCreateEvent) + - [newRewarderEvent](#newRewarderEvent) + - [stakeEvent](#stakeEvent) + - [withdrawEvent](#withdrawEvent) + - [rewarderAnnualRewardsUpdateEvent](#rewarderAnnualRewardsUpdateEvent) + - [quarryRewardsUpdateEvent](#quarryRewardsUpdateEvent) - [Errors](#errors) ## Accounts @@ -160,8 +160,8 @@ | Account | Type | Description | | ------------------- | -------- | ----------- | -| `authority` | signer | | -| `rewarder` | writable | | +| `authAuthority` | signer | | +| `authRewarder` | writable | | | `newPauseAuthority` | readonly | | **Arguments:** @@ -235,10 +235,10 @@ **Accounts:** -| Account | Type | Description | -| ----------- | -------- | ----------- | -| `authority` | signer | | -| `rewarder` | writable | | +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `authAuthority` | signer | | +| `authRewarder` | writable | | **Arguments:** @@ -254,8 +254,8 @@ | Account | Type | Description | | --------------- | ---------------- | ----------- | | `quarry` | writable | | -| `authority` | signer | | -| `rewarder` | writable | | +| `authAuthority` | signer | | +| `authRewarder` | writable | | | `tokenMint` | readonly | | | `payer` | signer, writable | | | `unusedAccount` | readonly | | @@ -275,8 +275,8 @@ | Account | Type | Description | | --------------- | ---------------- | ----------- | | `quarry` | writable | | -| `authority` | signer | | -| `rewarder` | writable | | +| `authAuthority` | signer | | +| `authRewarder` | writable | | | `tokenMint` | readonly | | | `payer` | signer, writable | | | `systemProgram` | readonly | | @@ -291,11 +291,11 @@ **Accounts:** -| Account | Type | Description | -| ----------- | -------- | ----------- | -| `authority` | signer | | -| `rewarder` | writable | | -| `quarry` | writable | | +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `authAuthority` | signer | | +| `authRewarder` | writable | | +| `quarry` | writable | | **Arguments:** @@ -308,11 +308,11 @@ **Accounts:** -| Account | Type | Description | -| ----------- | -------- | ----------- | -| `authority` | signer | | -| `rewarder` | readonly | | -| `quarry` | writable | | +| Account | Type | Description | +| --------------- | -------- | ----------- | +| `authAuthority` | signer | | +| `authRewarder` | readonly | | +| `quarry` | writable | | **Arguments:** @@ -385,21 +385,21 @@ **Accounts:** -| Account | Type | Description | -| ---------------------- | -------- | ----------- | -| `mintWrapper` | writable | | -| `mintWrapperProgram` | readonly | | -| `minter` | writable | | -| `rewardsTokenMint` | writable | | -| `rewardsTokenAccount` | writable | | -| `claimFeeTokenAccount` | writable | | -| `authority` | signer | | -| `miner` | writable | | -| `quarry` | writable | | -| `unusedMinerVault` | readonly | | -| `unusedTokenAccount` | readonly | | -| `tokenProgram` | readonly | | -| `rewarder` | readonly | | +| Account | Type | Description | +| --------------------------- | -------- | ----------- | +| `mintWrapper` | writable | | +| `mintWrapperProgram` | readonly | | +| `minter` | writable | | +| `rewardsTokenMint` | writable | | +| `rewardsTokenAccount` | writable | | +| `claimFeeTokenAccount` | writable | | +| `claimV1Authority` | signer | | +| `claimV1Miner` | writable | | +| `claimV1Quarry` | writable | | +| `claimV1UnusedMinerVault` | readonly | | +| `claimV1UnusedTokenAccount` | readonly | | +| `claimV1TokenProgram` | readonly | | +| `claimV1Rewarder` | readonly | | **Arguments:** @@ -419,11 +419,11 @@ | `rewardsTokenMint` | writable | | | `rewardsTokenAccount` | writable | | | `claimFeeTokenAccount` | writable | | -| `authority` | signer | | -| `miner` | writable | | -| `quarry` | writable | | -| `tokenProgram` | readonly | | -| `rewarder` | readonly | | +| `claimAuthority` | signer | | +| `claimMiner` | writable | | +| `claimQuarry` | writable | | +| `claimTokenProgram` | readonly | | +| `claimRewarder` | readonly | | **Arguments:** @@ -652,15 +652,15 @@ ## Errors -- **unauthorized** (Code: 6000 / `6000` / `0x1770`) -- You are not authorized to perform this action. -- **insufficientBalance** (Code: 6001 / `6001` / `0x1771`) -- Insufficient staked balance for withdraw request. -- **pendingAuthorityNotSet** (Code: 6002 / `6002` / `0x1772`) -- Pending authority not set -- **invalidRewardsShare** (Code: 6003 / `6003` / `0x1773`) -- Invalid quarry rewards share -- **insufficientAllowance** (Code: 6004 / `6004` / `0x1774`) -- Insufficient allowance. -- **newVaultNotEmpty** (Code: 6005 / `6005` / `0x1775`) -- New vault not empty. -- **notEnoughTokens** (Code: 6006 / `6006` / `0x1776`) -- Not enough tokens. -- **invalidTimestamp** (Code: 6007 / `6007` / `0x1777`) -- Invalid timestamp. -- **invalidMaxClaimFee** (Code: 6008 / `6008` / `0x1778`) -- Invalid max claim fee. -- **maxAnnualRewardsRateExceeded** (Code: 6009 / `6009` / `0x1779`) -- Max annual rewards rate exceeded. -- **paused** (Code: 6010 / `6010` / `0x177a`) -- Rewarder is paused. -- **upperboundExceeded** (Code: 6011 / `6011` / `0x177b`) -- Rewards earned exceeded quarry's upper bound. +- **6000 - Unauthorized**: You are not authorized to perform this action. _(Hex: `0x1770`)_ +- **6001 - InsufficientBalance**: Insufficient staked balance for withdraw request. _(Hex: `0x1771`)_ +- **6002 - PendingAuthorityNotSet**: Pending authority not set _(Hex: `0x1772`)_ +- **6003 - InvalidRewardsShare**: Invalid quarry rewards share _(Hex: `0x1773`)_ +- **6004 - InsufficientAllowance**: Insufficient allowance. _(Hex: `0x1774`)_ +- **6005 - NewVaultNotEmpty**: New vault not empty. _(Hex: `0x1775`)_ +- **6006 - NotEnoughTokens**: Not enough tokens. _(Hex: `0x1776`)_ +- **6007 - InvalidTimestamp**: Invalid timestamp. _(Hex: `0x1777`)_ +- **6008 - InvalidMaxClaimFee**: Invalid max claim fee. _(Hex: `0x1778`)_ +- **6009 - MaxAnnualRewardsRateExceeded**: Max annual rewards rate exceeded. _(Hex: `0x1779`)_ +- **6010 - Paused**: Rewarder is paused. _(Hex: `0x177a`)_ +- **6011 - UpperboundExceeded**: Rewards earned exceeded quarry's upper bound. _(Hex: `0x177b`)_ diff --git a/clients/quarry/docs/quarry-mint-wrapper.md b/clients/quarry/docs/quarry-mint-wrapper.md index 8b6fed95..2fc52895 100644 --- a/clients/quarry/docs/quarry-mint-wrapper.md +++ b/clients/quarry/docs/quarry-mint-wrapper.md @@ -11,24 +11,24 @@ - [mintWrapper](#mintWrapper) - [minter](#minter) - [Instructions](#instructions) - - [newWrapper](#newWrapper-1) - - [newWrapperV2](#newWrapperV2-1) - - [transferAdmin](#transferAdmin-1) - - [acceptAdmin](#acceptAdmin-1) - - [newMinter](#newMinter-1) - - [newMinterV2](#newMinterV2-1) - - [minterUpdate](#minterUpdate-1) - - [performMint](#performMint-1) + - [newWrapper](#newWrapper) + - [newWrapperV2](#newWrapperV2) + - [transferAdmin](#transferAdmin) + - [acceptAdmin](#acceptAdmin) + - [newMinter](#newMinter) + - [newMinterV2](#newMinterV2) + - [minterUpdate](#minterUpdate) + - [performMint](#performMint) - [PDAs](#pdas) - - [mintWrapper](#mintWrapper-2) - - [minter](#minter-2) + - [mintWrapper](#mintWrapper) + - [minter](#minter) - [Types](#types) - - [newMintWrapperEvent](#newMintWrapperEvent-3) - - [mintWrapperAdminProposeEvent](#mintWrapperAdminProposeEvent-3) - - [mintWrapperAdminUpdateEvent](#mintWrapperAdminUpdateEvent-3) - - [newMinterEvent](#newMinterEvent-3) - - [minterAllowanceUpdateEvent](#minterAllowanceUpdateEvent-3) - - [minterMintEvent](#minterMintEvent-3) + - [newMintWrapperEvent](#newMintWrapperEvent) + - [mintWrapperAdminProposeEvent](#mintWrapperAdminProposeEvent) + - [mintWrapperAdminUpdateEvent](#mintWrapperAdminUpdateEvent) + - [newMinterEvent](#newMinterEvent) + - [minterAllowanceUpdateEvent](#minterAllowanceUpdateEvent) + - [minterMintEvent](#minterMintEvent) - [Errors](#errors) ## Accounts @@ -144,14 +144,14 @@ **Accounts:** -| Account | Type | Description | -| -------------------- | ---------------- | ----------- | -| `mintWrapper` | writable | | -| `admin` | signer | | -| `newMinterAuthority` | readonly | | -| `minter` | writable | | -| `payer` | signer, writable | | -| `systemProgram` | readonly | | +| Account | Type | Description | +| -------------------------- | ---------------- | ----------- | +| `newMinterAuthMintWrapper` | writable | | +| `newMinterAuthAdmin` | signer | | +| `newMinterAuthority` | readonly | | +| `minter` | writable | | +| `payer` | signer, writable | | +| `systemProgram` | readonly | | **Arguments:** @@ -164,14 +164,14 @@ **Accounts:** -| Account | Type | Description | -| -------------------- | ---------------- | ----------- | -| `mintWrapper` | writable | | -| `admin` | signer | | -| `newMinterAuthority` | readonly | | -| `minter` | writable | | -| `payer` | signer, writable | | -| `systemProgram` | readonly | | +| Account | Type | Description | +| ---------------------------- | ---------------- | ----------- | +| `newMinterV2AuthMintWrapper` | writable | | +| `newMinterV2AuthAdmin` | signer | | +| `newMinterAuthority` | readonly | | +| `minter` | writable | | +| `payer` | signer, writable | | +| `systemProgram` | readonly | | **Arguments:** @@ -183,11 +183,11 @@ **Accounts:** -| Account | Type | Description | -| ------------- | -------- | ----------- | -| `mintWrapper` | writable | | -| `admin` | signer | | -| `minter` | writable | | +| Account | Type | Description | +| ----------------------------- | -------- | ----------- | +| `minterUpdateAuthMintWrapper` | writable | | +| `minterUpdateAuthAdmin` | signer | | +| `minter` | writable | | **Arguments:** @@ -317,6 +317,6 @@ ## Errors -- **unauthorized** (Code: 6000 / `6000` / `0x1770`) -- You are not authorized to perform this action. -- **hardcapExceeded** (Code: 6001 / `6001` / `0x1771`) -- Cannot mint over hard cap. -- **minterAllowanceExceeded** (Code: 6002 / `6002` / `0x1772`) -- Minter allowance exceeded. +- **6000 - Unauthorized**: You are not authorized to perform this action. _(Hex: `0x1770`)_ +- **6001 - HardcapExceeded**: Cannot mint over hard cap. _(Hex: `0x1771`)_ +- **6002 - MinterAllowanceExceeded**: Minter allowance exceeded. _(Hex: `0x1772`)_ diff --git a/clients/quarry/docs/quarry-operator.md b/clients/quarry/docs/quarry-operator.md index 991ad03f..fa5f5654 100644 --- a/clients/quarry/docs/quarry-operator.md +++ b/clients/quarry/docs/quarry-operator.md @@ -10,19 +10,19 @@ - [Accounts](#accounts) - [operator](#operator) - [Instructions](#instructions) - - [createOperator](#createOperator-1) - - [createOperatorV2](#createOperatorV2-1) - - [setAdmin](#setAdmin-1) - - [setRateSetter](#setRateSetter-1) - - [setQuarryCreator](#setQuarryCreator-1) - - [setShareAllocator](#setShareAllocator-1) - - [delegateSetAnnualRewards](#delegateSetAnnualRewards-1) - - [delegateCreateQuarry](#delegateCreateQuarry-1) - - [delegateCreateQuarryV2](#delegateCreateQuarryV2-1) - - [delegateSetRewardsShare](#delegateSetRewardsShare-1) - - [delegateSetFamine](#delegateSetFamine-1) + - [createOperator](#createOperator) + - [createOperatorV2](#createOperatorV2) + - [setAdmin](#setAdmin) + - [setRateSetter](#setRateSetter) + - [setQuarryCreator](#setQuarryCreator) + - [setShareAllocator](#setShareAllocator) + - [delegateSetAnnualRewards](#delegateSetAnnualRewards) + - [delegateCreateQuarry](#delegateCreateQuarry) + - [delegateCreateQuarryV2](#delegateCreateQuarryV2) + - [delegateSetRewardsShare](#delegateSetRewardsShare) + - [delegateSetFamine](#delegateSetFamine) - [PDAs](#pdas) - - [operator](#operator-2) + - [operator](#operator) - [Errors](#errors) ## Accounts @@ -155,12 +155,12 @@ **Accounts:** -| Account | Type | Description | -| ------------------- | -------- | ----------- | -| `operator` | writable | | -| `delegate` | signer | | -| `rewarder` | writable | | -| `quarryMineProgram` | readonly | | +| Account | Type | Description | +| ----------------------------------------------- | -------- | ----------- | +| `setAnnualRewardsWithDelegateOperator` | writable | | +| `setAnnualRewardsWithDelegateDelegate` | signer | | +| `setAnnualRewardsWithDelegateRewarder` | writable | | +| `setAnnualRewardsWithDelegateQuarryMineProgram` | readonly | | **Arguments:** @@ -173,17 +173,17 @@ **Accounts:** -| Account | Type | Description | -| ------------------- | ---------------- | ----------- | -| `operator` | writable | | -| `delegate` | signer | | -| `rewarder` | writable | | -| `quarryMineProgram` | readonly | | -| `quarry` | writable | | -| `tokenMint` | readonly | | -| `payer` | signer, writable | | -| `unusedAccount` | readonly | | -| `systemProgram` | readonly | | +| Account | Type | Description | +| ------------------------------------------- | ---------------- | ----------- | +| `createQuarryWithDelegateOperator` | writable | | +| `createQuarryWithDelegateDelegate` | signer | | +| `createQuarryWithDelegateRewarder` | writable | | +| `createQuarryWithDelegateQuarryMineProgram` | readonly | | +| `quarry` | writable | | +| `tokenMint` | readonly | | +| `payer` | signer, writable | | +| `unusedAccount` | readonly | | +| `systemProgram` | readonly | | **Arguments:** @@ -196,16 +196,16 @@ **Accounts:** -| Account | Type | Description | -| ------------------- | ---------------- | ----------- | -| `operator` | writable | | -| `delegate` | signer | | -| `rewarder` | writable | | -| `quarryMineProgram` | readonly | | -| `quarry` | writable | | -| `tokenMint` | readonly | | -| `payer` | signer, writable | | -| `systemProgram` | readonly | | +| Account | Type | Description | +| --------------------------------------------- | ---------------- | ----------- | +| `createQuarryV2WithDelegateOperator` | writable | | +| `createQuarryV2WithDelegateDelegate` | signer | | +| `createQuarryV2WithDelegateRewarder` | writable | | +| `createQuarryV2WithDelegateQuarryMineProgram` | readonly | | +| `quarry` | writable | | +| `tokenMint` | readonly | | +| `payer` | signer, writable | | +| `systemProgram` | readonly | | **Arguments:** @@ -217,13 +217,13 @@ **Accounts:** -| Account | Type | Description | -| ------------------- | -------- | ----------- | -| `operator` | writable | | -| `delegate` | signer | | -| `rewarder` | writable | | -| `quarryMineProgram` | readonly | | -| `quarry` | writable | | +| Account | Type | Description | +| ---------------------------------------------- | -------- | ----------- | +| `setRewardsShareWithDelegateOperator` | writable | | +| `setRewardsShareWithDelegateDelegate` | signer | | +| `setRewardsShareWithDelegateRewarder` | writable | | +| `setRewardsShareWithDelegateQuarryMineProgram` | readonly | | +| `quarry` | writable | | **Arguments:** @@ -236,13 +236,13 @@ **Accounts:** -| Account | Type | Description | -| ------------------- | -------- | ----------- | -| `operator` | writable | | -| `delegate` | signer | | -| `rewarder` | writable | | -| `quarryMineProgram` | readonly | | -| `quarry` | writable | | +| Account | Type | Description | +| ---------------------------------------- | -------- | ----------- | +| `setFamineWithDelegateOperator` | writable | | +| `setFamineWithDelegateDelegate` | signer | | +| `setFamineWithDelegateRewarder` | writable | | +| `setFamineWithDelegateQuarryMineProgram` | readonly | | +| `quarry` | writable | | **Arguments:** @@ -264,6 +264,6 @@ ## Errors -- **unauthorized** (Code: 6000 / `6000` / `0x1770`) -- Signer is not authorized to perform this action. -- **pendingAuthorityNotSet** (Code: 6001 / `6001` / `0x1771`) -- Pending authority must be set to the created operator. -- **operatorNotRewarderAuthority** (Code: 6002 / `6002` / `0x1772`) -- Operator is not the Rewarder authority. +- **6000 - Unauthorized**: Signer is not authorized to perform this action. _(Hex: `0x1770`)_ +- **6001 - PendingAuthorityNotSet**: Pending authority must be set to the created operator. _(Hex: `0x1771`)_ +- **6002 - OperatorNotRewarderAuthority**: Operator is not the Rewarder authority. _(Hex: `0x1772`)_ diff --git a/clients/quarry/docs/quarry-redeemer.md b/clients/quarry/docs/quarry-redeemer.md index ef9a0578..e94f7ea2 100644 --- a/clients/quarry/docs/quarry-redeemer.md +++ b/clients/quarry/docs/quarry-redeemer.md @@ -10,13 +10,13 @@ - [Accounts](#accounts) - [redeemer](#redeemer) - [Instructions](#instructions) - - [createRedeemer](#createRedeemer-1) - - [redeemTokens](#redeemTokens-1) - - [redeemAllTokens](#redeemAllTokens-1) + - [createRedeemer](#createRedeemer) + - [redeemTokens](#redeemTokens) + - [redeemAllTokens](#redeemAllTokens) - [PDAs](#pdas) - - [redeemer](#redeemer-2) + - [redeemer](#redeemer) - [Types](#types) - - [redeemTokensEvent](#redeemTokensEvent-3) + - [redeemTokensEvent](#redeemTokensEvent) - [Errors](#errors) ## Accounts @@ -125,4 +125,4 @@ ## Errors -- **unauthorized** (Code: 6000 / `6000` / `0x1770`) -- Unauthorized. +- **6000 - Unauthorized**: Unauthorized. _(Hex: `0x1770`)_ diff --git a/clients/quarry/docs/quarry-registry.md b/clients/quarry/docs/quarry-registry.md index d24a458f..56d7c375 100644 --- a/clients/quarry/docs/quarry-registry.md +++ b/clients/quarry/docs/quarry-registry.md @@ -10,10 +10,10 @@ - [Accounts](#accounts) - [registry](#registry) - [Instructions](#instructions) - - [newRegistry](#newRegistry-1) - - [syncQuarry](#syncQuarry-1) + - [newRegistry](#newRegistry) + - [syncQuarry](#syncQuarry) - [PDAs](#pdas) - - [registry](#registry-2) + - [registry](#registry) ## Accounts diff --git a/clients/quarry/package.json b/clients/quarry/package.json index bd9f1a0c..16ee387b 100644 --- a/clients/quarry/package.json +++ b/clients/quarry/package.json @@ -8,13 +8,15 @@ "homepage": "https://github.com/macalinao/coda", "license": "Apache-2.0", "keywords": [ + "coda", "solana", "quarry", "mining", "staking", "client", "esm", - "typescript" + "typescript", + "ian-macalinao" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -52,7 +54,6 @@ "@macalinao/eslint-config": "catalog:", "@macalinao/tsconfig": "catalog:", "@solana/kit": "*", - "codama": "*", "eslint": "catalog:", "typescript": "catalog:" }, diff --git a/clients/quarry/src/generated/accounts/mergeMiner.ts b/clients/quarry/src/generated/accounts/mergeMiner.ts index 1d82617a..7648fd5c 100644 --- a/clients/quarry/src/generated/accounts/mergeMiner.ts +++ b/clients/quarry/src/generated/accounts/mergeMiner.ts @@ -41,7 +41,7 @@ import { transformEncoder, } from "@solana/kit"; -export const MERGE_MINER_DISCRIMINATOR = new Uint8Array([ +export const MERGE_MINER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 243, 97, 253, 80, 19, 210, 148, 120, ]); diff --git a/clients/quarry/src/generated/accounts/mergePool.ts b/clients/quarry/src/generated/accounts/mergePool.ts index f1836d35..2c3fb93f 100644 --- a/clients/quarry/src/generated/accounts/mergePool.ts +++ b/clients/quarry/src/generated/accounts/mergePool.ts @@ -43,7 +43,7 @@ import { transformEncoder, } from "@solana/kit"; -export const MERGE_POOL_DISCRIMINATOR = new Uint8Array([ +export const MERGE_POOL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 15, 189, 242, 87, 188, 75, 64, 244, ]); diff --git a/clients/quarry/src/generated/accounts/miner.ts b/clients/quarry/src/generated/accounts/miner.ts index 3b68c7f4..f3cfaf9f 100644 --- a/clients/quarry/src/generated/accounts/miner.ts +++ b/clients/quarry/src/generated/accounts/miner.ts @@ -43,7 +43,7 @@ import { transformEncoder, } from "@solana/kit"; -export const MINER_DISCRIMINATOR = new Uint8Array([ +export const MINER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 223, 113, 15, 54, 123, 122, 140, 100, ]); diff --git a/clients/quarry/src/generated/accounts/mintWrapper.ts b/clients/quarry/src/generated/accounts/mintWrapper.ts index 2ab1abef..2fccda2b 100644 --- a/clients/quarry/src/generated/accounts/mintWrapper.ts +++ b/clients/quarry/src/generated/accounts/mintWrapper.ts @@ -41,7 +41,7 @@ import { transformEncoder, } from "@solana/kit"; -export const MINT_WRAPPER_DISCRIMINATOR = new Uint8Array([ +export const MINT_WRAPPER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 154, 166, 64, 239, 170, 99, 74, 158, ]); diff --git a/clients/quarry/src/generated/accounts/minter.ts b/clients/quarry/src/generated/accounts/minter.ts index 961f69f5..5c88e939 100644 --- a/clients/quarry/src/generated/accounts/minter.ts +++ b/clients/quarry/src/generated/accounts/minter.ts @@ -41,7 +41,7 @@ import { transformEncoder, } from "@solana/kit"; -export const MINTER_DISCRIMINATOR = new Uint8Array([ +export const MINTER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 28, 69, 107, 166, 41, 139, 205, 247, ]); diff --git a/clients/quarry/src/generated/accounts/operator.ts b/clients/quarry/src/generated/accounts/operator.ts index f1fc839a..2822395d 100644 --- a/clients/quarry/src/generated/accounts/operator.ts +++ b/clients/quarry/src/generated/accounts/operator.ts @@ -43,7 +43,7 @@ import { transformEncoder, } from "@solana/kit"; -export const OPERATOR_DISCRIMINATOR = new Uint8Array([ +export const OPERATOR_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 219, 31, 188, 145, 69, 139, 204, 117, ]); diff --git a/clients/quarry/src/generated/accounts/quarry.ts b/clients/quarry/src/generated/accounts/quarry.ts index b4f7d066..b9e751d3 100644 --- a/clients/quarry/src/generated/accounts/quarry.ts +++ b/clients/quarry/src/generated/accounts/quarry.ts @@ -47,7 +47,7 @@ import { transformEncoder, } from "@solana/kit"; -export const QUARRY_DISCRIMINATOR = new Uint8Array([ +export const QUARRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 243, 248, 54, 182, 240, 85, 9, 77, ]); diff --git a/clients/quarry/src/generated/accounts/redeemer.ts b/clients/quarry/src/generated/accounts/redeemer.ts index 22cffb7a..baff455d 100644 --- a/clients/quarry/src/generated/accounts/redeemer.ts +++ b/clients/quarry/src/generated/accounts/redeemer.ts @@ -41,7 +41,7 @@ import { transformEncoder, } from "@solana/kit"; -export const REDEEMER_DISCRIMINATOR = new Uint8Array([ +export const REDEEMER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 41, 191, 197, 8, 98, 64, 17, 99, ]); diff --git a/clients/quarry/src/generated/accounts/registry.ts b/clients/quarry/src/generated/accounts/registry.ts index d1eb1fa3..13662451 100644 --- a/clients/quarry/src/generated/accounts/registry.ts +++ b/clients/quarry/src/generated/accounts/registry.ts @@ -41,7 +41,7 @@ import { transformEncoder, } from "@solana/kit"; -export const REGISTRY_DISCRIMINATOR = new Uint8Array([ +export const REGISTRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 47, 174, 110, 246, 184, 182, 252, 218, ]); diff --git a/clients/quarry/src/generated/accounts/rewarder.ts b/clients/quarry/src/generated/accounts/rewarder.ts index f1cc824c..ec277a90 100644 --- a/clients/quarry/src/generated/accounts/rewarder.ts +++ b/clients/quarry/src/generated/accounts/rewarder.ts @@ -45,7 +45,7 @@ import { transformEncoder, } from "@solana/kit"; -export const REWARDER_DISCRIMINATOR = new Uint8Array([ +export const REWARDER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 83, 3, 203, 174, 244, 30, 172, 198, ]); diff --git a/clients/quarry/src/generated/instructions/acceptAdmin.ts b/clients/quarry/src/generated/instructions/acceptAdmin.ts index 15321a84..aa94fb73 100644 --- a/clients/quarry/src/generated/instructions/acceptAdmin.ts +++ b/clients/quarry/src/generated/instructions/acceptAdmin.ts @@ -35,7 +35,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const ACCEPT_ADMIN_DISCRIMINATOR = new Uint8Array([ +export const ACCEPT_ADMIN_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 112, 42, 45, 90, 116, 181, 13, 170, ]); diff --git a/clients/quarry/src/generated/instructions/acceptAuthority.ts b/clients/quarry/src/generated/instructions/acceptAuthority.ts index ce50984b..4fd9ec5e 100644 --- a/clients/quarry/src/generated/instructions/acceptAuthority.ts +++ b/clients/quarry/src/generated/instructions/acceptAuthority.ts @@ -35,9 +35,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const ACCEPT_AUTHORITY_DISCRIMINATOR = new Uint8Array([ - 107, 86, 198, 91, 33, 12, 107, 160, -]); +export const ACCEPT_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([107, 86, 198, 91, 33, 12, 107, 160]); export function getAcceptAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/claimRewards.ts b/clients/quarry/src/generated/instructions/claimRewards.ts index 5eff9c16..4b84e2cd 100644 --- a/clients/quarry/src/generated/instructions/claimRewards.ts +++ b/clients/quarry/src/generated/instructions/claimRewards.ts @@ -36,7 +36,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const CLAIM_REWARDS_DISCRIMINATOR = new Uint8Array([ +export const CLAIM_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 4, 144, 132, 71, 116, 23, 151, 80, ]); @@ -56,15 +56,15 @@ export type ClaimRewardsInstruction< TAccountRewardsTokenMint extends string | AccountMeta = string, TAccountRewardsTokenAccount extends string | AccountMeta = string, TAccountClaimFeeTokenAccount extends string | AccountMeta = string, - TAccountAuthority extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountUnusedMinerVault extends string | AccountMeta = string, - TAccountUnusedTokenAccount extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountClaimV1Authority extends string | AccountMeta = string, + TAccountClaimV1Miner extends string | AccountMeta = string, + TAccountClaimV1Quarry extends string | AccountMeta = string, + TAccountClaimV1UnusedMinerVault extends string | AccountMeta = string, + TAccountClaimV1UnusedTokenAccount extends string | AccountMeta = string, + TAccountClaimV1TokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountRewarder extends string | AccountMeta = string, + TAccountClaimV1Rewarder extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & @@ -88,28 +88,28 @@ export type ClaimRewardsInstruction< TAccountClaimFeeTokenAccount extends string ? WritableAccount : TAccountClaimFeeTokenAccount, - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountUnusedMinerVault extends string - ? ReadonlyAccount - : TAccountUnusedMinerVault, - TAccountUnusedTokenAccount extends string - ? ReadonlyAccount - : TAccountUnusedTokenAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, + TAccountClaimV1Authority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountClaimV1Authority, + TAccountClaimV1Miner extends string + ? WritableAccount + : TAccountClaimV1Miner, + TAccountClaimV1Quarry extends string + ? WritableAccount + : TAccountClaimV1Quarry, + TAccountClaimV1UnusedMinerVault extends string + ? ReadonlyAccount + : TAccountClaimV1UnusedMinerVault, + TAccountClaimV1UnusedTokenAccount extends string + ? ReadonlyAccount + : TAccountClaimV1UnusedTokenAccount, + TAccountClaimV1TokenProgram extends string + ? ReadonlyAccount + : TAccountClaimV1TokenProgram, + TAccountClaimV1Rewarder extends string + ? ReadonlyAccount + : TAccountClaimV1Rewarder, ...TRemainingAccounts, ] >; @@ -150,13 +150,13 @@ export interface ClaimRewardsInput< TAccountRewardsTokenMint extends string = string, TAccountRewardsTokenAccount extends string = string, TAccountClaimFeeTokenAccount extends string = string, - TAccountAuthority extends string = string, - TAccountMiner extends string = string, - TAccountQuarry extends string = string, - TAccountUnusedMinerVault extends string = string, - TAccountUnusedTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountRewarder extends string = string, + TAccountClaimV1Authority extends string = string, + TAccountClaimV1Miner extends string = string, + TAccountClaimV1Quarry extends string = string, + TAccountClaimV1UnusedMinerVault extends string = string, + TAccountClaimV1UnusedTokenAccount extends string = string, + TAccountClaimV1TokenProgram extends string = string, + TAccountClaimV1Rewarder extends string = string, > { mintWrapper: Address; mintWrapperProgram?: Address; @@ -164,13 +164,13 @@ export interface ClaimRewardsInput< rewardsTokenMint: Address; rewardsTokenAccount: Address; claimFeeTokenAccount: Address; - authority: TransactionSigner; - miner: Address; - quarry: Address; - unusedMinerVault: Address; - unusedTokenAccount: Address; - tokenProgram?: Address; - rewarder: Address; + claimV1Authority: TransactionSigner; + claimV1Miner: Address; + claimV1Quarry: Address; + claimV1UnusedMinerVault: Address; + claimV1UnusedTokenAccount: Address; + claimV1TokenProgram?: Address; + claimV1Rewarder: Address; } export function getClaimRewardsInstruction< @@ -180,13 +180,13 @@ export function getClaimRewardsInstruction< TAccountRewardsTokenMint extends string, TAccountRewardsTokenAccount extends string, TAccountClaimFeeTokenAccount extends string, - TAccountAuthority extends string, - TAccountMiner extends string, - TAccountQuarry extends string, - TAccountUnusedMinerVault extends string, - TAccountUnusedTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountRewarder extends string, + TAccountClaimV1Authority extends string, + TAccountClaimV1Miner extends string, + TAccountClaimV1Quarry extends string, + TAccountClaimV1UnusedMinerVault extends string, + TAccountClaimV1UnusedTokenAccount extends string, + TAccountClaimV1TokenProgram extends string, + TAccountClaimV1Rewarder extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( input: ClaimRewardsInput< @@ -196,13 +196,13 @@ export function getClaimRewardsInstruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountUnusedMinerVault, - TAccountUnusedTokenAccount, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimV1Authority, + TAccountClaimV1Miner, + TAccountClaimV1Quarry, + TAccountClaimV1UnusedMinerVault, + TAccountClaimV1UnusedTokenAccount, + TAccountClaimV1TokenProgram, + TAccountClaimV1Rewarder >, config?: { programAddress?: TProgramAddress }, ): ClaimRewardsInstruction< @@ -213,13 +213,13 @@ export function getClaimRewardsInstruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountUnusedMinerVault, - TAccountUnusedTokenAccount, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimV1Authority, + TAccountClaimV1Miner, + TAccountClaimV1Quarry, + TAccountClaimV1UnusedMinerVault, + TAccountClaimV1UnusedTokenAccount, + TAccountClaimV1TokenProgram, + TAccountClaimV1Rewarder > { // Program address. const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; @@ -244,19 +244,28 @@ export function getClaimRewardsInstruction< value: input.claimFeeTokenAccount ?? null, isWritable: true, }, - authority: { value: input.authority ?? null, isWritable: false }, - miner: { value: input.miner ?? null, isWritable: true }, - quarry: { value: input.quarry ?? null, isWritable: true }, - unusedMinerVault: { - value: input.unusedMinerVault ?? null, + claimV1Authority: { + value: input.claimV1Authority ?? null, isWritable: false, }, - unusedTokenAccount: { - value: input.unusedTokenAccount ?? null, + claimV1Miner: { value: input.claimV1Miner ?? null, isWritable: true }, + claimV1Quarry: { value: input.claimV1Quarry ?? null, isWritable: true }, + claimV1UnusedMinerVault: { + value: input.claimV1UnusedMinerVault ?? null, + isWritable: false, + }, + claimV1UnusedTokenAccount: { + value: input.claimV1UnusedTokenAccount ?? null, + isWritable: false, + }, + claimV1TokenProgram: { + value: input.claimV1TokenProgram ?? null, + isWritable: false, + }, + claimV1Rewarder: { + value: input.claimV1Rewarder ?? null, isWritable: false, }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -268,8 +277,8 @@ export function getClaimRewardsInstruction< accounts.mintWrapperProgram.value = "QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV" as Address<"QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV">; } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.claimV1TokenProgram.value) { + accounts.claimV1TokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } @@ -282,13 +291,13 @@ export function getClaimRewardsInstruction< getAccountMeta(accounts.rewardsTokenMint), getAccountMeta(accounts.rewardsTokenAccount), getAccountMeta(accounts.claimFeeTokenAccount), - getAccountMeta(accounts.authority), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.unusedMinerVault), - getAccountMeta(accounts.unusedTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.claimV1Authority), + getAccountMeta(accounts.claimV1Miner), + getAccountMeta(accounts.claimV1Quarry), + getAccountMeta(accounts.claimV1UnusedMinerVault), + getAccountMeta(accounts.claimV1UnusedTokenAccount), + getAccountMeta(accounts.claimV1TokenProgram), + getAccountMeta(accounts.claimV1Rewarder), ], programAddress, data: getClaimRewardsInstructionDataEncoder().encode({}), @@ -300,13 +309,13 @@ export function getClaimRewardsInstruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountUnusedMinerVault, - TAccountUnusedTokenAccount, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimV1Authority, + TAccountClaimV1Miner, + TAccountClaimV1Quarry, + TAccountClaimV1UnusedMinerVault, + TAccountClaimV1UnusedTokenAccount, + TAccountClaimV1TokenProgram, + TAccountClaimV1Rewarder >; return instruction; @@ -324,13 +333,13 @@ export interface ParsedClaimRewardsInstruction< rewardsTokenMint: TAccountMetas[3]; rewardsTokenAccount: TAccountMetas[4]; claimFeeTokenAccount: TAccountMetas[5]; - authority: TAccountMetas[6]; - miner: TAccountMetas[7]; - quarry: TAccountMetas[8]; - unusedMinerVault: TAccountMetas[9]; - unusedTokenAccount: TAccountMetas[10]; - tokenProgram: TAccountMetas[11]; - rewarder: TAccountMetas[12]; + claimV1Authority: TAccountMetas[6]; + claimV1Miner: TAccountMetas[7]; + claimV1Quarry: TAccountMetas[8]; + claimV1UnusedMinerVault: TAccountMetas[9]; + claimV1UnusedTokenAccount: TAccountMetas[10]; + claimV1TokenProgram: TAccountMetas[11]; + claimV1Rewarder: TAccountMetas[12]; }; data: ClaimRewardsInstructionData; } @@ -362,13 +371,13 @@ export function parseClaimRewardsInstruction< rewardsTokenMint: getNextAccount(), rewardsTokenAccount: getNextAccount(), claimFeeTokenAccount: getNextAccount(), - authority: getNextAccount(), - miner: getNextAccount(), - quarry: getNextAccount(), - unusedMinerVault: getNextAccount(), - unusedTokenAccount: getNextAccount(), - tokenProgram: getNextAccount(), - rewarder: getNextAccount(), + claimV1Authority: getNextAccount(), + claimV1Miner: getNextAccount(), + claimV1Quarry: getNextAccount(), + claimV1UnusedMinerVault: getNextAccount(), + claimV1UnusedTokenAccount: getNextAccount(), + claimV1TokenProgram: getNextAccount(), + claimV1Rewarder: getNextAccount(), }, data: getClaimRewardsInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/claimRewardsMM.ts b/clients/quarry/src/generated/instructions/claimRewardsMM.ts index 4bb24a14..ff7e1a4f 100644 --- a/clients/quarry/src/generated/instructions/claimRewardsMM.ts +++ b/clients/quarry/src/generated/instructions/claimRewardsMM.ts @@ -33,9 +33,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const CLAIM_REWARDS_M_M_DISCRIMINATOR = new Uint8Array([ - 4, 144, 132, 71, 116, 23, 151, 80, -]); +export const CLAIM_REWARDS_M_M_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([4, 144, 132, 71, 116, 23, 151, 80]); export function getClaimRewardsMMDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -54,16 +53,16 @@ export type ClaimRewardsMMInstruction< TAccountRewardsTokenAccount extends string | AccountMeta = string, TAccountClaimFeeTokenAccount extends string | AccountMeta = string, TAccountStakeTokenAccount extends string | AccountMeta = string, - TAccountPool extends string | AccountMeta = string, - TAccountMm extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountMinerVault extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountClaimRewardsStakePool extends string | AccountMeta = string, + TAccountClaimRewardsStakeMm extends string | AccountMeta = string, + TAccountClaimRewardsStakeRewarder extends string | AccountMeta = string, + TAccountClaimRewardsStakeQuarry extends string | AccountMeta = string, + TAccountClaimRewardsStakeMiner extends string | AccountMeta = string, + TAccountClaimRewardsStakeMinerVault extends string | AccountMeta = string, + TAccountClaimRewardsStakeTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountMineProgram extends + TAccountClaimRewardsStakeMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -92,28 +91,30 @@ export type ClaimRewardsMMInstruction< TAccountStakeTokenAccount extends string ? WritableAccount : TAccountStakeTokenAccount, - TAccountPool extends string - ? WritableAccount - : TAccountPool, - TAccountMm extends string ? WritableAccount : TAccountMm, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountMinerVault extends string - ? WritableAccount - : TAccountMinerVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountMineProgram extends string - ? ReadonlyAccount - : TAccountMineProgram, + TAccountClaimRewardsStakePool extends string + ? WritableAccount + : TAccountClaimRewardsStakePool, + TAccountClaimRewardsStakeMm extends string + ? WritableAccount + : TAccountClaimRewardsStakeMm, + TAccountClaimRewardsStakeRewarder extends string + ? ReadonlyAccount + : TAccountClaimRewardsStakeRewarder, + TAccountClaimRewardsStakeQuarry extends string + ? WritableAccount + : TAccountClaimRewardsStakeQuarry, + TAccountClaimRewardsStakeMiner extends string + ? WritableAccount + : TAccountClaimRewardsStakeMiner, + TAccountClaimRewardsStakeMinerVault extends string + ? WritableAccount + : TAccountClaimRewardsStakeMinerVault, + TAccountClaimRewardsStakeTokenProgram extends string + ? ReadonlyAccount + : TAccountClaimRewardsStakeTokenProgram, + TAccountClaimRewardsStakeMineProgram extends string + ? ReadonlyAccount + : TAccountClaimRewardsStakeMineProgram, ...TRemainingAccounts, ] >; @@ -155,14 +156,14 @@ export interface ClaimRewardsMMInput< TAccountRewardsTokenAccount extends string = string, TAccountClaimFeeTokenAccount extends string = string, TAccountStakeTokenAccount extends string = string, - TAccountPool extends string = string, - TAccountMm extends string = string, - TAccountRewarder extends string = string, - TAccountQuarry extends string = string, - TAccountMiner extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountMineProgram extends string = string, + TAccountClaimRewardsStakePool extends string = string, + TAccountClaimRewardsStakeMm extends string = string, + TAccountClaimRewardsStakeRewarder extends string = string, + TAccountClaimRewardsStakeQuarry extends string = string, + TAccountClaimRewardsStakeMiner extends string = string, + TAccountClaimRewardsStakeMinerVault extends string = string, + TAccountClaimRewardsStakeTokenProgram extends string = string, + TAccountClaimRewardsStakeMineProgram extends string = string, > { mintWrapper: Address; mintWrapperProgram?: Address; @@ -171,14 +172,14 @@ export interface ClaimRewardsMMInput< rewardsTokenAccount: Address; claimFeeTokenAccount: Address; stakeTokenAccount: Address; - pool: Address; - mm: Address; - rewarder: Address; - quarry: Address; - miner: Address; - minerVault: Address; - tokenProgram?: Address; - mineProgram?: Address; + claimRewardsStakePool: Address; + claimRewardsStakeMm: Address; + claimRewardsStakeRewarder: Address; + claimRewardsStakeQuarry: Address; + claimRewardsStakeMiner: Address; + claimRewardsStakeMinerVault: Address; + claimRewardsStakeTokenProgram?: Address; + claimRewardsStakeMineProgram?: Address; } export function getClaimRewardsMMInstruction< @@ -189,14 +190,14 @@ export function getClaimRewardsMMInstruction< TAccountRewardsTokenAccount extends string, TAccountClaimFeeTokenAccount extends string, TAccountStakeTokenAccount extends string, - TAccountPool extends string, - TAccountMm extends string, - TAccountRewarder extends string, - TAccountQuarry extends string, - TAccountMiner extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TAccountMineProgram extends string, + TAccountClaimRewardsStakePool extends string, + TAccountClaimRewardsStakeMm extends string, + TAccountClaimRewardsStakeRewarder extends string, + TAccountClaimRewardsStakeQuarry extends string, + TAccountClaimRewardsStakeMiner extends string, + TAccountClaimRewardsStakeMinerVault extends string, + TAccountClaimRewardsStakeTokenProgram extends string, + TAccountClaimRewardsStakeMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, >( input: ClaimRewardsMMInput< @@ -207,14 +208,14 @@ export function getClaimRewardsMMInstruction< TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, TAccountStakeTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountClaimRewardsStakePool, + TAccountClaimRewardsStakeMm, + TAccountClaimRewardsStakeRewarder, + TAccountClaimRewardsStakeQuarry, + TAccountClaimRewardsStakeMiner, + TAccountClaimRewardsStakeMinerVault, + TAccountClaimRewardsStakeTokenProgram, + TAccountClaimRewardsStakeMineProgram >, config?: { programAddress?: TProgramAddress }, ): ClaimRewardsMMInstruction< @@ -226,14 +227,14 @@ export function getClaimRewardsMMInstruction< TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, TAccountStakeTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountClaimRewardsStakePool, + TAccountClaimRewardsStakeMm, + TAccountClaimRewardsStakeRewarder, + TAccountClaimRewardsStakeQuarry, + TAccountClaimRewardsStakeMiner, + TAccountClaimRewardsStakeMinerVault, + TAccountClaimRewardsStakeTokenProgram, + TAccountClaimRewardsStakeMineProgram > { // Program address. const programAddress = @@ -263,14 +264,38 @@ export function getClaimRewardsMMInstruction< value: input.stakeTokenAccount ?? null, isWritable: true, }, - pool: { value: input.pool ?? null, isWritable: true }, - mm: { value: input.mm ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - quarry: { value: input.quarry ?? null, isWritable: true }, - miner: { value: input.miner ?? null, isWritable: true }, - minerVault: { value: input.minerVault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - mineProgram: { value: input.mineProgram ?? null, isWritable: false }, + claimRewardsStakePool: { + value: input.claimRewardsStakePool ?? null, + isWritable: true, + }, + claimRewardsStakeMm: { + value: input.claimRewardsStakeMm ?? null, + isWritable: true, + }, + claimRewardsStakeRewarder: { + value: input.claimRewardsStakeRewarder ?? null, + isWritable: false, + }, + claimRewardsStakeQuarry: { + value: input.claimRewardsStakeQuarry ?? null, + isWritable: true, + }, + claimRewardsStakeMiner: { + value: input.claimRewardsStakeMiner ?? null, + isWritable: true, + }, + claimRewardsStakeMinerVault: { + value: input.claimRewardsStakeMinerVault ?? null, + isWritable: true, + }, + claimRewardsStakeTokenProgram: { + value: input.claimRewardsStakeTokenProgram ?? null, + isWritable: false, + }, + claimRewardsStakeMineProgram: { + value: input.claimRewardsStakeMineProgram ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -282,12 +307,12 @@ export function getClaimRewardsMMInstruction< accounts.mintWrapperProgram.value = "QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV" as Address<"QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV">; } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.claimRewardsStakeTokenProgram.value) { + accounts.claimRewardsStakeTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } - if (!accounts.mineProgram.value) { - accounts.mineProgram.value = + if (!accounts.claimRewardsStakeMineProgram.value) { + accounts.claimRewardsStakeMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } @@ -301,14 +326,14 @@ export function getClaimRewardsMMInstruction< getAccountMeta(accounts.rewardsTokenAccount), getAccountMeta(accounts.claimFeeTokenAccount), getAccountMeta(accounts.stakeTokenAccount), - getAccountMeta(accounts.pool), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.mineProgram), + getAccountMeta(accounts.claimRewardsStakePool), + getAccountMeta(accounts.claimRewardsStakeMm), + getAccountMeta(accounts.claimRewardsStakeRewarder), + getAccountMeta(accounts.claimRewardsStakeQuarry), + getAccountMeta(accounts.claimRewardsStakeMiner), + getAccountMeta(accounts.claimRewardsStakeMinerVault), + getAccountMeta(accounts.claimRewardsStakeTokenProgram), + getAccountMeta(accounts.claimRewardsStakeMineProgram), ], programAddress, data: getClaimRewardsMMInstructionDataEncoder().encode({}), @@ -321,14 +346,14 @@ export function getClaimRewardsMMInstruction< TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, TAccountStakeTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountClaimRewardsStakePool, + TAccountClaimRewardsStakeMm, + TAccountClaimRewardsStakeRewarder, + TAccountClaimRewardsStakeQuarry, + TAccountClaimRewardsStakeMiner, + TAccountClaimRewardsStakeMinerVault, + TAccountClaimRewardsStakeTokenProgram, + TAccountClaimRewardsStakeMineProgram >; return instruction; @@ -347,14 +372,14 @@ export interface ParsedClaimRewardsMMInstruction< rewardsTokenAccount: TAccountMetas[4]; claimFeeTokenAccount: TAccountMetas[5]; stakeTokenAccount: TAccountMetas[6]; - pool: TAccountMetas[7]; - mm: TAccountMetas[8]; - rewarder: TAccountMetas[9]; - quarry: TAccountMetas[10]; - miner: TAccountMetas[11]; - minerVault: TAccountMetas[12]; - tokenProgram: TAccountMetas[13]; - mineProgram: TAccountMetas[14]; + claimRewardsStakePool: TAccountMetas[7]; + claimRewardsStakeMm: TAccountMetas[8]; + claimRewardsStakeRewarder: TAccountMetas[9]; + claimRewardsStakeQuarry: TAccountMetas[10]; + claimRewardsStakeMiner: TAccountMetas[11]; + claimRewardsStakeMinerVault: TAccountMetas[12]; + claimRewardsStakeTokenProgram: TAccountMetas[13]; + claimRewardsStakeMineProgram: TAccountMetas[14]; }; data: ClaimRewardsMMInstructionData; } @@ -387,14 +412,14 @@ export function parseClaimRewardsMMInstruction< rewardsTokenAccount: getNextAccount(), claimFeeTokenAccount: getNextAccount(), stakeTokenAccount: getNextAccount(), - pool: getNextAccount(), - mm: getNextAccount(), - rewarder: getNextAccount(), - quarry: getNextAccount(), - miner: getNextAccount(), - minerVault: getNextAccount(), - tokenProgram: getNextAccount(), - mineProgram: getNextAccount(), + claimRewardsStakePool: getNextAccount(), + claimRewardsStakeMm: getNextAccount(), + claimRewardsStakeRewarder: getNextAccount(), + claimRewardsStakeQuarry: getNextAccount(), + claimRewardsStakeMiner: getNextAccount(), + claimRewardsStakeMinerVault: getNextAccount(), + claimRewardsStakeTokenProgram: getNextAccount(), + claimRewardsStakeMineProgram: getNextAccount(), }, data: getClaimRewardsMMInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/claimRewardsV2.ts b/clients/quarry/src/generated/instructions/claimRewardsV2.ts index 96474f37..474f50f1 100644 --- a/clients/quarry/src/generated/instructions/claimRewardsV2.ts +++ b/clients/quarry/src/generated/instructions/claimRewardsV2.ts @@ -36,9 +36,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const CLAIM_REWARDS_V2_DISCRIMINATOR = new Uint8Array([ - 69, 49, 158, 229, 212, 133, 136, 227, -]); +export const CLAIM_REWARDS_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([69, 49, 158, 229, 212, 133, 136, 227]); export function getClaimRewardsV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -56,13 +55,13 @@ export type ClaimRewardsV2Instruction< TAccountRewardsTokenMint extends string | AccountMeta = string, TAccountRewardsTokenAccount extends string | AccountMeta = string, TAccountClaimFeeTokenAccount extends string | AccountMeta = string, - TAccountAuthority extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountClaimAuthority extends string | AccountMeta = string, + TAccountClaimMiner extends string | AccountMeta = string, + TAccountClaimQuarry extends string | AccountMeta = string, + TAccountClaimTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountRewarder extends string | AccountMeta = string, + TAccountClaimRewarder extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & @@ -86,22 +85,22 @@ export type ClaimRewardsV2Instruction< TAccountClaimFeeTokenAccount extends string ? WritableAccount : TAccountClaimFeeTokenAccount, - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, + TAccountClaimAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountClaimAuthority, + TAccountClaimMiner extends string + ? WritableAccount + : TAccountClaimMiner, + TAccountClaimQuarry extends string + ? WritableAccount + : TAccountClaimQuarry, + TAccountClaimTokenProgram extends string + ? ReadonlyAccount + : TAccountClaimTokenProgram, + TAccountClaimRewarder extends string + ? ReadonlyAccount + : TAccountClaimRewarder, ...TRemainingAccounts, ] >; @@ -142,11 +141,11 @@ export interface ClaimRewardsV2Input< TAccountRewardsTokenMint extends string = string, TAccountRewardsTokenAccount extends string = string, TAccountClaimFeeTokenAccount extends string = string, - TAccountAuthority extends string = string, - TAccountMiner extends string = string, - TAccountQuarry extends string = string, - TAccountTokenProgram extends string = string, - TAccountRewarder extends string = string, + TAccountClaimAuthority extends string = string, + TAccountClaimMiner extends string = string, + TAccountClaimQuarry extends string = string, + TAccountClaimTokenProgram extends string = string, + TAccountClaimRewarder extends string = string, > { mintWrapper: Address; mintWrapperProgram?: Address; @@ -154,11 +153,11 @@ export interface ClaimRewardsV2Input< rewardsTokenMint: Address; rewardsTokenAccount: Address; claimFeeTokenAccount: Address; - authority: TransactionSigner; - miner: Address; - quarry: Address; - tokenProgram?: Address; - rewarder: Address; + claimAuthority: TransactionSigner; + claimMiner: Address; + claimQuarry: Address; + claimTokenProgram?: Address; + claimRewarder: Address; } export function getClaimRewardsV2Instruction< @@ -168,11 +167,11 @@ export function getClaimRewardsV2Instruction< TAccountRewardsTokenMint extends string, TAccountRewardsTokenAccount extends string, TAccountClaimFeeTokenAccount extends string, - TAccountAuthority extends string, - TAccountMiner extends string, - TAccountQuarry extends string, - TAccountTokenProgram extends string, - TAccountRewarder extends string, + TAccountClaimAuthority extends string, + TAccountClaimMiner extends string, + TAccountClaimQuarry extends string, + TAccountClaimTokenProgram extends string, + TAccountClaimRewarder extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( input: ClaimRewardsV2Input< @@ -182,11 +181,11 @@ export function getClaimRewardsV2Instruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimAuthority, + TAccountClaimMiner, + TAccountClaimQuarry, + TAccountClaimTokenProgram, + TAccountClaimRewarder >, config?: { programAddress?: TProgramAddress }, ): ClaimRewardsV2Instruction< @@ -197,11 +196,11 @@ export function getClaimRewardsV2Instruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimAuthority, + TAccountClaimMiner, + TAccountClaimQuarry, + TAccountClaimTokenProgram, + TAccountClaimRewarder > { // Program address. const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; @@ -226,11 +225,14 @@ export function getClaimRewardsV2Instruction< value: input.claimFeeTokenAccount ?? null, isWritable: true, }, - authority: { value: input.authority ?? null, isWritable: false }, - miner: { value: input.miner ?? null, isWritable: true }, - quarry: { value: input.quarry ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, + claimAuthority: { value: input.claimAuthority ?? null, isWritable: false }, + claimMiner: { value: input.claimMiner ?? null, isWritable: true }, + claimQuarry: { value: input.claimQuarry ?? null, isWritable: true }, + claimTokenProgram: { + value: input.claimTokenProgram ?? null, + isWritable: false, + }, + claimRewarder: { value: input.claimRewarder ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -242,8 +244,8 @@ export function getClaimRewardsV2Instruction< accounts.mintWrapperProgram.value = "QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV" as Address<"QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV">; } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.claimTokenProgram.value) { + accounts.claimTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } @@ -256,11 +258,11 @@ export function getClaimRewardsV2Instruction< getAccountMeta(accounts.rewardsTokenMint), getAccountMeta(accounts.rewardsTokenAccount), getAccountMeta(accounts.claimFeeTokenAccount), - getAccountMeta(accounts.authority), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.claimAuthority), + getAccountMeta(accounts.claimMiner), + getAccountMeta(accounts.claimQuarry), + getAccountMeta(accounts.claimTokenProgram), + getAccountMeta(accounts.claimRewarder), ], programAddress, data: getClaimRewardsV2InstructionDataEncoder().encode({}), @@ -272,11 +274,11 @@ export function getClaimRewardsV2Instruction< TAccountRewardsTokenMint, TAccountRewardsTokenAccount, TAccountClaimFeeTokenAccount, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountTokenProgram, - TAccountRewarder + TAccountClaimAuthority, + TAccountClaimMiner, + TAccountClaimQuarry, + TAccountClaimTokenProgram, + TAccountClaimRewarder >; return instruction; @@ -294,11 +296,11 @@ export interface ParsedClaimRewardsV2Instruction< rewardsTokenMint: TAccountMetas[3]; rewardsTokenAccount: TAccountMetas[4]; claimFeeTokenAccount: TAccountMetas[5]; - authority: TAccountMetas[6]; - miner: TAccountMetas[7]; - quarry: TAccountMetas[8]; - tokenProgram: TAccountMetas[9]; - rewarder: TAccountMetas[10]; + claimAuthority: TAccountMetas[6]; + claimMiner: TAccountMetas[7]; + claimQuarry: TAccountMetas[8]; + claimTokenProgram: TAccountMetas[9]; + claimRewarder: TAccountMetas[10]; }; data: ClaimRewardsV2InstructionData; } @@ -330,11 +332,11 @@ export function parseClaimRewardsV2Instruction< rewardsTokenMint: getNextAccount(), rewardsTokenAccount: getNextAccount(), claimFeeTokenAccount: getNextAccount(), - authority: getNextAccount(), - miner: getNextAccount(), - quarry: getNextAccount(), - tokenProgram: getNextAccount(), - rewarder: getNextAccount(), + claimAuthority: getNextAccount(), + claimMiner: getNextAccount(), + claimQuarry: getNextAccount(), + claimTokenProgram: getNextAccount(), + claimRewarder: getNextAccount(), }, data: getClaimRewardsV2InstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/createMiner.ts b/clients/quarry/src/generated/instructions/createMiner.ts index d1dc310c..43fe2aaa 100644 --- a/clients/quarry/src/generated/instructions/createMiner.ts +++ b/clients/quarry/src/generated/instructions/createMiner.ts @@ -27,10 +27,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -39,9 +37,9 @@ import { } from "@solana/kit"; import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_MINER_DISCRIMINATOR = new Uint8Array([ +export const CREATE_MINER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 126, 23, 157, 1, 147, 94, 245, 69, ]); @@ -140,145 +138,6 @@ export function getCreateMinerInstructionDataCodec(): FixedSizeCodec< ); } -export interface CreateMinerAsyncInput< - TAccountAuthority extends string = string, - TAccountMiner extends string = string, - TAccountQuarry extends string = string, - TAccountRewarder extends string = string, - TAccountSystemProgram extends string = string, - TAccountPayer extends string = string, - TAccountTokenMint extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, -> { - authority: TransactionSigner; - miner?: Address; - quarry: Address; - rewarder: Address; - systemProgram?: Address; - payer: TransactionSigner; - tokenMint: Address; - minerVault: Address; - tokenProgram?: Address; - bump: CreateMinerInstructionDataArgs["bump"]; -} - -export async function getCreateMinerInstructionAsync< - TAccountAuthority extends string, - TAccountMiner extends string, - TAccountQuarry extends string, - TAccountRewarder extends string, - TAccountSystemProgram extends string, - TAccountPayer extends string, - TAccountTokenMint extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, ->( - input: CreateMinerAsyncInput< - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - CreateMinerInstruction< - TProgramAddress, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - miner: { value: input.miner ?? null, isWritable: true }, - quarry: { value: input.quarry ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - tokenMint: { value: input.tokenMint ?? null, isWritable: false }, - minerVault: { value: input.minerVault ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.miner.value) { - accounts.miner.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 77, 105, 110, 101, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.quarry.value)), - getAddressEncoder().encode(expectAddress(accounts.authority.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenMint), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - ], - programAddress, - data: getCreateMinerInstructionDataEncoder().encode( - args as CreateMinerInstructionDataArgs, - ), - } as CreateMinerInstruction< - TProgramAddress, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - >; - - return instruction; -} - export interface CreateMinerInput< TAccountAuthority extends string = string, TAccountMiner extends string = string, diff --git a/clients/quarry/src/generated/instructions/createMinerV2.ts b/clients/quarry/src/generated/instructions/createMinerV2.ts index a04fa2e0..f9d09006 100644 --- a/clients/quarry/src/generated/instructions/createMinerV2.ts +++ b/clients/quarry/src/generated/instructions/createMinerV2.ts @@ -27,21 +27,19 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from "@solana/kit"; import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_MINER_V2_DISCRIMINATOR = new Uint8Array([ - 177, 242, 29, 176, 13, 217, 36, 71, -]); +export const CREATE_MINER_V2_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [177, 242, 29, 176, 13, 217, 36, 71], +); export function getCreateMinerV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -131,139 +129,6 @@ export function getCreateMinerV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface CreateMinerV2AsyncInput< - TAccountAuthority extends string = string, - TAccountMiner extends string = string, - TAccountQuarry extends string = string, - TAccountRewarder extends string = string, - TAccountSystemProgram extends string = string, - TAccountPayer extends string = string, - TAccountTokenMint extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, -> { - authority: TransactionSigner; - miner?: Address; - quarry: Address; - rewarder: Address; - systemProgram?: Address; - payer: TransactionSigner; - tokenMint: Address; - minerVault: Address; - tokenProgram?: Address; -} - -export async function getCreateMinerV2InstructionAsync< - TAccountAuthority extends string, - TAccountMiner extends string, - TAccountQuarry extends string, - TAccountRewarder extends string, - TAccountSystemProgram extends string, - TAccountPayer extends string, - TAccountTokenMint extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, ->( - input: CreateMinerV2AsyncInput< - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - CreateMinerV2Instruction< - TProgramAddress, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - miner: { value: input.miner ?? null, isWritable: true }, - quarry: { value: input.quarry ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - tokenMint: { value: input.tokenMint ?? null, isWritable: false }, - minerVault: { value: input.minerVault ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.miner.value) { - accounts.miner.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 77, 105, 110, 101, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.quarry.value)), - getAddressEncoder().encode(expectAddress(accounts.authority.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenMint), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - ], - programAddress, - data: getCreateMinerV2InstructionDataEncoder().encode({}), - } as CreateMinerV2Instruction< - TProgramAddress, - TAccountAuthority, - TAccountMiner, - TAccountQuarry, - TAccountRewarder, - TAccountSystemProgram, - TAccountPayer, - TAccountTokenMint, - TAccountMinerVault, - TAccountTokenProgram - >; - - return instruction; -} - export interface CreateMinerV2Input< TAccountAuthority extends string = string, TAccountMiner extends string = string, diff --git a/clients/quarry/src/generated/instructions/createOperator.ts b/clients/quarry/src/generated/instructions/createOperator.ts index 0356c4e2..989dd959 100644 --- a/clients/quarry/src/generated/instructions/createOperator.ts +++ b/clients/quarry/src/generated/instructions/createOperator.ts @@ -27,10 +27,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -39,11 +37,11 @@ import { } from "@solana/kit"; import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_OPERATOR_DISCRIMINATOR = new Uint8Array([ - 145, 40, 238, 75, 181, 252, 59, 11, -]); +export const CREATE_OPERATOR_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [145, 40, 238, 75, 181, 252, 59, 11], +); export function getCreateOperatorDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -131,132 +129,6 @@ export function getCreateOperatorInstructionDataCodec(): FixedSizeCodec< ); } -export interface CreateOperatorAsyncInput< - TAccountBase extends string = string, - TAccountOperator extends string = string, - TAccountRewarder extends string = string, - TAccountAdmin extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, - TAccountQuarryMineProgram extends string = string, -> { - base: TransactionSigner; - operator?: Address; - rewarder: Address; - admin: Address; - payer: TransactionSigner; - systemProgram?: Address; - quarryMineProgram?: Address; - bump: CreateOperatorInstructionDataArgs["bump"]; -} - -export async function getCreateOperatorInstructionAsync< - TAccountBase extends string, - TAccountOperator extends string, - TAccountRewarder extends string, - TAccountAdmin extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TAccountQuarryMineProgram extends string, - TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, ->( - input: CreateOperatorAsyncInput< - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - CreateOperatorInstruction< - TProgramAddress, - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_OPERATOR_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - operator: { value: input.operator ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, - isWritable: false, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.operator.value) { - accounts.operator.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 79, 112, 101, 114, 97, 116, 111, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = - "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.operator), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.admin), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.quarryMineProgram), - ], - programAddress, - data: getCreateOperatorInstructionDataEncoder().encode( - args as CreateOperatorInstructionDataArgs, - ), - } as CreateOperatorInstruction< - TProgramAddress, - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - >; - - return instruction; -} - export interface CreateOperatorInput< TAccountBase extends string = string, TAccountOperator extends string = string, diff --git a/clients/quarry/src/generated/instructions/createOperatorV2.ts b/clients/quarry/src/generated/instructions/createOperatorV2.ts index d5073d50..361a34fd 100644 --- a/clients/quarry/src/generated/instructions/createOperatorV2.ts +++ b/clients/quarry/src/generated/instructions/createOperatorV2.ts @@ -27,21 +27,18 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from "@solana/kit"; import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_OPERATOR_V2_DISCRIMINATOR = new Uint8Array([ - 179, 106, 174, 35, 45, 26, 10, 67, -]); +export const CREATE_OPERATOR_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([179, 106, 174, 35, 45, 26, 10, 67]); export function getCreateOperatorV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -122,126 +119,6 @@ export function getCreateOperatorV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface CreateOperatorV2AsyncInput< - TAccountBase extends string = string, - TAccountOperator extends string = string, - TAccountRewarder extends string = string, - TAccountAdmin extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, - TAccountQuarryMineProgram extends string = string, -> { - base: TransactionSigner; - operator?: Address; - rewarder: Address; - admin: Address; - payer: TransactionSigner; - systemProgram?: Address; - quarryMineProgram?: Address; -} - -export async function getCreateOperatorV2InstructionAsync< - TAccountBase extends string, - TAccountOperator extends string, - TAccountRewarder extends string, - TAccountAdmin extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TAccountQuarryMineProgram extends string, - TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, ->( - input: CreateOperatorV2AsyncInput< - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - CreateOperatorV2Instruction< - TProgramAddress, - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_OPERATOR_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - operator: { value: input.operator ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, - isWritable: false, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.operator.value) { - accounts.operator.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 79, 112, 101, 114, 97, 116, 111, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = - "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.operator), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.admin), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.quarryMineProgram), - ], - programAddress, - data: getCreateOperatorV2InstructionDataEncoder().encode({}), - } as CreateOperatorV2Instruction< - TProgramAddress, - TAccountBase, - TAccountOperator, - TAccountRewarder, - TAccountAdmin, - TAccountPayer, - TAccountSystemProgram, - TAccountQuarryMineProgram - >; - - return instruction; -} - export interface CreateOperatorV2Input< TAccountBase extends string = string, TAccountOperator extends string = string, diff --git a/clients/quarry/src/generated/instructions/createQuarry.ts b/clients/quarry/src/generated/instructions/createQuarry.ts index 21a1e5d7..097eea8c 100644 --- a/clients/quarry/src/generated/instructions/createQuarry.ts +++ b/clients/quarry/src/generated/instructions/createQuarry.ts @@ -39,7 +39,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_QUARRY_DISCRIMINATOR = new Uint8Array([ +export const CREATE_QUARRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 18, 113, 223, 132, 105, 208, 102, 93, ]); @@ -52,8 +52,8 @@ export function getCreateQuarryDiscriminatorBytes(): ReadonlyUint8Array { export type CreateQuarryInstruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, TAccountQuarry extends string | AccountMeta = string, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TAccountTokenMint extends string | AccountMeta = string, TAccountPayer extends string | AccountMeta = string, TAccountUnusedAccount extends string | AccountMeta = string, @@ -68,13 +68,13 @@ export type CreateQuarryInstruction< TAccountQuarry extends string ? WritableAccount : TAccountQuarry, - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? WritableAccount + : TAccountAuthRewarder, TAccountTokenMint extends string ? ReadonlyAccount : TAccountTokenMint, @@ -130,16 +130,16 @@ export function getCreateQuarryInstructionDataCodec(): FixedSizeCodec< export interface CreateQuarryInput< TAccountQuarry extends string = string, - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, TAccountTokenMint extends string = string, TAccountPayer extends string = string, TAccountUnusedAccount extends string = string, TAccountSystemProgram extends string = string, > { quarry: Address; - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; tokenMint: Address; payer: TransactionSigner; unusedAccount: Address; @@ -149,8 +149,8 @@ export interface CreateQuarryInput< export function getCreateQuarryInstruction< TAccountQuarry extends string, - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TAccountTokenMint extends string, TAccountPayer extends string, TAccountUnusedAccount extends string, @@ -159,8 +159,8 @@ export function getCreateQuarryInstruction< >( input: CreateQuarryInput< TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountUnusedAccount, @@ -170,8 +170,8 @@ export function getCreateQuarryInstruction< ): CreateQuarryInstruction< TProgramAddress, TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountUnusedAccount, @@ -183,8 +183,8 @@ export function getCreateQuarryInstruction< // Original accounts. const originalAccounts = { quarry: { value: input.quarry ?? null, isWritable: true }, - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: true }, tokenMint: { value: input.tokenMint ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true }, unusedAccount: { value: input.unusedAccount ?? null, isWritable: false }, @@ -208,8 +208,8 @@ export function getCreateQuarryInstruction< const instruction = { accounts: [ getAccountMeta(accounts.quarry), - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), getAccountMeta(accounts.tokenMint), getAccountMeta(accounts.payer), getAccountMeta(accounts.unusedAccount), @@ -222,8 +222,8 @@ export function getCreateQuarryInstruction< } as CreateQuarryInstruction< TProgramAddress, TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountUnusedAccount, @@ -240,8 +240,8 @@ export interface ParsedCreateQuarryInstruction< programAddress: Address; accounts: { quarry: TAccountMetas[0]; - authority: TAccountMetas[1]; - rewarder: TAccountMetas[2]; + authAuthority: TAccountMetas[1]; + authRewarder: TAccountMetas[2]; tokenMint: TAccountMetas[3]; payer: TAccountMetas[4]; unusedAccount: TAccountMetas[5]; @@ -272,8 +272,8 @@ export function parseCreateQuarryInstruction< programAddress: instruction.programAddress, accounts: { quarry: getNextAccount(), - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), tokenMint: getNextAccount(), payer: getNextAccount(), unusedAccount: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/createQuarryV2.ts b/clients/quarry/src/generated/instructions/createQuarryV2.ts index 7b9cb804..55e4ba57 100644 --- a/clients/quarry/src/generated/instructions/createQuarryV2.ts +++ b/clients/quarry/src/generated/instructions/createQuarryV2.ts @@ -37,9 +37,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_QUARRY_V2_DISCRIMINATOR = new Uint8Array([ - 46, 84, 33, 67, 174, 252, 67, 148, -]); +export const CREATE_QUARRY_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([46, 84, 33, 67, 174, 252, 67, 148]); export function getCreateQuarryV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -50,8 +49,8 @@ export function getCreateQuarryV2DiscriminatorBytes(): ReadonlyUint8Array { export type CreateQuarryV2Instruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, TAccountQuarry extends string | AccountMeta = string, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TAccountTokenMint extends string | AccountMeta = string, TAccountPayer extends string | AccountMeta = string, TAccountSystemProgram extends @@ -65,13 +64,13 @@ export type CreateQuarryV2Instruction< TAccountQuarry extends string ? WritableAccount : TAccountQuarry, - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? WritableAccount + : TAccountAuthRewarder, TAccountTokenMint extends string ? ReadonlyAccount : TAccountTokenMint, @@ -117,15 +116,15 @@ export function getCreateQuarryV2InstructionDataCodec(): FixedSizeCodec< export interface CreateQuarryV2Input< TAccountQuarry extends string = string, - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, TAccountTokenMint extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string, > { quarry: Address; - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; tokenMint: Address; payer: TransactionSigner; systemProgram?: Address; @@ -133,8 +132,8 @@ export interface CreateQuarryV2Input< export function getCreateQuarryV2Instruction< TAccountQuarry extends string, - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TAccountTokenMint extends string, TAccountPayer extends string, TAccountSystemProgram extends string, @@ -142,8 +141,8 @@ export function getCreateQuarryV2Instruction< >( input: CreateQuarryV2Input< TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountSystemProgram @@ -152,8 +151,8 @@ export function getCreateQuarryV2Instruction< ): CreateQuarryV2Instruction< TProgramAddress, TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountSystemProgram @@ -164,8 +163,8 @@ export function getCreateQuarryV2Instruction< // Original accounts. const originalAccounts = { quarry: { value: input.quarry ?? null, isWritable: true }, - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: true }, tokenMint: { value: input.tokenMint ?? null, isWritable: false }, payer: { value: input.payer ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, @@ -185,8 +184,8 @@ export function getCreateQuarryV2Instruction< const instruction = { accounts: [ getAccountMeta(accounts.quarry), - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), getAccountMeta(accounts.tokenMint), getAccountMeta(accounts.payer), getAccountMeta(accounts.systemProgram), @@ -196,8 +195,8 @@ export function getCreateQuarryV2Instruction< } as CreateQuarryV2Instruction< TProgramAddress, TAccountQuarry, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountTokenMint, TAccountPayer, TAccountSystemProgram @@ -213,8 +212,8 @@ export interface ParsedCreateQuarryV2Instruction< programAddress: Address; accounts: { quarry: TAccountMetas[0]; - authority: TAccountMetas[1]; - rewarder: TAccountMetas[2]; + authAuthority: TAccountMetas[1]; + authRewarder: TAccountMetas[2]; tokenMint: TAccountMetas[3]; payer: TAccountMetas[4]; systemProgram: TAccountMetas[5]; @@ -244,8 +243,8 @@ export function parseCreateQuarryV2Instruction< programAddress: instruction.programAddress, accounts: { quarry: getNextAccount(), - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), tokenMint: getNextAccount(), payer: getNextAccount(), systemProgram: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/createRedeemer.ts b/clients/quarry/src/generated/instructions/createRedeemer.ts index eec22856..3fd1e665 100644 --- a/clients/quarry/src/generated/instructions/createRedeemer.ts +++ b/clients/quarry/src/generated/instructions/createRedeemer.ts @@ -26,10 +26,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -38,11 +36,11 @@ import { } from "@solana/kit"; import { QUARRY_REDEEMER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const CREATE_REDEEMER_DISCRIMINATOR = new Uint8Array([ - 137, 228, 81, 63, 209, 33, 131, 195, -]); +export const CREATE_REDEEMER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [137, 228, 81, 63, 209, 33, 131, 195], +); export function getCreateRedeemerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -120,112 +118,6 @@ export function getCreateRedeemerInstructionDataCodec(): FixedSizeCodec< ); } -export interface CreateRedeemerAsyncInput< - TAccountRedeemer extends string = string, - TAccountIouMint extends string = string, - TAccountRedemptionMint extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - redeemer?: Address; - iouMint: Address; - redemptionMint: Address; - payer: TransactionSigner; - systemProgram?: Address; - bump: CreateRedeemerInstructionDataArgs["bump"]; -} - -export async function getCreateRedeemerInstructionAsync< - TAccountRedeemer extends string, - TAccountIouMint extends string, - TAccountRedemptionMint extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_REDEEMER_PROGRAM_ADDRESS, ->( - input: CreateRedeemerAsyncInput< - TAccountRedeemer, - TAccountIouMint, - TAccountRedemptionMint, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - CreateRedeemerInstruction< - TProgramAddress, - TAccountRedeemer, - TAccountIouMint, - TAccountRedemptionMint, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_REDEEMER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - redeemer: { value: input.redeemer ?? null, isWritable: true }, - iouMint: { value: input.iouMint ?? null, isWritable: false }, - redemptionMint: { value: input.redemptionMint ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.redeemer.value) { - accounts.redeemer.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 82, 101, 100, 101, 101, 109, 101, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.iouMint.value)), - getAddressEncoder().encode( - expectAddress(accounts.redemptionMint.value), - ), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.redeemer), - getAccountMeta(accounts.iouMint), - getAccountMeta(accounts.redemptionMint), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getCreateRedeemerInstructionDataEncoder().encode( - args as CreateRedeemerInstructionDataArgs, - ), - } as CreateRedeemerInstruction< - TProgramAddress, - TAccountRedeemer, - TAccountIouMint, - TAccountRedemptionMint, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface CreateRedeemerInput< TAccountRedeemer extends string = string, TAccountIouMint extends string = string, diff --git a/clients/quarry/src/generated/instructions/delegateCreateQuarry.ts b/clients/quarry/src/generated/instructions/delegateCreateQuarry.ts index 7a660be0..3ad7eac3 100644 --- a/clients/quarry/src/generated/instructions/delegateCreateQuarry.ts +++ b/clients/quarry/src/generated/instructions/delegateCreateQuarry.ts @@ -39,9 +39,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const DELEGATE_CREATE_QUARRY_DISCRIMINATOR = new Uint8Array([ - 245, 238, 31, 14, 175, 233, 75, 237, -]); +export const DELEGATE_CREATE_QUARRY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([245, 238, 31, 14, 175, 233, 75, 237]); export function getDelegateCreateQuarryDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -51,10 +50,16 @@ export function getDelegateCreateQuarryDiscriminatorBytes(): ReadonlyUint8Array export type DelegateCreateQuarryInstruction< TProgram extends string = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, - TAccountOperator extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarryMineProgram extends + TAccountCreateQuarryWithDelegateOperator extends + | string + | AccountMeta = string, + TAccountCreateQuarryWithDelegateDelegate extends + | string + | AccountMeta = string, + TAccountCreateQuarryWithDelegateRewarder extends + | string + | AccountMeta = string, + TAccountCreateQuarryWithDelegateQuarryMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TAccountQuarry extends string | AccountMeta = string, @@ -69,19 +74,19 @@ export type DelegateCreateQuarryInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountOperator extends string - ? WritableAccount - : TAccountOperator, - TAccountDelegate extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDelegate, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, - TAccountQuarryMineProgram extends string - ? ReadonlyAccount - : TAccountQuarryMineProgram, + TAccountCreateQuarryWithDelegateOperator extends string + ? WritableAccount + : TAccountCreateQuarryWithDelegateOperator, + TAccountCreateQuarryWithDelegateDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountCreateQuarryWithDelegateDelegate, + TAccountCreateQuarryWithDelegateRewarder extends string + ? WritableAccount + : TAccountCreateQuarryWithDelegateRewarder, + TAccountCreateQuarryWithDelegateQuarryMineProgram extends string + ? ReadonlyAccount + : TAccountCreateQuarryWithDelegateQuarryMineProgram, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -142,20 +147,20 @@ export function getDelegateCreateQuarryInstructionDataCodec(): FixedSizeCodec< } export interface DelegateCreateQuarryInput< - TAccountOperator extends string = string, - TAccountDelegate extends string = string, - TAccountRewarder extends string = string, - TAccountQuarryMineProgram extends string = string, + TAccountCreateQuarryWithDelegateOperator extends string = string, + TAccountCreateQuarryWithDelegateDelegate extends string = string, + TAccountCreateQuarryWithDelegateRewarder extends string = string, + TAccountCreateQuarryWithDelegateQuarryMineProgram extends string = string, TAccountQuarry extends string = string, TAccountTokenMint extends string = string, TAccountPayer extends string = string, TAccountUnusedAccount extends string = string, TAccountSystemProgram extends string = string, > { - operator: Address; - delegate: TransactionSigner; - rewarder: Address; - quarryMineProgram?: Address; + createQuarryWithDelegateOperator: Address; + createQuarryWithDelegateDelegate: TransactionSigner; + createQuarryWithDelegateRewarder: Address; + createQuarryWithDelegateQuarryMineProgram?: Address; quarry: Address; tokenMint: Address; payer: TransactionSigner; @@ -165,10 +170,10 @@ export interface DelegateCreateQuarryInput< } export function getDelegateCreateQuarryInstruction< - TAccountOperator extends string, - TAccountDelegate extends string, - TAccountRewarder extends string, - TAccountQuarryMineProgram extends string, + TAccountCreateQuarryWithDelegateOperator extends string, + TAccountCreateQuarryWithDelegateDelegate extends string, + TAccountCreateQuarryWithDelegateRewarder extends string, + TAccountCreateQuarryWithDelegateQuarryMineProgram extends string, TAccountQuarry extends string, TAccountTokenMint extends string, TAccountPayer extends string, @@ -177,10 +182,10 @@ export function getDelegateCreateQuarryInstruction< TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, >( input: DelegateCreateQuarryInput< - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryWithDelegateOperator, + TAccountCreateQuarryWithDelegateDelegate, + TAccountCreateQuarryWithDelegateRewarder, + TAccountCreateQuarryWithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -190,10 +195,10 @@ export function getDelegateCreateQuarryInstruction< config?: { programAddress?: TProgramAddress }, ): DelegateCreateQuarryInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryWithDelegateOperator, + TAccountCreateQuarryWithDelegateDelegate, + TAccountCreateQuarryWithDelegateRewarder, + TAccountCreateQuarryWithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -206,11 +211,20 @@ export function getDelegateCreateQuarryInstruction< // Original accounts. const originalAccounts = { - operator: { value: input.operator ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, + createQuarryWithDelegateOperator: { + value: input.createQuarryWithDelegateOperator ?? null, + isWritable: true, + }, + createQuarryWithDelegateDelegate: { + value: input.createQuarryWithDelegateDelegate ?? null, + isWritable: false, + }, + createQuarryWithDelegateRewarder: { + value: input.createQuarryWithDelegateRewarder ?? null, + isWritable: true, + }, + createQuarryWithDelegateQuarryMineProgram: { + value: input.createQuarryWithDelegateQuarryMineProgram ?? null, isWritable: false, }, quarry: { value: input.quarry ?? null, isWritable: true }, @@ -228,8 +242,8 @@ export function getDelegateCreateQuarryInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = + if (!accounts.createQuarryWithDelegateQuarryMineProgram.value) { + accounts.createQuarryWithDelegateQuarryMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } if (!accounts.systemProgram.value) { @@ -240,10 +254,10 @@ export function getDelegateCreateQuarryInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.operator), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarryMineProgram), + getAccountMeta(accounts.createQuarryWithDelegateOperator), + getAccountMeta(accounts.createQuarryWithDelegateDelegate), + getAccountMeta(accounts.createQuarryWithDelegateRewarder), + getAccountMeta(accounts.createQuarryWithDelegateQuarryMineProgram), getAccountMeta(accounts.quarry), getAccountMeta(accounts.tokenMint), getAccountMeta(accounts.payer), @@ -256,10 +270,10 @@ export function getDelegateCreateQuarryInstruction< ), } as DelegateCreateQuarryInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryWithDelegateOperator, + TAccountCreateQuarryWithDelegateDelegate, + TAccountCreateQuarryWithDelegateRewarder, + TAccountCreateQuarryWithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -276,10 +290,10 @@ export interface ParsedDelegateCreateQuarryInstruction< > { programAddress: Address; accounts: { - operator: TAccountMetas[0]; - delegate: TAccountMetas[1]; - rewarder: TAccountMetas[2]; - quarryMineProgram: TAccountMetas[3]; + createQuarryWithDelegateOperator: TAccountMetas[0]; + createQuarryWithDelegateDelegate: TAccountMetas[1]; + createQuarryWithDelegateRewarder: TAccountMetas[2]; + createQuarryWithDelegateQuarryMineProgram: TAccountMetas[3]; quarry: TAccountMetas[4]; tokenMint: TAccountMetas[5]; payer: TAccountMetas[6]; @@ -310,10 +324,10 @@ export function parseDelegateCreateQuarryInstruction< return { programAddress: instruction.programAddress, accounts: { - operator: getNextAccount(), - delegate: getNextAccount(), - rewarder: getNextAccount(), - quarryMineProgram: getNextAccount(), + createQuarryWithDelegateOperator: getNextAccount(), + createQuarryWithDelegateDelegate: getNextAccount(), + createQuarryWithDelegateRewarder: getNextAccount(), + createQuarryWithDelegateQuarryMineProgram: getNextAccount(), quarry: getNextAccount(), tokenMint: getNextAccount(), payer: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/delegateCreateQuarryV2.ts b/clients/quarry/src/generated/instructions/delegateCreateQuarryV2.ts index adb0bbc7..43af075f 100644 --- a/clients/quarry/src/generated/instructions/delegateCreateQuarryV2.ts +++ b/clients/quarry/src/generated/instructions/delegateCreateQuarryV2.ts @@ -37,9 +37,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const DELEGATE_CREATE_QUARRY_V2_DISCRIMINATOR = new Uint8Array([ - 69, 180, 9, 212, 75, 142, 202, 62, -]); +export const DELEGATE_CREATE_QUARRY_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([69, 180, 9, 212, 75, 142, 202, 62]); export function getDelegateCreateQuarryV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -49,10 +48,16 @@ export function getDelegateCreateQuarryV2DiscriminatorBytes(): ReadonlyUint8Arra export type DelegateCreateQuarryV2Instruction< TProgram extends string = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, - TAccountOperator extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarryMineProgram extends + TAccountCreateQuarryV2WithDelegateOperator extends + | string + | AccountMeta = string, + TAccountCreateQuarryV2WithDelegateDelegate extends + | string + | AccountMeta = string, + TAccountCreateQuarryV2WithDelegateRewarder extends + | string + | AccountMeta = string, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TAccountQuarry extends string | AccountMeta = string, @@ -66,19 +71,19 @@ export type DelegateCreateQuarryV2Instruction< InstructionWithData & InstructionWithAccounts< [ - TAccountOperator extends string - ? WritableAccount - : TAccountOperator, - TAccountDelegate extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDelegate, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, - TAccountQuarryMineProgram extends string - ? ReadonlyAccount - : TAccountQuarryMineProgram, + TAccountCreateQuarryV2WithDelegateOperator extends string + ? WritableAccount + : TAccountCreateQuarryV2WithDelegateOperator, + TAccountCreateQuarryV2WithDelegateDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountCreateQuarryV2WithDelegateDelegate, + TAccountCreateQuarryV2WithDelegateRewarder extends string + ? WritableAccount + : TAccountCreateQuarryV2WithDelegateRewarder, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram extends string + ? ReadonlyAccount + : TAccountCreateQuarryV2WithDelegateQuarryMineProgram, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -129,19 +134,19 @@ export function getDelegateCreateQuarryV2InstructionDataCodec(): FixedSizeCodec< } export interface DelegateCreateQuarryV2Input< - TAccountOperator extends string = string, - TAccountDelegate extends string = string, - TAccountRewarder extends string = string, - TAccountQuarryMineProgram extends string = string, + TAccountCreateQuarryV2WithDelegateOperator extends string = string, + TAccountCreateQuarryV2WithDelegateDelegate extends string = string, + TAccountCreateQuarryV2WithDelegateRewarder extends string = string, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram extends string = string, TAccountQuarry extends string = string, TAccountTokenMint extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string, > { - operator: Address; - delegate: TransactionSigner; - rewarder: Address; - quarryMineProgram?: Address; + createQuarryV2WithDelegateOperator: Address; + createQuarryV2WithDelegateDelegate: TransactionSigner; + createQuarryV2WithDelegateRewarder: Address; + createQuarryV2WithDelegateQuarryMineProgram?: Address; quarry: Address; tokenMint: Address; payer: TransactionSigner; @@ -149,10 +154,10 @@ export interface DelegateCreateQuarryV2Input< } export function getDelegateCreateQuarryV2Instruction< - TAccountOperator extends string, - TAccountDelegate extends string, - TAccountRewarder extends string, - TAccountQuarryMineProgram extends string, + TAccountCreateQuarryV2WithDelegateOperator extends string, + TAccountCreateQuarryV2WithDelegateDelegate extends string, + TAccountCreateQuarryV2WithDelegateRewarder extends string, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram extends string, TAccountQuarry extends string, TAccountTokenMint extends string, TAccountPayer extends string, @@ -160,10 +165,10 @@ export function getDelegateCreateQuarryV2Instruction< TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, >( input: DelegateCreateQuarryV2Input< - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryV2WithDelegateOperator, + TAccountCreateQuarryV2WithDelegateDelegate, + TAccountCreateQuarryV2WithDelegateRewarder, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -172,10 +177,10 @@ export function getDelegateCreateQuarryV2Instruction< config?: { programAddress?: TProgramAddress }, ): DelegateCreateQuarryV2Instruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryV2WithDelegateOperator, + TAccountCreateQuarryV2WithDelegateDelegate, + TAccountCreateQuarryV2WithDelegateRewarder, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -187,11 +192,20 @@ export function getDelegateCreateQuarryV2Instruction< // Original accounts. const originalAccounts = { - operator: { value: input.operator ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, + createQuarryV2WithDelegateOperator: { + value: input.createQuarryV2WithDelegateOperator ?? null, + isWritable: true, + }, + createQuarryV2WithDelegateDelegate: { + value: input.createQuarryV2WithDelegateDelegate ?? null, + isWritable: false, + }, + createQuarryV2WithDelegateRewarder: { + value: input.createQuarryV2WithDelegateRewarder ?? null, + isWritable: true, + }, + createQuarryV2WithDelegateQuarryMineProgram: { + value: input.createQuarryV2WithDelegateQuarryMineProgram ?? null, isWritable: false, }, quarry: { value: input.quarry ?? null, isWritable: true }, @@ -205,8 +219,8 @@ export function getDelegateCreateQuarryV2Instruction< >; // Resolve default values. - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = + if (!accounts.createQuarryV2WithDelegateQuarryMineProgram.value) { + accounts.createQuarryV2WithDelegateQuarryMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } if (!accounts.systemProgram.value) { @@ -217,10 +231,10 @@ export function getDelegateCreateQuarryV2Instruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.operator), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarryMineProgram), + getAccountMeta(accounts.createQuarryV2WithDelegateOperator), + getAccountMeta(accounts.createQuarryV2WithDelegateDelegate), + getAccountMeta(accounts.createQuarryV2WithDelegateRewarder), + getAccountMeta(accounts.createQuarryV2WithDelegateQuarryMineProgram), getAccountMeta(accounts.quarry), getAccountMeta(accounts.tokenMint), getAccountMeta(accounts.payer), @@ -230,10 +244,10 @@ export function getDelegateCreateQuarryV2Instruction< data: getDelegateCreateQuarryV2InstructionDataEncoder().encode({}), } as DelegateCreateQuarryV2Instruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountCreateQuarryV2WithDelegateOperator, + TAccountCreateQuarryV2WithDelegateDelegate, + TAccountCreateQuarryV2WithDelegateRewarder, + TAccountCreateQuarryV2WithDelegateQuarryMineProgram, TAccountQuarry, TAccountTokenMint, TAccountPayer, @@ -249,10 +263,10 @@ export interface ParsedDelegateCreateQuarryV2Instruction< > { programAddress: Address; accounts: { - operator: TAccountMetas[0]; - delegate: TAccountMetas[1]; - rewarder: TAccountMetas[2]; - quarryMineProgram: TAccountMetas[3]; + createQuarryV2WithDelegateOperator: TAccountMetas[0]; + createQuarryV2WithDelegateDelegate: TAccountMetas[1]; + createQuarryV2WithDelegateRewarder: TAccountMetas[2]; + createQuarryV2WithDelegateQuarryMineProgram: TAccountMetas[3]; quarry: TAccountMetas[4]; tokenMint: TAccountMetas[5]; payer: TAccountMetas[6]; @@ -282,10 +296,10 @@ export function parseDelegateCreateQuarryV2Instruction< return { programAddress: instruction.programAddress, accounts: { - operator: getNextAccount(), - delegate: getNextAccount(), - rewarder: getNextAccount(), - quarryMineProgram: getNextAccount(), + createQuarryV2WithDelegateOperator: getNextAccount(), + createQuarryV2WithDelegateDelegate: getNextAccount(), + createQuarryV2WithDelegateRewarder: getNextAccount(), + createQuarryV2WithDelegateQuarryMineProgram: getNextAccount(), quarry: getNextAccount(), tokenMint: getNextAccount(), payer: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/delegateSetAnnualRewards.ts b/clients/quarry/src/generated/instructions/delegateSetAnnualRewards.ts index f10a61fa..6ed5d6f4 100644 --- a/clients/quarry/src/generated/instructions/delegateSetAnnualRewards.ts +++ b/clients/quarry/src/generated/instructions/delegateSetAnnualRewards.ts @@ -38,9 +38,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const DELEGATE_SET_ANNUAL_REWARDS_DISCRIMINATOR = new Uint8Array([ - 121, 174, 85, 150, 174, 18, 13, 31, -]); +export const DELEGATE_SET_ANNUAL_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([121, 174, 85, 150, 174, 18, 13, 31]); export function getDelegateSetAnnualRewardsDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -50,10 +49,16 @@ export function getDelegateSetAnnualRewardsDiscriminatorBytes(): ReadonlyUint8Ar export type DelegateSetAnnualRewardsInstruction< TProgram extends string = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, - TAccountOperator extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarryMineProgram extends + TAccountSetAnnualRewardsWithDelegateOperator extends + | string + | AccountMeta = string, + TAccountSetAnnualRewardsWithDelegateDelegate extends + | string + | AccountMeta = string, + TAccountSetAnnualRewardsWithDelegateRewarder extends + | string + | AccountMeta = string, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -61,19 +66,19 @@ export type DelegateSetAnnualRewardsInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountOperator extends string - ? WritableAccount - : TAccountOperator, - TAccountDelegate extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDelegate, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, - TAccountQuarryMineProgram extends string - ? ReadonlyAccount - : TAccountQuarryMineProgram, + TAccountSetAnnualRewardsWithDelegateOperator extends string + ? WritableAccount + : TAccountSetAnnualRewardsWithDelegateOperator, + TAccountSetAnnualRewardsWithDelegateDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSetAnnualRewardsWithDelegateDelegate, + TAccountSetAnnualRewardsWithDelegateRewarder extends string + ? WritableAccount + : TAccountSetAnnualRewardsWithDelegateRewarder, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram extends string + ? ReadonlyAccount + : TAccountSetAnnualRewardsWithDelegateQuarryMineProgram, ...TRemainingAccounts, ] >; @@ -118,38 +123,38 @@ export function getDelegateSetAnnualRewardsInstructionDataCodec(): FixedSizeCode } export interface DelegateSetAnnualRewardsInput< - TAccountOperator extends string = string, - TAccountDelegate extends string = string, - TAccountRewarder extends string = string, - TAccountQuarryMineProgram extends string = string, + TAccountSetAnnualRewardsWithDelegateOperator extends string = string, + TAccountSetAnnualRewardsWithDelegateDelegate extends string = string, + TAccountSetAnnualRewardsWithDelegateRewarder extends string = string, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram extends string = string, > { - operator: Address; - delegate: TransactionSigner; - rewarder: Address; - quarryMineProgram?: Address; + setAnnualRewardsWithDelegateOperator: Address; + setAnnualRewardsWithDelegateDelegate: TransactionSigner; + setAnnualRewardsWithDelegateRewarder: Address; + setAnnualRewardsWithDelegateQuarryMineProgram?: Address; newRate: DelegateSetAnnualRewardsInstructionDataArgs["newRate"]; } export function getDelegateSetAnnualRewardsInstruction< - TAccountOperator extends string, - TAccountDelegate extends string, - TAccountRewarder extends string, - TAccountQuarryMineProgram extends string, + TAccountSetAnnualRewardsWithDelegateOperator extends string, + TAccountSetAnnualRewardsWithDelegateDelegate extends string, + TAccountSetAnnualRewardsWithDelegateRewarder extends string, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, >( input: DelegateSetAnnualRewardsInput< - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram + TAccountSetAnnualRewardsWithDelegateOperator, + TAccountSetAnnualRewardsWithDelegateDelegate, + TAccountSetAnnualRewardsWithDelegateRewarder, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram >, config?: { programAddress?: TProgramAddress }, ): DelegateSetAnnualRewardsInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram + TAccountSetAnnualRewardsWithDelegateOperator, + TAccountSetAnnualRewardsWithDelegateDelegate, + TAccountSetAnnualRewardsWithDelegateRewarder, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram > { // Program address. const programAddress = @@ -157,11 +162,20 @@ export function getDelegateSetAnnualRewardsInstruction< // Original accounts. const originalAccounts = { - operator: { value: input.operator ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, + setAnnualRewardsWithDelegateOperator: { + value: input.setAnnualRewardsWithDelegateOperator ?? null, + isWritable: true, + }, + setAnnualRewardsWithDelegateDelegate: { + value: input.setAnnualRewardsWithDelegateDelegate ?? null, + isWritable: false, + }, + setAnnualRewardsWithDelegateRewarder: { + value: input.setAnnualRewardsWithDelegateRewarder ?? null, + isWritable: true, + }, + setAnnualRewardsWithDelegateQuarryMineProgram: { + value: input.setAnnualRewardsWithDelegateQuarryMineProgram ?? null, isWritable: false, }, }; @@ -174,18 +188,18 @@ export function getDelegateSetAnnualRewardsInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = + if (!accounts.setAnnualRewardsWithDelegateQuarryMineProgram.value) { + accounts.setAnnualRewardsWithDelegateQuarryMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.operator), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarryMineProgram), + getAccountMeta(accounts.setAnnualRewardsWithDelegateOperator), + getAccountMeta(accounts.setAnnualRewardsWithDelegateDelegate), + getAccountMeta(accounts.setAnnualRewardsWithDelegateRewarder), + getAccountMeta(accounts.setAnnualRewardsWithDelegateQuarryMineProgram), ], programAddress, data: getDelegateSetAnnualRewardsInstructionDataEncoder().encode( @@ -193,10 +207,10 @@ export function getDelegateSetAnnualRewardsInstruction< ), } as DelegateSetAnnualRewardsInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram + TAccountSetAnnualRewardsWithDelegateOperator, + TAccountSetAnnualRewardsWithDelegateDelegate, + TAccountSetAnnualRewardsWithDelegateRewarder, + TAccountSetAnnualRewardsWithDelegateQuarryMineProgram >; return instruction; @@ -208,10 +222,10 @@ export interface ParsedDelegateSetAnnualRewardsInstruction< > { programAddress: Address; accounts: { - operator: TAccountMetas[0]; - delegate: TAccountMetas[1]; - rewarder: TAccountMetas[2]; - quarryMineProgram: TAccountMetas[3]; + setAnnualRewardsWithDelegateOperator: TAccountMetas[0]; + setAnnualRewardsWithDelegateDelegate: TAccountMetas[1]; + setAnnualRewardsWithDelegateRewarder: TAccountMetas[2]; + setAnnualRewardsWithDelegateQuarryMineProgram: TAccountMetas[3]; }; data: DelegateSetAnnualRewardsInstructionData; } @@ -237,10 +251,10 @@ export function parseDelegateSetAnnualRewardsInstruction< return { programAddress: instruction.programAddress, accounts: { - operator: getNextAccount(), - delegate: getNextAccount(), - rewarder: getNextAccount(), - quarryMineProgram: getNextAccount(), + setAnnualRewardsWithDelegateOperator: getNextAccount(), + setAnnualRewardsWithDelegateDelegate: getNextAccount(), + setAnnualRewardsWithDelegateRewarder: getNextAccount(), + setAnnualRewardsWithDelegateQuarryMineProgram: getNextAccount(), }, data: getDelegateSetAnnualRewardsInstructionDataDecoder().decode( instruction.data, diff --git a/clients/quarry/src/generated/instructions/delegateSetFamine.ts b/clients/quarry/src/generated/instructions/delegateSetFamine.ts index 626b31e6..ec36f24f 100644 --- a/clients/quarry/src/generated/instructions/delegateSetFamine.ts +++ b/clients/quarry/src/generated/instructions/delegateSetFamine.ts @@ -38,9 +38,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const DELEGATE_SET_FAMINE_DISCRIMINATOR = new Uint8Array([ - 1, 196, 52, 171, 199, 237, 240, 134, -]); +export const DELEGATE_SET_FAMINE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([1, 196, 52, 171, 199, 237, 240, 134]); export function getDelegateSetFamineDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -50,10 +49,10 @@ export function getDelegateSetFamineDiscriminatorBytes(): ReadonlyUint8Array { export type DelegateSetFamineInstruction< TProgram extends string = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, - TAccountOperator extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarryMineProgram extends + TAccountSetFamineWithDelegateOperator extends string | AccountMeta = string, + TAccountSetFamineWithDelegateDelegate extends string | AccountMeta = string, + TAccountSetFamineWithDelegateRewarder extends string | AccountMeta = string, + TAccountSetFamineWithDelegateQuarryMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TAccountQuarry extends string | AccountMeta = string, @@ -62,19 +61,19 @@ export type DelegateSetFamineInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountOperator extends string - ? WritableAccount - : TAccountOperator, - TAccountDelegate extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDelegate, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, - TAccountQuarryMineProgram extends string - ? ReadonlyAccount - : TAccountQuarryMineProgram, + TAccountSetFamineWithDelegateOperator extends string + ? WritableAccount + : TAccountSetFamineWithDelegateOperator, + TAccountSetFamineWithDelegateDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSetFamineWithDelegateDelegate, + TAccountSetFamineWithDelegateRewarder extends string + ? WritableAccount + : TAccountSetFamineWithDelegateRewarder, + TAccountSetFamineWithDelegateQuarryMineProgram extends string + ? ReadonlyAccount + : TAccountSetFamineWithDelegateQuarryMineProgram, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -119,42 +118,42 @@ export function getDelegateSetFamineInstructionDataCodec(): FixedSizeCodec< } export interface DelegateSetFamineInput< - TAccountOperator extends string = string, - TAccountDelegate extends string = string, - TAccountRewarder extends string = string, - TAccountQuarryMineProgram extends string = string, + TAccountSetFamineWithDelegateOperator extends string = string, + TAccountSetFamineWithDelegateDelegate extends string = string, + TAccountSetFamineWithDelegateRewarder extends string = string, + TAccountSetFamineWithDelegateQuarryMineProgram extends string = string, TAccountQuarry extends string = string, > { - operator: Address; - delegate: TransactionSigner; - rewarder: Address; - quarryMineProgram?: Address; + setFamineWithDelegateOperator: Address; + setFamineWithDelegateDelegate: TransactionSigner; + setFamineWithDelegateRewarder: Address; + setFamineWithDelegateQuarryMineProgram?: Address; quarry: Address; famineTs: DelegateSetFamineInstructionDataArgs["famineTs"]; } export function getDelegateSetFamineInstruction< - TAccountOperator extends string, - TAccountDelegate extends string, - TAccountRewarder extends string, - TAccountQuarryMineProgram extends string, + TAccountSetFamineWithDelegateOperator extends string, + TAccountSetFamineWithDelegateDelegate extends string, + TAccountSetFamineWithDelegateRewarder extends string, + TAccountSetFamineWithDelegateQuarryMineProgram extends string, TAccountQuarry extends string, TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, >( input: DelegateSetFamineInput< - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetFamineWithDelegateOperator, + TAccountSetFamineWithDelegateDelegate, + TAccountSetFamineWithDelegateRewarder, + TAccountSetFamineWithDelegateQuarryMineProgram, TAccountQuarry >, config?: { programAddress?: TProgramAddress }, ): DelegateSetFamineInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetFamineWithDelegateOperator, + TAccountSetFamineWithDelegateDelegate, + TAccountSetFamineWithDelegateRewarder, + TAccountSetFamineWithDelegateQuarryMineProgram, TAccountQuarry > { // Program address. @@ -163,11 +162,20 @@ export function getDelegateSetFamineInstruction< // Original accounts. const originalAccounts = { - operator: { value: input.operator ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, + setFamineWithDelegateOperator: { + value: input.setFamineWithDelegateOperator ?? null, + isWritable: true, + }, + setFamineWithDelegateDelegate: { + value: input.setFamineWithDelegateDelegate ?? null, + isWritable: false, + }, + setFamineWithDelegateRewarder: { + value: input.setFamineWithDelegateRewarder ?? null, + isWritable: true, + }, + setFamineWithDelegateQuarryMineProgram: { + value: input.setFamineWithDelegateQuarryMineProgram ?? null, isWritable: false, }, quarry: { value: input.quarry ?? null, isWritable: true }, @@ -181,18 +189,18 @@ export function getDelegateSetFamineInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = + if (!accounts.setFamineWithDelegateQuarryMineProgram.value) { + accounts.setFamineWithDelegateQuarryMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.operator), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarryMineProgram), + getAccountMeta(accounts.setFamineWithDelegateOperator), + getAccountMeta(accounts.setFamineWithDelegateDelegate), + getAccountMeta(accounts.setFamineWithDelegateRewarder), + getAccountMeta(accounts.setFamineWithDelegateQuarryMineProgram), getAccountMeta(accounts.quarry), ], programAddress, @@ -201,10 +209,10 @@ export function getDelegateSetFamineInstruction< ), } as DelegateSetFamineInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetFamineWithDelegateOperator, + TAccountSetFamineWithDelegateDelegate, + TAccountSetFamineWithDelegateRewarder, + TAccountSetFamineWithDelegateQuarryMineProgram, TAccountQuarry >; @@ -217,10 +225,10 @@ export interface ParsedDelegateSetFamineInstruction< > { programAddress: Address; accounts: { - operator: TAccountMetas[0]; - delegate: TAccountMetas[1]; - rewarder: TAccountMetas[2]; - quarryMineProgram: TAccountMetas[3]; + setFamineWithDelegateOperator: TAccountMetas[0]; + setFamineWithDelegateDelegate: TAccountMetas[1]; + setFamineWithDelegateRewarder: TAccountMetas[2]; + setFamineWithDelegateQuarryMineProgram: TAccountMetas[3]; quarry: TAccountMetas[4]; }; data: DelegateSetFamineInstructionData; @@ -247,10 +255,10 @@ export function parseDelegateSetFamineInstruction< return { programAddress: instruction.programAddress, accounts: { - operator: getNextAccount(), - delegate: getNextAccount(), - rewarder: getNextAccount(), - quarryMineProgram: getNextAccount(), + setFamineWithDelegateOperator: getNextAccount(), + setFamineWithDelegateDelegate: getNextAccount(), + setFamineWithDelegateRewarder: getNextAccount(), + setFamineWithDelegateQuarryMineProgram: getNextAccount(), quarry: getNextAccount(), }, data: getDelegateSetFamineInstructionDataDecoder().decode(instruction.data), diff --git a/clients/quarry/src/generated/instructions/delegateSetRewardsShare.ts b/clients/quarry/src/generated/instructions/delegateSetRewardsShare.ts index 1389a859..41d9b845 100644 --- a/clients/quarry/src/generated/instructions/delegateSetRewardsShare.ts +++ b/clients/quarry/src/generated/instructions/delegateSetRewardsShare.ts @@ -38,9 +38,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const DELEGATE_SET_REWARDS_SHARE_DISCRIMINATOR = new Uint8Array([ - 111, 198, 20, 112, 172, 82, 102, 66, -]); +export const DELEGATE_SET_REWARDS_SHARE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([111, 198, 20, 112, 172, 82, 102, 66]); export function getDelegateSetRewardsShareDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -50,10 +49,16 @@ export function getDelegateSetRewardsShareDiscriminatorBytes(): ReadonlyUint8Arr export type DelegateSetRewardsShareInstruction< TProgram extends string = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, - TAccountOperator extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarryMineProgram extends + TAccountSetRewardsShareWithDelegateOperator extends + | string + | AccountMeta = string, + TAccountSetRewardsShareWithDelegateDelegate extends + | string + | AccountMeta = string, + TAccountSetRewardsShareWithDelegateRewarder extends + | string + | AccountMeta = string, + TAccountSetRewardsShareWithDelegateQuarryMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TAccountQuarry extends string | AccountMeta = string, @@ -62,19 +67,19 @@ export type DelegateSetRewardsShareInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountOperator extends string - ? WritableAccount - : TAccountOperator, - TAccountDelegate extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDelegate, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, - TAccountQuarryMineProgram extends string - ? ReadonlyAccount - : TAccountQuarryMineProgram, + TAccountSetRewardsShareWithDelegateOperator extends string + ? WritableAccount + : TAccountSetRewardsShareWithDelegateOperator, + TAccountSetRewardsShareWithDelegateDelegate extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSetRewardsShareWithDelegateDelegate, + TAccountSetRewardsShareWithDelegateRewarder extends string + ? WritableAccount + : TAccountSetRewardsShareWithDelegateRewarder, + TAccountSetRewardsShareWithDelegateQuarryMineProgram extends string + ? ReadonlyAccount + : TAccountSetRewardsShareWithDelegateQuarryMineProgram, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -122,42 +127,42 @@ export function getDelegateSetRewardsShareInstructionDataCodec(): FixedSizeCodec } export interface DelegateSetRewardsShareInput< - TAccountOperator extends string = string, - TAccountDelegate extends string = string, - TAccountRewarder extends string = string, - TAccountQuarryMineProgram extends string = string, + TAccountSetRewardsShareWithDelegateOperator extends string = string, + TAccountSetRewardsShareWithDelegateDelegate extends string = string, + TAccountSetRewardsShareWithDelegateRewarder extends string = string, + TAccountSetRewardsShareWithDelegateQuarryMineProgram extends string = string, TAccountQuarry extends string = string, > { - operator: Address; - delegate: TransactionSigner; - rewarder: Address; - quarryMineProgram?: Address; + setRewardsShareWithDelegateOperator: Address; + setRewardsShareWithDelegateDelegate: TransactionSigner; + setRewardsShareWithDelegateRewarder: Address; + setRewardsShareWithDelegateQuarryMineProgram?: Address; quarry: Address; newShare: DelegateSetRewardsShareInstructionDataArgs["newShare"]; } export function getDelegateSetRewardsShareInstruction< - TAccountOperator extends string, - TAccountDelegate extends string, - TAccountRewarder extends string, - TAccountQuarryMineProgram extends string, + TAccountSetRewardsShareWithDelegateOperator extends string, + TAccountSetRewardsShareWithDelegateDelegate extends string, + TAccountSetRewardsShareWithDelegateRewarder extends string, + TAccountSetRewardsShareWithDelegateQuarryMineProgram extends string, TAccountQuarry extends string, TProgramAddress extends Address = typeof QUARRY_OPERATOR_PROGRAM_ADDRESS, >( input: DelegateSetRewardsShareInput< - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetRewardsShareWithDelegateOperator, + TAccountSetRewardsShareWithDelegateDelegate, + TAccountSetRewardsShareWithDelegateRewarder, + TAccountSetRewardsShareWithDelegateQuarryMineProgram, TAccountQuarry >, config?: { programAddress?: TProgramAddress }, ): DelegateSetRewardsShareInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetRewardsShareWithDelegateOperator, + TAccountSetRewardsShareWithDelegateDelegate, + TAccountSetRewardsShareWithDelegateRewarder, + TAccountSetRewardsShareWithDelegateQuarryMineProgram, TAccountQuarry > { // Program address. @@ -166,11 +171,20 @@ export function getDelegateSetRewardsShareInstruction< // Original accounts. const originalAccounts = { - operator: { value: input.operator ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - quarryMineProgram: { - value: input.quarryMineProgram ?? null, + setRewardsShareWithDelegateOperator: { + value: input.setRewardsShareWithDelegateOperator ?? null, + isWritable: true, + }, + setRewardsShareWithDelegateDelegate: { + value: input.setRewardsShareWithDelegateDelegate ?? null, + isWritable: false, + }, + setRewardsShareWithDelegateRewarder: { + value: input.setRewardsShareWithDelegateRewarder ?? null, + isWritable: true, + }, + setRewardsShareWithDelegateQuarryMineProgram: { + value: input.setRewardsShareWithDelegateQuarryMineProgram ?? null, isWritable: false, }, quarry: { value: input.quarry ?? null, isWritable: true }, @@ -184,18 +198,18 @@ export function getDelegateSetRewardsShareInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.quarryMineProgram.value) { - accounts.quarryMineProgram.value = + if (!accounts.setRewardsShareWithDelegateQuarryMineProgram.value) { + accounts.setRewardsShareWithDelegateQuarryMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.operator), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarryMineProgram), + getAccountMeta(accounts.setRewardsShareWithDelegateOperator), + getAccountMeta(accounts.setRewardsShareWithDelegateDelegate), + getAccountMeta(accounts.setRewardsShareWithDelegateRewarder), + getAccountMeta(accounts.setRewardsShareWithDelegateQuarryMineProgram), getAccountMeta(accounts.quarry), ], programAddress, @@ -204,10 +218,10 @@ export function getDelegateSetRewardsShareInstruction< ), } as DelegateSetRewardsShareInstruction< TProgramAddress, - TAccountOperator, - TAccountDelegate, - TAccountRewarder, - TAccountQuarryMineProgram, + TAccountSetRewardsShareWithDelegateOperator, + TAccountSetRewardsShareWithDelegateDelegate, + TAccountSetRewardsShareWithDelegateRewarder, + TAccountSetRewardsShareWithDelegateQuarryMineProgram, TAccountQuarry >; @@ -220,10 +234,10 @@ export interface ParsedDelegateSetRewardsShareInstruction< > { programAddress: Address; accounts: { - operator: TAccountMetas[0]; - delegate: TAccountMetas[1]; - rewarder: TAccountMetas[2]; - quarryMineProgram: TAccountMetas[3]; + setRewardsShareWithDelegateOperator: TAccountMetas[0]; + setRewardsShareWithDelegateDelegate: TAccountMetas[1]; + setRewardsShareWithDelegateRewarder: TAccountMetas[2]; + setRewardsShareWithDelegateQuarryMineProgram: TAccountMetas[3]; quarry: TAccountMetas[4]; }; data: DelegateSetRewardsShareInstructionData; @@ -250,10 +264,10 @@ export function parseDelegateSetRewardsShareInstruction< return { programAddress: instruction.programAddress, accounts: { - operator: getNextAccount(), - delegate: getNextAccount(), - rewarder: getNextAccount(), - quarryMineProgram: getNextAccount(), + setRewardsShareWithDelegateOperator: getNextAccount(), + setRewardsShareWithDelegateDelegate: getNextAccount(), + setRewardsShareWithDelegateRewarder: getNextAccount(), + setRewardsShareWithDelegateQuarryMineProgram: getNextAccount(), quarry: getNextAccount(), }, data: getDelegateSetRewardsShareInstructionDataDecoder().decode( diff --git a/clients/quarry/src/generated/instructions/extractFees.ts b/clients/quarry/src/generated/instructions/extractFees.ts index 19dd2590..ff962d53 100644 --- a/clients/quarry/src/generated/instructions/extractFees.ts +++ b/clients/quarry/src/generated/instructions/extractFees.ts @@ -33,7 +33,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const EXTRACT_FEES_DISCRIMINATOR = new Uint8Array([ +export const EXTRACT_FEES_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 57, 219, 44, 55, 130, 127, 165, 183, ]); diff --git a/clients/quarry/src/generated/instructions/initMergeMiner.ts b/clients/quarry/src/generated/instructions/initMergeMiner.ts index 422a26f8..7a1d4e3d 100644 --- a/clients/quarry/src/generated/instructions/initMergeMiner.ts +++ b/clients/quarry/src/generated/instructions/initMergeMiner.ts @@ -26,10 +26,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -38,11 +36,10 @@ import { } from "@solana/kit"; import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const INIT_MERGE_MINER_DISCRIMINATOR = new Uint8Array([ - 23, 22, 142, 134, 78, 63, 147, 161, -]); +export const INIT_MERGE_MINER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([23, 22, 142, 134, 78, 63, 147, 161]); export function getInitMergeMinerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -118,112 +115,6 @@ export function getInitMergeMinerInstructionDataCodec(): FixedSizeCodec< ); } -export interface InitMergeMinerAsyncInput< - TAccountPool extends string = string, - TAccountOwner extends string = string, - TAccountMm extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - pool: Address; - owner: Address; - mm?: Address; - payer: TransactionSigner; - systemProgram?: Address; - bump: InitMergeMinerInstructionDataArgs["bump"]; -} - -export async function getInitMergeMinerInstructionAsync< - TAccountPool extends string, - TAccountOwner extends string, - TAccountMm extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, ->( - input: InitMergeMinerAsyncInput< - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - InitMergeMinerInstruction< - TProgramAddress, - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MERGE_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pool: { value: input.pool ?? null, isWritable: false }, - owner: { value: input.owner ?? null, isWritable: false }, - mm: { value: input.mm ?? null, isWritable: true }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.mm.value) { - accounts.mm.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 77, 101, 114, 103, 101, 77, 105, 110, 101, 114, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.pool.value)), - getAddressEncoder().encode(expectAddress(accounts.owner.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.pool), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitMergeMinerInstructionDataEncoder().encode( - args as InitMergeMinerInstructionDataArgs, - ), - } as InitMergeMinerInstruction< - TProgramAddress, - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface InitMergeMinerInput< TAccountPool extends string = string, TAccountOwner extends string = string, diff --git a/clients/quarry/src/generated/instructions/initMergeMinerV2.ts b/clients/quarry/src/generated/instructions/initMergeMinerV2.ts index 9d0dfef3..373b47ba 100644 --- a/clients/quarry/src/generated/instructions/initMergeMinerV2.ts +++ b/clients/quarry/src/generated/instructions/initMergeMinerV2.ts @@ -26,21 +26,18 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from "@solana/kit"; import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const INIT_MERGE_MINER_V2_DISCRIMINATOR = new Uint8Array([ - 153, 44, 29, 197, 171, 114, 71, 208, -]); +export const INIT_MERGE_MINER_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([153, 44, 29, 197, 171, 114, 71, 208]); export function getInitMergeMinerV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -109,106 +106,6 @@ export function getInitMergeMinerV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface InitMergeMinerV2AsyncInput< - TAccountPool extends string = string, - TAccountOwner extends string = string, - TAccountMm extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - pool: Address; - owner: Address; - mm?: Address; - payer: TransactionSigner; - systemProgram?: Address; -} - -export async function getInitMergeMinerV2InstructionAsync< - TAccountPool extends string, - TAccountOwner extends string, - TAccountMm extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, ->( - input: InitMergeMinerV2AsyncInput< - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - InitMergeMinerV2Instruction< - TProgramAddress, - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MERGE_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pool: { value: input.pool ?? null, isWritable: false }, - owner: { value: input.owner ?? null, isWritable: false }, - mm: { value: input.mm ?? null, isWritable: true }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.mm.value) { - accounts.mm.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 77, 101, 114, 103, 101, 77, 105, 110, 101, 114, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.pool.value)), - getAddressEncoder().encode(expectAddress(accounts.owner.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.pool), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitMergeMinerV2InstructionDataEncoder().encode({}), - } as InitMergeMinerV2Instruction< - TProgramAddress, - TAccountPool, - TAccountOwner, - TAccountMm, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface InitMergeMinerV2Input< TAccountPool extends string = string, TAccountOwner extends string = string, diff --git a/clients/quarry/src/generated/instructions/initMinerMM.ts b/clients/quarry/src/generated/instructions/initMinerMM.ts index 3934b10d..75d34720 100644 --- a/clients/quarry/src/generated/instructions/initMinerMM.ts +++ b/clients/quarry/src/generated/instructions/initMinerMM.ts @@ -38,7 +38,7 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const INIT_MINER_M_M_DISCRIMINATOR = new Uint8Array([ +export const INIT_MINER_M_M_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 144, 159, 202, 208, 234, 154, 242, 55, ]); diff --git a/clients/quarry/src/generated/instructions/initMinerMMV2.ts b/clients/quarry/src/generated/instructions/initMinerMMV2.ts index 9ac0a952..2719a3f4 100644 --- a/clients/quarry/src/generated/instructions/initMinerMMV2.ts +++ b/clients/quarry/src/generated/instructions/initMinerMMV2.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const INIT_MINER_M_M_V2_DISCRIMINATOR = new Uint8Array([ - 189, 125, 116, 157, 73, 4, 253, 156, -]); +export const INIT_MINER_M_M_V2_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([189, 125, 116, 157, 73, 4, 253, 156]); export function getInitMinerMMV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/minterUpdate.ts b/clients/quarry/src/generated/instructions/minterUpdate.ts index caa8f292..436dda4a 100644 --- a/clients/quarry/src/generated/instructions/minterUpdate.ts +++ b/clients/quarry/src/generated/instructions/minterUpdate.ts @@ -37,7 +37,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const MINTER_UPDATE_DISCRIMINATOR = new Uint8Array([ +export const MINTER_UPDATE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 11, 219, 68, 245, 38, 222, 221, 184, ]); @@ -49,21 +49,21 @@ export function getMinterUpdateDiscriminatorBytes(): ReadonlyUint8Array { export type MinterUpdateInstruction< TProgram extends string = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, - TAccountMintWrapper extends string | AccountMeta = string, - TAccountAdmin extends string | AccountMeta = string, + TAccountMinterUpdateAuthMintWrapper extends string | AccountMeta = string, + TAccountMinterUpdateAuthAdmin extends string | AccountMeta = string, TAccountMinter extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountMintWrapper extends string - ? WritableAccount - : TAccountMintWrapper, - TAccountAdmin extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAdmin, + TAccountMinterUpdateAuthMintWrapper extends string + ? WritableAccount + : TAccountMinterUpdateAuthMintWrapper, + TAccountMinterUpdateAuthAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountMinterUpdateAuthAdmin, TAccountMinter extends string ? WritableAccount : TAccountMinter, @@ -108,28 +108,32 @@ export function getMinterUpdateInstructionDataCodec(): FixedSizeCodec< } export interface MinterUpdateInput< - TAccountMintWrapper extends string = string, - TAccountAdmin extends string = string, + TAccountMinterUpdateAuthMintWrapper extends string = string, + TAccountMinterUpdateAuthAdmin extends string = string, TAccountMinter extends string = string, > { - mintWrapper: Address; - admin: TransactionSigner; + minterUpdateAuthMintWrapper: Address; + minterUpdateAuthAdmin: TransactionSigner; minter: Address; allowance: MinterUpdateInstructionDataArgs["allowance"]; } export function getMinterUpdateInstruction< - TAccountMintWrapper extends string, - TAccountAdmin extends string, + TAccountMinterUpdateAuthMintWrapper extends string, + TAccountMinterUpdateAuthAdmin extends string, TAccountMinter extends string, TProgramAddress extends Address = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, >( - input: MinterUpdateInput, + input: MinterUpdateInput< + TAccountMinterUpdateAuthMintWrapper, + TAccountMinterUpdateAuthAdmin, + TAccountMinter + >, config?: { programAddress?: TProgramAddress }, ): MinterUpdateInstruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountMinterUpdateAuthMintWrapper, + TAccountMinterUpdateAuthAdmin, TAccountMinter > { // Program address. @@ -138,8 +142,14 @@ export function getMinterUpdateInstruction< // Original accounts. const originalAccounts = { - mintWrapper: { value: input.mintWrapper ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, + minterUpdateAuthMintWrapper: { + value: input.minterUpdateAuthMintWrapper ?? null, + isWritable: true, + }, + minterUpdateAuthAdmin: { + value: input.minterUpdateAuthAdmin ?? null, + isWritable: false, + }, minter: { value: input.minter ?? null, isWritable: true }, }; const accounts = originalAccounts as Record< @@ -153,8 +163,8 @@ export function getMinterUpdateInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.admin), + getAccountMeta(accounts.minterUpdateAuthMintWrapper), + getAccountMeta(accounts.minterUpdateAuthAdmin), getAccountMeta(accounts.minter), ], programAddress, @@ -163,8 +173,8 @@ export function getMinterUpdateInstruction< ), } as MinterUpdateInstruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountMinterUpdateAuthMintWrapper, + TAccountMinterUpdateAuthAdmin, TAccountMinter >; @@ -177,8 +187,8 @@ export interface ParsedMinterUpdateInstruction< > { programAddress: Address; accounts: { - mintWrapper: TAccountMetas[0]; - admin: TAccountMetas[1]; + minterUpdateAuthMintWrapper: TAccountMetas[0]; + minterUpdateAuthAdmin: TAccountMetas[1]; minter: TAccountMetas[2]; }; data: MinterUpdateInstructionData; @@ -205,8 +215,8 @@ export function parseMinterUpdateInstruction< return { programAddress: instruction.programAddress, accounts: { - mintWrapper: getNextAccount(), - admin: getNextAccount(), + minterUpdateAuthMintWrapper: getNextAccount(), + minterUpdateAuthAdmin: getNextAccount(), minter: getNextAccount(), }, data: getMinterUpdateInstructionDataDecoder().decode(instruction.data), diff --git a/clients/quarry/src/generated/instructions/newMinter.ts b/clients/quarry/src/generated/instructions/newMinter.ts index dde35e7e..bec115b3 100644 --- a/clients/quarry/src/generated/instructions/newMinter.ts +++ b/clients/quarry/src/generated/instructions/newMinter.ts @@ -39,7 +39,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_MINTER_DISCRIMINATOR = new Uint8Array([ +export const NEW_MINTER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 14, 95, 216, 55, 122, 115, 37, 250, ]); @@ -49,8 +49,8 @@ export function getNewMinterDiscriminatorBytes(): ReadonlyUint8Array { export type NewMinterInstruction< TProgram extends string = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, - TAccountMintWrapper extends string | AccountMeta = string, - TAccountAdmin extends string | AccountMeta = string, + TAccountNewMinterAuthMintWrapper extends string | AccountMeta = string, + TAccountNewMinterAuthAdmin extends string | AccountMeta = string, TAccountNewMinterAuthority extends string | AccountMeta = string, TAccountMinter extends string | AccountMeta = string, TAccountPayer extends string | AccountMeta = string, @@ -62,13 +62,13 @@ export type NewMinterInstruction< InstructionWithData & InstructionWithAccounts< [ - TAccountMintWrapper extends string - ? WritableAccount - : TAccountMintWrapper, - TAccountAdmin extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAdmin, + TAccountNewMinterAuthMintWrapper extends string + ? WritableAccount + : TAccountNewMinterAuthMintWrapper, + TAccountNewMinterAuthAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountNewMinterAuthAdmin, TAccountNewMinterAuthority extends string ? ReadonlyAccount : TAccountNewMinterAuthority, @@ -123,15 +123,15 @@ export function getNewMinterInstructionDataCodec(): FixedSizeCodec< } export interface NewMinterInput< - TAccountMintWrapper extends string = string, - TAccountAdmin extends string = string, + TAccountNewMinterAuthMintWrapper extends string = string, + TAccountNewMinterAuthAdmin extends string = string, TAccountNewMinterAuthority extends string = string, TAccountMinter extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string, > { - mintWrapper: Address; - admin: TransactionSigner; + newMinterAuthMintWrapper: Address; + newMinterAuthAdmin: TransactionSigner; newMinterAuthority: Address; minter: Address; payer: TransactionSigner; @@ -140,8 +140,8 @@ export interface NewMinterInput< } export function getNewMinterInstruction< - TAccountMintWrapper extends string, - TAccountAdmin extends string, + TAccountNewMinterAuthMintWrapper extends string, + TAccountNewMinterAuthAdmin extends string, TAccountNewMinterAuthority extends string, TAccountMinter extends string, TAccountPayer extends string, @@ -149,8 +149,8 @@ export function getNewMinterInstruction< TProgramAddress extends Address = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, >( input: NewMinterInput< - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterAuthMintWrapper, + TAccountNewMinterAuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -159,8 +159,8 @@ export function getNewMinterInstruction< config?: { programAddress?: TProgramAddress }, ): NewMinterInstruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterAuthMintWrapper, + TAccountNewMinterAuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -172,8 +172,14 @@ export function getNewMinterInstruction< // Original accounts. const originalAccounts = { - mintWrapper: { value: input.mintWrapper ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, + newMinterAuthMintWrapper: { + value: input.newMinterAuthMintWrapper ?? null, + isWritable: true, + }, + newMinterAuthAdmin: { + value: input.newMinterAuthAdmin ?? null, + isWritable: false, + }, newMinterAuthority: { value: input.newMinterAuthority ?? null, isWritable: false, @@ -199,8 +205,8 @@ export function getNewMinterInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.admin), + getAccountMeta(accounts.newMinterAuthMintWrapper), + getAccountMeta(accounts.newMinterAuthAdmin), getAccountMeta(accounts.newMinterAuthority), getAccountMeta(accounts.minter), getAccountMeta(accounts.payer), @@ -212,8 +218,8 @@ export function getNewMinterInstruction< ), } as NewMinterInstruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterAuthMintWrapper, + TAccountNewMinterAuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -229,8 +235,8 @@ export interface ParsedNewMinterInstruction< > { programAddress: Address; accounts: { - mintWrapper: TAccountMetas[0]; - admin: TAccountMetas[1]; + newMinterAuthMintWrapper: TAccountMetas[0]; + newMinterAuthAdmin: TAccountMetas[1]; newMinterAuthority: TAccountMetas[2]; minter: TAccountMetas[3]; payer: TAccountMetas[4]; @@ -260,8 +266,8 @@ export function parseNewMinterInstruction< return { programAddress: instruction.programAddress, accounts: { - mintWrapper: getNextAccount(), - admin: getNextAccount(), + newMinterAuthMintWrapper: getNextAccount(), + newMinterAuthAdmin: getNextAccount(), newMinterAuthority: getNextAccount(), minter: getNextAccount(), payer: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/newMinterV2.ts b/clients/quarry/src/generated/instructions/newMinterV2.ts index c2ecdfda..e41a78da 100644 --- a/clients/quarry/src/generated/instructions/newMinterV2.ts +++ b/clients/quarry/src/generated/instructions/newMinterV2.ts @@ -37,7 +37,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_MINTER_V2_DISCRIMINATOR = new Uint8Array([ +export const NEW_MINTER_V2_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 7, 93, 245, 202, 126, 212, 61, 195, ]); @@ -49,8 +49,8 @@ export function getNewMinterV2DiscriminatorBytes(): ReadonlyUint8Array { export type NewMinterV2Instruction< TProgram extends string = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, - TAccountMintWrapper extends string | AccountMeta = string, - TAccountAdmin extends string | AccountMeta = string, + TAccountNewMinterV2AuthMintWrapper extends string | AccountMeta = string, + TAccountNewMinterV2AuthAdmin extends string | AccountMeta = string, TAccountNewMinterAuthority extends string | AccountMeta = string, TAccountMinter extends string | AccountMeta = string, TAccountPayer extends string | AccountMeta = string, @@ -62,13 +62,13 @@ export type NewMinterV2Instruction< InstructionWithData & InstructionWithAccounts< [ - TAccountMintWrapper extends string - ? WritableAccount - : TAccountMintWrapper, - TAccountAdmin extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAdmin, + TAccountNewMinterV2AuthMintWrapper extends string + ? WritableAccount + : TAccountNewMinterV2AuthMintWrapper, + TAccountNewMinterV2AuthAdmin extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountNewMinterV2AuthAdmin, TAccountNewMinterAuthority extends string ? ReadonlyAccount : TAccountNewMinterAuthority, @@ -116,15 +116,15 @@ export function getNewMinterV2InstructionDataCodec(): FixedSizeCodec< } export interface NewMinterV2Input< - TAccountMintWrapper extends string = string, - TAccountAdmin extends string = string, + TAccountNewMinterV2AuthMintWrapper extends string = string, + TAccountNewMinterV2AuthAdmin extends string = string, TAccountNewMinterAuthority extends string = string, TAccountMinter extends string = string, TAccountPayer extends string = string, TAccountSystemProgram extends string = string, > { - mintWrapper: Address; - admin: TransactionSigner; + newMinterV2AuthMintWrapper: Address; + newMinterV2AuthAdmin: TransactionSigner; newMinterAuthority: Address; minter: Address; payer: TransactionSigner; @@ -132,8 +132,8 @@ export interface NewMinterV2Input< } export function getNewMinterV2Instruction< - TAccountMintWrapper extends string, - TAccountAdmin extends string, + TAccountNewMinterV2AuthMintWrapper extends string, + TAccountNewMinterV2AuthAdmin extends string, TAccountNewMinterAuthority extends string, TAccountMinter extends string, TAccountPayer extends string, @@ -141,8 +141,8 @@ export function getNewMinterV2Instruction< TProgramAddress extends Address = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, >( input: NewMinterV2Input< - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterV2AuthMintWrapper, + TAccountNewMinterV2AuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -151,8 +151,8 @@ export function getNewMinterV2Instruction< config?: { programAddress?: TProgramAddress }, ): NewMinterV2Instruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterV2AuthMintWrapper, + TAccountNewMinterV2AuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -164,8 +164,14 @@ export function getNewMinterV2Instruction< // Original accounts. const originalAccounts = { - mintWrapper: { value: input.mintWrapper ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, + newMinterV2AuthMintWrapper: { + value: input.newMinterV2AuthMintWrapper ?? null, + isWritable: true, + }, + newMinterV2AuthAdmin: { + value: input.newMinterV2AuthAdmin ?? null, + isWritable: false, + }, newMinterAuthority: { value: input.newMinterAuthority ?? null, isWritable: false, @@ -188,8 +194,8 @@ export function getNewMinterV2Instruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.admin), + getAccountMeta(accounts.newMinterV2AuthMintWrapper), + getAccountMeta(accounts.newMinterV2AuthAdmin), getAccountMeta(accounts.newMinterAuthority), getAccountMeta(accounts.minter), getAccountMeta(accounts.payer), @@ -199,8 +205,8 @@ export function getNewMinterV2Instruction< data: getNewMinterV2InstructionDataEncoder().encode({}), } as NewMinterV2Instruction< TProgramAddress, - TAccountMintWrapper, - TAccountAdmin, + TAccountNewMinterV2AuthMintWrapper, + TAccountNewMinterV2AuthAdmin, TAccountNewMinterAuthority, TAccountMinter, TAccountPayer, @@ -216,8 +222,8 @@ export interface ParsedNewMinterV2Instruction< > { programAddress: Address; accounts: { - mintWrapper: TAccountMetas[0]; - admin: TAccountMetas[1]; + newMinterV2AuthMintWrapper: TAccountMetas[0]; + newMinterV2AuthAdmin: TAccountMetas[1]; newMinterAuthority: TAccountMetas[2]; minter: TAccountMetas[3]; payer: TAccountMetas[4]; @@ -247,8 +253,8 @@ export function parseNewMinterV2Instruction< return { programAddress: instruction.programAddress, accounts: { - mintWrapper: getNextAccount(), - admin: getNextAccount(), + newMinterV2AuthMintWrapper: getNextAccount(), + newMinterV2AuthAdmin: getNextAccount(), newMinterAuthority: getNextAccount(), minter: getNextAccount(), payer: getNextAccount(), diff --git a/clients/quarry/src/generated/instructions/newPool.ts b/clients/quarry/src/generated/instructions/newPool.ts index 63d657e8..44bdba61 100644 --- a/clients/quarry/src/generated/instructions/newPool.ts +++ b/clients/quarry/src/generated/instructions/newPool.ts @@ -26,10 +26,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -38,9 +36,9 @@ import { } from "@solana/kit"; import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_POOL_DISCRIMINATOR = new Uint8Array([ +export const NEW_POOL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 38, 63, 210, 32, 246, 20, 239, 112, ]); @@ -134,147 +132,6 @@ export function getNewPoolInstructionDataCodec(): FixedSizeCodec< ); } -export interface NewPoolAsyncInput< - TAccountPool extends string = string, - TAccountPrimaryMint extends string = string, - TAccountReplicaMint extends string = string, - TAccountPayer extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountRent extends string = string, -> { - pool?: Address; - primaryMint: Address; - replicaMint?: Address; - payer: TransactionSigner; - tokenProgram?: Address; - systemProgram?: Address; - rent?: Address; - bump: NewPoolInstructionDataArgs["bump"]; - mintBump: NewPoolInstructionDataArgs["mintBump"]; -} - -export async function getNewPoolInstructionAsync< - TAccountPool extends string, - TAccountPrimaryMint extends string, - TAccountReplicaMint extends string, - TAccountPayer extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountRent extends string, - TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, ->( - input: NewPoolAsyncInput< - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewPoolInstruction< - TProgramAddress, - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MERGE_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pool: { value: input.pool ?? null, isWritable: true }, - primaryMint: { value: input.primaryMint ?? null, isWritable: false }, - replicaMint: { value: input.replicaMint ?? null, isWritable: true }, - payer: { value: input.payer ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - rent: { value: input.rent ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.pool.value) { - accounts.pool.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 77, 101, 114, 103, 101, 80, 111, 111, 108, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.primaryMint.value)), - ], - }); - } - if (!accounts.replicaMint.value) { - accounts.replicaMint.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 82, 101, 112, 108, 105, 99, 97, 77, 105, 110, 116, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.pool.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.rent.value) { - accounts.rent.value = - "SysvarRent111111111111111111111111111111111" as Address<"SysvarRent111111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.pool), - getAccountMeta(accounts.primaryMint), - getAccountMeta(accounts.replicaMint), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.rent), - ], - programAddress, - data: getNewPoolInstructionDataEncoder().encode( - args as NewPoolInstructionDataArgs, - ), - } as NewPoolInstruction< - TProgramAddress, - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - >; - - return instruction; -} - export interface NewPoolInput< TAccountPool extends string = string, TAccountPrimaryMint extends string = string, diff --git a/clients/quarry/src/generated/instructions/newPoolV2.ts b/clients/quarry/src/generated/instructions/newPoolV2.ts index 6a2a5820..e4d42c5a 100644 --- a/clients/quarry/src/generated/instructions/newPoolV2.ts +++ b/clients/quarry/src/generated/instructions/newPoolV2.ts @@ -26,19 +26,17 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from "@solana/kit"; import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_POOL_V2_DISCRIMINATOR = new Uint8Array([ +export const NEW_POOL_V2_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 107, 122, 206, 99, 39, 6, 23, 195, ]); @@ -121,140 +119,6 @@ export function getNewPoolV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface NewPoolV2AsyncInput< - TAccountPool extends string = string, - TAccountPrimaryMint extends string = string, - TAccountReplicaMint extends string = string, - TAccountPayer extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountRent extends string = string, -> { - pool?: Address; - primaryMint: Address; - replicaMint?: Address; - payer: TransactionSigner; - tokenProgram?: Address; - systemProgram?: Address; - rent?: Address; -} - -export async function getNewPoolV2InstructionAsync< - TAccountPool extends string, - TAccountPrimaryMint extends string, - TAccountReplicaMint extends string, - TAccountPayer extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountRent extends string, - TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, ->( - input: NewPoolV2AsyncInput< - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewPoolV2Instruction< - TProgramAddress, - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MERGE_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pool: { value: input.pool ?? null, isWritable: true }, - primaryMint: { value: input.primaryMint ?? null, isWritable: false }, - replicaMint: { value: input.replicaMint ?? null, isWritable: true }, - payer: { value: input.payer ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - rent: { value: input.rent ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.pool.value) { - accounts.pool.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 77, 101, 114, 103, 101, 80, 111, 111, 108, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.primaryMint.value)), - ], - }); - } - if (!accounts.replicaMint.value) { - accounts.replicaMint.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 82, 101, 112, 108, 105, 99, 97, 77, 105, 110, 116, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.pool.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - if (!accounts.rent.value) { - accounts.rent.value = - "SysvarRent111111111111111111111111111111111" as Address<"SysvarRent111111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.pool), - getAccountMeta(accounts.primaryMint), - getAccountMeta(accounts.replicaMint), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.rent), - ], - programAddress, - data: getNewPoolV2InstructionDataEncoder().encode({}), - } as NewPoolV2Instruction< - TProgramAddress, - TAccountPool, - TAccountPrimaryMint, - TAccountReplicaMint, - TAccountPayer, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountRent - >; - - return instruction; -} - export interface NewPoolV2Input< TAccountPool extends string = string, TAccountPrimaryMint extends string = string, diff --git a/clients/quarry/src/generated/instructions/newRegistry.ts b/clients/quarry/src/generated/instructions/newRegistry.ts index 7c66c7f8..5d6edcc4 100644 --- a/clients/quarry/src/generated/instructions/newRegistry.ts +++ b/clients/quarry/src/generated/instructions/newRegistry.ts @@ -26,10 +26,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -40,9 +38,9 @@ import { } from "@solana/kit"; import { QUARRY_REGISTRY_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_REGISTRY_DISCRIMINATOR = new Uint8Array([ +export const NEW_REGISTRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 237, 187, 50, 70, 74, 26, 144, 230, ]); @@ -122,105 +120,6 @@ export function getNewRegistryInstructionDataCodec(): FixedSizeCodec< ); } -export interface NewRegistryAsyncInput< - TAccountRewarder extends string = string, - TAccountRegistry extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - rewarder: Address; - registry?: Address; - payer: TransactionSigner; - systemProgram?: Address; - maxQuarries: NewRegistryInstructionDataArgs["maxQuarries"]; - bump: NewRegistryInstructionDataArgs["bump"]; -} - -export async function getNewRegistryInstructionAsync< - TAccountRewarder extends string, - TAccountRegistry extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_REGISTRY_PROGRAM_ADDRESS, ->( - input: NewRegistryAsyncInput< - TAccountRewarder, - TAccountRegistry, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewRegistryInstruction< - TProgramAddress, - TAccountRewarder, - TAccountRegistry, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_REGISTRY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - rewarder: { value: input.rewarder ?? null, isWritable: false }, - registry: { value: input.registry ?? null, isWritable: true }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.registry.value) { - accounts.registry.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 81, 117, 97, 114, 114, 121, 82, 101, 103, 105, 115, 116, 114, - 121, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.rewarder.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.registry), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getNewRegistryInstructionDataEncoder().encode( - args as NewRegistryInstructionDataArgs, - ), - } as NewRegistryInstruction< - TProgramAddress, - TAccountRewarder, - TAccountRegistry, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface NewRegistryInput< TAccountRewarder extends string = string, TAccountRegistry extends string = string, diff --git a/clients/quarry/src/generated/instructions/newRewarder.ts b/clients/quarry/src/generated/instructions/newRewarder.ts index bb02e9c0..d537ebf4 100644 --- a/clients/quarry/src/generated/instructions/newRewarder.ts +++ b/clients/quarry/src/generated/instructions/newRewarder.ts @@ -27,10 +27,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -39,9 +37,9 @@ import { } from "@solana/kit"; import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_REWARDER_DISCRIMINATOR = new Uint8Array([ +export const NEW_REWARDER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 1, 115, 16, 244, 109, 74, 67, 209, ]); @@ -137,149 +135,6 @@ export function getNewRewarderInstructionDataCodec(): FixedSizeCodec< ); } -export interface NewRewarderAsyncInput< - TAccountBase extends string = string, - TAccountRewarder extends string = string, - TAccountInitialAuthority extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, - TAccountUnusedAccount extends string = string, - TAccountMintWrapper extends string = string, - TAccountRewardsTokenMint extends string = string, - TAccountClaimFeeTokenAccount extends string = string, -> { - base: TransactionSigner; - rewarder?: Address; - initialAuthority: Address; - payer: TransactionSigner; - systemProgram?: Address; - unusedAccount: Address; - mintWrapper: Address; - rewardsTokenMint: Address; - claimFeeTokenAccount: Address; - bump: NewRewarderInstructionDataArgs["bump"]; -} - -export async function getNewRewarderInstructionAsync< - TAccountBase extends string, - TAccountRewarder extends string, - TAccountInitialAuthority extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TAccountUnusedAccount extends string, - TAccountMintWrapper extends string, - TAccountRewardsTokenMint extends string, - TAccountClaimFeeTokenAccount extends string, - TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, ->( - input: NewRewarderAsyncInput< - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountUnusedAccount, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewRewarderInstruction< - TProgramAddress, - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountUnusedAccount, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - > -> { - // Program address. - const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - initialAuthority: { - value: input.initialAuthority ?? null, - isWritable: false, - }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - unusedAccount: { value: input.unusedAccount ?? null, isWritable: false }, - mintWrapper: { value: input.mintWrapper ?? null, isWritable: false }, - rewardsTokenMint: { - value: input.rewardsTokenMint ?? null, - isWritable: false, - }, - claimFeeTokenAccount: { - value: input.claimFeeTokenAccount ?? null, - isWritable: false, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.rewarder.value) { - accounts.rewarder.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 82, 101, 119, 97, 114, 100, 101, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.initialAuthority), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.unusedAccount), - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.rewardsTokenMint), - getAccountMeta(accounts.claimFeeTokenAccount), - ], - programAddress, - data: getNewRewarderInstructionDataEncoder().encode( - args as NewRewarderInstructionDataArgs, - ), - } as NewRewarderInstruction< - TProgramAddress, - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountUnusedAccount, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - >; - - return instruction; -} - export interface NewRewarderInput< TAccountBase extends string = string, TAccountRewarder extends string = string, diff --git a/clients/quarry/src/generated/instructions/newRewarderV2.ts b/clients/quarry/src/generated/instructions/newRewarderV2.ts index fe9f90b1..63dd7924 100644 --- a/clients/quarry/src/generated/instructions/newRewarderV2.ts +++ b/clients/quarry/src/generated/instructions/newRewarderV2.ts @@ -27,21 +27,19 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from "@solana/kit"; import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_REWARDER_V2_DISCRIMINATOR = new Uint8Array([ - 173, 189, 26, 25, 79, 177, 60, 173, -]); +export const NEW_REWARDER_V2_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [173, 189, 26, 25, 79, 177, 60, 173], +); export function getNewRewarderV2DiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -124,135 +122,6 @@ export function getNewRewarderV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface NewRewarderV2AsyncInput< - TAccountBase extends string = string, - TAccountRewarder extends string = string, - TAccountInitialAuthority extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, - TAccountMintWrapper extends string = string, - TAccountRewardsTokenMint extends string = string, - TAccountClaimFeeTokenAccount extends string = string, -> { - base: TransactionSigner; - rewarder?: Address; - initialAuthority: Address; - payer: TransactionSigner; - systemProgram?: Address; - mintWrapper: Address; - rewardsTokenMint: Address; - claimFeeTokenAccount: Address; -} - -export async function getNewRewarderV2InstructionAsync< - TAccountBase extends string, - TAccountRewarder extends string, - TAccountInitialAuthority extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TAccountMintWrapper extends string, - TAccountRewardsTokenMint extends string, - TAccountClaimFeeTokenAccount extends string, - TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, ->( - input: NewRewarderV2AsyncInput< - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewRewarderV2Instruction< - TProgramAddress, - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - > -> { - // Program address. - const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, - initialAuthority: { - value: input.initialAuthority ?? null, - isWritable: false, - }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - mintWrapper: { value: input.mintWrapper ?? null, isWritable: false }, - rewardsTokenMint: { - value: input.rewardsTokenMint ?? null, - isWritable: false, - }, - claimFeeTokenAccount: { - value: input.claimFeeTokenAccount ?? null, - isWritable: false, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.rewarder.value) { - accounts.rewarder.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([34, 82, 101, 119, 97, 114, 100, 101, 114, 34]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.initialAuthority), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.rewardsTokenMint), - getAccountMeta(accounts.claimFeeTokenAccount), - ], - programAddress, - data: getNewRewarderV2InstructionDataEncoder().encode({}), - } as NewRewarderV2Instruction< - TProgramAddress, - TAccountBase, - TAccountRewarder, - TAccountInitialAuthority, - TAccountPayer, - TAccountSystemProgram, - TAccountMintWrapper, - TAccountRewardsTokenMint, - TAccountClaimFeeTokenAccount - >; - - return instruction; -} - export interface NewRewarderV2Input< TAccountBase extends string = string, TAccountRewarder extends string = string, diff --git a/clients/quarry/src/generated/instructions/newWrapper.ts b/clients/quarry/src/generated/instructions/newWrapper.ts index 1edac049..82e84540 100644 --- a/clients/quarry/src/generated/instructions/newWrapper.ts +++ b/clients/quarry/src/generated/instructions/newWrapper.ts @@ -27,10 +27,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU8Decoder, @@ -41,9 +39,9 @@ import { } from "@solana/kit"; import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_WRAPPER_DISCRIMINATOR = new Uint8Array([ +export const NEW_WRAPPER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 106, 226, 139, 13, 35, 121, 62, 171, ]); @@ -135,132 +133,6 @@ export function getNewWrapperInstructionDataCodec(): FixedSizeCodec< ); } -export interface NewWrapperAsyncInput< - TAccountBase extends string = string, - TAccountMintWrapper extends string = string, - TAccountAdmin extends string = string, - TAccountTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - base: TransactionSigner; - mintWrapper?: Address; - admin: Address; - tokenMint: Address; - tokenProgram?: Address; - payer: TransactionSigner; - systemProgram?: Address; - bump: NewWrapperInstructionDataArgs["bump"]; - hardCap: NewWrapperInstructionDataArgs["hardCap"]; -} - -export async function getNewWrapperInstructionAsync< - TAccountBase extends string, - TAccountMintWrapper extends string, - TAccountAdmin extends string, - TAccountTokenMint extends string, - TAccountTokenProgram extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, ->( - input: NewWrapperAsyncInput< - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewWrapperInstruction< - TProgramAddress, - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - mintWrapper: { value: input.mintWrapper ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, - tokenMint: { value: input.tokenMint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.mintWrapper.value) { - accounts.mintWrapper.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 77, 105, 110, 116, 87, 114, 97, 112, 112, 101, 114, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.admin), - getAccountMeta(accounts.tokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getNewWrapperInstructionDataEncoder().encode( - args as NewWrapperInstructionDataArgs, - ), - } as NewWrapperInstruction< - TProgramAddress, - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface NewWrapperInput< TAccountBase extends string = string, TAccountMintWrapper extends string = string, diff --git a/clients/quarry/src/generated/instructions/newWrapperV2.ts b/clients/quarry/src/generated/instructions/newWrapperV2.ts index d547059e..dc520fe9 100644 --- a/clients/quarry/src/generated/instructions/newWrapperV2.ts +++ b/clients/quarry/src/generated/instructions/newWrapperV2.ts @@ -27,10 +27,8 @@ import { combineCodec, fixDecoderSize, fixEncoderSize, - getAddressEncoder, getBytesDecoder, getBytesEncoder, - getProgramDerivedAddress, getStructDecoder, getStructEncoder, getU64Decoder, @@ -39,9 +37,9 @@ import { } from "@solana/kit"; import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; -import { expectAddress, getAccountMetaFactory } from "../shared/index.js"; +import { getAccountMetaFactory } from "../shared/index.js"; -export const NEW_WRAPPER_V2_DISCRIMINATOR = new Uint8Array([ +export const NEW_WRAPPER_V2_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 140, 106, 205, 202, 15, 176, 85, 19, ]); @@ -131,131 +129,6 @@ export function getNewWrapperV2InstructionDataCodec(): FixedSizeCodec< ); } -export interface NewWrapperV2AsyncInput< - TAccountBase extends string = string, - TAccountMintWrapper extends string = string, - TAccountAdmin extends string = string, - TAccountTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountPayer extends string = string, - TAccountSystemProgram extends string = string, -> { - base: TransactionSigner; - mintWrapper?: Address; - admin: Address; - tokenMint: Address; - tokenProgram?: Address; - payer: TransactionSigner; - systemProgram?: Address; - hardCap: NewWrapperV2InstructionDataArgs["hardCap"]; -} - -export async function getNewWrapperV2InstructionAsync< - TAccountBase extends string, - TAccountMintWrapper extends string, - TAccountAdmin extends string, - TAccountTokenMint extends string, - TAccountTokenProgram extends string, - TAccountPayer extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS, ->( - input: NewWrapperV2AsyncInput< - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress }, -): Promise< - NewWrapperV2Instruction< - TProgramAddress, - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - base: { value: input.base ?? null, isWritable: false }, - mintWrapper: { value: input.mintWrapper ?? null, isWritable: true }, - admin: { value: input.admin ?? null, isWritable: false }, - tokenMint: { value: input.tokenMint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.mintWrapper.value) { - accounts.mintWrapper.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 34, 77, 105, 110, 116, 87, 114, 97, 112, 112, 101, 114, 34, - ]), - ), - getAddressEncoder().encode(expectAddress(accounts.base.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); - const instruction = { - accounts: [ - getAccountMeta(accounts.base), - getAccountMeta(accounts.mintWrapper), - getAccountMeta(accounts.admin), - getAccountMeta(accounts.tokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getNewWrapperV2InstructionDataEncoder().encode( - args as NewWrapperV2InstructionDataArgs, - ), - } as NewWrapperV2Instruction< - TProgramAddress, - TAccountBase, - TAccountMintWrapper, - TAccountAdmin, - TAccountTokenMint, - TAccountTokenProgram, - TAccountPayer, - TAccountSystemProgram - >; - - return instruction; -} - export interface NewWrapperV2Input< TAccountBase extends string = string, TAccountMintWrapper extends string = string, diff --git a/clients/quarry/src/generated/instructions/pause.ts b/clients/quarry/src/generated/instructions/pause.ts index b00a00bd..c4920ee0 100644 --- a/clients/quarry/src/generated/instructions/pause.ts +++ b/clients/quarry/src/generated/instructions/pause.ts @@ -35,7 +35,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const PAUSE_DISCRIMINATOR = new Uint8Array([ +export const PAUSE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 211, 22, 221, 251, 74, 121, 193, 47, ]); diff --git a/clients/quarry/src/generated/instructions/performMint.ts b/clients/quarry/src/generated/instructions/performMint.ts index 29ac0fa3..732d22b3 100644 --- a/clients/quarry/src/generated/instructions/performMint.ts +++ b/clients/quarry/src/generated/instructions/performMint.ts @@ -38,7 +38,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const PERFORM_MINT_DISCRIMINATOR = new Uint8Array([ +export const PERFORM_MINT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 8, 41, 142, 248, 38, 22, 106, 23, ]); diff --git a/clients/quarry/src/generated/instructions/redeemAllTokens.ts b/clients/quarry/src/generated/instructions/redeemAllTokens.ts index 68b7b3c8..3713dfc7 100644 --- a/clients/quarry/src/generated/instructions/redeemAllTokens.ts +++ b/clients/quarry/src/generated/instructions/redeemAllTokens.ts @@ -36,9 +36,8 @@ import { QUARRY_REDEEMER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const REDEEM_ALL_TOKENS_DISCRIMINATOR = new Uint8Array([ - 68, 38, 47, 47, 226, 176, 31, 48, -]); +export const REDEEM_ALL_TOKENS_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([68, 38, 47, 47, 226, 176, 31, 48]); export function getRedeemAllTokensDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/redeemTokens.ts b/clients/quarry/src/generated/instructions/redeemTokens.ts index 3e6bd060..be50123e 100644 --- a/clients/quarry/src/generated/instructions/redeemTokens.ts +++ b/clients/quarry/src/generated/instructions/redeemTokens.ts @@ -38,7 +38,7 @@ import { QUARRY_REDEEMER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const REDEEM_TOKENS_DISCRIMINATOR = new Uint8Array([ +export const REDEEM_TOKENS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 246, 98, 134, 41, 152, 33, 120, 69, ]); diff --git a/clients/quarry/src/generated/instructions/rescueTokens.ts b/clients/quarry/src/generated/instructions/rescueTokens.ts index 895ca4f6..9c45d861 100644 --- a/clients/quarry/src/generated/instructions/rescueTokens.ts +++ b/clients/quarry/src/generated/instructions/rescueTokens.ts @@ -36,7 +36,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const RESCUE_TOKENS_DISCRIMINATOR = new Uint8Array([ +export const RESCUE_TOKENS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 222, 81, 199, 209, 182, 62, 62, 186, ]); diff --git a/clients/quarry/src/generated/instructions/rescueTokensMM.ts b/clients/quarry/src/generated/instructions/rescueTokensMM.ts index b605b5ef..3f8ec23e 100644 --- a/clients/quarry/src/generated/instructions/rescueTokensMM.ts +++ b/clients/quarry/src/generated/instructions/rescueTokensMM.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const RESCUE_TOKENS_M_M_DISCRIMINATOR = new Uint8Array([ - 222, 81, 199, 209, 182, 62, 62, 186, -]); +export const RESCUE_TOKENS_M_M_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([222, 81, 199, 209, 182, 62, 62, 186]); export function getRescueTokensMMDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/setAdmin.ts b/clients/quarry/src/generated/instructions/setAdmin.ts index f16252e8..b54b6bbb 100644 --- a/clients/quarry/src/generated/instructions/setAdmin.ts +++ b/clients/quarry/src/generated/instructions/setAdmin.ts @@ -36,7 +36,7 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_ADMIN_DISCRIMINATOR = new Uint8Array([ +export const SET_ADMIN_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 251, 163, 0, 52, 91, 194, 187, 92, ]); diff --git a/clients/quarry/src/generated/instructions/setAnnualRewards.ts b/clients/quarry/src/generated/instructions/setAnnualRewards.ts index 026a3cdb..c55e95c8 100644 --- a/clients/quarry/src/generated/instructions/setAnnualRewards.ts +++ b/clients/quarry/src/generated/instructions/setAnnualRewards.ts @@ -37,9 +37,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_ANNUAL_REWARDS_DISCRIMINATOR = new Uint8Array([ - 135, 125, 92, 160, 100, 101, 141, 84, -]); +export const SET_ANNUAL_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([135, 125, 92, 160, 100, 101, 141, 84]); export function getSetAnnualRewardsDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -49,20 +48,20 @@ export function getSetAnnualRewardsDiscriminatorBytes(): ReadonlyUint8Array { export type SetAnnualRewardsInstruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? WritableAccount + : TAccountAuthRewarder, ...TRemainingAccounts, ] >; @@ -104,33 +103,33 @@ export function getSetAnnualRewardsInstructionDataCodec(): FixedSizeCodec< } export interface SetAnnualRewardsInput< - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, > { - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; newRate: SetAnnualRewardsInstructionDataArgs["newRate"]; } export function getSetAnnualRewardsInstruction< - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( - input: SetAnnualRewardsInput, + input: SetAnnualRewardsInput, config?: { programAddress?: TProgramAddress }, ): SetAnnualRewardsInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder + TAccountAuthAuthority, + TAccountAuthRewarder > { // Program address. const programAddress = config?.programAddress ?? QUARRY_MINE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: true }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -143,8 +142,8 @@ export function getSetAnnualRewardsInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), ], programAddress, data: getSetAnnualRewardsInstructionDataEncoder().encode( @@ -152,8 +151,8 @@ export function getSetAnnualRewardsInstruction< ), } as SetAnnualRewardsInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder + TAccountAuthAuthority, + TAccountAuthRewarder >; return instruction; @@ -165,8 +164,8 @@ export interface ParsedSetAnnualRewardsInstruction< > { programAddress: Address; accounts: { - authority: TAccountMetas[0]; - rewarder: TAccountMetas[1]; + authAuthority: TAccountMetas[0]; + authRewarder: TAccountMetas[1]; }; data: SetAnnualRewardsInstructionData; } @@ -192,8 +191,8 @@ export function parseSetAnnualRewardsInstruction< return { programAddress: instruction.programAddress, accounts: { - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), }, data: getSetAnnualRewardsInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/setFamine.ts b/clients/quarry/src/generated/instructions/setFamine.ts index 7a0bed9c..d4c8ffb1 100644 --- a/clients/quarry/src/generated/instructions/setFamine.ts +++ b/clients/quarry/src/generated/instructions/setFamine.ts @@ -38,7 +38,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_FAMINE_DISCRIMINATOR = new Uint8Array([ +export const SET_FAMINE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 30, 50, 21, 169, 103, 68, 155, 192, ]); @@ -48,21 +48,21 @@ export function getSetFamineDiscriminatorBytes(): ReadonlyUint8Array { export type SetFamineInstruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TAccountQuarry extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? ReadonlyAccount + : TAccountAuthRewarder, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -107,28 +107,32 @@ export function getSetFamineInstructionDataCodec(): FixedSizeCodec< } export interface SetFamineInput< - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, TAccountQuarry extends string = string, > { - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; quarry: Address; famineTs: SetFamineInstructionDataArgs["famineTs"]; } export function getSetFamineInstruction< - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TAccountQuarry extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( - input: SetFamineInput, + input: SetFamineInput< + TAccountAuthAuthority, + TAccountAuthRewarder, + TAccountQuarry + >, config?: { programAddress?: TProgramAddress }, ): SetFamineInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountQuarry > { // Program address. @@ -136,8 +140,8 @@ export function getSetFamineInstruction< // Original accounts. const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: false }, quarry: { value: input.quarry ?? null, isWritable: true }, }; const accounts = originalAccounts as Record< @@ -151,8 +155,8 @@ export function getSetFamineInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), getAccountMeta(accounts.quarry), ], programAddress, @@ -161,8 +165,8 @@ export function getSetFamineInstruction< ), } as SetFamineInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountQuarry >; @@ -175,8 +179,8 @@ export interface ParsedSetFamineInstruction< > { programAddress: Address; accounts: { - authority: TAccountMetas[0]; - rewarder: TAccountMetas[1]; + authAuthority: TAccountMetas[0]; + authRewarder: TAccountMetas[1]; quarry: TAccountMetas[2]; }; data: SetFamineInstructionData; @@ -203,8 +207,8 @@ export function parseSetFamineInstruction< return { programAddress: instruction.programAddress, accounts: { - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), quarry: getNextAccount(), }, data: getSetFamineInstructionDataDecoder().decode(instruction.data), diff --git a/clients/quarry/src/generated/instructions/setPauseAuthority.ts b/clients/quarry/src/generated/instructions/setPauseAuthority.ts index 0acf7603..302ec3e2 100644 --- a/clients/quarry/src/generated/instructions/setPauseAuthority.ts +++ b/clients/quarry/src/generated/instructions/setPauseAuthority.ts @@ -36,9 +36,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_PAUSE_AUTHORITY_DISCRIMINATOR = new Uint8Array([ - 127, 70, 214, 12, 172, 8, 89, 114, -]); +export const SET_PAUSE_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([127, 70, 214, 12, 172, 8, 89, 114]); export function getSetPauseAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -48,21 +47,21 @@ export function getSetPauseAuthorityDiscriminatorBytes(): ReadonlyUint8Array { export type SetPauseAuthorityInstruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TAccountNewPauseAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? WritableAccount + : TAccountAuthRewarder, TAccountNewPauseAuthority extends string ? ReadonlyAccount : TAccountNewPauseAuthority, @@ -100,31 +99,31 @@ export function getSetPauseAuthorityInstructionDataCodec(): FixedSizeCodec< } export interface SetPauseAuthorityInput< - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, TAccountNewPauseAuthority extends string = string, > { - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; newPauseAuthority: Address; } export function getSetPauseAuthorityInstruction< - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TAccountNewPauseAuthority extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( input: SetPauseAuthorityInput< - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountNewPauseAuthority >, config?: { programAddress?: TProgramAddress }, ): SetPauseAuthorityInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountNewPauseAuthority > { // Program address. @@ -132,8 +131,8 @@ export function getSetPauseAuthorityInstruction< // Original accounts. const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: true }, newPauseAuthority: { value: input.newPauseAuthority ?? null, isWritable: false, @@ -147,16 +146,16 @@ export function getSetPauseAuthorityInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), getAccountMeta(accounts.newPauseAuthority), ], programAddress, data: getSetPauseAuthorityInstructionDataEncoder().encode({}), } as SetPauseAuthorityInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountNewPauseAuthority >; @@ -169,8 +168,8 @@ export interface ParsedSetPauseAuthorityInstruction< > { programAddress: Address; accounts: { - authority: TAccountMetas[0]; - rewarder: TAccountMetas[1]; + authAuthority: TAccountMetas[0]; + authRewarder: TAccountMetas[1]; newPauseAuthority: TAccountMetas[2]; }; data: SetPauseAuthorityInstructionData; @@ -197,8 +196,8 @@ export function parseSetPauseAuthorityInstruction< return { programAddress: instruction.programAddress, accounts: { - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), newPauseAuthority: getNextAccount(), }, data: getSetPauseAuthorityInstructionDataDecoder().decode(instruction.data), diff --git a/clients/quarry/src/generated/instructions/setQuarryCreator.ts b/clients/quarry/src/generated/instructions/setQuarryCreator.ts index 478a7c38..9a1ba0e8 100644 --- a/clients/quarry/src/generated/instructions/setQuarryCreator.ts +++ b/clients/quarry/src/generated/instructions/setQuarryCreator.ts @@ -36,9 +36,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_QUARRY_CREATOR_DISCRIMINATOR = new Uint8Array([ - 59, 91, 208, 54, 209, 64, 234, 68, -]); +export const SET_QUARRY_CREATOR_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([59, 91, 208, 54, 209, 64, 234, 68]); export function getSetQuarryCreatorDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/setRateSetter.ts b/clients/quarry/src/generated/instructions/setRateSetter.ts index d4404d12..72039b92 100644 --- a/clients/quarry/src/generated/instructions/setRateSetter.ts +++ b/clients/quarry/src/generated/instructions/setRateSetter.ts @@ -36,9 +36,9 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_RATE_SETTER_DISCRIMINATOR = new Uint8Array([ - 59, 193, 107, 111, 94, 23, 64, 107, -]); +export const SET_RATE_SETTER_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [59, 193, 107, 111, 94, 23, 64, 107], +); export function getSetRateSetterDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/setRewardsShare.ts b/clients/quarry/src/generated/instructions/setRewardsShare.ts index abcf8de1..0d25d782 100644 --- a/clients/quarry/src/generated/instructions/setRewardsShare.ts +++ b/clients/quarry/src/generated/instructions/setRewardsShare.ts @@ -37,9 +37,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_REWARDS_SHARE_DISCRIMINATOR = new Uint8Array([ - 186, 168, 34, 15, 178, 135, 189, 129, -]); +export const SET_REWARDS_SHARE_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([186, 168, 34, 15, 178, 135, 189, 129]); export function getSetRewardsShareDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -49,21 +48,21 @@ export function getSetRewardsShareDiscriminatorBytes(): ReadonlyUint8Array { export type SetRewardsShareInstruction< TProgram extends string = typeof QUARRY_MINE_PROGRAM_ADDRESS, - TAccountAuthority extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, + TAccountAuthAuthority extends string | AccountMeta = string, + TAccountAuthRewarder extends string | AccountMeta = string, TAccountQuarry extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ - TAccountAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthority, - TAccountRewarder extends string - ? WritableAccount - : TAccountRewarder, + TAccountAuthAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthAuthority, + TAccountAuthRewarder extends string + ? WritableAccount + : TAccountAuthRewarder, TAccountQuarry extends string ? WritableAccount : TAccountQuarry, @@ -108,32 +107,32 @@ export function getSetRewardsShareInstructionDataCodec(): FixedSizeCodec< } export interface SetRewardsShareInput< - TAccountAuthority extends string = string, - TAccountRewarder extends string = string, + TAccountAuthAuthority extends string = string, + TAccountAuthRewarder extends string = string, TAccountQuarry extends string = string, > { - authority: TransactionSigner; - rewarder: Address; + authAuthority: TransactionSigner; + authRewarder: Address; quarry: Address; newShare: SetRewardsShareInstructionDataArgs["newShare"]; } export function getSetRewardsShareInstruction< - TAccountAuthority extends string, - TAccountRewarder extends string, + TAccountAuthAuthority extends string, + TAccountAuthRewarder extends string, TAccountQuarry extends string, TProgramAddress extends Address = typeof QUARRY_MINE_PROGRAM_ADDRESS, >( input: SetRewardsShareInput< - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountQuarry >, config?: { programAddress?: TProgramAddress }, ): SetRewardsShareInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountQuarry > { // Program address. @@ -141,8 +140,8 @@ export function getSetRewardsShareInstruction< // Original accounts. const originalAccounts = { - authority: { value: input.authority ?? null, isWritable: false }, - rewarder: { value: input.rewarder ?? null, isWritable: true }, + authAuthority: { value: input.authAuthority ?? null, isWritable: false }, + authRewarder: { value: input.authRewarder ?? null, isWritable: true }, quarry: { value: input.quarry ?? null, isWritable: true }, }; const accounts = originalAccounts as Record< @@ -156,8 +155,8 @@ export function getSetRewardsShareInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); const instruction = { accounts: [ - getAccountMeta(accounts.authority), - getAccountMeta(accounts.rewarder), + getAccountMeta(accounts.authAuthority), + getAccountMeta(accounts.authRewarder), getAccountMeta(accounts.quarry), ], programAddress, @@ -166,8 +165,8 @@ export function getSetRewardsShareInstruction< ), } as SetRewardsShareInstruction< TProgramAddress, - TAccountAuthority, - TAccountRewarder, + TAccountAuthAuthority, + TAccountAuthRewarder, TAccountQuarry >; @@ -180,8 +179,8 @@ export interface ParsedSetRewardsShareInstruction< > { programAddress: Address; accounts: { - authority: TAccountMetas[0]; - rewarder: TAccountMetas[1]; + authAuthority: TAccountMetas[0]; + authRewarder: TAccountMetas[1]; quarry: TAccountMetas[2]; }; data: SetRewardsShareInstructionData; @@ -208,8 +207,8 @@ export function parseSetRewardsShareInstruction< return { programAddress: instruction.programAddress, accounts: { - authority: getNextAccount(), - rewarder: getNextAccount(), + authAuthority: getNextAccount(), + authRewarder: getNextAccount(), quarry: getNextAccount(), }, data: getSetRewardsShareInstructionDataDecoder().decode(instruction.data), diff --git a/clients/quarry/src/generated/instructions/setShareAllocator.ts b/clients/quarry/src/generated/instructions/setShareAllocator.ts index 39349bbd..61bd7316 100644 --- a/clients/quarry/src/generated/instructions/setShareAllocator.ts +++ b/clients/quarry/src/generated/instructions/setShareAllocator.ts @@ -36,9 +36,8 @@ import { QUARRY_OPERATOR_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SET_SHARE_ALLOCATOR_DISCRIMINATOR = new Uint8Array([ - 96, 77, 203, 216, 167, 175, 61, 189, -]); +export const SET_SHARE_ALLOCATOR_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([96, 77, 203, 216, 167, 175, 61, 189]); export function getSetShareAllocatorDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/stakePrimaryMiner.ts b/clients/quarry/src/generated/instructions/stakePrimaryMiner.ts index 15b54e89..5757352c 100644 --- a/clients/quarry/src/generated/instructions/stakePrimaryMiner.ts +++ b/clients/quarry/src/generated/instructions/stakePrimaryMiner.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const STAKE_PRIMARY_MINER_DISCRIMINATOR = new Uint8Array([ - 72, 59, 23, 242, 117, 178, 129, 138, -]); +export const STAKE_PRIMARY_MINER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([72, 59, 23, 242, 117, 178, 129, 138]); export function getStakePrimaryMinerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -50,16 +49,18 @@ export type StakePrimaryMinerInstruction< TProgram extends string = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, TAccountMmOwner extends string | AccountMeta = string, TAccountMmPrimaryTokenAccount extends string | AccountMeta = string, - TAccountPool extends string | AccountMeta = string, - TAccountMm extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountMinerVault extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountStakePrimaryMinerStakePool extends string | AccountMeta = string, + TAccountStakePrimaryMinerStakeMm extends string | AccountMeta = string, + TAccountStakePrimaryMinerStakeRewarder extends string | AccountMeta = string, + TAccountStakePrimaryMinerStakeQuarry extends string | AccountMeta = string, + TAccountStakePrimaryMinerStakeMiner extends string | AccountMeta = string, + TAccountStakePrimaryMinerStakeMinerVault extends + | string + | AccountMeta = string, + TAccountStakePrimaryMinerStakeTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountMineProgram extends + TAccountStakePrimaryMinerStakeMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -74,28 +75,30 @@ export type StakePrimaryMinerInstruction< TAccountMmPrimaryTokenAccount extends string ? WritableAccount : TAccountMmPrimaryTokenAccount, - TAccountPool extends string - ? WritableAccount - : TAccountPool, - TAccountMm extends string ? WritableAccount : TAccountMm, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountMinerVault extends string - ? WritableAccount - : TAccountMinerVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountMineProgram extends string - ? ReadonlyAccount - : TAccountMineProgram, + TAccountStakePrimaryMinerStakePool extends string + ? WritableAccount + : TAccountStakePrimaryMinerStakePool, + TAccountStakePrimaryMinerStakeMm extends string + ? WritableAccount + : TAccountStakePrimaryMinerStakeMm, + TAccountStakePrimaryMinerStakeRewarder extends string + ? ReadonlyAccount + : TAccountStakePrimaryMinerStakeRewarder, + TAccountStakePrimaryMinerStakeQuarry extends string + ? WritableAccount + : TAccountStakePrimaryMinerStakeQuarry, + TAccountStakePrimaryMinerStakeMiner extends string + ? WritableAccount + : TAccountStakePrimaryMinerStakeMiner, + TAccountStakePrimaryMinerStakeMinerVault extends string + ? WritableAccount + : TAccountStakePrimaryMinerStakeMinerVault, + TAccountStakePrimaryMinerStakeTokenProgram extends string + ? ReadonlyAccount + : TAccountStakePrimaryMinerStakeTokenProgram, + TAccountStakePrimaryMinerStakeMineProgram extends string + ? ReadonlyAccount + : TAccountStakePrimaryMinerStakeMineProgram, ...TRemainingAccounts, ] >; @@ -132,65 +135,65 @@ export function getStakePrimaryMinerInstructionDataCodec(): FixedSizeCodec< export interface StakePrimaryMinerInput< TAccountMmOwner extends string = string, TAccountMmPrimaryTokenAccount extends string = string, - TAccountPool extends string = string, - TAccountMm extends string = string, - TAccountRewarder extends string = string, - TAccountQuarry extends string = string, - TAccountMiner extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountMineProgram extends string = string, + TAccountStakePrimaryMinerStakePool extends string = string, + TAccountStakePrimaryMinerStakeMm extends string = string, + TAccountStakePrimaryMinerStakeRewarder extends string = string, + TAccountStakePrimaryMinerStakeQuarry extends string = string, + TAccountStakePrimaryMinerStakeMiner extends string = string, + TAccountStakePrimaryMinerStakeMinerVault extends string = string, + TAccountStakePrimaryMinerStakeTokenProgram extends string = string, + TAccountStakePrimaryMinerStakeMineProgram extends string = string, > { mmOwner: TransactionSigner; mmPrimaryTokenAccount: Address; - pool: Address; - mm: Address; - rewarder: Address; - quarry: Address; - miner: Address; - minerVault: Address; - tokenProgram?: Address; - mineProgram?: Address; + stakePrimaryMinerStakePool: Address; + stakePrimaryMinerStakeMm: Address; + stakePrimaryMinerStakeRewarder: Address; + stakePrimaryMinerStakeQuarry: Address; + stakePrimaryMinerStakeMiner: Address; + stakePrimaryMinerStakeMinerVault: Address; + stakePrimaryMinerStakeTokenProgram?: Address; + stakePrimaryMinerStakeMineProgram?: Address; } export function getStakePrimaryMinerInstruction< TAccountMmOwner extends string, TAccountMmPrimaryTokenAccount extends string, - TAccountPool extends string, - TAccountMm extends string, - TAccountRewarder extends string, - TAccountQuarry extends string, - TAccountMiner extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TAccountMineProgram extends string, + TAccountStakePrimaryMinerStakePool extends string, + TAccountStakePrimaryMinerStakeMm extends string, + TAccountStakePrimaryMinerStakeRewarder extends string, + TAccountStakePrimaryMinerStakeQuarry extends string, + TAccountStakePrimaryMinerStakeMiner extends string, + TAccountStakePrimaryMinerStakeMinerVault extends string, + TAccountStakePrimaryMinerStakeTokenProgram extends string, + TAccountStakePrimaryMinerStakeMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, >( input: StakePrimaryMinerInput< TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakePrimaryMinerStakePool, + TAccountStakePrimaryMinerStakeMm, + TAccountStakePrimaryMinerStakeRewarder, + TAccountStakePrimaryMinerStakeQuarry, + TAccountStakePrimaryMinerStakeMiner, + TAccountStakePrimaryMinerStakeMinerVault, + TAccountStakePrimaryMinerStakeTokenProgram, + TAccountStakePrimaryMinerStakeMineProgram >, config?: { programAddress?: TProgramAddress }, ): StakePrimaryMinerInstruction< TProgramAddress, TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakePrimaryMinerStakePool, + TAccountStakePrimaryMinerStakeMm, + TAccountStakePrimaryMinerStakeRewarder, + TAccountStakePrimaryMinerStakeQuarry, + TAccountStakePrimaryMinerStakeMiner, + TAccountStakePrimaryMinerStakeMinerVault, + TAccountStakePrimaryMinerStakeTokenProgram, + TAccountStakePrimaryMinerStakeMineProgram > { // Program address. const programAddress = @@ -203,14 +206,38 @@ export function getStakePrimaryMinerInstruction< value: input.mmPrimaryTokenAccount ?? null, isWritable: true, }, - pool: { value: input.pool ?? null, isWritable: true }, - mm: { value: input.mm ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - quarry: { value: input.quarry ?? null, isWritable: true }, - miner: { value: input.miner ?? null, isWritable: true }, - minerVault: { value: input.minerVault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - mineProgram: { value: input.mineProgram ?? null, isWritable: false }, + stakePrimaryMinerStakePool: { + value: input.stakePrimaryMinerStakePool ?? null, + isWritable: true, + }, + stakePrimaryMinerStakeMm: { + value: input.stakePrimaryMinerStakeMm ?? null, + isWritable: true, + }, + stakePrimaryMinerStakeRewarder: { + value: input.stakePrimaryMinerStakeRewarder ?? null, + isWritable: false, + }, + stakePrimaryMinerStakeQuarry: { + value: input.stakePrimaryMinerStakeQuarry ?? null, + isWritable: true, + }, + stakePrimaryMinerStakeMiner: { + value: input.stakePrimaryMinerStakeMiner ?? null, + isWritable: true, + }, + stakePrimaryMinerStakeMinerVault: { + value: input.stakePrimaryMinerStakeMinerVault ?? null, + isWritable: true, + }, + stakePrimaryMinerStakeTokenProgram: { + value: input.stakePrimaryMinerStakeTokenProgram ?? null, + isWritable: false, + }, + stakePrimaryMinerStakeMineProgram: { + value: input.stakePrimaryMinerStakeMineProgram ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -218,12 +245,12 @@ export function getStakePrimaryMinerInstruction< >; // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.stakePrimaryMinerStakeTokenProgram.value) { + accounts.stakePrimaryMinerStakeTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } - if (!accounts.mineProgram.value) { - accounts.mineProgram.value = + if (!accounts.stakePrimaryMinerStakeMineProgram.value) { + accounts.stakePrimaryMinerStakeMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } @@ -232,14 +259,14 @@ export function getStakePrimaryMinerInstruction< accounts: [ getAccountMeta(accounts.mmOwner), getAccountMeta(accounts.mmPrimaryTokenAccount), - getAccountMeta(accounts.pool), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.mineProgram), + getAccountMeta(accounts.stakePrimaryMinerStakePool), + getAccountMeta(accounts.stakePrimaryMinerStakeMm), + getAccountMeta(accounts.stakePrimaryMinerStakeRewarder), + getAccountMeta(accounts.stakePrimaryMinerStakeQuarry), + getAccountMeta(accounts.stakePrimaryMinerStakeMiner), + getAccountMeta(accounts.stakePrimaryMinerStakeMinerVault), + getAccountMeta(accounts.stakePrimaryMinerStakeTokenProgram), + getAccountMeta(accounts.stakePrimaryMinerStakeMineProgram), ], programAddress, data: getStakePrimaryMinerInstructionDataEncoder().encode({}), @@ -247,14 +274,14 @@ export function getStakePrimaryMinerInstruction< TProgramAddress, TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakePrimaryMinerStakePool, + TAccountStakePrimaryMinerStakeMm, + TAccountStakePrimaryMinerStakeRewarder, + TAccountStakePrimaryMinerStakeQuarry, + TAccountStakePrimaryMinerStakeMiner, + TAccountStakePrimaryMinerStakeMinerVault, + TAccountStakePrimaryMinerStakeTokenProgram, + TAccountStakePrimaryMinerStakeMineProgram >; return instruction; @@ -268,14 +295,14 @@ export interface ParsedStakePrimaryMinerInstruction< accounts: { mmOwner: TAccountMetas[0]; mmPrimaryTokenAccount: TAccountMetas[1]; - pool: TAccountMetas[2]; - mm: TAccountMetas[3]; - rewarder: TAccountMetas[4]; - quarry: TAccountMetas[5]; - miner: TAccountMetas[6]; - minerVault: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - mineProgram: TAccountMetas[9]; + stakePrimaryMinerStakePool: TAccountMetas[2]; + stakePrimaryMinerStakeMm: TAccountMetas[3]; + stakePrimaryMinerStakeRewarder: TAccountMetas[4]; + stakePrimaryMinerStakeQuarry: TAccountMetas[5]; + stakePrimaryMinerStakeMiner: TAccountMetas[6]; + stakePrimaryMinerStakeMinerVault: TAccountMetas[7]; + stakePrimaryMinerStakeTokenProgram: TAccountMetas[8]; + stakePrimaryMinerStakeMineProgram: TAccountMetas[9]; }; data: StakePrimaryMinerInstructionData; } @@ -303,14 +330,14 @@ export function parseStakePrimaryMinerInstruction< accounts: { mmOwner: getNextAccount(), mmPrimaryTokenAccount: getNextAccount(), - pool: getNextAccount(), - mm: getNextAccount(), - rewarder: getNextAccount(), - quarry: getNextAccount(), - miner: getNextAccount(), - minerVault: getNextAccount(), - tokenProgram: getNextAccount(), - mineProgram: getNextAccount(), + stakePrimaryMinerStakePool: getNextAccount(), + stakePrimaryMinerStakeMm: getNextAccount(), + stakePrimaryMinerStakeRewarder: getNextAccount(), + stakePrimaryMinerStakeQuarry: getNextAccount(), + stakePrimaryMinerStakeMiner: getNextAccount(), + stakePrimaryMinerStakeMinerVault: getNextAccount(), + stakePrimaryMinerStakeTokenProgram: getNextAccount(), + stakePrimaryMinerStakeMineProgram: getNextAccount(), }, data: getStakePrimaryMinerInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/stakeReplicaMiner.ts b/clients/quarry/src/generated/instructions/stakeReplicaMiner.ts index 5c42ddd6..d6bf5921 100644 --- a/clients/quarry/src/generated/instructions/stakeReplicaMiner.ts +++ b/clients/quarry/src/generated/instructions/stakeReplicaMiner.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const STAKE_REPLICA_MINER_DISCRIMINATOR = new Uint8Array([ - 246, 171, 25, 201, 242, 145, 94, 47, -]); +export const STAKE_REPLICA_MINER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([246, 171, 25, 201, 242, 145, 94, 47]); export function getStakeReplicaMinerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -51,16 +50,18 @@ export type StakeReplicaMinerInstruction< TAccountMmOwner extends string | AccountMeta = string, TAccountReplicaMint extends string | AccountMeta = string, TAccountReplicaMintTokenAccount extends string | AccountMeta = string, - TAccountPool extends string | AccountMeta = string, - TAccountMm extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountMinerVault extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountStakeReplicaMinerStakePool extends string | AccountMeta = string, + TAccountStakeReplicaMinerStakeMm extends string | AccountMeta = string, + TAccountStakeReplicaMinerStakeRewarder extends string | AccountMeta = string, + TAccountStakeReplicaMinerStakeQuarry extends string | AccountMeta = string, + TAccountStakeReplicaMinerStakeMiner extends string | AccountMeta = string, + TAccountStakeReplicaMinerStakeMinerVault extends + | string + | AccountMeta = string, + TAccountStakeReplicaMinerStakeTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountMineProgram extends + TAccountStakeReplicaMinerStakeMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -78,28 +79,30 @@ export type StakeReplicaMinerInstruction< TAccountReplicaMintTokenAccount extends string ? WritableAccount : TAccountReplicaMintTokenAccount, - TAccountPool extends string - ? WritableAccount - : TAccountPool, - TAccountMm extends string ? WritableAccount : TAccountMm, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountMinerVault extends string - ? WritableAccount - : TAccountMinerVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountMineProgram extends string - ? ReadonlyAccount - : TAccountMineProgram, + TAccountStakeReplicaMinerStakePool extends string + ? WritableAccount + : TAccountStakeReplicaMinerStakePool, + TAccountStakeReplicaMinerStakeMm extends string + ? WritableAccount + : TAccountStakeReplicaMinerStakeMm, + TAccountStakeReplicaMinerStakeRewarder extends string + ? ReadonlyAccount + : TAccountStakeReplicaMinerStakeRewarder, + TAccountStakeReplicaMinerStakeQuarry extends string + ? WritableAccount + : TAccountStakeReplicaMinerStakeQuarry, + TAccountStakeReplicaMinerStakeMiner extends string + ? WritableAccount + : TAccountStakeReplicaMinerStakeMiner, + TAccountStakeReplicaMinerStakeMinerVault extends string + ? WritableAccount + : TAccountStakeReplicaMinerStakeMinerVault, + TAccountStakeReplicaMinerStakeTokenProgram extends string + ? ReadonlyAccount + : TAccountStakeReplicaMinerStakeTokenProgram, + TAccountStakeReplicaMinerStakeMineProgram extends string + ? ReadonlyAccount + : TAccountStakeReplicaMinerStakeMineProgram, ...TRemainingAccounts, ] >; @@ -137,54 +140,54 @@ export interface StakeReplicaMinerInput< TAccountMmOwner extends string = string, TAccountReplicaMint extends string = string, TAccountReplicaMintTokenAccount extends string = string, - TAccountPool extends string = string, - TAccountMm extends string = string, - TAccountRewarder extends string = string, - TAccountQuarry extends string = string, - TAccountMiner extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountMineProgram extends string = string, + TAccountStakeReplicaMinerStakePool extends string = string, + TAccountStakeReplicaMinerStakeMm extends string = string, + TAccountStakeReplicaMinerStakeRewarder extends string = string, + TAccountStakeReplicaMinerStakeQuarry extends string = string, + TAccountStakeReplicaMinerStakeMiner extends string = string, + TAccountStakeReplicaMinerStakeMinerVault extends string = string, + TAccountStakeReplicaMinerStakeTokenProgram extends string = string, + TAccountStakeReplicaMinerStakeMineProgram extends string = string, > { mmOwner: TransactionSigner; replicaMint: Address; replicaMintTokenAccount: Address; - pool: Address; - mm: Address; - rewarder: Address; - quarry: Address; - miner: Address; - minerVault: Address; - tokenProgram?: Address; - mineProgram?: Address; + stakeReplicaMinerStakePool: Address; + stakeReplicaMinerStakeMm: Address; + stakeReplicaMinerStakeRewarder: Address; + stakeReplicaMinerStakeQuarry: Address; + stakeReplicaMinerStakeMiner: Address; + stakeReplicaMinerStakeMinerVault: Address; + stakeReplicaMinerStakeTokenProgram?: Address; + stakeReplicaMinerStakeMineProgram?: Address; } export function getStakeReplicaMinerInstruction< TAccountMmOwner extends string, TAccountReplicaMint extends string, TAccountReplicaMintTokenAccount extends string, - TAccountPool extends string, - TAccountMm extends string, - TAccountRewarder extends string, - TAccountQuarry extends string, - TAccountMiner extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TAccountMineProgram extends string, + TAccountStakeReplicaMinerStakePool extends string, + TAccountStakeReplicaMinerStakeMm extends string, + TAccountStakeReplicaMinerStakeRewarder extends string, + TAccountStakeReplicaMinerStakeQuarry extends string, + TAccountStakeReplicaMinerStakeMiner extends string, + TAccountStakeReplicaMinerStakeMinerVault extends string, + TAccountStakeReplicaMinerStakeTokenProgram extends string, + TAccountStakeReplicaMinerStakeMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, >( input: StakeReplicaMinerInput< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakeReplicaMinerStakePool, + TAccountStakeReplicaMinerStakeMm, + TAccountStakeReplicaMinerStakeRewarder, + TAccountStakeReplicaMinerStakeQuarry, + TAccountStakeReplicaMinerStakeMiner, + TAccountStakeReplicaMinerStakeMinerVault, + TAccountStakeReplicaMinerStakeTokenProgram, + TAccountStakeReplicaMinerStakeMineProgram >, config?: { programAddress?: TProgramAddress }, ): StakeReplicaMinerInstruction< @@ -192,14 +195,14 @@ export function getStakeReplicaMinerInstruction< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakeReplicaMinerStakePool, + TAccountStakeReplicaMinerStakeMm, + TAccountStakeReplicaMinerStakeRewarder, + TAccountStakeReplicaMinerStakeQuarry, + TAccountStakeReplicaMinerStakeMiner, + TAccountStakeReplicaMinerStakeMinerVault, + TAccountStakeReplicaMinerStakeTokenProgram, + TAccountStakeReplicaMinerStakeMineProgram > { // Program address. const programAddress = @@ -213,14 +216,38 @@ export function getStakeReplicaMinerInstruction< value: input.replicaMintTokenAccount ?? null, isWritable: true, }, - pool: { value: input.pool ?? null, isWritable: true }, - mm: { value: input.mm ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - quarry: { value: input.quarry ?? null, isWritable: true }, - miner: { value: input.miner ?? null, isWritable: true }, - minerVault: { value: input.minerVault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - mineProgram: { value: input.mineProgram ?? null, isWritable: false }, + stakeReplicaMinerStakePool: { + value: input.stakeReplicaMinerStakePool ?? null, + isWritable: true, + }, + stakeReplicaMinerStakeMm: { + value: input.stakeReplicaMinerStakeMm ?? null, + isWritable: true, + }, + stakeReplicaMinerStakeRewarder: { + value: input.stakeReplicaMinerStakeRewarder ?? null, + isWritable: false, + }, + stakeReplicaMinerStakeQuarry: { + value: input.stakeReplicaMinerStakeQuarry ?? null, + isWritable: true, + }, + stakeReplicaMinerStakeMiner: { + value: input.stakeReplicaMinerStakeMiner ?? null, + isWritable: true, + }, + stakeReplicaMinerStakeMinerVault: { + value: input.stakeReplicaMinerStakeMinerVault ?? null, + isWritable: true, + }, + stakeReplicaMinerStakeTokenProgram: { + value: input.stakeReplicaMinerStakeTokenProgram ?? null, + isWritable: false, + }, + stakeReplicaMinerStakeMineProgram: { + value: input.stakeReplicaMinerStakeMineProgram ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -228,12 +255,12 @@ export function getStakeReplicaMinerInstruction< >; // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.stakeReplicaMinerStakeTokenProgram.value) { + accounts.stakeReplicaMinerStakeTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } - if (!accounts.mineProgram.value) { - accounts.mineProgram.value = + if (!accounts.stakeReplicaMinerStakeMineProgram.value) { + accounts.stakeReplicaMinerStakeMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } @@ -243,14 +270,14 @@ export function getStakeReplicaMinerInstruction< getAccountMeta(accounts.mmOwner), getAccountMeta(accounts.replicaMint), getAccountMeta(accounts.replicaMintTokenAccount), - getAccountMeta(accounts.pool), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.mineProgram), + getAccountMeta(accounts.stakeReplicaMinerStakePool), + getAccountMeta(accounts.stakeReplicaMinerStakeMm), + getAccountMeta(accounts.stakeReplicaMinerStakeRewarder), + getAccountMeta(accounts.stakeReplicaMinerStakeQuarry), + getAccountMeta(accounts.stakeReplicaMinerStakeMiner), + getAccountMeta(accounts.stakeReplicaMinerStakeMinerVault), + getAccountMeta(accounts.stakeReplicaMinerStakeTokenProgram), + getAccountMeta(accounts.stakeReplicaMinerStakeMineProgram), ], programAddress, data: getStakeReplicaMinerInstructionDataEncoder().encode({}), @@ -259,14 +286,14 @@ export function getStakeReplicaMinerInstruction< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountStakeReplicaMinerStakePool, + TAccountStakeReplicaMinerStakeMm, + TAccountStakeReplicaMinerStakeRewarder, + TAccountStakeReplicaMinerStakeQuarry, + TAccountStakeReplicaMinerStakeMiner, + TAccountStakeReplicaMinerStakeMinerVault, + TAccountStakeReplicaMinerStakeTokenProgram, + TAccountStakeReplicaMinerStakeMineProgram >; return instruction; @@ -281,14 +308,14 @@ export interface ParsedStakeReplicaMinerInstruction< mmOwner: TAccountMetas[0]; replicaMint: TAccountMetas[1]; replicaMintTokenAccount: TAccountMetas[2]; - pool: TAccountMetas[3]; - mm: TAccountMetas[4]; - rewarder: TAccountMetas[5]; - quarry: TAccountMetas[6]; - miner: TAccountMetas[7]; - minerVault: TAccountMetas[8]; - tokenProgram: TAccountMetas[9]; - mineProgram: TAccountMetas[10]; + stakeReplicaMinerStakePool: TAccountMetas[3]; + stakeReplicaMinerStakeMm: TAccountMetas[4]; + stakeReplicaMinerStakeRewarder: TAccountMetas[5]; + stakeReplicaMinerStakeQuarry: TAccountMetas[6]; + stakeReplicaMinerStakeMiner: TAccountMetas[7]; + stakeReplicaMinerStakeMinerVault: TAccountMetas[8]; + stakeReplicaMinerStakeTokenProgram: TAccountMetas[9]; + stakeReplicaMinerStakeMineProgram: TAccountMetas[10]; }; data: StakeReplicaMinerInstructionData; } @@ -317,14 +344,14 @@ export function parseStakeReplicaMinerInstruction< mmOwner: getNextAccount(), replicaMint: getNextAccount(), replicaMintTokenAccount: getNextAccount(), - pool: getNextAccount(), - mm: getNextAccount(), - rewarder: getNextAccount(), - quarry: getNextAccount(), - miner: getNextAccount(), - minerVault: getNextAccount(), - tokenProgram: getNextAccount(), - mineProgram: getNextAccount(), + stakeReplicaMinerStakePool: getNextAccount(), + stakeReplicaMinerStakeMm: getNextAccount(), + stakeReplicaMinerStakeRewarder: getNextAccount(), + stakeReplicaMinerStakeQuarry: getNextAccount(), + stakeReplicaMinerStakeMiner: getNextAccount(), + stakeReplicaMinerStakeMinerVault: getNextAccount(), + stakeReplicaMinerStakeTokenProgram: getNextAccount(), + stakeReplicaMinerStakeMineProgram: getNextAccount(), }, data: getStakeReplicaMinerInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/quarry/src/generated/instructions/stakeTokens.ts b/clients/quarry/src/generated/instructions/stakeTokens.ts index 17405bb5..ee3001f6 100644 --- a/clients/quarry/src/generated/instructions/stakeTokens.ts +++ b/clients/quarry/src/generated/instructions/stakeTokens.ts @@ -38,7 +38,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const STAKE_TOKENS_DISCRIMINATOR = new Uint8Array([ +export const STAKE_TOKENS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 136, 126, 91, 162, 40, 131, 13, 127, ]); diff --git a/clients/quarry/src/generated/instructions/syncQuarry.ts b/clients/quarry/src/generated/instructions/syncQuarry.ts index bfae968d..1ce1e4ab 100644 --- a/clients/quarry/src/generated/instructions/syncQuarry.ts +++ b/clients/quarry/src/generated/instructions/syncQuarry.ts @@ -33,7 +33,7 @@ import { QUARRY_REGISTRY_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const SYNC_QUARRY_DISCRIMINATOR = new Uint8Array([ +export const SYNC_QUARRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 48, 99, 184, 151, 219, 101, 253, 170, ]); diff --git a/clients/quarry/src/generated/instructions/transferAdmin.ts b/clients/quarry/src/generated/instructions/transferAdmin.ts index f9837d09..62c7c209 100644 --- a/clients/quarry/src/generated/instructions/transferAdmin.ts +++ b/clients/quarry/src/generated/instructions/transferAdmin.ts @@ -36,7 +36,7 @@ import { QUARRY_MINT_WRAPPER_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const TRANSFER_ADMIN_DISCRIMINATOR = new Uint8Array([ +export const TRANSFER_ADMIN_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 42, 242, 66, 106, 228, 10, 111, 156, ]); diff --git a/clients/quarry/src/generated/instructions/transferAuthority.ts b/clients/quarry/src/generated/instructions/transferAuthority.ts index e7169f17..8c43f91b 100644 --- a/clients/quarry/src/generated/instructions/transferAuthority.ts +++ b/clients/quarry/src/generated/instructions/transferAuthority.ts @@ -37,9 +37,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const TRANSFER_AUTHORITY_DISCRIMINATOR = new Uint8Array([ - 48, 169, 76, 72, 229, 180, 55, 161, -]); +export const TRANSFER_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([48, 169, 76, 72, 229, 180, 55, 161]); export function getTransferAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/unpause.ts b/clients/quarry/src/generated/instructions/unpause.ts index e6369b41..743911ea 100644 --- a/clients/quarry/src/generated/instructions/unpause.ts +++ b/clients/quarry/src/generated/instructions/unpause.ts @@ -35,7 +35,7 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ +export const UNPAUSE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 169, 144, 4, 38, 10, 141, 188, 255, ]); diff --git a/clients/quarry/src/generated/instructions/unstakeAllReplicaMiner.ts b/clients/quarry/src/generated/instructions/unstakeAllReplicaMiner.ts index e613726b..0db1c450 100644 --- a/clients/quarry/src/generated/instructions/unstakeAllReplicaMiner.ts +++ b/clients/quarry/src/generated/instructions/unstakeAllReplicaMiner.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const UNSTAKE_ALL_REPLICA_MINER_DISCRIMINATOR = new Uint8Array([ - 250, 4, 3, 209, 154, 125, 71, 168, -]); +export const UNSTAKE_ALL_REPLICA_MINER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([250, 4, 3, 209, 154, 125, 71, 168]); export function getUnstakeAllReplicaMinerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -51,16 +50,24 @@ export type UnstakeAllReplicaMinerInstruction< TAccountMmOwner extends string | AccountMeta = string, TAccountReplicaMint extends string | AccountMeta = string, TAccountReplicaMintTokenAccount extends string | AccountMeta = string, - TAccountPool extends string | AccountMeta = string, - TAccountMm extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountMinerVault extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountUnstakeAllReplicaMinerStakePool extends string | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeMm extends string | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeRewarder extends + | string + | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeQuarry extends + | string + | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeMiner extends + | string + | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeMinerVault extends + | string + | AccountMeta = string, + TAccountUnstakeAllReplicaMinerStakeTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountMineProgram extends + TAccountUnstakeAllReplicaMinerStakeMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -78,28 +85,30 @@ export type UnstakeAllReplicaMinerInstruction< TAccountReplicaMintTokenAccount extends string ? WritableAccount : TAccountReplicaMintTokenAccount, - TAccountPool extends string - ? WritableAccount - : TAccountPool, - TAccountMm extends string ? WritableAccount : TAccountMm, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountMinerVault extends string - ? WritableAccount - : TAccountMinerVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountMineProgram extends string - ? ReadonlyAccount - : TAccountMineProgram, + TAccountUnstakeAllReplicaMinerStakePool extends string + ? WritableAccount + : TAccountUnstakeAllReplicaMinerStakePool, + TAccountUnstakeAllReplicaMinerStakeMm extends string + ? WritableAccount + : TAccountUnstakeAllReplicaMinerStakeMm, + TAccountUnstakeAllReplicaMinerStakeRewarder extends string + ? ReadonlyAccount + : TAccountUnstakeAllReplicaMinerStakeRewarder, + TAccountUnstakeAllReplicaMinerStakeQuarry extends string + ? WritableAccount + : TAccountUnstakeAllReplicaMinerStakeQuarry, + TAccountUnstakeAllReplicaMinerStakeMiner extends string + ? WritableAccount + : TAccountUnstakeAllReplicaMinerStakeMiner, + TAccountUnstakeAllReplicaMinerStakeMinerVault extends string + ? WritableAccount + : TAccountUnstakeAllReplicaMinerStakeMinerVault, + TAccountUnstakeAllReplicaMinerStakeTokenProgram extends string + ? ReadonlyAccount + : TAccountUnstakeAllReplicaMinerStakeTokenProgram, + TAccountUnstakeAllReplicaMinerStakeMineProgram extends string + ? ReadonlyAccount + : TAccountUnstakeAllReplicaMinerStakeMineProgram, ...TRemainingAccounts, ] >; @@ -140,54 +149,54 @@ export interface UnstakeAllReplicaMinerInput< TAccountMmOwner extends string = string, TAccountReplicaMint extends string = string, TAccountReplicaMintTokenAccount extends string = string, - TAccountPool extends string = string, - TAccountMm extends string = string, - TAccountRewarder extends string = string, - TAccountQuarry extends string = string, - TAccountMiner extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountMineProgram extends string = string, + TAccountUnstakeAllReplicaMinerStakePool extends string = string, + TAccountUnstakeAllReplicaMinerStakeMm extends string = string, + TAccountUnstakeAllReplicaMinerStakeRewarder extends string = string, + TAccountUnstakeAllReplicaMinerStakeQuarry extends string = string, + TAccountUnstakeAllReplicaMinerStakeMiner extends string = string, + TAccountUnstakeAllReplicaMinerStakeMinerVault extends string = string, + TAccountUnstakeAllReplicaMinerStakeTokenProgram extends string = string, + TAccountUnstakeAllReplicaMinerStakeMineProgram extends string = string, > { mmOwner: TransactionSigner; replicaMint: Address; replicaMintTokenAccount: Address; - pool: Address; - mm: Address; - rewarder: Address; - quarry: Address; - miner: Address; - minerVault: Address; - tokenProgram?: Address; - mineProgram?: Address; + unstakeAllReplicaMinerStakePool: Address; + unstakeAllReplicaMinerStakeMm: Address; + unstakeAllReplicaMinerStakeRewarder: Address; + unstakeAllReplicaMinerStakeQuarry: Address; + unstakeAllReplicaMinerStakeMiner: Address; + unstakeAllReplicaMinerStakeMinerVault: Address; + unstakeAllReplicaMinerStakeTokenProgram?: Address; + unstakeAllReplicaMinerStakeMineProgram?: Address; } export function getUnstakeAllReplicaMinerInstruction< TAccountMmOwner extends string, TAccountReplicaMint extends string, TAccountReplicaMintTokenAccount extends string, - TAccountPool extends string, - TAccountMm extends string, - TAccountRewarder extends string, - TAccountQuarry extends string, - TAccountMiner extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TAccountMineProgram extends string, + TAccountUnstakeAllReplicaMinerStakePool extends string, + TAccountUnstakeAllReplicaMinerStakeMm extends string, + TAccountUnstakeAllReplicaMinerStakeRewarder extends string, + TAccountUnstakeAllReplicaMinerStakeQuarry extends string, + TAccountUnstakeAllReplicaMinerStakeMiner extends string, + TAccountUnstakeAllReplicaMinerStakeMinerVault extends string, + TAccountUnstakeAllReplicaMinerStakeTokenProgram extends string, + TAccountUnstakeAllReplicaMinerStakeMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, >( input: UnstakeAllReplicaMinerInput< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakeAllReplicaMinerStakePool, + TAccountUnstakeAllReplicaMinerStakeMm, + TAccountUnstakeAllReplicaMinerStakeRewarder, + TAccountUnstakeAllReplicaMinerStakeQuarry, + TAccountUnstakeAllReplicaMinerStakeMiner, + TAccountUnstakeAllReplicaMinerStakeMinerVault, + TAccountUnstakeAllReplicaMinerStakeTokenProgram, + TAccountUnstakeAllReplicaMinerStakeMineProgram >, config?: { programAddress?: TProgramAddress }, ): UnstakeAllReplicaMinerInstruction< @@ -195,14 +204,14 @@ export function getUnstakeAllReplicaMinerInstruction< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakeAllReplicaMinerStakePool, + TAccountUnstakeAllReplicaMinerStakeMm, + TAccountUnstakeAllReplicaMinerStakeRewarder, + TAccountUnstakeAllReplicaMinerStakeQuarry, + TAccountUnstakeAllReplicaMinerStakeMiner, + TAccountUnstakeAllReplicaMinerStakeMinerVault, + TAccountUnstakeAllReplicaMinerStakeTokenProgram, + TAccountUnstakeAllReplicaMinerStakeMineProgram > { // Program address. const programAddress = @@ -216,14 +225,38 @@ export function getUnstakeAllReplicaMinerInstruction< value: input.replicaMintTokenAccount ?? null, isWritable: true, }, - pool: { value: input.pool ?? null, isWritable: true }, - mm: { value: input.mm ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - quarry: { value: input.quarry ?? null, isWritable: true }, - miner: { value: input.miner ?? null, isWritable: true }, - minerVault: { value: input.minerVault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - mineProgram: { value: input.mineProgram ?? null, isWritable: false }, + unstakeAllReplicaMinerStakePool: { + value: input.unstakeAllReplicaMinerStakePool ?? null, + isWritable: true, + }, + unstakeAllReplicaMinerStakeMm: { + value: input.unstakeAllReplicaMinerStakeMm ?? null, + isWritable: true, + }, + unstakeAllReplicaMinerStakeRewarder: { + value: input.unstakeAllReplicaMinerStakeRewarder ?? null, + isWritable: false, + }, + unstakeAllReplicaMinerStakeQuarry: { + value: input.unstakeAllReplicaMinerStakeQuarry ?? null, + isWritable: true, + }, + unstakeAllReplicaMinerStakeMiner: { + value: input.unstakeAllReplicaMinerStakeMiner ?? null, + isWritable: true, + }, + unstakeAllReplicaMinerStakeMinerVault: { + value: input.unstakeAllReplicaMinerStakeMinerVault ?? null, + isWritable: true, + }, + unstakeAllReplicaMinerStakeTokenProgram: { + value: input.unstakeAllReplicaMinerStakeTokenProgram ?? null, + isWritable: false, + }, + unstakeAllReplicaMinerStakeMineProgram: { + value: input.unstakeAllReplicaMinerStakeMineProgram ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -231,12 +264,12 @@ export function getUnstakeAllReplicaMinerInstruction< >; // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.unstakeAllReplicaMinerStakeTokenProgram.value) { + accounts.unstakeAllReplicaMinerStakeTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } - if (!accounts.mineProgram.value) { - accounts.mineProgram.value = + if (!accounts.unstakeAllReplicaMinerStakeMineProgram.value) { + accounts.unstakeAllReplicaMinerStakeMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } @@ -246,14 +279,14 @@ export function getUnstakeAllReplicaMinerInstruction< getAccountMeta(accounts.mmOwner), getAccountMeta(accounts.replicaMint), getAccountMeta(accounts.replicaMintTokenAccount), - getAccountMeta(accounts.pool), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.mineProgram), + getAccountMeta(accounts.unstakeAllReplicaMinerStakePool), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeMm), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeRewarder), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeQuarry), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeMiner), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeMinerVault), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeTokenProgram), + getAccountMeta(accounts.unstakeAllReplicaMinerStakeMineProgram), ], programAddress, data: getUnstakeAllReplicaMinerInstructionDataEncoder().encode({}), @@ -262,14 +295,14 @@ export function getUnstakeAllReplicaMinerInstruction< TAccountMmOwner, TAccountReplicaMint, TAccountReplicaMintTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakeAllReplicaMinerStakePool, + TAccountUnstakeAllReplicaMinerStakeMm, + TAccountUnstakeAllReplicaMinerStakeRewarder, + TAccountUnstakeAllReplicaMinerStakeQuarry, + TAccountUnstakeAllReplicaMinerStakeMiner, + TAccountUnstakeAllReplicaMinerStakeMinerVault, + TAccountUnstakeAllReplicaMinerStakeTokenProgram, + TAccountUnstakeAllReplicaMinerStakeMineProgram >; return instruction; @@ -284,14 +317,14 @@ export interface ParsedUnstakeAllReplicaMinerInstruction< mmOwner: TAccountMetas[0]; replicaMint: TAccountMetas[1]; replicaMintTokenAccount: TAccountMetas[2]; - pool: TAccountMetas[3]; - mm: TAccountMetas[4]; - rewarder: TAccountMetas[5]; - quarry: TAccountMetas[6]; - miner: TAccountMetas[7]; - minerVault: TAccountMetas[8]; - tokenProgram: TAccountMetas[9]; - mineProgram: TAccountMetas[10]; + unstakeAllReplicaMinerStakePool: TAccountMetas[3]; + unstakeAllReplicaMinerStakeMm: TAccountMetas[4]; + unstakeAllReplicaMinerStakeRewarder: TAccountMetas[5]; + unstakeAllReplicaMinerStakeQuarry: TAccountMetas[6]; + unstakeAllReplicaMinerStakeMiner: TAccountMetas[7]; + unstakeAllReplicaMinerStakeMinerVault: TAccountMetas[8]; + unstakeAllReplicaMinerStakeTokenProgram: TAccountMetas[9]; + unstakeAllReplicaMinerStakeMineProgram: TAccountMetas[10]; }; data: UnstakeAllReplicaMinerInstructionData; } @@ -320,14 +353,14 @@ export function parseUnstakeAllReplicaMinerInstruction< mmOwner: getNextAccount(), replicaMint: getNextAccount(), replicaMintTokenAccount: getNextAccount(), - pool: getNextAccount(), - mm: getNextAccount(), - rewarder: getNextAccount(), - quarry: getNextAccount(), - miner: getNextAccount(), - minerVault: getNextAccount(), - tokenProgram: getNextAccount(), - mineProgram: getNextAccount(), + unstakeAllReplicaMinerStakePool: getNextAccount(), + unstakeAllReplicaMinerStakeMm: getNextAccount(), + unstakeAllReplicaMinerStakeRewarder: getNextAccount(), + unstakeAllReplicaMinerStakeQuarry: getNextAccount(), + unstakeAllReplicaMinerStakeMiner: getNextAccount(), + unstakeAllReplicaMinerStakeMinerVault: getNextAccount(), + unstakeAllReplicaMinerStakeTokenProgram: getNextAccount(), + unstakeAllReplicaMinerStakeMineProgram: getNextAccount(), }, data: getUnstakeAllReplicaMinerInstructionDataDecoder().decode( instruction.data, diff --git a/clients/quarry/src/generated/instructions/unstakePrimaryMiner.ts b/clients/quarry/src/generated/instructions/unstakePrimaryMiner.ts index 25c9376b..a06b5737 100644 --- a/clients/quarry/src/generated/instructions/unstakePrimaryMiner.ts +++ b/clients/quarry/src/generated/instructions/unstakePrimaryMiner.ts @@ -38,9 +38,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const UNSTAKE_PRIMARY_MINER_DISCRIMINATOR = new Uint8Array([ - 45, 62, 3, 33, 114, 156, 186, 26, -]); +export const UNSTAKE_PRIMARY_MINER_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([45, 62, 3, 33, 114, 156, 186, 26]); export function getUnstakePrimaryMinerDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( @@ -52,16 +51,20 @@ export type UnstakePrimaryMinerInstruction< TProgram extends string = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, TAccountMmOwner extends string | AccountMeta = string, TAccountMmPrimaryTokenAccount extends string | AccountMeta = string, - TAccountPool extends string | AccountMeta = string, - TAccountMm extends string | AccountMeta = string, - TAccountRewarder extends string | AccountMeta = string, - TAccountQuarry extends string | AccountMeta = string, - TAccountMiner extends string | AccountMeta = string, - TAccountMinerVault extends string | AccountMeta = string, - TAccountTokenProgram extends + TAccountUnstakePrimaryMinerStakePool extends string | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeMm extends string | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeRewarder extends + | string + | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeQuarry extends string | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeMiner extends string | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeMinerVault extends + | string + | AccountMeta = string, + TAccountUnstakePrimaryMinerStakeTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - TAccountMineProgram extends + TAccountUnstakePrimaryMinerStakeMineProgram extends | string | AccountMeta = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB", TRemainingAccounts extends readonly AccountMeta[] = [], @@ -76,28 +79,30 @@ export type UnstakePrimaryMinerInstruction< TAccountMmPrimaryTokenAccount extends string ? WritableAccount : TAccountMmPrimaryTokenAccount, - TAccountPool extends string - ? WritableAccount - : TAccountPool, - TAccountMm extends string ? WritableAccount : TAccountMm, - TAccountRewarder extends string - ? ReadonlyAccount - : TAccountRewarder, - TAccountQuarry extends string - ? WritableAccount - : TAccountQuarry, - TAccountMiner extends string - ? WritableAccount - : TAccountMiner, - TAccountMinerVault extends string - ? WritableAccount - : TAccountMinerVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountMineProgram extends string - ? ReadonlyAccount - : TAccountMineProgram, + TAccountUnstakePrimaryMinerStakePool extends string + ? WritableAccount + : TAccountUnstakePrimaryMinerStakePool, + TAccountUnstakePrimaryMinerStakeMm extends string + ? WritableAccount + : TAccountUnstakePrimaryMinerStakeMm, + TAccountUnstakePrimaryMinerStakeRewarder extends string + ? ReadonlyAccount + : TAccountUnstakePrimaryMinerStakeRewarder, + TAccountUnstakePrimaryMinerStakeQuarry extends string + ? WritableAccount + : TAccountUnstakePrimaryMinerStakeQuarry, + TAccountUnstakePrimaryMinerStakeMiner extends string + ? WritableAccount + : TAccountUnstakePrimaryMinerStakeMiner, + TAccountUnstakePrimaryMinerStakeMinerVault extends string + ? WritableAccount + : TAccountUnstakePrimaryMinerStakeMinerVault, + TAccountUnstakePrimaryMinerStakeTokenProgram extends string + ? ReadonlyAccount + : TAccountUnstakePrimaryMinerStakeTokenProgram, + TAccountUnstakePrimaryMinerStakeMineProgram extends string + ? ReadonlyAccount + : TAccountUnstakePrimaryMinerStakeMineProgram, ...TRemainingAccounts, ] >; @@ -144,66 +149,66 @@ export function getUnstakePrimaryMinerInstructionDataCodec(): FixedSizeCodec< export interface UnstakePrimaryMinerInput< TAccountMmOwner extends string = string, TAccountMmPrimaryTokenAccount extends string = string, - TAccountPool extends string = string, - TAccountMm extends string = string, - TAccountRewarder extends string = string, - TAccountQuarry extends string = string, - TAccountMiner extends string = string, - TAccountMinerVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountMineProgram extends string = string, + TAccountUnstakePrimaryMinerStakePool extends string = string, + TAccountUnstakePrimaryMinerStakeMm extends string = string, + TAccountUnstakePrimaryMinerStakeRewarder extends string = string, + TAccountUnstakePrimaryMinerStakeQuarry extends string = string, + TAccountUnstakePrimaryMinerStakeMiner extends string = string, + TAccountUnstakePrimaryMinerStakeMinerVault extends string = string, + TAccountUnstakePrimaryMinerStakeTokenProgram extends string = string, + TAccountUnstakePrimaryMinerStakeMineProgram extends string = string, > { mmOwner: TransactionSigner; mmPrimaryTokenAccount: Address; - pool: Address; - mm: Address; - rewarder: Address; - quarry: Address; - miner: Address; - minerVault: Address; - tokenProgram?: Address; - mineProgram?: Address; + unstakePrimaryMinerStakePool: Address; + unstakePrimaryMinerStakeMm: Address; + unstakePrimaryMinerStakeRewarder: Address; + unstakePrimaryMinerStakeQuarry: Address; + unstakePrimaryMinerStakeMiner: Address; + unstakePrimaryMinerStakeMinerVault: Address; + unstakePrimaryMinerStakeTokenProgram?: Address; + unstakePrimaryMinerStakeMineProgram?: Address; amount: UnstakePrimaryMinerInstructionDataArgs["amount"]; } export function getUnstakePrimaryMinerInstruction< TAccountMmOwner extends string, TAccountMmPrimaryTokenAccount extends string, - TAccountPool extends string, - TAccountMm extends string, - TAccountRewarder extends string, - TAccountQuarry extends string, - TAccountMiner extends string, - TAccountMinerVault extends string, - TAccountTokenProgram extends string, - TAccountMineProgram extends string, + TAccountUnstakePrimaryMinerStakePool extends string, + TAccountUnstakePrimaryMinerStakeMm extends string, + TAccountUnstakePrimaryMinerStakeRewarder extends string, + TAccountUnstakePrimaryMinerStakeQuarry extends string, + TAccountUnstakePrimaryMinerStakeMiner extends string, + TAccountUnstakePrimaryMinerStakeMinerVault extends string, + TAccountUnstakePrimaryMinerStakeTokenProgram extends string, + TAccountUnstakePrimaryMinerStakeMineProgram extends string, TProgramAddress extends Address = typeof QUARRY_MERGE_MINE_PROGRAM_ADDRESS, >( input: UnstakePrimaryMinerInput< TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakePrimaryMinerStakePool, + TAccountUnstakePrimaryMinerStakeMm, + TAccountUnstakePrimaryMinerStakeRewarder, + TAccountUnstakePrimaryMinerStakeQuarry, + TAccountUnstakePrimaryMinerStakeMiner, + TAccountUnstakePrimaryMinerStakeMinerVault, + TAccountUnstakePrimaryMinerStakeTokenProgram, + TAccountUnstakePrimaryMinerStakeMineProgram >, config?: { programAddress?: TProgramAddress }, ): UnstakePrimaryMinerInstruction< TProgramAddress, TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakePrimaryMinerStakePool, + TAccountUnstakePrimaryMinerStakeMm, + TAccountUnstakePrimaryMinerStakeRewarder, + TAccountUnstakePrimaryMinerStakeQuarry, + TAccountUnstakePrimaryMinerStakeMiner, + TAccountUnstakePrimaryMinerStakeMinerVault, + TAccountUnstakePrimaryMinerStakeTokenProgram, + TAccountUnstakePrimaryMinerStakeMineProgram > { // Program address. const programAddress = @@ -216,14 +221,38 @@ export function getUnstakePrimaryMinerInstruction< value: input.mmPrimaryTokenAccount ?? null, isWritable: true, }, - pool: { value: input.pool ?? null, isWritable: true }, - mm: { value: input.mm ?? null, isWritable: true }, - rewarder: { value: input.rewarder ?? null, isWritable: false }, - quarry: { value: input.quarry ?? null, isWritable: true }, - miner: { value: input.miner ?? null, isWritable: true }, - minerVault: { value: input.minerVault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - mineProgram: { value: input.mineProgram ?? null, isWritable: false }, + unstakePrimaryMinerStakePool: { + value: input.unstakePrimaryMinerStakePool ?? null, + isWritable: true, + }, + unstakePrimaryMinerStakeMm: { + value: input.unstakePrimaryMinerStakeMm ?? null, + isWritable: true, + }, + unstakePrimaryMinerStakeRewarder: { + value: input.unstakePrimaryMinerStakeRewarder ?? null, + isWritable: false, + }, + unstakePrimaryMinerStakeQuarry: { + value: input.unstakePrimaryMinerStakeQuarry ?? null, + isWritable: true, + }, + unstakePrimaryMinerStakeMiner: { + value: input.unstakePrimaryMinerStakeMiner ?? null, + isWritable: true, + }, + unstakePrimaryMinerStakeMinerVault: { + value: input.unstakePrimaryMinerStakeMinerVault ?? null, + isWritable: true, + }, + unstakePrimaryMinerStakeTokenProgram: { + value: input.unstakePrimaryMinerStakeTokenProgram ?? null, + isWritable: false, + }, + unstakePrimaryMinerStakeMineProgram: { + value: input.unstakePrimaryMinerStakeMineProgram ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -234,12 +263,12 @@ export function getUnstakePrimaryMinerInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = + if (!accounts.unstakePrimaryMinerStakeTokenProgram.value) { + accounts.unstakePrimaryMinerStakeTokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } - if (!accounts.mineProgram.value) { - accounts.mineProgram.value = + if (!accounts.unstakePrimaryMinerStakeMineProgram.value) { + accounts.unstakePrimaryMinerStakeMineProgram.value = "QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB" as Address<"QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB">; } @@ -248,14 +277,14 @@ export function getUnstakePrimaryMinerInstruction< accounts: [ getAccountMeta(accounts.mmOwner), getAccountMeta(accounts.mmPrimaryTokenAccount), - getAccountMeta(accounts.pool), - getAccountMeta(accounts.mm), - getAccountMeta(accounts.rewarder), - getAccountMeta(accounts.quarry), - getAccountMeta(accounts.miner), - getAccountMeta(accounts.minerVault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.mineProgram), + getAccountMeta(accounts.unstakePrimaryMinerStakePool), + getAccountMeta(accounts.unstakePrimaryMinerStakeMm), + getAccountMeta(accounts.unstakePrimaryMinerStakeRewarder), + getAccountMeta(accounts.unstakePrimaryMinerStakeQuarry), + getAccountMeta(accounts.unstakePrimaryMinerStakeMiner), + getAccountMeta(accounts.unstakePrimaryMinerStakeMinerVault), + getAccountMeta(accounts.unstakePrimaryMinerStakeTokenProgram), + getAccountMeta(accounts.unstakePrimaryMinerStakeMineProgram), ], programAddress, data: getUnstakePrimaryMinerInstructionDataEncoder().encode( @@ -265,14 +294,14 @@ export function getUnstakePrimaryMinerInstruction< TProgramAddress, TAccountMmOwner, TAccountMmPrimaryTokenAccount, - TAccountPool, - TAccountMm, - TAccountRewarder, - TAccountQuarry, - TAccountMiner, - TAccountMinerVault, - TAccountTokenProgram, - TAccountMineProgram + TAccountUnstakePrimaryMinerStakePool, + TAccountUnstakePrimaryMinerStakeMm, + TAccountUnstakePrimaryMinerStakeRewarder, + TAccountUnstakePrimaryMinerStakeQuarry, + TAccountUnstakePrimaryMinerStakeMiner, + TAccountUnstakePrimaryMinerStakeMinerVault, + TAccountUnstakePrimaryMinerStakeTokenProgram, + TAccountUnstakePrimaryMinerStakeMineProgram >; return instruction; @@ -286,14 +315,14 @@ export interface ParsedUnstakePrimaryMinerInstruction< accounts: { mmOwner: TAccountMetas[0]; mmPrimaryTokenAccount: TAccountMetas[1]; - pool: TAccountMetas[2]; - mm: TAccountMetas[3]; - rewarder: TAccountMetas[4]; - quarry: TAccountMetas[5]; - miner: TAccountMetas[6]; - minerVault: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - mineProgram: TAccountMetas[9]; + unstakePrimaryMinerStakePool: TAccountMetas[2]; + unstakePrimaryMinerStakeMm: TAccountMetas[3]; + unstakePrimaryMinerStakeRewarder: TAccountMetas[4]; + unstakePrimaryMinerStakeQuarry: TAccountMetas[5]; + unstakePrimaryMinerStakeMiner: TAccountMetas[6]; + unstakePrimaryMinerStakeMinerVault: TAccountMetas[7]; + unstakePrimaryMinerStakeTokenProgram: TAccountMetas[8]; + unstakePrimaryMinerStakeMineProgram: TAccountMetas[9]; }; data: UnstakePrimaryMinerInstructionData; } @@ -321,14 +350,14 @@ export function parseUnstakePrimaryMinerInstruction< accounts: { mmOwner: getNextAccount(), mmPrimaryTokenAccount: getNextAccount(), - pool: getNextAccount(), - mm: getNextAccount(), - rewarder: getNextAccount(), - quarry: getNextAccount(), - miner: getNextAccount(), - minerVault: getNextAccount(), - tokenProgram: getNextAccount(), - mineProgram: getNextAccount(), + unstakePrimaryMinerStakePool: getNextAccount(), + unstakePrimaryMinerStakeMm: getNextAccount(), + unstakePrimaryMinerStakeRewarder: getNextAccount(), + unstakePrimaryMinerStakeQuarry: getNextAccount(), + unstakePrimaryMinerStakeMiner: getNextAccount(), + unstakePrimaryMinerStakeMinerVault: getNextAccount(), + unstakePrimaryMinerStakeTokenProgram: getNextAccount(), + unstakePrimaryMinerStakeMineProgram: getNextAccount(), }, data: getUnstakePrimaryMinerInstructionDataDecoder().decode( instruction.data, diff --git a/clients/quarry/src/generated/instructions/updateQuarryRewards.ts b/clients/quarry/src/generated/instructions/updateQuarryRewards.ts index c3f15a25..46f27dff 100644 --- a/clients/quarry/src/generated/instructions/updateQuarryRewards.ts +++ b/clients/quarry/src/generated/instructions/updateQuarryRewards.ts @@ -33,9 +33,8 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const UPDATE_QUARRY_REWARDS_DISCRIMINATOR = new Uint8Array([ - 42, 213, 243, 249, 125, 145, 44, 242, -]); +export const UPDATE_QUARRY_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([42, 213, 243, 249, 125, 145, 44, 242]); export function getUpdateQuarryRewardsDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/withdrawTokens.ts b/clients/quarry/src/generated/instructions/withdrawTokens.ts index 1f61e6ff..6e263656 100644 --- a/clients/quarry/src/generated/instructions/withdrawTokens.ts +++ b/clients/quarry/src/generated/instructions/withdrawTokens.ts @@ -38,9 +38,9 @@ import { QUARRY_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const WITHDRAW_TOKENS_DISCRIMINATOR = new Uint8Array([ - 2, 4, 225, 61, 19, 182, 106, 170, -]); +export const WITHDRAW_TOKENS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( + [2, 4, 225, 61, 19, 182, 106, 170], +); export function getWithdrawTokensDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/src/generated/instructions/withdrawTokensMM.ts b/clients/quarry/src/generated/instructions/withdrawTokensMM.ts index b908187c..38e81c60 100644 --- a/clients/quarry/src/generated/instructions/withdrawTokensMM.ts +++ b/clients/quarry/src/generated/instructions/withdrawTokensMM.ts @@ -36,9 +36,8 @@ import { QUARRY_MERGE_MINE_PROGRAM_ADDRESS } from "../programs/index.js"; import type { ResolvedAccount } from "../shared/index.js"; import { getAccountMetaFactory } from "../shared/index.js"; -export const WITHDRAW_TOKENS_M_M_DISCRIMINATOR = new Uint8Array([ - 2, 4, 225, 61, 19, 182, 106, 170, -]); +export const WITHDRAW_TOKENS_M_M_DISCRIMINATOR: ReadonlyUint8Array = + new Uint8Array([2, 4, 225, 61, 19, 182, 106, 170]); export function getWithdrawTokensMMDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( diff --git a/clients/quarry/tsconfig.json b/clients/quarry/tsconfig.json index c9d54033..e528d933 100644 --- a/clients/quarry/tsconfig.json +++ b/clients/quarry/tsconfig.json @@ -1,6 +1,3 @@ { - "extends": "@macalinao/tsconfig/tsconfig.base.json", - "compilerOptions": { - "isolatedDeclarations": false - } + "extends": "@macalinao/tsconfig/tsconfig.base.json" } diff --git a/clients/token-metadata/coda.config.mjs b/clients/token-metadata/coda.config.mjs index 9652c6a8..53c3f881 100644 --- a/clients/token-metadata/coda.config.mjs +++ b/clients/token-metadata/coda.config.mjs @@ -1,10 +1,10 @@ -import { defineConfig } from "@macalinao/coda"; import { addPdasVisitor, constantPdaSeedNodeFromString, + defineConfig, publicKeyTypeNode, variablePdaSeedNode, -} from "codama"; +} from "@macalinao/coda"; const addCustomPDAsVisitor = addPdasVisitor({ tokenMetadata: [ diff --git a/clients/token-metadata/docs/token-metadata.md b/clients/token-metadata/docs/token-metadata.md index afa2a170..1b621e2b 100644 --- a/clients/token-metadata/docs/token-metadata.md +++ b/clients/token-metadata/docs/token-metadata.md @@ -23,118 +23,118 @@ - [reservationListV1](#reservationListV1) - [useAuthorityRecord](#useAuthorityRecord) - [Instructions](#instructions) - - [createMetadataAccount](#createMetadataAccount-1) - - [updateMetadataAccount](#updateMetadataAccount-1) - - [deprecatedCreateMasterEdition](#deprecatedCreateMasterEdition-1) - - [deprecatedMintNewEditionFromMasterEditionViaPrintingToken](#deprecatedMintNewEditionFromMasterEditionViaPrintingToken-1) - - [updatePrimarySaleHappenedViaToken](#updatePrimarySaleHappenedViaToken-1) - - [deprecatedSetReservationList](#deprecatedSetReservationList-1) - - [deprecatedCreateReservationList](#deprecatedCreateReservationList-1) - - [signMetadata](#signMetadata-1) - - [deprecatedMintPrintingTokensViaToken](#deprecatedMintPrintingTokensViaToken-1) - - [deprecatedMintPrintingTokens](#deprecatedMintPrintingTokens-1) - - [createMasterEdition](#createMasterEdition-1) - - [mintNewEditionFromMasterEditionViaToken](#mintNewEditionFromMasterEditionViaToken-1) - - [convertMasterEditionV1ToV2](#convertMasterEditionV1ToV2-1) - - [mintNewEditionFromMasterEditionViaVaultProxy](#mintNewEditionFromMasterEditionViaVaultProxy-1) - - [puffMetadata](#puffMetadata-1) - - [updateMetadataAccountV2](#updateMetadataAccountV2-1) - - [createMetadataAccountV2](#createMetadataAccountV2-1) - - [createMasterEditionV3](#createMasterEditionV3-1) - - [verifyCollection](#verifyCollection-1) - - [utilize](#utilize-1) - - [approveUseAuthority](#approveUseAuthority-1) - - [revokeUseAuthority](#revokeUseAuthority-1) - - [unverifyCollection](#unverifyCollection-1) - - [approveCollectionAuthority](#approveCollectionAuthority-1) - - [revokeCollectionAuthority](#revokeCollectionAuthority-1) - - [setAndVerifyCollection](#setAndVerifyCollection-1) - - [freezeDelegatedAccount](#freezeDelegatedAccount-1) - - [thawDelegatedAccount](#thawDelegatedAccount-1) - - [removeCreatorVerification](#removeCreatorVerification-1) - - [burnNft](#burnNft-1) - - [verifySizedCollectionItem](#verifySizedCollectionItem-1) - - [unverifySizedCollectionItem](#unverifySizedCollectionItem-1) - - [setAndVerifySizedCollectionItem](#setAndVerifySizedCollectionItem-1) - - [createMetadataAccountV3](#createMetadataAccountV3-1) - - [setCollectionSize](#setCollectionSize-1) - - [setTokenStandard](#setTokenStandard-1) - - [bubblegumSetCollectionSize](#bubblegumSetCollectionSize-1) - - [burnEditionNft](#burnEditionNft-1) - - [createEscrowAccount](#createEscrowAccount-1) - - [closeEscrowAccount](#closeEscrowAccount-1) - - [transferOutOfEscrow](#transferOutOfEscrow-1) - - [burn](#burn-1) - - [create](#create-1) - - [mint](#mint-1) - - [delegate](#delegate-1) - - [revoke](#revoke-1) - - [lock](#lock-1) - - [unlock](#unlock-1) - - [migrate](#migrate-1) - - [transfer](#transfer-1) - - [update](#update-1) - - [use](#use-1) - - [verify](#verify-1) - - [unverify](#unverify-1) - - [collect](#collect-1) - - [print](#print-1) - - [resize](#resize-1) - - [closeAccounts](#closeAccounts-1) + - [createMetadataAccount](#createMetadataAccount) + - [updateMetadataAccount](#updateMetadataAccount) + - [deprecatedCreateMasterEdition](#deprecatedCreateMasterEdition) + - [deprecatedMintNewEditionFromMasterEditionViaPrintingToken](#deprecatedMintNewEditionFromMasterEditionViaPrintingToken) + - [updatePrimarySaleHappenedViaToken](#updatePrimarySaleHappenedViaToken) + - [deprecatedSetReservationList](#deprecatedSetReservationList) + - [deprecatedCreateReservationList](#deprecatedCreateReservationList) + - [signMetadata](#signMetadata) + - [deprecatedMintPrintingTokensViaToken](#deprecatedMintPrintingTokensViaToken) + - [deprecatedMintPrintingTokens](#deprecatedMintPrintingTokens) + - [createMasterEdition](#createMasterEdition) + - [mintNewEditionFromMasterEditionViaToken](#mintNewEditionFromMasterEditionViaToken) + - [convertMasterEditionV1ToV2](#convertMasterEditionV1ToV2) + - [mintNewEditionFromMasterEditionViaVaultProxy](#mintNewEditionFromMasterEditionViaVaultProxy) + - [puffMetadata](#puffMetadata) + - [updateMetadataAccountV2](#updateMetadataAccountV2) + - [createMetadataAccountV2](#createMetadataAccountV2) + - [createMasterEditionV3](#createMasterEditionV3) + - [verifyCollection](#verifyCollection) + - [utilize](#utilize) + - [approveUseAuthority](#approveUseAuthority) + - [revokeUseAuthority](#revokeUseAuthority) + - [unverifyCollection](#unverifyCollection) + - [approveCollectionAuthority](#approveCollectionAuthority) + - [revokeCollectionAuthority](#revokeCollectionAuthority) + - [setAndVerifyCollection](#setAndVerifyCollection) + - [freezeDelegatedAccount](#freezeDelegatedAccount) + - [thawDelegatedAccount](#thawDelegatedAccount) + - [removeCreatorVerification](#removeCreatorVerification) + - [burnNft](#burnNft) + - [verifySizedCollectionItem](#verifySizedCollectionItem) + - [unverifySizedCollectionItem](#unverifySizedCollectionItem) + - [setAndVerifySizedCollectionItem](#setAndVerifySizedCollectionItem) + - [createMetadataAccountV3](#createMetadataAccountV3) + - [setCollectionSize](#setCollectionSize) + - [setTokenStandard](#setTokenStandard) + - [bubblegumSetCollectionSize](#bubblegumSetCollectionSize) + - [burnEditionNft](#burnEditionNft) + - [createEscrowAccount](#createEscrowAccount) + - [closeEscrowAccount](#closeEscrowAccount) + - [transferOutOfEscrow](#transferOutOfEscrow) + - [burn](#burn) + - [create](#create) + - [mint](#mint) + - [delegate](#delegate) + - [revoke](#revoke) + - [lock](#lock) + - [unlock](#unlock) + - [migrate](#migrate) + - [transfer](#transfer) + - [update](#update) + - [use](#use) + - [verify](#verify) + - [unverify](#unverify) + - [collect](#collect) + - [print](#print) + - [resize](#resize) + - [closeAccounts](#closeAccounts) - [PDAs](#pdas) - - [metadata](#metadata-2) + - [metadata](#metadata) - [Types](#types) - - [setCollectionSizeArgs](#setCollectionSizeArgs-3) - - [createMasterEditionArgs](#createMasterEditionArgs-3) - - [mintNewEditionFromMasterEditionViaTokenArgs](#mintNewEditionFromMasterEditionViaTokenArgs-3) - - [transferOutOfEscrowArgs](#transferOutOfEscrowArgs-3) - - [createMetadataAccountArgsV3](#createMetadataAccountArgsV3-3) - - [updateMetadataAccountArgsV2](#updateMetadataAccountArgsV2-3) - - [approveUseAuthorityArgs](#approveUseAuthorityArgs-3) - - [utilizeArgs](#utilizeArgs-3) - - [authorizationData](#authorizationData-3) - - [assetData](#assetData-3) - - [collection](#collection-3) - - [creator](#creator-3) - - [data](#data-3) - - [dataV2](#dataV2-3) - - [reservation](#reservation-3) - - [reservationV1](#reservationV1-3) - - [seedsVec](#seedsVec-3) - - [proofInfo](#proofInfo-3) - - [payload](#payload-3) - - [uses](#uses-3) - - [burnArgs](#burnArgs-3) - - [delegateArgs](#delegateArgs-3) - - [revokeArgs](#revokeArgs-3) - - [metadataDelegateRole](#metadataDelegateRole-3) - - [holderDelegateRole](#holderDelegateRole-3) - - [createArgs](#createArgs-3) - - [mintArgs](#mintArgs-3) - - [transferArgs](#transferArgs-3) - - [updateArgs](#updateArgs-3) - - [collectionToggle](#collectionToggle-3) - - [usesToggle](#usesToggle-3) - - [collectionDetailsToggle](#collectionDetailsToggle-3) - - [ruleSetToggle](#ruleSetToggle-3) - - [printArgs](#printArgs-3) - - [lockArgs](#lockArgs-3) - - [unlockArgs](#unlockArgs-3) - - [useArgs](#useArgs-3) - - [verificationArgs](#verificationArgs-3) - - [tokenStandard](#tokenStandard-3) - - [key](#key-3) - - [collectionDetails](#collectionDetails-3) - - [escrowAuthority](#escrowAuthority-3) - - [printSupply](#printSupply-3) - - [programmableConfig](#programmableConfig-3) - - [migrationType](#migrationType-3) - - [tokenState](#tokenState-3) - - [tokenDelegateRole](#tokenDelegateRole-3) - - [authorityType](#authorityType-3) - - [payloadKey](#payloadKey-3) - - [payloadType](#payloadType-3) - - [useMethod](#useMethod-3) + - [setCollectionSizeArgs](#setCollectionSizeArgs) + - [createMasterEditionArgs](#createMasterEditionArgs) + - [mintNewEditionFromMasterEditionViaTokenArgs](#mintNewEditionFromMasterEditionViaTokenArgs) + - [transferOutOfEscrowArgs](#transferOutOfEscrowArgs) + - [createMetadataAccountArgsV3](#createMetadataAccountArgsV3) + - [updateMetadataAccountArgsV2](#updateMetadataAccountArgsV2) + - [approveUseAuthorityArgs](#approveUseAuthorityArgs) + - [utilizeArgs](#utilizeArgs) + - [authorizationData](#authorizationData) + - [assetData](#assetData) + - [collection](#collection) + - [creator](#creator) + - [data](#data) + - [dataV2](#dataV2) + - [reservation](#reservation) + - [reservationV1](#reservationV1) + - [seedsVec](#seedsVec) + - [proofInfo](#proofInfo) + - [payload](#payload) + - [uses](#uses) + - [burnArgs](#burnArgs) + - [delegateArgs](#delegateArgs) + - [revokeArgs](#revokeArgs) + - [metadataDelegateRole](#metadataDelegateRole) + - [holderDelegateRole](#holderDelegateRole) + - [createArgs](#createArgs) + - [mintArgs](#mintArgs) + - [transferArgs](#transferArgs) + - [updateArgs](#updateArgs) + - [collectionToggle](#collectionToggle) + - [usesToggle](#usesToggle) + - [collectionDetailsToggle](#collectionDetailsToggle) + - [ruleSetToggle](#ruleSetToggle) + - [printArgs](#printArgs) + - [lockArgs](#lockArgs) + - [unlockArgs](#unlockArgs) + - [useArgs](#useArgs) + - [verificationArgs](#verificationArgs) + - [tokenStandard](#tokenStandard) + - [key](#key) + - [collectionDetails](#collectionDetails) + - [escrowAuthority](#escrowAuthority) + - [printSupply](#printSupply) + - [programmableConfig](#programmableConfig) + - [migrationType](#migrationType) + - [tokenState](#tokenState) + - [tokenDelegateRole](#tokenDelegateRole) + - [authorityType](#authorityType) + - [payloadKey](#payloadKey) + - [payloadType](#payloadType) + - [useMethod](#useMethod) - [Errors](#errors) ## Accounts @@ -2173,206 +2173,206 @@ ## Errors -- **instructionUnpackError** (Code: 0 / `000` / `0x0`) -- -- **instructionPackError** (Code: 1 / `001` / `0x1`) -- -- **notRentExempt** (Code: 2 / `002` / `0x2`) -- Lamport balance below rent-exempt threshold -- **alreadyInitialized** (Code: 3 / `003` / `0x3`) -- Already initialized -- **uninitialized** (Code: 4 / `004` / `0x4`) -- Uninitialized -- **invalidMetadataKey** (Code: 5 / `005` / `0x5`) -- Metadata's key must match seed of ['metadata', program id, mint] provided -- **invalidEditionKey** (Code: 6 / `006` / `0x6`) -- Edition's key must match seed of ['metadata', program id, name, 'edition'] provided -- **updateAuthorityIncorrect** (Code: 7 / `007` / `0x7`) -- Update Authority given does not match -- **updateAuthorityIsNotSigner** (Code: 8 / `008` / `0x8`) -- Update Authority needs to be signer to update metadata -- **notMintAuthority** (Code: 9 / `009` / `0x9`) -- You must be the mint authority and signer on this transaction -- **invalidMintAuthority** (Code: 10 / `010` / `0xa`) -- Mint authority provided does not match the authority on the mint -- **nameTooLong** (Code: 11 / `011` / `0xb`) -- Name too long -- **symbolTooLong** (Code: 12 / `012` / `0xc`) -- Symbol too long -- **uriTooLong** (Code: 13 / `013` / `0xd`) -- URI too long -- **updateAuthorityMustBeEqualToMetadataAuthorityAndSigner** (Code: 14 / `014` / `0xe`) -- -- **mintMismatch** (Code: 15 / `015` / `0xf`) -- Mint given does not match mint on Metadata -- **editionsMustHaveExactlyOneToken** (Code: 16 / `016` / `0x10`) -- Editions must have exactly one token -- **maxEditionsMintedAlready** (Code: 17 / `017` / `0x11`) -- -- **tokenMintToFailed** (Code: 18 / `018` / `0x12`) -- -- **masterRecordMismatch** (Code: 19 / `019` / `0x13`) -- -- **destinationMintMismatch** (Code: 20 / `020` / `0x14`) -- -- **editionAlreadyMinted** (Code: 21 / `021` / `0x15`) -- -- **printingMintDecimalsShouldBeZero** (Code: 22 / `022` / `0x16`) -- -- **oneTimePrintingAuthorizationMintDecimalsShouldBeZero** (Code: 23 / `023` / `0x17`) -- -- **editionMintDecimalsShouldBeZero** (Code: 24 / `024` / `0x18`) -- EditionMintDecimalsShouldBeZero -- **tokenBurnFailed** (Code: 25 / `025` / `0x19`) -- -- **tokenAccountOneTimeAuthMintMismatch** (Code: 26 / `026` / `0x1a`) -- -- **derivedKeyInvalid** (Code: 27 / `027` / `0x1b`) -- Derived key invalid -- **printingMintMismatch** (Code: 28 / `028` / `0x1c`) -- The Printing mint does not match that on the master edition! -- **oneTimePrintingAuthMintMismatch** (Code: 29 / `029` / `0x1d`) -- The One Time Printing Auth mint does not match that on the master edition! -- **tokenAccountMintMismatch** (Code: 30 / `030` / `0x1e`) -- The mint of the token account does not match the Printing mint! -- **tokenAccountMintMismatchV2** (Code: 31 / `031` / `0x1f`) -- The mint of the token account does not match the master metadata mint! -- **notEnoughTokens** (Code: 32 / `032` / `0x20`) -- Not enough tokens to mint a limited edition -- **printingMintAuthorizationAccountMismatch** (Code: 33 / `033` / `0x21`) -- -- **authorizationTokenAccountOwnerMismatch** (Code: 34 / `034` / `0x22`) -- -- **disabled** (Code: 35 / `035` / `0x23`) -- -- **creatorsTooLong** (Code: 36 / `036` / `0x24`) -- Creators list too long -- **creatorsMustBeAtleastOne** (Code: 37 / `037` / `0x25`) -- Creators must be at least one if set -- **mustBeOneOfCreators** (Code: 38 / `038` / `0x26`) -- -- **noCreatorsPresentOnMetadata** (Code: 39 / `039` / `0x27`) -- This metadata does not have creators -- **creatorNotFound** (Code: 40 / `040` / `0x28`) -- This creator address was not found -- **invalidBasisPoints** (Code: 41 / `041` / `0x29`) -- Basis points cannot be more than 10000 -- **primarySaleCanOnlyBeFlippedToTrue** (Code: 42 / `042` / `0x2a`) -- Primary sale can only be flipped to true and is immutable -- **ownerMismatch** (Code: 43 / `043` / `0x2b`) -- Owner does not match that on the account given -- **noBalanceInAccountForAuthorization** (Code: 44 / `044` / `0x2c`) -- This account has no tokens to be used for authorization -- **shareTotalMustBe100** (Code: 45 / `045` / `0x2d`) -- Share total must equal 100 for creator array -- **reservationExists** (Code: 46 / `046` / `0x2e`) -- -- **reservationDoesNotExist** (Code: 47 / `047` / `0x2f`) -- -- **reservationNotSet** (Code: 48 / `048` / `0x30`) -- -- **reservationAlreadyMade** (Code: 49 / `049` / `0x31`) -- -- **beyondMaxAddressSize** (Code: 50 / `050` / `0x32`) -- -- **numericalOverflowError** (Code: 51 / `051` / `0x33`) -- NumericalOverflowError -- **reservationBreachesMaximumSupply** (Code: 52 / `052` / `0x34`) -- -- **addressNotInReservation** (Code: 53 / `053` / `0x35`) -- -- **cannotVerifyAnotherCreator** (Code: 54 / `054` / `0x36`) -- You cannot unilaterally verify another creator, they must sign -- **cannotUnverifyAnotherCreator** (Code: 55 / `055` / `0x37`) -- You cannot unilaterally unverify another creator -- **spotMismatch** (Code: 56 / `056` / `0x38`) -- -- **incorrectOwner** (Code: 57 / `057` / `0x39`) -- Incorrect account owner -- **printingWouldBreachMaximumSupply** (Code: 58 / `058` / `0x3a`) -- -- **dataIsImmutable** (Code: 59 / `059` / `0x3b`) -- Data is immutable -- **duplicateCreatorAddress** (Code: 60 / `060` / `0x3c`) -- No duplicate creator addresses -- **reservationSpotsRemainingShouldMatchTotalSpotsAtStart** (Code: 61 / `061` / `0x3d`) -- -- **invalidTokenProgram** (Code: 62 / `062` / `0x3e`) -- Invalid token program -- **dataTypeMismatch** (Code: 63 / `063` / `0x3f`) -- Data type mismatch -- **beyondAlottedAddressSize** (Code: 64 / `064` / `0x40`) -- -- **reservationNotComplete** (Code: 65 / `065` / `0x41`) -- -- **triedToReplaceAnExistingReservation** (Code: 66 / `066` / `0x42`) -- -- **invalidOperation** (Code: 67 / `067` / `0x43`) -- Invalid operation -- **invalidOwner** (Code: 68 / `068` / `0x44`) -- Invalid Owner -- **printingMintSupplyMustBeZeroForConversion** (Code: 69 / `069` / `0x45`) -- Printing mint supply must be zero for conversion -- **oneTimeAuthMintSupplyMustBeZeroForConversion** (Code: 70 / `070` / `0x46`) -- One Time Auth mint supply must be zero for conversion -- **invalidEditionIndex** (Code: 71 / `071` / `0x47`) -- You tried to insert one edition too many into an edition mark pda -- **reservationArrayShouldBeSizeOne** (Code: 72 / `072` / `0x48`) -- -- **isMutableCanOnlyBeFlippedToFalse** (Code: 73 / `073` / `0x49`) -- Is Mutable can only be flipped to false -- **collectionCannotBeVerifiedInThisInstruction** (Code: 74 / `074` / `0x4a`) -- Collection cannot be verified in this instruction -- **removed** (Code: 75 / `075` / `0x4b`) -- This instruction was deprecated in a previous release and is now removed -- **mustBeBurned** (Code: 76 / `076` / `0x4c`) -- -- **invalidUseMethod** (Code: 77 / `077` / `0x4d`) -- This use method is invalid -- **cannotChangeUseMethodAfterFirstUse** (Code: 78 / `078` / `0x4e`) -- Cannot Change Use Method after the first use -- **cannotChangeUsesAfterFirstUse** (Code: 79 / `079` / `0x4f`) -- Cannot Change Remaining or Available uses after the first use -- **collectionNotFound** (Code: 80 / `080` / `0x50`) -- Collection Not Found on Metadata -- **invalidCollectionUpdateAuthority** (Code: 81 / `081` / `0x51`) -- Collection Update Authority is invalid -- **collectionMustBeAUniqueMasterEdition** (Code: 82 / `082` / `0x52`) -- Collection Must Be a Unique Master Edition v2 -- **useAuthorityRecordAlreadyExists** (Code: 83 / `083` / `0x53`) -- The Use Authority Record Already Exists, to modify it Revoke, then Approve -- **useAuthorityRecordAlreadyRevoked** (Code: 84 / `084` / `0x54`) -- The Use Authority Record is empty or already revoked -- **unusable** (Code: 85 / `085` / `0x55`) -- This token has no uses -- **notEnoughUses** (Code: 86 / `086` / `0x56`) -- There are not enough Uses left on this token. -- **collectionAuthorityRecordAlreadyExists** (Code: 87 / `087` / `0x57`) -- This Collection Authority Record Already Exists. -- **collectionAuthorityDoesNotExist** (Code: 88 / `088` / `0x58`) -- This Collection Authority Record Does Not Exist. -- **invalidUseAuthorityRecord** (Code: 89 / `089` / `0x59`) -- This Use Authority Record is invalid. -- **invalidCollectionAuthorityRecord** (Code: 90 / `090` / `0x5a`) -- -- **invalidFreezeAuthority** (Code: 91 / `091` / `0x5b`) -- Metadata does not match the freeze authority on the mint -- **invalidDelegate** (Code: 92 / `092` / `0x5c`) -- All tokens in this account have not been delegated to this user. -- **cannotAdjustVerifiedCreator** (Code: 93 / `093` / `0x5d`) -- -- **cannotRemoveVerifiedCreator** (Code: 94 / `094` / `0x5e`) -- Verified creators cannot be removed. -- **cannotWipeVerifiedCreators** (Code: 95 / `095` / `0x5f`) -- -- **notAllowedToChangeSellerFeeBasisPoints** (Code: 96 / `096` / `0x60`) -- -- **editionOverrideCannotBeZero** (Code: 97 / `097` / `0x61`) -- Edition override cannot be zero -- **invalidUser** (Code: 98 / `098` / `0x62`) -- Invalid User -- **revokeCollectionAuthoritySignerIncorrect** (Code: 99 / `099` / `0x63`) -- Revoke Collection Authority signer is incorrect -- **tokenCloseFailed** (Code: 100 / `100` / `0x64`) -- -- **unsizedCollection** (Code: 101 / `101` / `0x65`) -- Can't use this function on unsized collection -- **sizedCollection** (Code: 102 / `102` / `0x66`) -- Can't use this function on a sized collection -- **missingCollectionMetadata** (Code: 103 / `103` / `0x67`) -- Missing collection metadata account -- **notAMemberOfCollection** (Code: 104 / `104` / `0x68`) -- This NFT is not a member of the specified collection. -- **notVerifiedMemberOfCollection** (Code: 105 / `105` / `0x69`) -- This NFT is not a verified member of the specified collection. -- **notACollectionParent** (Code: 106 / `106` / `0x6a`) -- This NFT is not a collection parent NFT. -- **couldNotDetermineTokenStandard** (Code: 107 / `107` / `0x6b`) -- Could not determine a TokenStandard type. -- **missingEditionAccount** (Code: 108 / `108` / `0x6c`) -- This mint account has an edition but none was provided. -- **notAMasterEdition** (Code: 109 / `109` / `0x6d`) -- This edition is not a Master Edition -- **masterEditionHasPrints** (Code: 110 / `110` / `0x6e`) -- This Master Edition has existing prints -- **borshDeserializationError** (Code: 111 / `111` / `0x6f`) -- -- **cannotUpdateVerifiedCollection** (Code: 112 / `112` / `0x70`) -- Cannot update a verified collection in this command -- **collectionMasterEditionAccountInvalid** (Code: 113 / `113` / `0x71`) -- Edition account doesnt match collection -- **alreadyVerified** (Code: 114 / `114` / `0x72`) -- Item is already verified. -- **alreadyUnverified** (Code: 115 / `115` / `0x73`) -- -- **notAPrintEdition** (Code: 116 / `116` / `0x74`) -- This edition is not a Print Edition -- **invalidMasterEdition** (Code: 117 / `117` / `0x75`) -- Invalid Master Edition -- **invalidPrintEdition** (Code: 118 / `118` / `0x76`) -- Invalid Print Edition -- **invalidEditionMarker** (Code: 119 / `119` / `0x77`) -- Invalid Edition Marker -- **reservationListDeprecated** (Code: 120 / `120` / `0x78`) -- Reservation List is Deprecated -- **printEditionDoesNotMatchMasterEdition** (Code: 121 / `121` / `0x79`) -- Print Edition does not match Master Edition -- **editionNumberGreaterThanMaxSupply** (Code: 122 / `122` / `0x7a`) -- Edition Number greater than max supply -- **mustUnverify** (Code: 123 / `123` / `0x7b`) -- Must unverify before migrating collections. -- **invalidEscrowBumpSeed** (Code: 124 / `124` / `0x7c`) -- Invalid Escrow Account Bump Seed -- **mustBeEscrowAuthority** (Code: 125 / `125` / `0x7d`) -- Must Escrow Authority -- **invalidSystemProgram** (Code: 126 / `126` / `0x7e`) -- Invalid System Program -- **mustBeNonFungible** (Code: 127 / `127` / `0x7f`) -- Must be a Non Fungible Token -- **insufficientTokens** (Code: 128 / `128` / `0x80`) -- Insufficient tokens for transfer -- **borshSerializationError** (Code: 129 / `129` / `0x81`) -- Borsh Serialization Error -- **noFreezeAuthoritySet** (Code: 130 / `130` / `0x82`) -- Cannot create NFT with no Freeze Authority. -- **invalidCollectionSizeChange** (Code: 131 / `131` / `0x83`) -- Invalid collection size change -- **invalidBubblegumSigner** (Code: 132 / `132` / `0x84`) -- Invalid bubblegum signer -- **escrowParentHasDelegate** (Code: 133 / `133` / `0x85`) -- Escrow parent cannot have a delegate -- **mintIsNotSigner** (Code: 134 / `134` / `0x86`) -- Mint needs to be signer to initialize the account -- **invalidTokenStandard** (Code: 135 / `135` / `0x87`) -- Invalid token standard -- **invalidMintForTokenStandard** (Code: 136 / `136` / `0x88`) -- Invalid mint account for specified token standard -- **invalidAuthorizationRules** (Code: 137 / `137` / `0x89`) -- Invalid authorization rules account -- **missingAuthorizationRules** (Code: 138 / `138` / `0x8a`) -- Missing authorization rules account -- **missingProgrammableConfig** (Code: 139 / `139` / `0x8b`) -- Missing programmable configuration -- **invalidProgrammableConfig** (Code: 140 / `140` / `0x8c`) -- Invalid programmable configuration -- **delegateAlreadyExists** (Code: 141 / `141` / `0x8d`) -- Delegate already exists -- **delegateNotFound** (Code: 142 / `142` / `0x8e`) -- Delegate not found -- **missingAccountInBuilder** (Code: 143 / `143` / `0x8f`) -- Required account not set in instruction builder -- **missingArgumentInBuilder** (Code: 144 / `144` / `0x90`) -- Required argument not set in instruction builder -- **featureNotSupported** (Code: 145 / `145` / `0x91`) -- Feature not supported currently -- **invalidSystemWallet** (Code: 146 / `146` / `0x92`) -- Invalid system wallet -- **onlySaleDelegateCanTransfer** (Code: 147 / `147` / `0x93`) -- Only the sale delegate can transfer while its set -- **missingTokenAccount** (Code: 148 / `148` / `0x94`) -- Missing token account -- **missingSplTokenProgram** (Code: 149 / `149` / `0x95`) -- Missing SPL token program -- **missingAuthorizationRulesProgram** (Code: 150 / `150` / `0x96`) -- Missing authorization rules program -- **invalidDelegateRoleForTransfer** (Code: 151 / `151` / `0x97`) -- Invalid delegate role for transfer -- **invalidTransferAuthority** (Code: 152 / `152` / `0x98`) -- Invalid transfer authority -- **instructionNotSupported** (Code: 153 / `153` / `0x99`) -- Instruction not supported for ProgrammableNonFungible assets -- **keyMismatch** (Code: 154 / `154` / `0x9a`) -- Public key does not match expected value -- **lockedToken** (Code: 155 / `155` / `0x9b`) -- Token is locked -- **unlockedToken** (Code: 156 / `156` / `0x9c`) -- Token is unlocked -- **missingDelegateRole** (Code: 157 / `157` / `0x9d`) -- Missing delegate role -- **invalidAuthorityType** (Code: 158 / `158` / `0x9e`) -- Invalid authority type -- **missingTokenRecord** (Code: 159 / `159` / `0x9f`) -- Missing token record account -- **mintSupplyMustBeZero** (Code: 160 / `160` / `0xa0`) -- Mint supply must be zero for programmable assets -- **dataIsEmptyOrZeroed** (Code: 161 / `161` / `0xa1`) -- Data is empty or zeroed -- **missingTokenOwnerAccount** (Code: 162 / `162` / `0xa2`) -- Missing token owner -- **invalidMasterEditionAccountLength** (Code: 163 / `163` / `0xa3`) -- Master edition account has an invalid length -- **incorrectTokenState** (Code: 164 / `164` / `0xa4`) -- Incorrect token state -- **invalidDelegateRole** (Code: 165 / `165` / `0xa5`) -- Invalid delegate role -- **missingPrintSupply** (Code: 166 / `166` / `0xa6`) -- Print supply is required for non-fungibles -- **missingMasterEditionAccount** (Code: 167 / `167` / `0xa7`) -- Missing master edition account -- **amountMustBeGreaterThanZero** (Code: 168 / `168` / `0xa8`) -- Amount must be greater than zero -- **invalidDelegateArgs** (Code: 169 / `169` / `0xa9`) -- Invalid delegate args -- **missingLockedTransferAddress** (Code: 170 / `170` / `0xaa`) -- Missing address for locked transfer -- **invalidLockedTransferAddress** (Code: 171 / `171` / `0xab`) -- Invalid destination address for locked transfer -- **dataIncrementLimitExceeded** (Code: 172 / `172` / `0xac`) -- Exceeded account realloc increase limit -- **cannotUpdateAssetWithDelegate** (Code: 173 / `173` / `0xad`) -- Cannot update the rule set of a programmable asset that has a delegate -- **invalidAmount** (Code: 174 / `174` / `0xae`) -- Invalid token amount for this operation or token standard -- **missingMasterEditionMintAccount** (Code: 175 / `175` / `0xaf`) -- Missing master edition mint account -- **missingMasterEditionTokenAccount** (Code: 176 / `176` / `0xb0`) -- Missing master edition token account -- **missingEditionMarkerAccount** (Code: 177 / `177` / `0xb1`) -- Missing edition marker account -- **cannotBurnWithDelegate** (Code: 178 / `178` / `0xb2`) -- Cannot burn while persistent delegate is set -- **missingEdition** (Code: 179 / `179` / `0xb3`) -- Missing edition account -- **invalidAssociatedTokenAccountProgram** (Code: 180 / `180` / `0xb4`) -- Invalid Associated Token Account Program -- **invalidInstructionsSysvar** (Code: 181 / `181` / `0xb5`) -- Invalid InstructionsSysvar -- **invalidParentAccounts** (Code: 182 / `182` / `0xb6`) -- Invalid or Unneeded parent accounts -- **invalidUpdateArgs** (Code: 183 / `183` / `0xb7`) -- Authority cannot apply all update args -- **insufficientTokenBalance** (Code: 184 / `184` / `0xb8`) -- Token account does not have enough tokens -- **missingCollectionMint** (Code: 185 / `185` / `0xb9`) -- Missing collection account -- **missingCollectionMasterEdition** (Code: 186 / `186` / `0xba`) -- Missing collection master edition account -- **invalidTokenRecord** (Code: 187 / `187` / `0xbb`) -- Invalid token record account -- **invalidCloseAuthority** (Code: 188 / `188` / `0xbc`) -- The close authority needs to be revoked by the Utility Delegate -- **invalidInstruction** (Code: 189 / `189` / `0xbd`) -- Invalid or removed instruction -- **missingDelegateRecord** (Code: 190 / `190` / `0xbe`) -- Missing delegate record -- **invalidFeeAccount** (Code: 191 / `191` / `0xbf`) -- -- **invalidMetadataFlags** (Code: 192 / `192` / `0xc0`) -- -- **cannotChangeUpdateAuthorityWithDelegate** (Code: 193 / `193` / `0xc1`) -- Cannot change the update authority with a delegate -- **invalidMintExtensionType** (Code: 194 / `194` / `0xc2`) -- Invalid mint extension type -- **invalidMintCloseAuthority** (Code: 195 / `195` / `0xc3`) -- Invalid mint close authority -- **invalidMetadataPointer** (Code: 196 / `196` / `0xc4`) -- Invalid metadata pointer -- **invalidTokenExtensionType** (Code: 197 / `197` / `0xc5`) -- Invalid token extension type -- **missingImmutableOwnerExtension** (Code: 198 / `198` / `0xc6`) -- Missing immutable owner extension -- **expectedUninitializedAccount** (Code: 199 / `199` / `0xc7`) -- Expected account to be uninitialized -- **invalidEditionAccountLength** (Code: 200 / `200` / `0xc8`) -- Edition account has an invalid length -- **accountAlreadyResized** (Code: 201 / `201` / `0xc9`) -- Account has already been resized -- **conditionsForClosingNotMet** (Code: 202 / `202` / `0xca`) -- Conditions for closing not met +- **0 - InstructionUnpackError**: _(Hex: `0x0`)_ +- **1 - InstructionPackError**: _(Hex: `0x1`)_ +- **2 - NotRentExempt**: Lamport balance below rent-exempt threshold _(Hex: `0x2`)_ +- **3 - AlreadyInitialized**: Already initialized _(Hex: `0x3`)_ +- **4 - Uninitialized**: Uninitialized _(Hex: `0x4`)_ +- **5 - InvalidMetadataKey**: Metadata's key must match seed of ['metadata', program id, mint] provided _(Hex: `0x5`)_ +- **6 - InvalidEditionKey**: Edition's key must match seed of ['metadata', program id, name, 'edition'] provided _(Hex: `0x6`)_ +- **7 - UpdateAuthorityIncorrect**: Update Authority given does not match _(Hex: `0x7`)_ +- **8 - UpdateAuthorityIsNotSigner**: Update Authority needs to be signer to update metadata _(Hex: `0x8`)_ +- **9 - NotMintAuthority**: You must be the mint authority and signer on this transaction _(Hex: `0x9`)_ +- **10 - InvalidMintAuthority**: Mint authority provided does not match the authority on the mint _(Hex: `0xa`)_ +- **11 - NameTooLong**: Name too long _(Hex: `0xb`)_ +- **12 - SymbolTooLong**: Symbol too long _(Hex: `0xc`)_ +- **13 - UriTooLong**: URI too long _(Hex: `0xd`)_ +- **14 - UpdateAuthorityMustBeEqualToMetadataAuthorityAndSigner**: _(Hex: `0xe`)_ +- **15 - MintMismatch**: Mint given does not match mint on Metadata _(Hex: `0xf`)_ +- **16 - EditionsMustHaveExactlyOneToken**: Editions must have exactly one token _(Hex: `0x10`)_ +- **17 - MaxEditionsMintedAlready**: _(Hex: `0x11`)_ +- **18 - TokenMintToFailed**: _(Hex: `0x12`)_ +- **19 - MasterRecordMismatch**: _(Hex: `0x13`)_ +- **20 - DestinationMintMismatch**: _(Hex: `0x14`)_ +- **21 - EditionAlreadyMinted**: _(Hex: `0x15`)_ +- **22 - PrintingMintDecimalsShouldBeZero**: _(Hex: `0x16`)_ +- **23 - OneTimePrintingAuthorizationMintDecimalsShouldBeZero**: _(Hex: `0x17`)_ +- **24 - EditionMintDecimalsShouldBeZero**: EditionMintDecimalsShouldBeZero _(Hex: `0x18`)_ +- **25 - TokenBurnFailed**: _(Hex: `0x19`)_ +- **26 - TokenAccountOneTimeAuthMintMismatch**: _(Hex: `0x1a`)_ +- **27 - DerivedKeyInvalid**: Derived key invalid _(Hex: `0x1b`)_ +- **28 - PrintingMintMismatch**: The Printing mint does not match that on the master edition! _(Hex: `0x1c`)_ +- **29 - OneTimePrintingAuthMintMismatch**: The One Time Printing Auth mint does not match that on the master edition! _(Hex: `0x1d`)_ +- **30 - TokenAccountMintMismatch**: The mint of the token account does not match the Printing mint! _(Hex: `0x1e`)_ +- **31 - TokenAccountMintMismatchV2**: The mint of the token account does not match the master metadata mint! _(Hex: `0x1f`)_ +- **32 - NotEnoughTokens**: Not enough tokens to mint a limited edition _(Hex: `0x20`)_ +- **33 - PrintingMintAuthorizationAccountMismatch**: _(Hex: `0x21`)_ +- **34 - AuthorizationTokenAccountOwnerMismatch**: _(Hex: `0x22`)_ +- **35 - Disabled**: _(Hex: `0x23`)_ +- **36 - CreatorsTooLong**: Creators list too long _(Hex: `0x24`)_ +- **37 - CreatorsMustBeAtleastOne**: Creators must be at least one if set _(Hex: `0x25`)_ +- **38 - MustBeOneOfCreators**: _(Hex: `0x26`)_ +- **39 - NoCreatorsPresentOnMetadata**: This metadata does not have creators _(Hex: `0x27`)_ +- **40 - CreatorNotFound**: This creator address was not found _(Hex: `0x28`)_ +- **41 - InvalidBasisPoints**: Basis points cannot be more than 10000 _(Hex: `0x29`)_ +- **42 - PrimarySaleCanOnlyBeFlippedToTrue**: Primary sale can only be flipped to true and is immutable _(Hex: `0x2a`)_ +- **43 - OwnerMismatch**: Owner does not match that on the account given _(Hex: `0x2b`)_ +- **44 - NoBalanceInAccountForAuthorization**: This account has no tokens to be used for authorization _(Hex: `0x2c`)_ +- **45 - ShareTotalMustBe100**: Share total must equal 100 for creator array _(Hex: `0x2d`)_ +- **46 - ReservationExists**: _(Hex: `0x2e`)_ +- **47 - ReservationDoesNotExist**: _(Hex: `0x2f`)_ +- **48 - ReservationNotSet**: _(Hex: `0x30`)_ +- **49 - ReservationAlreadyMade**: _(Hex: `0x31`)_ +- **50 - BeyondMaxAddressSize**: _(Hex: `0x32`)_ +- **51 - NumericalOverflowError**: NumericalOverflowError _(Hex: `0x33`)_ +- **52 - ReservationBreachesMaximumSupply**: _(Hex: `0x34`)_ +- **53 - AddressNotInReservation**: _(Hex: `0x35`)_ +- **54 - CannotVerifyAnotherCreator**: You cannot unilaterally verify another creator, they must sign _(Hex: `0x36`)_ +- **55 - CannotUnverifyAnotherCreator**: You cannot unilaterally unverify another creator _(Hex: `0x37`)_ +- **56 - SpotMismatch**: _(Hex: `0x38`)_ +- **57 - IncorrectOwner**: Incorrect account owner _(Hex: `0x39`)_ +- **58 - PrintingWouldBreachMaximumSupply**: _(Hex: `0x3a`)_ +- **59 - DataIsImmutable**: Data is immutable _(Hex: `0x3b`)_ +- **60 - DuplicateCreatorAddress**: No duplicate creator addresses _(Hex: `0x3c`)_ +- **61 - ReservationSpotsRemainingShouldMatchTotalSpotsAtStart**: _(Hex: `0x3d`)_ +- **62 - InvalidTokenProgram**: Invalid token program _(Hex: `0x3e`)_ +- **63 - DataTypeMismatch**: Data type mismatch _(Hex: `0x3f`)_ +- **64 - BeyondAlottedAddressSize**: _(Hex: `0x40`)_ +- **65 - ReservationNotComplete**: _(Hex: `0x41`)_ +- **66 - TriedToReplaceAnExistingReservation**: _(Hex: `0x42`)_ +- **67 - InvalidOperation**: Invalid operation _(Hex: `0x43`)_ +- **68 - InvalidOwner**: Invalid Owner _(Hex: `0x44`)_ +- **69 - PrintingMintSupplyMustBeZeroForConversion**: Printing mint supply must be zero for conversion _(Hex: `0x45`)_ +- **70 - OneTimeAuthMintSupplyMustBeZeroForConversion**: One Time Auth mint supply must be zero for conversion _(Hex: `0x46`)_ +- **71 - InvalidEditionIndex**: You tried to insert one edition too many into an edition mark pda _(Hex: `0x47`)_ +- **72 - ReservationArrayShouldBeSizeOne**: _(Hex: `0x48`)_ +- **73 - IsMutableCanOnlyBeFlippedToFalse**: Is Mutable can only be flipped to false _(Hex: `0x49`)_ +- **74 - CollectionCannotBeVerifiedInThisInstruction**: Collection cannot be verified in this instruction _(Hex: `0x4a`)_ +- **75 - Removed**: This instruction was deprecated in a previous release and is now removed _(Hex: `0x4b`)_ +- **76 - MustBeBurned**: _(Hex: `0x4c`)_ +- **77 - InvalidUseMethod**: This use method is invalid _(Hex: `0x4d`)_ +- **78 - CannotChangeUseMethodAfterFirstUse**: Cannot Change Use Method after the first use _(Hex: `0x4e`)_ +- **79 - CannotChangeUsesAfterFirstUse**: Cannot Change Remaining or Available uses after the first use _(Hex: `0x4f`)_ +- **80 - CollectionNotFound**: Collection Not Found on Metadata _(Hex: `0x50`)_ +- **81 - InvalidCollectionUpdateAuthority**: Collection Update Authority is invalid _(Hex: `0x51`)_ +- **82 - CollectionMustBeAUniqueMasterEdition**: Collection Must Be a Unique Master Edition v2 _(Hex: `0x52`)_ +- **83 - UseAuthorityRecordAlreadyExists**: The Use Authority Record Already Exists, to modify it Revoke, then Approve _(Hex: `0x53`)_ +- **84 - UseAuthorityRecordAlreadyRevoked**: The Use Authority Record is empty or already revoked _(Hex: `0x54`)_ +- **85 - Unusable**: This token has no uses _(Hex: `0x55`)_ +- **86 - NotEnoughUses**: There are not enough Uses left on this token. _(Hex: `0x56`)_ +- **87 - CollectionAuthorityRecordAlreadyExists**: This Collection Authority Record Already Exists. _(Hex: `0x57`)_ +- **88 - CollectionAuthorityDoesNotExist**: This Collection Authority Record Does Not Exist. _(Hex: `0x58`)_ +- **89 - InvalidUseAuthorityRecord**: This Use Authority Record is invalid. _(Hex: `0x59`)_ +- **90 - InvalidCollectionAuthorityRecord**: _(Hex: `0x5a`)_ +- **91 - InvalidFreezeAuthority**: Metadata does not match the freeze authority on the mint _(Hex: `0x5b`)_ +- **92 - InvalidDelegate**: All tokens in this account have not been delegated to this user. _(Hex: `0x5c`)_ +- **93 - CannotAdjustVerifiedCreator**: _(Hex: `0x5d`)_ +- **94 - CannotRemoveVerifiedCreator**: Verified creators cannot be removed. _(Hex: `0x5e`)_ +- **95 - CannotWipeVerifiedCreators**: _(Hex: `0x5f`)_ +- **96 - NotAllowedToChangeSellerFeeBasisPoints**: _(Hex: `0x60`)_ +- **97 - EditionOverrideCannotBeZero**: Edition override cannot be zero _(Hex: `0x61`)_ +- **98 - InvalidUser**: Invalid User _(Hex: `0x62`)_ +- **99 - RevokeCollectionAuthoritySignerIncorrect**: Revoke Collection Authority signer is incorrect _(Hex: `0x63`)_ +- **100 - TokenCloseFailed**: _(Hex: `0x64`)_ +- **101 - UnsizedCollection**: Can't use this function on unsized collection _(Hex: `0x65`)_ +- **102 - SizedCollection**: Can't use this function on a sized collection _(Hex: `0x66`)_ +- **103 - MissingCollectionMetadata**: Missing collection metadata account _(Hex: `0x67`)_ +- **104 - NotAMemberOfCollection**: This NFT is not a member of the specified collection. _(Hex: `0x68`)_ +- **105 - NotVerifiedMemberOfCollection**: This NFT is not a verified member of the specified collection. _(Hex: `0x69`)_ +- **106 - NotACollectionParent**: This NFT is not a collection parent NFT. _(Hex: `0x6a`)_ +- **107 - CouldNotDetermineTokenStandard**: Could not determine a TokenStandard type. _(Hex: `0x6b`)_ +- **108 - MissingEditionAccount**: This mint account has an edition but none was provided. _(Hex: `0x6c`)_ +- **109 - NotAMasterEdition**: This edition is not a Master Edition _(Hex: `0x6d`)_ +- **110 - MasterEditionHasPrints**: This Master Edition has existing prints _(Hex: `0x6e`)_ +- **111 - BorshDeserializationError**: _(Hex: `0x6f`)_ +- **112 - CannotUpdateVerifiedCollection**: Cannot update a verified collection in this command _(Hex: `0x70`)_ +- **113 - CollectionMasterEditionAccountInvalid**: Edition account doesnt match collection _(Hex: `0x71`)_ +- **114 - AlreadyVerified**: Item is already verified. _(Hex: `0x72`)_ +- **115 - AlreadyUnverified**: _(Hex: `0x73`)_ +- **116 - NotAPrintEdition**: This edition is not a Print Edition _(Hex: `0x74`)_ +- **117 - InvalidMasterEdition**: Invalid Master Edition _(Hex: `0x75`)_ +- **118 - InvalidPrintEdition**: Invalid Print Edition _(Hex: `0x76`)_ +- **119 - InvalidEditionMarker**: Invalid Edition Marker _(Hex: `0x77`)_ +- **120 - ReservationListDeprecated**: Reservation List is Deprecated _(Hex: `0x78`)_ +- **121 - PrintEditionDoesNotMatchMasterEdition**: Print Edition does not match Master Edition _(Hex: `0x79`)_ +- **122 - EditionNumberGreaterThanMaxSupply**: Edition Number greater than max supply _(Hex: `0x7a`)_ +- **123 - MustUnverify**: Must unverify before migrating collections. _(Hex: `0x7b`)_ +- **124 - InvalidEscrowBumpSeed**: Invalid Escrow Account Bump Seed _(Hex: `0x7c`)_ +- **125 - MustBeEscrowAuthority**: Must Escrow Authority _(Hex: `0x7d`)_ +- **126 - InvalidSystemProgram**: Invalid System Program _(Hex: `0x7e`)_ +- **127 - MustBeNonFungible**: Must be a Non Fungible Token _(Hex: `0x7f`)_ +- **128 - InsufficientTokens**: Insufficient tokens for transfer _(Hex: `0x80`)_ +- **129 - BorshSerializationError**: Borsh Serialization Error _(Hex: `0x81`)_ +- **130 - NoFreezeAuthoritySet**: Cannot create NFT with no Freeze Authority. _(Hex: `0x82`)_ +- **131 - InvalidCollectionSizeChange**: Invalid collection size change _(Hex: `0x83`)_ +- **132 - InvalidBubblegumSigner**: Invalid bubblegum signer _(Hex: `0x84`)_ +- **133 - EscrowParentHasDelegate**: Escrow parent cannot have a delegate _(Hex: `0x85`)_ +- **134 - MintIsNotSigner**: Mint needs to be signer to initialize the account _(Hex: `0x86`)_ +- **135 - InvalidTokenStandard**: Invalid token standard _(Hex: `0x87`)_ +- **136 - InvalidMintForTokenStandard**: Invalid mint account for specified token standard _(Hex: `0x88`)_ +- **137 - InvalidAuthorizationRules**: Invalid authorization rules account _(Hex: `0x89`)_ +- **138 - MissingAuthorizationRules**: Missing authorization rules account _(Hex: `0x8a`)_ +- **139 - MissingProgrammableConfig**: Missing programmable configuration _(Hex: `0x8b`)_ +- **140 - InvalidProgrammableConfig**: Invalid programmable configuration _(Hex: `0x8c`)_ +- **141 - DelegateAlreadyExists**: Delegate already exists _(Hex: `0x8d`)_ +- **142 - DelegateNotFound**: Delegate not found _(Hex: `0x8e`)_ +- **143 - MissingAccountInBuilder**: Required account not set in instruction builder _(Hex: `0x8f`)_ +- **144 - MissingArgumentInBuilder**: Required argument not set in instruction builder _(Hex: `0x90`)_ +- **145 - FeatureNotSupported**: Feature not supported currently _(Hex: `0x91`)_ +- **146 - InvalidSystemWallet**: Invalid system wallet _(Hex: `0x92`)_ +- **147 - OnlySaleDelegateCanTransfer**: Only the sale delegate can transfer while its set _(Hex: `0x93`)_ +- **148 - MissingTokenAccount**: Missing token account _(Hex: `0x94`)_ +- **149 - MissingSplTokenProgram**: Missing SPL token program _(Hex: `0x95`)_ +- **150 - MissingAuthorizationRulesProgram**: Missing authorization rules program _(Hex: `0x96`)_ +- **151 - InvalidDelegateRoleForTransfer**: Invalid delegate role for transfer _(Hex: `0x97`)_ +- **152 - InvalidTransferAuthority**: Invalid transfer authority _(Hex: `0x98`)_ +- **153 - InstructionNotSupported**: Instruction not supported for ProgrammableNonFungible assets _(Hex: `0x99`)_ +- **154 - KeyMismatch**: Public key does not match expected value _(Hex: `0x9a`)_ +- **155 - LockedToken**: Token is locked _(Hex: `0x9b`)_ +- **156 - UnlockedToken**: Token is unlocked _(Hex: `0x9c`)_ +- **157 - MissingDelegateRole**: Missing delegate role _(Hex: `0x9d`)_ +- **158 - InvalidAuthorityType**: Invalid authority type _(Hex: `0x9e`)_ +- **159 - MissingTokenRecord**: Missing token record account _(Hex: `0x9f`)_ +- **160 - MintSupplyMustBeZero**: Mint supply must be zero for programmable assets _(Hex: `0xa0`)_ +- **161 - DataIsEmptyOrZeroed**: Data is empty or zeroed _(Hex: `0xa1`)_ +- **162 - MissingTokenOwnerAccount**: Missing token owner _(Hex: `0xa2`)_ +- **163 - InvalidMasterEditionAccountLength**: Master edition account has an invalid length _(Hex: `0xa3`)_ +- **164 - IncorrectTokenState**: Incorrect token state _(Hex: `0xa4`)_ +- **165 - InvalidDelegateRole**: Invalid delegate role _(Hex: `0xa5`)_ +- **166 - MissingPrintSupply**: Print supply is required for non-fungibles _(Hex: `0xa6`)_ +- **167 - MissingMasterEditionAccount**: Missing master edition account _(Hex: `0xa7`)_ +- **168 - AmountMustBeGreaterThanZero**: Amount must be greater than zero _(Hex: `0xa8`)_ +- **169 - InvalidDelegateArgs**: Invalid delegate args _(Hex: `0xa9`)_ +- **170 - MissingLockedTransferAddress**: Missing address for locked transfer _(Hex: `0xaa`)_ +- **171 - InvalidLockedTransferAddress**: Invalid destination address for locked transfer _(Hex: `0xab`)_ +- **172 - DataIncrementLimitExceeded**: Exceeded account realloc increase limit _(Hex: `0xac`)_ +- **173 - CannotUpdateAssetWithDelegate**: Cannot update the rule set of a programmable asset that has a delegate _(Hex: `0xad`)_ +- **174 - InvalidAmount**: Invalid token amount for this operation or token standard _(Hex: `0xae`)_ +- **175 - MissingMasterEditionMintAccount**: Missing master edition mint account _(Hex: `0xaf`)_ +- **176 - MissingMasterEditionTokenAccount**: Missing master edition token account _(Hex: `0xb0`)_ +- **177 - MissingEditionMarkerAccount**: Missing edition marker account _(Hex: `0xb1`)_ +- **178 - CannotBurnWithDelegate**: Cannot burn while persistent delegate is set _(Hex: `0xb2`)_ +- **179 - MissingEdition**: Missing edition account _(Hex: `0xb3`)_ +- **180 - InvalidAssociatedTokenAccountProgram**: Invalid Associated Token Account Program _(Hex: `0xb4`)_ +- **181 - InvalidInstructionsSysvar**: Invalid InstructionsSysvar _(Hex: `0xb5`)_ +- **182 - InvalidParentAccounts**: Invalid or Unneeded parent accounts _(Hex: `0xb6`)_ +- **183 - InvalidUpdateArgs**: Authority cannot apply all update args _(Hex: `0xb7`)_ +- **184 - InsufficientTokenBalance**: Token account does not have enough tokens _(Hex: `0xb8`)_ +- **185 - MissingCollectionMint**: Missing collection account _(Hex: `0xb9`)_ +- **186 - MissingCollectionMasterEdition**: Missing collection master edition account _(Hex: `0xba`)_ +- **187 - InvalidTokenRecord**: Invalid token record account _(Hex: `0xbb`)_ +- **188 - InvalidCloseAuthority**: The close authority needs to be revoked by the Utility Delegate _(Hex: `0xbc`)_ +- **189 - InvalidInstruction**: Invalid or removed instruction _(Hex: `0xbd`)_ +- **190 - MissingDelegateRecord**: Missing delegate record _(Hex: `0xbe`)_ +- **191 - InvalidFeeAccount**: _(Hex: `0xbf`)_ +- **192 - InvalidMetadataFlags**: _(Hex: `0xc0`)_ +- **193 - CannotChangeUpdateAuthorityWithDelegate**: Cannot change the update authority with a delegate _(Hex: `0xc1`)_ +- **194 - InvalidMintExtensionType**: Invalid mint extension type _(Hex: `0xc2`)_ +- **195 - InvalidMintCloseAuthority**: Invalid mint close authority _(Hex: `0xc3`)_ +- **196 - InvalidMetadataPointer**: Invalid metadata pointer _(Hex: `0xc4`)_ +- **197 - InvalidTokenExtensionType**: Invalid token extension type _(Hex: `0xc5`)_ +- **198 - MissingImmutableOwnerExtension**: Missing immutable owner extension _(Hex: `0xc6`)_ +- **199 - ExpectedUninitializedAccount**: Expected account to be uninitialized _(Hex: `0xc7`)_ +- **200 - InvalidEditionAccountLength**: Edition account has an invalid length _(Hex: `0xc8`)_ +- **201 - AccountAlreadyResized**: Account has already been resized _(Hex: `0xc9`)_ +- **202 - ConditionsForClosingNotMet**: Conditions for closing not met _(Hex: `0xca`)_ diff --git a/clients/token-metadata/package.json b/clients/token-metadata/package.json index eaf41de8..cf7231a7 100644 --- a/clients/token-metadata/package.json +++ b/clients/token-metadata/package.json @@ -8,13 +8,15 @@ "homepage": "https://coda.ianm.com", "license": "Apache-2.0", "keywords": [ + "coda", "solana", "metaplex", "token-metadata", "nft", "client", "esm", - "typescript" + "typescript", + "ian-macalinao" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -51,7 +53,6 @@ "@macalinao/eslint-config": "catalog:", "@macalinao/tsconfig": "catalog:", "@solana/kit": "*", - "codama": "*", "eslint": "catalog:", "typescript": "catalog:" }, diff --git a/package.json b/package.json index 571a6886..83df9fdf 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,22 @@ "react-dom": "^19.1.0", "gill": "^0.10.3", "gill-react": "^0.5.0", - "@types/bun": "^1.2.20" + "@types/bun": "^1.2.20", + "codama": "^1.3.3", + "@codama/nodes": "^1.3.3", + "@codama/nodes-from-anchor": "^1.2.5", + "@codama/validators": "^1.1.3", + "@codama/visitors": "^1.1.3", + "@codama/errors": "^1.1.3", + "@codama/node-types": "^1.1.3", + "@codama/renderers-core": "^1.0.19", + "@codama/renderers-js": "^1.3.4", + "@codama/visitors-core": "^1.3.3" } }, "scripts": { "build": "turbo build", + "build:ci": "turbo build --filter='./{packages,clients}/**'", "build:packages": "turbo build --filter='./packages/**'", "build:watch": "turbo watch build", "build:watch:packages": "turbo watch build --filter='./packages/**'", @@ -52,7 +63,7 @@ "devDependencies": { "@biomejs/biome": "^2.2.0", "@changesets/cli": "^2.29.6", - "eslint": "^9.33.0", + "eslint": "^9.34.0", "glob": "^11.0.3", "husky": "^9.1.7", "lint-staged": "^16.1.5", @@ -67,8 +78,5 @@ "overrides": { "react": "^19.1.1", "react-dom": "^19.1.1" - }, - "dependencies": { - "dnum": "^2.15.0" } } diff --git a/packages/coda/README.md b/packages/coda/README.md index f7cb56ec..1e71a094 100644 --- a/packages/coda/README.md +++ b/packages/coda/README.md @@ -1,33 +1,13 @@ # Coda -Automated client generation for Solana programs. - -## Why Coda? - -Building on Solana requires interacting with on-chain programs through their IDLs (Interface Definition Language). Traditionally, developers need to: - -1. **Manually write client code** for each program they interact with -2. **Keep clients in sync** when programs update -3. **Handle serialization/deserialization** of complex data structures -4. **Maintain type safety** across their application +[![npm version](https://img.shields.io/npm/v/@macalinao/coda.svg)](https://www.npmjs.com/package/@macalinao/coda) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/coda.svg)](https://www.npmjs.com/package/@macalinao/coda) -This leads to: -- **Boilerplate code** that's error-prone and time-consuming to write -- **Version mismatches** between your client and the on-chain program -- **Type errors** that only surface at runtime -- **Inconsistent implementations** across different projects - -**Coda solves these problems** by automatically generating type-safe, production-ready clients from your program's IDL. Built on top of [Codama](https://github.com/codama-idl/codama), Coda provides a zero-config CLI that transforms Anchor IDLs into modern TypeScript clients with full type safety and ES modules support. +Automated client generation for Solana programs. -## Features +## Documentation -- 🚀 **Zero configuration** - Works out of the box with sensible defaults -- 🔧 **Fully customizable** - Extend and transform generated code with visitors -- 📦 **ES modules native** - Modern JavaScript with proper `.js` extensions -- 🎯 **Type-safe** - Full TypeScript support with precise types -- 🔄 **Anchor compatible** - Works with any Anchor IDL -- 🏗️ **Extensible** - Add custom visitors to transform the Codama tree -- ⚡ **Fast** - Optimized code generation pipeline +Visit [coda.ianm.com](https://coda.ianm.com) for comprehensive documentation. ## Installation @@ -36,396 +16,21 @@ bun add -D @macalinao/coda ``` Or with npm: + ```bash npm install -D @macalinao/coda ``` ## Quick Start -### 1. Generate a client from your Anchor IDL - -```bash -# Using default paths -bunx coda generate - -# With custom paths -bunx coda generate --idl ./target/idl/my_program.json --output ./src/generated -``` - -By default, Coda looks for: -- IDL at `./target/idl/program.json` -- Outputs to `./src/generated` - -### 2. Use the generated client - -```typescript -import { createTransferInstruction } from "./generated"; -import { Address, pipe } from "@solana/web3.js"; - -// Create an instruction with full type safety -const instruction = createTransferInstruction({ - source: sourceAddress, - destination: destAddress, - authority: authorityAddress, - amount: 1000n, -}); - -// Use with your Solana client -const transaction = pipe( - createTransaction({ version: "legacy" }), - tx => addInstruction(instruction, tx), - tx => setTransactionFeePayer(payerAddress, tx) -); -``` - -## Configuration - -Create a `coda.config.mjs` file to customize code generation: - -```bash -bunx coda init -``` - -This creates a configuration file where you can: -- Set custom IDL and output paths -- Add Codama visitors to transform generated code -- Configure program-specific settings - -### Example configuration - -```javascript -// coda.config.mjs -import { defineConfig } from "@macalinao/coda"; -import { addPdasVisitor } from "codama"; - -export default defineConfig({ - // Custom paths (optional) - idlPath: "./idls/my_program.json", - outputDir: "./src/clients/my_program", - - // Add visitors to customize generation - visitors: [ - // Add custom PDAs - addPdasVisitor({ - myAccount: [ - { - name: "authority", - seeds: [ - { kind: "constant", value: "authority" }, - { kind: "variable", name: "user", type: publicKeyTypeNode() } - ] - } - ] - }) - ] -}); -``` - -### Dynamic configuration - -You can also use a function to access the IDL and conditionally apply visitors: - -```javascript -export default defineConfig({ - visitors: ({ idl }) => { - const visitors = []; - - // Conditionally add visitors based on IDL content - if (idl.name === "my_program") { - visitors.push(myCustomVisitor()); - } - - return visitors; - } -}); -``` - -## What Gets Generated - -Coda generates a complete TypeScript client with: - -### Instructions -```typescript -// Fully typed instruction builders -export function createTransferInstruction( - input: TransferInstructionInput -): Instruction; - -// With proper discriminators and serialization -export function getTransferInstructionDataEncoder(): Encoder; -``` - -### Accounts -```typescript -// Account decoders with type safety -export function decodeTokenAccount( - encodedAccount: EncodedAccount -): TokenAccount; - -// Fetch and decode in one step -export async function fetchTokenAccount( - rpc: Rpc, - address: Address -): Promise; -``` - -### Types -```typescript -// All types from your IDL -export type TokenAccount = { - mint: Address; - owner: Address; - amount: bigint; - // ... other fields -}; -``` - -### PDAs -```typescript -// PDA helpers with proper seed derivation -export async function findAuthorityPda( - seeds: { - user: Address; - } -): Promise<[Address, number]>; -``` - -### Errors -```typescript -// Typed error codes -export enum MyProgramError { - InvalidAmount = 0x1770, - Unauthorized = 0x1771, - // ... -} -``` - -## CLI Commands - -### `coda generate` - -Generate TypeScript clients from an Anchor IDL. - ```bash -bunx coda generate [options] - -Options: - -i, --idl Path to Anchor IDL file (default: "./target/idl/program.json") - -o, --output Output directory (default: "./src/generated") - -c, --config Path to config file (default: "./coda.config.mjs") -``` - -### `coda init` - -Initialize a new configuration file. - -```bash -bunx coda init [options] - -Options: - -c, --config Path for config file (default: "./coda.config.mjs") -``` - -## Integration with Build Tools - -### Package.json Scripts - -Add to your `package.json`: +# Generate a client from your Anchor IDL +coda generate -```json -{ - "scripts": { - "codegen": "coda generate", - "codegen:watch": "coda generate --watch" - } -} +# Initialize a configuration file +coda init ``` -### Turbo Integration - -For monorepos using Turborepo: - -```json -// turbo.json -{ - "tasks": { - "codegen": { - "outputs": ["./src/generated/**"], - "cache": false - } - } -} -``` - -## Advanced Usage - -### Custom Visitors - -Extend and transform the generated code using Codama visitors: - -```javascript -// coda.config.mjs -import { defineConfig } from "@macalinao/coda"; -import { updateInstructionsVisitor } from "codama"; - -const customVisitor = updateInstructionsVisitor({ - // Customize specific instructions - transfer: { - // Add custom defaults - defaults: { - amount: 0n - } - } -}); - -export default defineConfig({ - visitors: [customVisitor] -}); -``` - -### Multiple Programs - -Generate clients for multiple programs: - -```bash -# Main program -bunx coda generate --idl ./idls/main.json --output ./src/clients/main - -# Auxiliary program -bunx coda generate --idl ./idls/aux.json --output ./src/clients/aux -``` - -Or with separate configs: - -```javascript -// coda.main.mjs -export default defineConfig({ - idlPath: "./idls/main.json", - outputDir: "./src/clients/main" -}); - -// coda.aux.mjs -export default defineConfig({ - idlPath: "./idls/aux.json", - outputDir: "./src/clients/aux" -}); -``` - -```bash -bunx coda generate --config ./coda.main.mjs -bunx coda generate --config ./coda.aux.mjs -``` - -## Working with Generated Clients - -### With @solana/web3.js v2 - -```typescript -import { createSolanaRpc } from "@solana/web3.js"; -import { - fetchTokenAccount, - createTransferInstruction -} from "./generated"; - -const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com"); - -// Fetch and decode accounts -const account = await fetchTokenAccount(rpc, accountAddress); -console.log(`Balance: ${account.amount}`); - -// Build instructions -const ix = createTransferInstruction({ - source: account.address, - destination: destAddress, - authority: wallet.address, - amount: 100n -}); -``` - -### With Transaction Builders - -```typescript -import { pipe } from "@solana/web3.js"; -import { - createInitializeInstruction, - createTransferInstruction -} from "./generated"; - -const transaction = pipe( - createTransaction({ version: "legacy" }), - tx => addInstruction(createInitializeInstruction({...}), tx), - tx => addInstruction(createTransferInstruction({...}), tx), - tx => setTransactionFeePayer(wallet.address, tx) -); - -const signature = await sendAndConfirmTransaction(client, transaction); -``` - -## Philosophy - -Coda follows these principles: - -1. **Zero-config by default** - Should work immediately after installation -2. **Progressive customization** - Simple things simple, complex things possible -3. **Type safety first** - Catch errors at compile time, not runtime -4. **Modern JavaScript** - ES modules, async/await, bigint support -5. **Codama-powered** - Leverage the full Codama ecosystem - -## Comparison with Alternatives - -### vs Anchor TypeScript Client - -- ✅ **ES modules native** - No build step required -- ✅ **Customizable** - Transform generated code with visitors -- ✅ **Lighter weight** - Only generates what you need -- ✅ **Better tree-shaking** - Modular exports - -### vs Manual Implementation - -- ✅ **Always in sync** - Regenerate when IDL changes -- ✅ **Type-safe** - No runtime type errors -- ✅ **Consistent** - Same patterns across all programs -- ✅ **Time-saving** - No boilerplate to write - -## Troubleshooting - -### IDL Not Found - -Ensure your Anchor program is built: -```bash -anchor build -``` - -Or specify the path explicitly: -```bash -bunx coda generate --idl ./path/to/idl.json -``` - -### Config Not Loading - -1. Check file is named `coda.config.mjs` (note the `.mjs`) -2. Ensure it has a default export -3. Try specifying explicitly: `--config ./coda.config.mjs` - -### Types Not Resolving - -Make sure TypeScript can find the generated files: -```json -// tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@/generated/*": ["./src/generated/*"] - } - } -} -``` - -## Contributing - -Contributions are welcome! Please feel free to submit a Pull Request. - ## License Copyright © 2025 Ian Macalinao diff --git a/packages/coda/package.json b/packages/coda/package.json index 2dd75dcb..47de1728 100644 --- a/packages/coda/package.json +++ b/packages/coda/package.json @@ -15,7 +15,8 @@ "client", "code-generation", "esm", - "typescript" + "typescript", + "ian-macalinao" ], "bin": { "coda": "./dist/bin/cli.js" @@ -47,10 +48,12 @@ "test": "echo 'No tests yet'" }, "dependencies": { - "@codama/nodes-from-anchor": "*", + "@codama/nodes-from-anchor": "catalog:", + "@macalinao/codama-nodes-from-anchor-x": "workspace:*", "@macalinao/codama-renderers-js-esm": "workspace:*", "@macalinao/codama-renderers-markdown": "workspace:*", - "codama": "*", + "@macalinao/codama-rename-visitor": "workspace:*", + "codama": "catalog:", "commander": "^14.0.0", "glob": "^11.0.3" }, diff --git a/packages/coda/src/index.ts b/packages/coda/src/index.ts index 66bdd2c0..664d5a6d 100644 --- a/packages/coda/src/index.ts +++ b/packages/coda/src/index.ts @@ -1,5 +1,6 @@ // Re-export useful visitors and utilities +export { renameVisitor } from "@macalinao/codama-rename-visitor"; export { ESM_DEPENDENCY_MAP, renderESMTypeScriptVisitor, diff --git a/packages/coda/src/utils/create-codama-from-idls.ts b/packages/coda/src/utils/create-codama-from-idls.ts index ca6cc653..6c433b8d 100644 --- a/packages/coda/src/utils/create-codama-from-idls.ts +++ b/packages/coda/src/utils/create-codama-from-idls.ts @@ -1,40 +1,16 @@ -import type { AnchorIdl, IdlV00, IdlV01 } from "@codama/nodes-from-anchor"; -import { - programNodeFromAnchorV00, - programNodeFromAnchorV01, -} from "@codama/nodes-from-anchor"; +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { rootNodeFromAnchorIdls } from "@macalinao/codama-nodes-from-anchor-x"; import type { Codama } from "codama"; -import { createFromRoot, rootNode } from "codama"; +import { createFromRoot } from "codama"; /** * Create a Codama instance from IDLs */ export function createCodamaFromIdls(idls: AnchorIdl[]): Codama { - if (idls.length === 0) { - throw new Error("No IDL files were loaded"); - } - console.log( `Creating Codama nodes from ${idls.length.toString()} Anchor IDL(s)...`, ); - // Create program nodes from IDLs - const programNodes = idls.map((idl) => { - if ( - idl.metadata && - "spec" in idl.metadata && - idl.metadata.spec === "0.1.0" - ) { - return programNodeFromAnchorV01(idl as unknown as IdlV01); - } - return programNodeFromAnchorV00(idl as unknown as IdlV00); - }); - - const [firstProgramNode, ...restProgramNodes] = programNodes; - if (!firstProgramNode) { - throw new Error("Unexpected: No program nodes loaded"); - } - - const root = rootNode(firstProgramNode, restProgramNodes); + const root = rootNodeFromAnchorIdls(idls); return createFromRoot(root); } diff --git a/packages/codama-instruction-accounts-dedupe-visitor/README.md b/packages/codama-instruction-accounts-dedupe-visitor/README.md index 35b6957e..194d03a2 100644 --- a/packages/codama-instruction-accounts-dedupe-visitor/README.md +++ b/packages/codama-instruction-accounts-dedupe-visitor/README.md @@ -1,19 +1,25 @@ # @macalinao/codama-instruction-accounts-dedupe-visitor [![npm version](https://img.shields.io/npm/v/@macalinao/codama-instruction-accounts-dedupe-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-instruction-accounts-dedupe-visitor) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-instruction-accounts-dedupe-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-instruction-accounts-dedupe-visitor) Codama visitor for deduplicating and flattening instruction accounts from Anchor IDL. This package helps handle nested account structures in Anchor programs by flattening them into a single-level structure with properly prefixed names. -## Why This Package Exists +## Quick Start with Coda CLI -Anchor IDL supports nested account structures where accounts can be grouped together. When converting these to Codama nodes, the nested structure needs to be flattened while preserving the relationship through naming conventions. This visitor: +This visitor is best used through the [Coda CLI](https://coda.ianm.com), which provides a complete solution for Solana client generation: -1. **Flattens Nested Accounts**: Converts nested account groups into flat structures -2. **Preserves Relationships**: Uses underscore-separated naming to maintain parent-child relationships -3. **Updates PDA Seeds**: Properly adjusts PDA seed references when accounts are flattened -4. **Maintains Type Safety**: Ensures all account references remain valid after flattening +```bash +# Install Coda CLI +bun add -D @macalinao/coda + +# Initialize configuration +coda init + +# Add this visitor to your coda.config.mjs +``` -See: https://github.com/codama-idl/codama/issues/754 for the active issue in Codama on this topic. +Learn more about Coda's zero-config approach and powerful visitor system at [coda.ianm.com](https://coda.ianm.com). ## Installation diff --git a/packages/codama-instruction-accounts-dedupe-visitor/package.json b/packages/codama-instruction-accounts-dedupe-visitor/package.json index 23066f71..1317c595 100644 --- a/packages/codama-instruction-accounts-dedupe-visitor/package.json +++ b/packages/codama-instruction-accounts-dedupe-visitor/package.json @@ -9,11 +9,13 @@ "license": "Apache-2.0", "keywords": [ "codama", + "coda", "solana", "anchor", "idl", "esm", - "typescript" + "typescript", + "ian-macalinao" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -38,11 +40,12 @@ "scripts": { "build": "tsc", "clean": "rm -fr dist/", - "lint": "eslint . --cache" + "lint": "eslint . --cache", + "test": "bun test src/" }, "dependencies": { - "@codama/nodes-from-anchor": "*", - "codama": "*" + "@codama/nodes-from-anchor": "catalog:", + "codama": "catalog:" }, "devDependencies": { "@macalinao/eslint-config": "catalog:", diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/index.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/index.ts index 7a02c59f..d5431e53 100644 --- a/packages/codama-instruction-accounts-dedupe-visitor/src/index.ts +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/index.ts @@ -1,130 +1,3 @@ -import type { - AnchorIdl, - IdlV01InstructionAccountItem, -} from "@codama/nodes-from-anchor"; -import { instructionAccountNodeFromAnchorV01 } from "@codama/nodes-from-anchor"; -import type { - AccountNode, - InstructionAccountNode, - InstructionArgumentNode, -} from "codama"; -import { - assertIsNode, - bottomUpTransformerVisitor, - camelCase, - rootNodeVisitor, - visit, -} from "codama"; - -function instructionAccountNodesFromAnchorV01( - allAccounts: AccountNode[], - instructionArguments: InstructionArgumentNode[], - idl: IdlV01InstructionAccountItem[], - parent: string | null = null, -): InstructionAccountNode[] { - return idl.flatMap((account) => - "accounts" in account - ? instructionAccountNodesFromAnchorV01( - allAccounts, - instructionArguments, - account.accounts, - // null, - parent ? `${parent}_${account.name}` : account.name, - ) - : [ - instructionAccountNodeFromAnchorV01( - allAccounts, - instructionArguments, - { - ...account, - name: parent ? `${parent}_${account.name}` : account.name, - pda: - account.pda && parent - ? { - ...account.pda, - seeds: account.pda.seeds.map((seed) => { - if (seed.kind === "account") { - return { - ...seed, - path: `${parent}_${seed.path}`, - }; - } - return seed; - }), - } - : undefined, - }, - idl, - ), - ], - ); -} - -/** - * Creates a Codama visitor that deduplicates and flattens nested instruction accounts from an Anchor IDL. - * - * This visitor addresses the issue where Anchor IDLs can have nested account structures (account groups) - * that need to be flattened into a single level for proper code generation. It preserves the relationships - * between parent and child accounts through naming conventions. - * - * @param idl - The Anchor IDL containing the instruction definitions with potentially nested accounts - * @returns A root node visitor that transforms all instruction nodes to have flattened account structures - * - * @example - * ```typescript - * // Given an Anchor IDL with nested accounts: - * // { - * // name: "mintAccounts", - * // accounts: [ - * // { name: "mint", ... }, - * // { name: "metadata", ... } - * // ] - * // } - * - * // The visitor will flatten to: - * // [ - * // { name: "mintAccounts_mint", ... }, - * // { name: "mintAccounts_metadata", ... } - * // ] - * - * const root = rootNodeFromAnchor(idl); - * const visitor = instructionAccountsDedupeVisitor(idl); - * const transformedRoot = visit(root, visitor); - * ``` - * - * @remarks - * - Account names are joined with underscores to maintain parent-child relationships - * - PDA seed paths are automatically updated to match the flattened structure - * - All account metadata and constraints are preserved during flattening - * - The visitor operates on instruction nodes using a bottom-up transformer - */ -export function instructionAccountsDedupeVisitor( - idl: AnchorIdl, -): ReturnType { - return rootNodeVisitor((node) => { - const accountNodes = node.program.accounts; - const instructionVisitor = bottomUpTransformerVisitor([ - { - select: "[instructionNode]", - transform: (node) => { - assertIsNode(node, "instructionNode"); - const idlIx = idl.instructions.find( - (ix) => camelCase(ix.name) === node.name, - ); - if (!idlIx) { - throw new Error(`Instruction ${node.name} not found in Idl`); - } - return { - ...node, - accounts: instructionAccountNodesFromAnchorV01( - accountNodes, - node.arguments, - idlIx.accounts, - ), - }; - }, - }, - ]); - return visit(node, instructionVisitor); - }); -} +export { instructionAccountNodesFromAnchorV01 } from "./instruction-account-nodes-from-anchor-v01.js"; +export { instructionAccountsDedupeProgramVisitor } from "./instruction-accounts-dedupe-program-visitor.js"; +export { instructionAccountsDedupeVisitor } from "./instruction-accounts-dedupe-visitor.js"; diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.test.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.test.ts new file mode 100644 index 00000000..f591595e --- /dev/null +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.test.ts @@ -0,0 +1,172 @@ +/// +import { describe, expect, it } from "bun:test"; +import type { IdlV01InstructionAccountItem } from "@codama/nodes-from-anchor"; +import type { AccountNode, InstructionArgumentNode } from "codama"; +import { camelCase } from "codama"; +import { instructionAccountNodesFromAnchorV01 } from "./instruction-account-nodes-from-anchor-v01.js"; + +describe("instructionAccountNodesFromAnchorV01", () => { + const mockAccounts: AccountNode[] = []; + const mockArguments: InstructionArgumentNode[] = []; + + it("should flatten nested account structures", () => { + const nestedAccounts: IdlV01InstructionAccountItem[] = [ + { + name: "mintAccounts", + accounts: [ + { name: "mint", writable: true, signer: false }, + { name: "metadata", writable: true, signer: false }, + ], + }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + nestedAccounts, + ); + + expect(result).toHaveLength(2); + expect(result[0]?.name).toBe(camelCase("mintAccountsMint")); + expect(result[1]?.name).toBe(camelCase("mintAccountsMetadata")); + }); + + it("should handle deeply nested account structures", () => { + const deeplyNested: IdlV01InstructionAccountItem[] = [ + { + name: "level1", + accounts: [ + { + name: "level2", + accounts: [ + { name: "account1", writable: false, signer: true }, + { name: "account2", writable: true, signer: false }, + ], + } as IdlV01InstructionAccountItem, + ], + }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + deeplyNested, + ); + + expect(result).toHaveLength(2); + expect(result[0]?.name).toBe(camelCase("level1Level2Account1")); + expect(result[1]?.name).toBe(camelCase("level1Level2Account2")); + }); + + it("should handle flat account structures", () => { + const flatAccounts: IdlV01InstructionAccountItem[] = [ + { name: "account1", writable: true, signer: false }, + { name: "account2", writable: false, signer: true }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + flatAccounts, + ); + + expect(result).toHaveLength(2); + expect(result[0]?.name).toBe(camelCase("account1")); + expect(result[1]?.name).toBe(camelCase("account2")); + }); + + it("should handle nested accounts with PDA", () => { + const accountsWithPda: IdlV01InstructionAccountItem[] = [ + { + name: "parent", + accounts: [ + { + name: "child", + writable: true, + signer: false, + }, + ], + }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + accountsWithPda, + ); + + expect(result).toHaveLength(1); + expect(result[0]?.name).toBe(camelCase("parentChild")); + + // The flattened account should be writable since writable=true + const account = result[0]; + expect(account?.isWritable).toBeDefined(); + }); + + it("should handle mixed nested and flat structures", () => { + const mixedAccounts: IdlV01InstructionAccountItem[] = [ + { name: "flatAccount", writable: true, signer: false }, + { + name: "nestedGroup", + accounts: [ + { name: "nested1", writable: false, signer: false }, + { name: "nested2", writable: true, signer: true }, + ], + }, + { name: "anotherFlat", writable: false, signer: true }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + mixedAccounts, + ); + + expect(result).toHaveLength(4); + expect(result[0]?.name).toBe(camelCase("flatAccount")); + expect(result[1]?.name).toBe(camelCase("nestedGroupNested1")); + expect(result[2]?.name).toBe(camelCase("nestedGroupNested2")); + expect(result[3]?.name).toBe(camelCase("anotherFlat")); + }); + + it("should handle empty account arrays", () => { + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + [], + ); + + expect(result).toHaveLength(0); + }); + + it("should preserve account properties during flattening", () => { + const accountsWithProps: IdlV01InstructionAccountItem[] = [ + { + name: "group", + accounts: [ + { + name: "mutableSigner", + writable: true, + signer: true, + docs: ["Test documentation"], + }, + ], + }, + ]; + + const result = instructionAccountNodesFromAnchorV01( + mockAccounts, + mockArguments, + accountsWithProps, + ); + + expect(result).toHaveLength(1); + const account = result[0]; + expect(account?.name).toBe(camelCase("groupMutableSigner")); + // The isWritable property is determined by writable + expect(account?.isWritable).toBeDefined(); + // The isSigner property is determined by the signer flag + expect(account?.isSigner).toBeDefined(); + expect(account?.docs).toEqual(["Test documentation"]); + }); +}); diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.ts new file mode 100644 index 00000000..36a18cc1 --- /dev/null +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-account-nodes-from-anchor-v01.ts @@ -0,0 +1,88 @@ +import type { IdlV01InstructionAccountItem } from "@codama/nodes-from-anchor"; +import { instructionAccountNodeFromAnchorV01 } from "@codama/nodes-from-anchor"; +import type { + AccountNode, + InstructionAccountNode, + InstructionArgumentNode, +} from "codama"; + +/** + * Recursively flattens nested instruction account structures from Anchor IDL v0.1.0 format. + * + * This function handles the nested account structures (account groups) that appear in + * Anchor IDLs and flattens them into a single array of instruction account nodes. + * Parent-child relationships are preserved through naming conventions. + * + * @param allAccounts - All account nodes available in the program + * @param instructionArguments - Arguments for the instruction + * @param idl - The instruction account items from the Anchor IDL, potentially nested + * @param parent - The parent account name prefix for nested accounts + * @returns Flattened array of instruction account nodes + * + * @example + * ```typescript + * // Given nested accounts: + * const nested = [ + * { + * name: "mintAccounts", + * accounts: [ + * { name: "mint", ... }, + * { name: "metadata", ... } + * ] + * } + * ]; + * + * // Returns flattened: + * // [ + * // { name: "mintAccounts_mint", ... }, + * // { name: "mintAccounts_metadata", ... } + * // ] + * ``` + * + * @remarks + * - Account names are joined with underscores when nested + * - PDA seed paths are updated to include the parent prefix + * - Recursively processes nested account groups + */ +export function instructionAccountNodesFromAnchorV01( + allAccounts: AccountNode[], + instructionArguments: InstructionArgumentNode[], + idl: IdlV01InstructionAccountItem[], + parent: string | null = null, +): InstructionAccountNode[] { + return idl.flatMap((account) => + "accounts" in account + ? instructionAccountNodesFromAnchorV01( + allAccounts, + instructionArguments, + account.accounts, + parent ? `${parent}_${account.name}` : account.name, + ) + : [ + instructionAccountNodeFromAnchorV01( + allAccounts, + instructionArguments, + { + ...account, + name: parent ? `${parent}_${account.name}` : account.name, + pda: + account.pda && parent + ? { + ...account.pda, + seeds: account.pda.seeds.map((seed) => { + if (seed.kind === "account") { + return { + ...seed, + path: `${parent}_${seed.path}`, + }; + } + return seed; + }), + } + : undefined, + }, + idl, + ), + ], + ); +} diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-program-visitor.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-program-visitor.ts new file mode 100644 index 00000000..5e22a49d --- /dev/null +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-program-visitor.ts @@ -0,0 +1,72 @@ +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import type { ProgramNode } from "codama"; +import { + assertIsNode, + bottomUpTransformerVisitor, + camelCase, + visit, +} from "codama"; +import { instructionAccountNodesFromAnchorV01 } from "./instruction-account-nodes-from-anchor-v01.js"; + +/** + * Creates a Codama program visitor that deduplicates and flattens nested instruction accounts from an Anchor IDL. + * + * This is a program-level visitor that can be composed with other visitors. It transforms + * instruction nodes to have flattened account structures, removing nested account groups. + * + * @param idl - The Anchor IDL containing the instruction definitions with potentially nested accounts + * @returns A visitor that transforms all instruction nodes to have flattened account structures + * + * @example + * ```typescript + * // Use with a single program + * const programNode = programNodeFromAnchor(idl); + * const visitor = instructionAccountsDedupeProgramVisitor(idl); + * const transformedProgram = visit(programNode, visitor); + * + * // Or compose with other visitors + * const composedVisitor = mergeVisitor( + * instructionAccountsDedupeProgramVisitor(idl), + * otherProgramVisitor(), + * ); + * ``` + * + * @remarks + * - This visitor operates at the program level, not the root level + * - Account names are joined with underscores to maintain parent-child relationships + * - PDA seed paths are automatically updated to match the flattened structure + * - All account metadata and constraints are preserved during flattening + */ +export function instructionAccountsDedupeProgramVisitor( + idl: AnchorIdl, + programNode: ProgramNode, +): ProgramNode { + const accountNodes = programNode.accounts; + const instructionVisitor = bottomUpTransformerVisitor([ + { + select: "[instructionNode]", + transform: (instructionNode) => { + assertIsNode(instructionNode, "instructionNode"); + const idlIx = idl.instructions.find( + (ix) => camelCase(ix.name) === instructionNode.name, + ); + if (!idlIx) { + throw new Error( + `Instruction ${instructionNode.name} not found in IDL`, + ); + } + // Always use the flattening visitor to handle nested accounts + return { + ...instructionNode, + accounts: instructionAccountNodesFromAnchorV01( + accountNodes, + instructionNode.arguments, + idlIx.accounts, + ), + }; + }, + }, + ]); + + return visit(programNode, instructionVisitor) as ProgramNode; +} diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.test.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.test.ts new file mode 100644 index 00000000..f2d515e6 --- /dev/null +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.test.ts @@ -0,0 +1,408 @@ +/// +import { describe, expect, it } from "bun:test"; +import type { AnchorIdl, IdlV01 } from "@codama/nodes-from-anchor"; +import type { RootNode } from "codama"; +import { + accountNode, + camelCase, + instructionArgumentNode, + instructionNode, + programNode, + rootNode, + visit, +} from "codama"; +import { instructionAccountsDedupeVisitor } from "./instruction-accounts-dedupe-visitor.js"; + +describe("instructionAccountsDedupeVisitor", () => { + it("should flatten nested instruction accounts", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "test_instruction", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { + name: "mint_accounts", + accounts: [ + { name: "mint", writable: true, signer: false }, + { name: "metadata", writable: true, signer: false }, + ], + }, + { name: "authority", writable: false, signer: true }, + ], + args: [], + }, + ], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "testInstruction", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const instruction = transformedRoot.program.instructions[0]; + expect(instruction?.accounts).toHaveLength(3); + expect(instruction?.accounts[0]?.name).toBe(camelCase("mintAccountsMint")); + expect(instruction?.accounts[1]?.name).toBe( + camelCase("mintAccountsMetadata"), + ); + expect(instruction?.accounts[2]?.name).toBe(camelCase("authority")); + }); + + it("should handle instructions with no nested accounts", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "simple_instruction", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { name: "account1", writable: true, signer: false }, + { name: "account2", writable: false, signer: true }, + ], + args: [], + }, + ], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "simpleInstruction", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const instruction = transformedRoot.program.instructions[0]; + expect(instruction?.accounts).toHaveLength(2); + expect(instruction?.accounts[0]?.name).toBe(camelCase("account1")); + expect(instruction?.accounts[1]?.name).toBe(camelCase("account2")); + }); + + it("should handle multiple instructions", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "first_instruction", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { + name: "nested", + accounts: [{ name: "inner", writable: true, signer: false }], + }, + ], + args: [], + }, + { + name: "second_instruction", + discriminator: [1, 2, 3, 4, 5, 6, 7, 8], + accounts: [{ name: "simple", writable: false, signer: true }], + args: [], + }, + ], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "firstInstruction", + accounts: [], + arguments: [], + }), + instructionNode({ + name: "secondInstruction", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const firstInstruction = transformedRoot.program.instructions[0]; + expect(firstInstruction?.accounts).toHaveLength(1); + expect(firstInstruction?.accounts[0]?.name).toBe(camelCase("nestedInner")); + + const secondInstruction = transformedRoot.program.instructions[1]; + expect(secondInstruction?.accounts).toHaveLength(1); + expect(secondInstruction?.accounts[0]?.name).toBe(camelCase("simple")); + }); + + it("should throw error if instruction not found in IDL", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "missingInstruction", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + + expect(() => visit(root, visitor)).toThrow( + "Instruction missingInstruction not found in IDL", + ); + }); + + it("should preserve instruction arguments", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "instruction_with_args", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { + name: "nested", + accounts: [{ name: "account", writable: true, signer: false }], + }, + ], + args: [ + { name: "amount", type: "u64" }, + { name: "data", type: "bytes" }, + ], + }, + ], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "instructionWithArgs", + accounts: [], + arguments: [ + instructionArgumentNode({ + name: "amount", + type: { kind: "numberTypeNode", format: "u64", endian: "le" }, + }), + instructionArgumentNode({ + name: "data", + type: { kind: "bytesTypeNode" }, + }), + ], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const instruction = transformedRoot.program.instructions[0]; + expect(instruction?.arguments).toHaveLength(2); + expect(instruction?.arguments[0]?.name).toBe(camelCase("amount")); + expect(instruction?.arguments[1]?.name).toBe(camelCase("data")); + expect(instruction?.accounts).toHaveLength(1); + expect(instruction?.accounts[0]?.name).toBe(camelCase("nestedAccount")); + }); + + it("should handle deeply nested account structures", () => { + const idl: IdlV01 = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "deep_nesting", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { + name: "level1", + accounts: [ + { + name: "level2", + }, + ], + }, + ], + args: [], + }, + ], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [], + instructions: [ + instructionNode({ + name: "deepNesting", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const instruction = transformedRoot.program.instructions[0]; + expect(instruction?.accounts).toHaveLength(1); + expect(instruction?.accounts[0]?.name).toBe(camelCase("level1Level2")); + }); + + it("should work with program accounts", () => { + const idl: AnchorIdl = { + address: "11111111111111111111111111111111", + metadata: { + name: "test_program", + version: "0.1.0", + spec: "0.1.0", + }, + instructions: [ + { + name: "use_program_account", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + accounts: [ + { + name: "accounts_group", + accounts: [ + { name: "user", writable: true, signer: false }, + { name: "data", writable: true, signer: false }, + ], + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "UserAccount", + discriminator: [0, 1, 2, 3, 4, 5, 6, 7], + }, + ], + types: [], + errors: [], + }; + + const root = rootNode( + programNode({ + name: "testProgram", + publicKey: "11111111111111111111111111111111", + accounts: [ + accountNode({ + name: "userAccount", + size: 8, + discriminators: [], + }), + ], + instructions: [ + instructionNode({ + name: "useProgramAccount", + accounts: [], + arguments: [], + }), + ], + }), + ); + + const visitor = instructionAccountsDedupeVisitor(idl); + const transformedRoot = visit(root, visitor) as RootNode; + + const instruction = transformedRoot.program.instructions[0]; + expect(instruction?.accounts).toHaveLength(2); + expect(instruction?.accounts[0]?.name).toBe(camelCase("accountsGroupUser")); + expect(instruction?.accounts[1]?.name).toBe(camelCase("accountsGroupData")); + + // Program accounts should remain unchanged + expect(transformedRoot.program.accounts).toHaveLength(1); + expect(transformedRoot.program.accounts[0]?.name).toBe( + camelCase("userAccount"), + ); + }); +}); diff --git a/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.ts b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.ts new file mode 100644 index 00000000..69596143 --- /dev/null +++ b/packages/codama-instruction-accounts-dedupe-visitor/src/instruction-accounts-dedupe-visitor.ts @@ -0,0 +1,58 @@ +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { rootNodeVisitor } from "codama"; +import { instructionAccountsDedupeProgramVisitor } from "./instruction-accounts-dedupe-program-visitor.js"; + +/** + * Creates a Codama visitor that deduplicates and flattens nested instruction accounts from an Anchor IDL. + * + * This visitor addresses the issue where Anchor IDLs can have nested account structures (account groups) + * that need to be flattened into a single level for proper code generation. It preserves the relationships + * between parent and child accounts through naming conventions. + * + * @param idl - The Anchor IDL containing the instruction definitions with potentially nested accounts + * @returns A root node visitor that transforms all instruction nodes to have flattened account structures + * + * @example + * ```typescript + * // Given an Anchor IDL with nested accounts: + * // { + * // name: "mintAccounts", + * // accounts: [ + * // { name: "mint", ... }, + * // { name: "metadata", ... } + * // ] + * // } + * + * // The visitor will flatten to: + * // [ + * // { name: "mintAccounts_mint", ... }, + * // { name: "mintAccounts_metadata", ... } + * // ] + * + * const root = rootNodeFromAnchor(idl); + * const visitor = instructionAccountsDedupeVisitor(idl); + * const transformedRoot = visit(root, visitor); + * ``` + * + * @remarks + * - Account names are joined with underscores to maintain parent-child relationships + * - PDA seed paths are automatically updated to match the flattened structure + * - All account metadata and constraints are preserved during flattening + * - The visitor operates on instruction nodes using a bottom-up transformer + */ +export function instructionAccountsDedupeVisitor( + idl: AnchorIdl, +): ReturnType { + return rootNodeVisitor((node) => { + // Apply the program visitor to the program node + const transformedProgram = instructionAccountsDedupeProgramVisitor( + idl, + node.program, + ); + + return { + ...node, + program: transformedProgram, + }; + }); +} diff --git a/packages/codama-nodes-from-anchor-x/README.md b/packages/codama-nodes-from-anchor-x/README.md new file mode 100644 index 00000000..09967026 --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/README.md @@ -0,0 +1,207 @@ +# @macalinao/codama-nodes-from-anchor-x + +[![npm version](https://img.shields.io/npm/v/@macalinao/codama-nodes-from-anchor-x.svg)](https://www.npmjs.com/package/@macalinao/codama-nodes-from-anchor-x) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-nodes-from-anchor-x.svg)](https://www.npmjs.com/package/@macalinao/codama-nodes-from-anchor-x) + +An enhanced version of `@codama/nodes-from-anchor` with additional features for improved Anchor IDL parsing and transformation. This is the default parser used by the [Coda CLI](https://github.com/macalinao/coda) for generating TypeScript clients from Solana programs. + +## Features + +This package extends `@codama/nodes-from-anchor` with: + +- **Multi-IDL Support**: Parse and combine multiple Anchor IDLs into a single Codama root node +- **Automatic Account Flattening**: Intelligently flattens nested account structures from Anchor IDLs for v0.1.0 format +- **Program-Level Visitors**: Apply transformations at the program level for better composability +- **Enhanced IDL Support**: Seamless handling of both v0.0.0 and v0.1.0 Anchor IDL formats + +## Quick Start with Coda CLI + +This package is used internally by the [Coda CLI](https://coda.ianm.com) for multi-program support: + +```bash +# Install Coda CLI +bun add -D @macalinao/coda + +# Generate clients from multiple IDLs +coda generate --idl "./idls/*.json" +``` + +Learn more at [coda.ianm.com](https://coda.ianm.com). + +## Installation + +```bash +bun add @macalinao/codama-nodes-from-anchor-x +``` + +Or with npm: +```bash +npm install @macalinao/codama-nodes-from-anchor-x +``` + +## Usage + +### Single IDL + +```typescript +import { rootNodeFromAnchor } from "@macalinao/codama-nodes-from-anchor-x"; +import { createFromRoot, visit } from "codama"; + +// Load your IDL +const idl = JSON.parse(fs.readFileSync("./idl.json", "utf-8")); + +// Create a root node from single IDL +const root = rootNodeFromAnchor(idl); + +// Create Codama instance and apply visitors +const codama = createFromRoot(root); +codama.accept(myVisitor); +``` + +### Multiple IDLs + +```typescript +import { rootNodeFromAnchorIdls } from "@macalinao/codama-nodes-from-anchor-x"; +import { createFromRoot, visit } from "codama"; + +// Load your IDLs +const idls = [ + JSON.parse(fs.readFileSync("./idls/program1.json", "utf-8")), + JSON.parse(fs.readFileSync("./idls/program2.json", "utf-8")), + JSON.parse(fs.readFileSync("./idls/program3.json", "utf-8")), +]; + +// Create a root node containing all programs +const root = rootNodeFromAnchorIdls(idls); + +// Create Codama instance +const codama = createFromRoot(root); + +// Apply visitors +codama.accept(myVisitor); +``` + +### Program Node + +```typescript +import { programNodeFromAnchor } from "@macalinao/codama-nodes-from-anchor-x"; + +// Get just the program node (without root wrapper) +const program = programNodeFromAnchor(idl); +``` + +## API + +### rootNodeFromAnchor + +Creates a Codama root node from a single Anchor IDL. + +```typescript +function rootNodeFromAnchor(idl: AnchorIdl): RootNode; +``` + +**Parameters:** +- `idl`: An Anchor IDL object + +**Returns:** +- A Codama root node containing the program from the IDL + +### rootNodeFromAnchorIdls + +Creates a Codama root node from multiple Anchor IDLs. + +```typescript +function rootNodeFromAnchorIdls(idls: AnchorIdl[]): RootNode; +``` + +**Parameters:** +- `idls`: An array of Anchor IDL objects + +**Returns:** +- A Codama root node containing all programs from the IDLs + +**Throws:** +- Error if no IDL files are provided +- Error if no program nodes could be created + +### programNodeFromAnchor + +Creates a Codama program node from a single Anchor IDL. + +```typescript +function programNodeFromAnchor(idl: AnchorIdl): ProgramNode; +``` + +**Parameters:** +- `idl`: An Anchor IDL object + +**Returns:** +- A Codama program node (without root wrapper) + +## Key Improvements over @codama/nodes-from-anchor + +### Automatic Account Flattening + +Anchor IDL v0.1.0 often has nested account structures that need to be flattened for proper code generation. This package automatically handles this: + +```javascript +// Anchor IDL with nested accounts: +{ + "name": "mint_accounts", + "accounts": [ + { "name": "mint", "writable": true }, + { "name": "metadata", "writable": true } + ] +} + +// Automatically flattened to: +[ + { "name": "mintAccountsMint", "writable": true }, + { "name": "mintAccountsMetadata", "writable": true } +] +``` + +### Version Detection + +The package automatically detects the IDL version (v0.0.0 or v0.1.0) and applies the appropriate parsing logic, including the account flattening visitor for v0.1.0 IDLs. + +## Use Cases + +### Multiple Related Programs + +When working with a protocol that consists of multiple programs: + +```typescript +const idls = [ + mainProgramIdl, + stakingProgramIdl, + rewardsProgramIdl, +]; + +const root = rootNodeFromAnchorIdls(idls); +// All three programs are now in the AST +``` + +### Program Versioning + +Load different versions of the same program: + +```typescript +const idls = [ + currentVersionIdl, + legacyVersionIdl, +]; + +const root = rootNodeFromAnchorIdls(idls); +// Both versions available for migration tools +``` + +## Integration with Coda + +This package is the default parser for [Coda](https://github.com/macalinao/coda), providing the foundation for generating modern, type-safe TypeScript clients for Solana programs. When you use `coda generate`, it uses this package under the hood to parse your Anchor IDLs. + +## License + +Copyright © 2025 Ian Macalinao + +Licensed under the Apache License, Version 2.0 \ No newline at end of file diff --git a/packages/codama-nodes-from-anchor-x/eslint.config.js b/packages/codama-nodes-from-anchor-x/eslint.config.js new file mode 100644 index 00000000..f3d4a91f --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/eslint.config.js @@ -0,0 +1,15 @@ +import { configs } from "@macalinao/eslint-config"; + +export default [ + ...configs.fast, + { + languageOptions: { + parserOptions: { + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + ignores: ["**/*.test.ts", "**/*.test.tsx", "dist/**"], + }, +]; diff --git a/packages/codama-nodes-from-anchor-x/package.json b/packages/codama-nodes-from-anchor-x/package.json new file mode 100644 index 00000000..8907492e --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/package.json @@ -0,0 +1,51 @@ +{ + "name": "@macalinao/codama-nodes-from-anchor-x", + "version": "0.0.1", + "description": "Create Codama root nodes from multiple Anchor IDLs", + "keywords": [ + "solana", + "codama", + "coda", + "anchor", + "idl", + "ast", + "ian-macalinao" + ], + "author": "Ian Macalinao ", + "homepage": "https://github.com/macalinao/coda/tree/master/packages/codama-nodes-from-anchor-x", + "license": "Apache-2.0", + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "files": [ + "dist" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/macalinao/coda.git" + }, + "scripts": { + "build": "tsc", + "clean": "rm -fr dist/", + "test": "bun test src/" + }, + "bugs": { + "url": "https://github.com/macalinao/coda/issues" + }, + "dependencies": { + "@codama/nodes": "catalog:", + "@codama/nodes-from-anchor": "catalog:", + "@macalinao/codama-instruction-accounts-dedupe-visitor": "^0.2.1", + "codama": "catalog:" + }, + "devDependencies": { + "@types/bun": "latest", + "typescript": "^5.9.2" + } +} diff --git a/packages/codama-nodes-from-anchor-x/src/index.ts b/packages/codama-nodes-from-anchor-x/src/index.ts new file mode 100644 index 00000000..ffafefee --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/index.ts @@ -0,0 +1,3 @@ +export { programNodeFromAnchor } from "./program-node-from-anchor.js"; +export { rootNodeFromAnchor } from "./root-node-from-anchor.js"; +export { rootNodeFromAnchorIdls } from "./root-node-from-anchor-idls.js"; diff --git a/packages/codama-nodes-from-anchor-x/src/program-node-from-anchor.ts b/packages/codama-nodes-from-anchor-x/src/program-node-from-anchor.ts new file mode 100644 index 00000000..7d146add --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/program-node-from-anchor.ts @@ -0,0 +1,45 @@ +import type { ProgramNode } from "@codama/nodes"; +import type { AnchorIdl, IdlV00, IdlV01 } from "@codama/nodes-from-anchor"; +import { + programNodeFromAnchorV00, + programNodeFromAnchorV01, +} from "@codama/nodes-from-anchor"; +import { instructionAccountsDedupeProgramVisitor } from "@macalinao/codama-instruction-accounts-dedupe-visitor"; + +/** + * Creates a Codama program node from a single Anchor IDL. + * + * This function takes an Anchor IDL object and converts it into + * a Codama program node that can be used with Codama visitors for + * code generation and AST transformation. For IDL v0.1.0, it automatically + * applies the instruction accounts dedupe visitor to flatten nested accounts. + * + * @param idl - An Anchor IDL object to convert + * @returns A Codama program node from the IDL + * + * @example + * ```typescript + * import { programNodeFromAnchor } from "@macalinao/codama-nodes-from-anchor-x"; + * import { visit } from "codama"; + * + * const idl = JSON.parse(fs.readFileSync("./idl.json", "utf-8")); + * const program = programNodeFromAnchor(idl); + * + * // Use with Codama visitors + * visit(program, myVisitor); + * ``` + * + * @remarks + * - Supports both Anchor IDL v0.0.0 and v0.1.0 formats + * - Automatically detects the IDL version and uses the appropriate parser + * - For v0.1.0 IDLs, applies instruction accounts deduplication + */ +export function programNodeFromAnchor(idl: AnchorIdl): ProgramNode { + // Detect IDL version and create program node + if (idl.metadata && "spec" in idl.metadata && idl.metadata.spec === "0.1.0") { + const idlV01 = idl as unknown as IdlV01; + const program = programNodeFromAnchorV01(idlV01); + return instructionAccountsDedupeProgramVisitor(idlV01, program); + } + return programNodeFromAnchorV00(idl as unknown as IdlV00); +} diff --git a/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.test.ts b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.test.ts new file mode 100644 index 00000000..183ff5d9 --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.test.ts @@ -0,0 +1,137 @@ +import { describe, expect, it } from "bun:test"; +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { rootNodeFromAnchorIdls } from "./root-node-from-anchor-idls.js"; + +describe("rootNodeFromAnchorIdls", () => { + const createMockIdl = (name: string, version = "0.0.0"): AnchorIdl => ({ + name, + version, + instructions: [], + accounts: [], + types: [], + errors: [], + }); + + const createMockIdlV01 = (name: string): AnchorIdl => ({ + version: "0.1.0", + metadata: { + spec: "0.1.0", + address: "11111111111111111111111111111111", + name, + }, + instructions: [], + accounts: [], + types: [], + errors: [], + }); + + it("should create a root node from a single IDL", () => { + const idl = createMockIdl("test_program"); + const root = rootNodeFromAnchorIdls([idl]); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("testProgram"); + expect(root.additionalPrograms).toHaveLength(0); + }); + + it("should create a root node from multiple IDLs", () => { + const idl1 = createMockIdl("program_one"); + const idl2 = createMockIdl("program_two"); + const idl3 = createMockIdl("program_three"); + + const root = rootNodeFromAnchorIdls([idl1, idl2, idl3]); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("programOne"); + expect(root.additionalPrograms).toHaveLength(2); + expect(root.additionalPrograms[0].name).toBe("programTwo"); + expect(root.additionalPrograms[1].name).toBe("programThree"); + }); + + it("should handle IDL v0.1.0 format", () => { + const idl = createMockIdlV01("new_format_program"); + const root = rootNodeFromAnchorIdls([idl]); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("newFormatProgram"); + // V0.1.0 IDL includes address in metadata but the program node might not expose it directly + expect(root.program.name).toBe("newFormatProgram"); + }); + + it("should handle mixed IDL versions", () => { + const idlV00 = createMockIdl("old_program"); + const idlV01 = createMockIdlV01("new_program"); + + const root = rootNodeFromAnchorIdls([idlV00, idlV01]); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("oldProgram"); + expect(root.additionalPrograms).toHaveLength(1); + expect(root.additionalPrograms[0].name).toBe("newProgram"); + // V0.1.0 IDL includes address in metadata but might not be exposed in the program node + expect(root.additionalPrograms[0].name).toBe("newProgram"); + }); + + it("should throw an error when no IDLs are provided", () => { + expect(() => rootNodeFromAnchorIdls([])).toThrow( + "No IDL files were provided", + ); + }); + + it("should convert snake_case names to camelCase", () => { + const idl = createMockIdl("my_snake_case_program"); + const root = rootNodeFromAnchorIdls([idl]); + + expect(root.program.name).toBe("mySnakeCaseProgram"); + }); + + it("should preserve the order of programs", () => { + const idls = [ + createMockIdl("first"), + createMockIdl("second"), + createMockIdl("third"), + createMockIdl("fourth"), + ]; + + const root = rootNodeFromAnchorIdls(idls); + + expect(root.program.name).toBe("first"); + expect(root.additionalPrograms[0].name).toBe("second"); + expect(root.additionalPrograms[1].name).toBe("third"); + expect(root.additionalPrograms[2].name).toBe("fourth"); + }); + + it("should handle IDLs with instructions and accounts", () => { + const idl: AnchorIdl = { + name: "complex_program", + version: "0.0.0", + instructions: [ + { + name: "initialize", + accounts: [], + args: [], + }, + ], + accounts: [ + { + name: "MyAccount", + type: { + kind: "struct", + fields: [{ name: "value", type: "u64" }], + }, + }, + ], + types: [], + errors: [], + }; + + const root = rootNodeFromAnchorIdls([idl]); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("complexProgram"); + expect(root.program.instructions).toHaveLength(1); + expect(root.program.instructions[0].name).toBe("initialize"); + expect(root.program.accounts).toHaveLength(1); + expect(root.program.accounts[0].name).toBe("myAccount"); + }); +}); diff --git a/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.ts b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.ts new file mode 100644 index 00000000..5e7189f4 --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor-idls.ts @@ -0,0 +1,50 @@ +import type { RootNode } from "@codama/nodes"; +import { rootNode } from "@codama/nodes"; +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { programNodeFromAnchor } from "./program-node-from-anchor.js"; + +/** + * Creates a Codama root node from multiple Anchor IDLs. + * + * This function takes an array of Anchor IDL objects and converts them into + * a single Codama root node that can be used with Codama visitors for + * code generation and AST transformation. + * + * @param idls - An array of Anchor IDL objects to convert + * @returns A Codama root node containing all programs from the IDLs + * + * @throws {Error} If no IDL files are provided + * @throws {Error} If no program nodes could be created + * + * @example + * ```typescript + * import { rootNodeFromAnchorIdls } from "@macalinao/codama-nodes-from-anchor-x"; + * import { visit } from "codama"; + * + * const idls = [idl1, idl2, idl3]; + * const root = rootNodeFromAnchorIdls(idls); + * + * // Use with Codama visitors + * visit(root, myVisitor); + * ``` + * + * @remarks + * - Supports both Anchor IDL v0.0.0 and v0.1.0 formats + * - The first IDL becomes the main program, others are additional programs + * - Use this when you need to work with multiple related programs together + */ +export function rootNodeFromAnchorIdls(idls: AnchorIdl[]): RootNode { + if (idls.length === 0) { + throw new Error("No IDL files were provided"); + } + + // Create program nodes from IDLs + const programNodes = idls.map((idl) => programNodeFromAnchor(idl)); + + const [firstProgramNode, ...restProgramNodes] = programNodes; + if (!firstProgramNode) { + throw new Error("No program nodes could be created from the provided IDLs"); + } + + return rootNode(firstProgramNode, restProgramNodes); +} diff --git a/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.test.ts b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.test.ts new file mode 100644 index 00000000..818d09e5 --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.test.ts @@ -0,0 +1,121 @@ +import { describe, expect, it } from "bun:test"; +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { rootNodeFromAnchor } from "./root-node-from-anchor.js"; + +describe("rootNodeFromAnchor", () => { + const createMockIdl = (name: string, version = "0.0.0"): AnchorIdl => ({ + name, + version, + instructions: [], + accounts: [], + types: [], + errors: [], + }); + + const createMockIdlV01 = (name: string): AnchorIdl => ({ + version: "0.1.0", + metadata: { + spec: "0.1.0", + address: "11111111111111111111111111111111", + name, + }, + instructions: [], + accounts: [], + types: [], + errors: [], + }); + + it("should create a root node from a v0.0.0 IDL", () => { + const idl = createMockIdl("test_program"); + const root = rootNodeFromAnchor(idl); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("testProgram"); + expect(root.additionalPrograms).toHaveLength(0); + }); + + it("should create a root node from a v0.1.0 IDL", () => { + const idl = createMockIdlV01("new_format_program"); + const root = rootNodeFromAnchor(idl); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("newFormatProgram"); + expect(root.additionalPrograms).toHaveLength(0); + }); + + it("should convert snake_case names to camelCase", () => { + const idl = createMockIdl("my_snake_case_program"); + const root = rootNodeFromAnchor(idl); + + expect(root.program.name).toBe("mySnakeCaseProgram"); + }); + + it("should handle IDLs with instructions and accounts", () => { + const idl: AnchorIdl = { + name: "complex_program", + version: "0.0.0", + instructions: [ + { + name: "initialize", + accounts: [], + args: [], + }, + { + name: "transfer", + accounts: [], + args: [{ name: "amount", type: "u64" }], + }, + ], + accounts: [ + { + name: "MyAccount", + type: { + kind: "struct", + fields: [ + { name: "value", type: "u64" }, + { name: "owner", type: "publicKey" }, + ], + }, + }, + ], + types: [], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "The amount is invalid", + }, + ], + }; + + const root = rootNodeFromAnchor(idl); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("complexProgram"); + expect(root.program.instructions).toHaveLength(2); + expect(root.program.instructions[0].name).toBe("initialize"); + expect(root.program.instructions[1].name).toBe("transfer"); + expect(root.program.accounts).toHaveLength(1); + expect(root.program.accounts[0].name).toBe("myAccount"); + expect(root.program.errors).toHaveLength(1); + }); + + it("should handle empty IDL", () => { + const idl: AnchorIdl = { + name: "empty_program", + version: "0.0.0", + instructions: [], + accounts: [], + types: [], + errors: [], + }; + + const root = rootNodeFromAnchor(idl); + + expect(root.kind).toBe("rootNode"); + expect(root.program.name).toBe("emptyProgram"); + expect(root.program.instructions).toHaveLength(0); + expect(root.program.accounts).toHaveLength(0); + expect(root.program.errors).toHaveLength(0); + }); +}); diff --git a/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.ts b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.ts new file mode 100644 index 00000000..628ed311 --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/src/root-node-from-anchor.ts @@ -0,0 +1,36 @@ +import type { RootNode } from "@codama/nodes"; +import { rootNode } from "@codama/nodes"; +import type { AnchorIdl } from "@codama/nodes-from-anchor"; +import { programNodeFromAnchor } from "./program-node-from-anchor.js"; + +/** + * Creates a Codama root node from a single Anchor IDL. + * + * This function takes an Anchor IDL object and converts it into + * a Codama root node that can be used with Codama visitors for + * code generation and AST transformation. + * + * @param idl - An Anchor IDL object to convert + * @returns A Codama root node containing the program from the IDL + * + * @example + * ```typescript + * import { rootNodeFromAnchor } from "@macalinao/codama-nodes-from-anchor-x"; + * import { visit } from "codama"; + * + * const idl = JSON.parse(fs.readFileSync("./idl.json", "utf-8")); + * const root = rootNodeFromAnchor(idl); + * + * // Use with Codama visitors + * visit(root, myVisitor); + * ``` + * + * @remarks + * - Supports both Anchor IDL v0.0.0 and v0.1.0 formats + * - Automatically detects the IDL version and uses the appropriate parser + * - For multiple IDLs, use `rootNodeFromAnchorIdls` instead + */ +export function rootNodeFromAnchor(idl: AnchorIdl): RootNode { + const program = programNodeFromAnchor(idl); + return rootNode(program); +} diff --git a/packages/codama-nodes-from-anchor-x/tsconfig.json b/packages/codama-nodes-from-anchor-x/tsconfig.json new file mode 100644 index 00000000..eef021ae --- /dev/null +++ b/packages/codama-nodes-from-anchor-x/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@macalinao/tsconfig/tsconfig.base.json", + "compilerOptions": { + "types": ["bun-types"] + }, + "include": ["src/**/*.ts"], + "exclude": ["**/*.test.ts", "dist"] +} diff --git a/packages/codama-rename-visitor/README.md b/packages/codama-rename-visitor/README.md index 2bcca3ce..f9dd5ecd 100644 --- a/packages/codama-rename-visitor/README.md +++ b/packages/codama-rename-visitor/README.md @@ -1,9 +1,30 @@ # @macalinao/codama-rename-visitor +[![npm version](https://img.shields.io/npm/v/@macalinao/codama-rename-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-rename-visitor) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-rename-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-rename-visitor) + A Codama visitor for renaming instructions and events within a Solana program. +## Quick Start with Coda CLI + +This visitor works seamlessly with the [Coda CLI](https://coda.ianm.com) for automated client generation: + +```bash +# Install Coda CLI +bun add -D @macalinao/coda + +# Initialize configuration +coda init + +# Add this visitor to your coda.config.mjs +``` + +Coda provides zero-config client generation with powerful customization through visitors like this one. Learn more at [coda.ianm.com](https://coda.ianm.com). + ## Installation +For direct usage: + ```bash npm install @macalinao/codama-rename-visitor ``` diff --git a/packages/codama-rename-visitor/package.json b/packages/codama-rename-visitor/package.json index 24204e4e..daa01aa9 100644 --- a/packages/codama-rename-visitor/package.json +++ b/packages/codama-rename-visitor/package.json @@ -9,12 +9,14 @@ "license": "Apache-2.0", "keywords": [ "codama", + "coda", "solana", "anchor", "idl", "rename", "visitor", - "typescript" + "typescript", + "ian-macalinao" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -40,10 +42,10 @@ "build": "tsc", "clean": "rm -fr dist/", "lint": "eslint . --cache", - "test": "bun test" + "test": "bun test src/" }, "dependencies": { - "codama": "*" + "codama": "catalog:" }, "devDependencies": { "@macalinao/eslint-config": "catalog:", diff --git a/packages/codama-rename-visitor/src/index.test.ts b/packages/codama-rename-visitor/src/index.test.ts deleted file mode 100644 index 0271862b..00000000 --- a/packages/codama-rename-visitor/src/index.test.ts +++ /dev/null @@ -1,409 +0,0 @@ -/// -import { describe, expect, it } from "bun:test"; -import type { ProgramNode, RootNode } from "codama"; -import { - camelCase, - definedTypeNode, - instructionAccountNode, - instructionNode, - numberTypeNode, - programNode, - publicKeyTypeNode, - rootNode, - visit, -} from "codama"; -import { - renameDefinedTypesVisitor, - renameEventsVisitor, - renameInstructionsVisitor, - renameVisitor, -} from "./index.js"; - -describe("renameInstructionsVisitor", () => { - it("should rename instructions based on the mapping", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("transfer"), - accounts: [ - instructionAccountNode({ - name: camelCase("source"), - isWritable: true, - isSigner: false, - }), - instructionAccountNode({ - name: camelCase("destination"), - isWritable: true, - isSigner: false, - }), - ], - }), - instructionNode({ - name: camelCase("mint"), - accounts: [ - instructionAccountNode({ - name: camelCase("mint"), - isWritable: true, - isSigner: false, - }), - ], - }), - ], - }); - - const root = rootNode(program); - const visitor = renameInstructionsVisitor({ - transfer: "transferTokens", - mint: "mintNft", - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - - expect(instructions[0].name.toString()).toBe("transferTokens"); - expect(instructions[1].name.toString()).toBe("mintNft"); - }); - - it("should leave unmapped instructions unchanged", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("burn"), - accounts: [], - }), - ], - }); - - const root = rootNode(program); - const visitor = renameInstructionsVisitor({ - transfer: "transferTokens", - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - - expect(instructions[0].name.toString()).toBe("burn"); - }); -}); - -describe("renameDefinedTypesVisitor", () => { - it("should rename defined types based on the mapping", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - definedTypes: [ - definedTypeNode({ - name: camelCase("counter"), - type: numberTypeNode("u64"), - }), - definedTypeNode({ - name: camelCase("config"), - type: publicKeyTypeNode(), - }), - ], - }); - - const root = rootNode(program); - const visitor = renameDefinedTypesVisitor({ - counter: "counterAccount", - config: "programConfig", - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const types = updatedRoot.program.definedTypes; - - expect(types[0].name.toString()).toBe("counterAccount"); - expect(types[1].name.toString()).toBe("programConfig"); - }); -}); - -describe("renameEventsVisitor", () => { - it("should rename events (as defined types with Event suffix)", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - definedTypes: [ - definedTypeNode({ - name: camelCase("tokenMintedEvent"), - type: numberTypeNode("u64"), - }), - definedTypeNode({ - name: camelCase("transferCompleteEvent"), - type: publicKeyTypeNode(), - }), - definedTypeNode({ - name: camelCase("regularType"), - type: numberTypeNode("u32"), - }), - ], - }); - - const root = rootNode(program); - const visitor = renameEventsVisitor({ - tokenMintedEvent: "nftMintedEvent", - transferCompleteEvent: "transferFinishedEvent", - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const types = updatedRoot.program.definedTypes; - - expect(types[0].name.toString()).toBe("nftMintedEvent"); - expect(types[1].name.toString()).toBe("transferFinishedEvent"); - expect(types[2].name.toString()).toBe("regularType"); // Should remain unchanged - }); - - it("should rename events without suffix if explicitly in mapping", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - definedTypes: [ - definedTypeNode({ - name: camelCase("tokenMinted"), - type: numberTypeNode("u64"), - }), - ], - }); - - const root = rootNode(program); - const visitor = renameEventsVisitor({ - tokenMinted: "nftMinted", - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const types = updatedRoot.program.definedTypes; - - expect(types[0].name.toString()).toBe("nftMinted"); - }); -}); - -describe("renameVisitor (legacy format)", () => { - it("should rename both instructions and events", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("transfer"), - accounts: [], - }), - ], - definedTypes: [ - definedTypeNode({ - name: camelCase("tokenMintedEvent"), - type: numberTypeNode("u64"), - }), - ], - }); - - const root = rootNode(program); - const visitor = renameVisitor({ - instructions: { - transfer: "transferTokens", - }, - events: { - tokenMintedEvent: "nftMintedEvent", - }, - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - const types = updatedRoot.program.definedTypes; - - expect(instructions[0].name.toString()).toBe("transferTokens"); - expect(types[0].name.toString()).toBe("nftMintedEvent"); - }); - - it("should handle empty options gracefully", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("transfer"), - accounts: [], - }), - ], - }); - - const root = rootNode(program); - const visitor = renameVisitor({}); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - - expect(instructions[0].name.toString()).toBe("transfer"); - }); -}); - -describe("renameVisitor (program-specific format)", () => { - it("should rename instructions in specific programs", () => { - const quarryMineProgram: ProgramNode = programNode({ - name: camelCase("quarryMine"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("claimRewards"), - accounts: [], - }), - instructionNode({ - name: camelCase("stake"), - accounts: [], - }), - ], - }); - - const tokenProgram: ProgramNode = programNode({ - name: camelCase("token"), - publicKey: "22222222222222222222222222222222", - instructions: [ - instructionNode({ - name: camelCase("transfer"), - accounts: [], - }), - instructionNode({ - name: camelCase("mint"), - accounts: [], - }), - ], - }); - - // Create a root with multiple programs - const root = rootNode(quarryMineProgram, [tokenProgram]); - - const visitor = renameVisitor({ - quarryMine: { - instructions: { - claimRewards: "claimRewardsMine", - }, - }, - token: { - instructions: { - transfer: "transferTokens", - mint: "mintNft", - }, - }, - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const quarryInstructions = updatedRoot.program.instructions; - const tokenInstructions = - updatedRoot.additionalPrograms?.[0]?.instructions ?? []; - - expect(quarryInstructions[0].name.toString()).toBe("claimRewardsMine"); - expect(quarryInstructions[1].name.toString()).toBe("stake"); // Unchanged - expect(tokenInstructions[0].name.toString()).toBe("transferTokens"); - expect(tokenInstructions[1].name.toString()).toBe("mintNft"); - }); - - it("should rename events and defined types in specific programs", () => { - const program: ProgramNode = programNode({ - name: camelCase("myProgram"), - publicKey: "11111111111111111111111111111111", - definedTypes: [ - definedTypeNode({ - name: camelCase("tokenMintedEvent"), - type: numberTypeNode("u64"), - }), - definedTypeNode({ - name: camelCase("counter"), - type: numberTypeNode("u64"), - }), - ], - }); - - const root = rootNode(program); - - const visitor = renameVisitor({ - myProgram: { - events: { - tokenMintedEvent: "nftMintedEvent", - }, - definedTypes: { - counter: "counterAccount", - }, - }, - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const types = updatedRoot.program.definedTypes; - - expect(types[0].name.toString()).toBe("nftMintedEvent"); - expect(types[1].name.toString()).toBe("counterAccount"); - }); - - it("should work with Quarry-style program names (camelCase)", () => { - const quarryMergeMineProgram: ProgramNode = programNode({ - name: camelCase("quarryMergeMine"), - publicKey: "QMMD16kjauP5knBwxNUJRZ1Z5o3deBuFrqVjBVmmqto", - instructions: [ - instructionNode({ - name: camelCase("claimRewards"), - accounts: [], - }), - instructionNode({ - name: camelCase("stake"), - accounts: [], - }), - ], - }); - - const root = rootNode(quarryMergeMineProgram); - - const visitor = renameVisitor({ - quarryMergeMine: { - instructions: { - claimRewards: "claimRewardsMergeMine", - }, - }, - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - - expect(instructions[0].name.toString()).toBe("claimRewardsMergeMine"); - expect(instructions[1].name.toString()).toBe("stake"); // Unchanged - }); - - it("should handle mixed program configurations", () => { - const program: ProgramNode = programNode({ - name: camelCase("testProgram"), - publicKey: "11111111111111111111111111111111", - instructions: [ - instructionNode({ - name: camelCase("transfer"), - accounts: [], - }), - ], - definedTypes: [ - definedTypeNode({ - name: camelCase("transferEvent"), - type: numberTypeNode("u64"), - }), - ], - }); - - const root = rootNode(program); - - const visitor = renameVisitor({ - testProgram: { - instructions: { - transfer: "sendTokens", - }, - events: { - transferEvent: "tokenSentEvent", - }, - }, - }); - - const updatedRoot = visit(root, visitor) as RootNode; - const instructions = updatedRoot.program.instructions; - const types = updatedRoot.program.definedTypes; - - expect(instructions[0].name.toString()).toBe("sendTokens"); - expect(types[0].name.toString()).toBe("tokenSentEvent"); - }); -}); diff --git a/packages/codama-rename-visitor/src/index.ts b/packages/codama-rename-visitor/src/index.ts index 86ff5490..f423d1d0 100644 --- a/packages/codama-rename-visitor/src/index.ts +++ b/packages/codama-rename-visitor/src/index.ts @@ -1,291 +1,14 @@ -import type { DefinedTypeNode, InstructionNode, Node, RootNode } from "codama"; -import { - assertIsNode, - bottomUpTransformerVisitor, - camelCase, - rootNodeVisitor, - visit, -} from "codama"; - -/** - * Rename mapping for a single program - */ -export interface ProgramRenameOptions { - /** Mapping of old instruction names to new instruction names */ - instructions?: Record; - /** Mapping of old event names (as defined types) to new event names */ - events?: Record; - /** Mapping of old defined type names to new defined type names */ - definedTypes?: Record; -} - -/** - * Options for the rename visitor (legacy interface) - */ -export type RenameVisitorOptions = ProgramRenameOptions; - -/** - * Creates a visitor that renames instructions in a Codama IDL. - * - * @param mapping - Object mapping old instruction names to new instruction names - * @returns A root node visitor that renames instructions - * - * @example - * ```typescript - * const visitor = renameInstructionsVisitor({ - * "transfer": "transferTokens", - * "mint": "mintNft" - * }); - * codama.update(visitor); - * ``` - */ -export function renameInstructionsVisitor( - mapping: Record, -): ReturnType { - return rootNodeVisitor((root) => { - const instructionVisitor = bottomUpTransformerVisitor([ - { - select: "[instructionNode]", - transform: (node) => { - assertIsNode(node, "instructionNode"); - const newName = mapping[node.name]; - if (!newName) { - return node; - } - return { - ...node, - name: camelCase(newName), - } as InstructionNode; - }, - }, - ]); - return visit(root, instructionVisitor); - }); -} - -/** - * Creates a visitor that renames events (as defined types) in a Codama IDL. - * - * Events in Anchor IDLs are typically converted to defined types in Codama, - * so this visitor renames specific defined types that represent events. - * - * @param mapping - Object mapping old event names to new event names - * @param eventSuffix - Optional suffix to identify event types (default: "Event") - * @returns A root node visitor that renames events - * - * @example - * ```typescript - * const visitor = renameEventsVisitor({ - * "tokenMinted": "nftMinted", - * "transferComplete": "transferFinished" - * }); - * codama.update(visitor); - * ``` - */ -export function renameEventsVisitor( - mapping: Record, - eventSuffix = "Event", -): ReturnType { - return rootNodeVisitor((root) => { - const eventVisitor = bottomUpTransformerVisitor([ - { - select: "[definedTypeNode]", - transform: (node) => { - assertIsNode(node, "definedTypeNode"); - - // Check if this is an event type (by suffix or by being in the mapping) - const isEventBySuffix = node.name.endsWith(eventSuffix); - const isEventInMapping = mapping[node.name] !== undefined; - - if (!(isEventBySuffix || isEventInMapping)) { - return node; - } - - const newName = mapping[node.name]; - if (!newName) { - return node; - } - - return { - ...node, - name: camelCase(newName), - } as DefinedTypeNode; - }, - }, - ]); - return visit(root, eventVisitor); - }); -} - -/** - * Creates a visitor that renames defined types in a Codama IDL. - * - * @param mapping - Object mapping old defined type names to new defined type names - * @returns A root node visitor that renames defined types - * - * @example - * ```typescript - * const visitor = renameDefinedTypesVisitor({ - * "counter": "counterAccount", - * "config": "programConfig" - * }); - * codama.update(visitor); - * ``` - */ -export function renameDefinedTypesVisitor( - mapping: Record, -): ReturnType { - return rootNodeVisitor((root) => { - const typeVisitor = bottomUpTransformerVisitor([ - { - select: "[definedTypeNode]", - transform: (node) => { - assertIsNode(node, "definedTypeNode"); - const newName = mapping[node.name]; - if (!newName) { - return node; - } - return { - ...node, - name: camelCase(newName), - } as DefinedTypeNode; - }, - }, - ]); - return visit(root, typeVisitor); - }); -} - -/** - * Creates a visitor that renames instructions, events, and defined types in specific programs. - * This follows the same pattern as addPdasVisitor from Codama. - * - * @param renamesByProgram - Object mapping program names to their rename configurations - * @returns A root node visitor that performs all specified renames - * - * @example - * ```typescript - * const visitor = renameVisitor({ - * quarryMine: { - * instructions: { - * claimRewards: "claimRewardsMine" - * } - * }, - * token: { - * instructions: { - * transfer: "transferTokens", - * mint: "mintNft" - * }, - * events: { - * tokenMinted: "nftMinted" - * } - * } - * }); - * codama.update(visitor); - * ``` - */ -export function renameVisitor( - renamesByProgram: Record, -): ReturnType { - return rootNodeVisitor((root) => { - // Check if this is the legacy single-program format - // (has instructions, events, or definedTypes at the top level) - const isLegacyFormat = - "instructions" in renamesByProgram || - "events" in renamesByProgram || - "definedTypes" in renamesByProgram; - - if (isLegacyFormat) { - // Legacy support: treat as single program renames - const options = renamesByProgram as unknown as RenameVisitorOptions; - let transformedRoot = root; - - // Apply instruction renaming - if ( - options.instructions && - Object.keys(options.instructions).length > 0 - ) { - transformedRoot = visit( - transformedRoot, - renameInstructionsVisitor(options.instructions), - ) as RootNode; - } - - // Apply event renaming - if (options.events && Object.keys(options.events).length > 0) { - transformedRoot = visit( - transformedRoot, - renameEventsVisitor(options.events), - ) as RootNode; - } - - // Apply defined type renaming - if ( - options.definedTypes && - Object.keys(options.definedTypes).length > 0 - ) { - transformedRoot = visit( - transformedRoot, - renameDefinedTypesVisitor(options.definedTypes), - ) as RootNode; - } - - return transformedRoot; - } - - // New format: program-specific renames - const transforms: { - select: string; - transform: (node: Node) => Node | null; - }[] = []; - - // Process each program's rename configuration - Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => { - // Add instruction renames for this program - if (renameOptions.instructions) { - Object.entries(renameOptions.instructions).forEach( - ([oldName, newName]) => { - transforms.push({ - select: `[programNode]${programName}.[instructionNode]${oldName}`, - transform: (node) => { - assertIsNode(node, "instructionNode"); - return { - ...node, - name: camelCase(newName), - } as InstructionNode; - }, - }); - }, - ); - } - - // Add event/defined type renames for this program - if (renameOptions.events || renameOptions.definedTypes) { - const allTypeRenames = { - ...(renameOptions.events ?? {}), - ...(renameOptions.definedTypes ?? {}), - }; - - Object.entries(allTypeRenames).forEach(([oldName, newName]) => { - transforms.push({ - select: `[programNode]${programName}.[definedTypeNode]${oldName}`, - transform: (node) => { - assertIsNode(node, "definedTypeNode"); - return { - ...node, - name: camelCase(newName), - } as DefinedTypeNode; - }, - }); - }); - } - }); - - if (transforms.length === 0) { - return root; - } - - const visitor = bottomUpTransformerVisitor(transforms); - return visit(root, visitor); - }); -} +export { + renameAccountsVisitor, + renameAccountTransform, +} from "./rename-accounts-visitor.js"; +export { + renameDefinedTypesVisitor, + renameDefinedTypeTransform, +} from "./rename-defined-types-visitor.js"; +export { + renameInstructionsVisitor, + renameInstructionTransform, +} from "./rename-instructions-visitor.js"; +export { renameVisitor } from "./rename-visitor.js"; +export type { ProgramRenameOptions } from "./types.js"; diff --git a/packages/codama-rename-visitor/src/rename-accounts-visitor.ts b/packages/codama-rename-visitor/src/rename-accounts-visitor.ts new file mode 100644 index 00000000..8abe6449 --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-accounts-visitor.ts @@ -0,0 +1,50 @@ +import type { AccountNode, Node, rootNodeVisitor } from "codama"; +import { assertIsNode, bottomUpTransformerVisitor, camelCase } from "codama"; + +/** + * Transform function that renames an account node based on a mapping. + * + * @param node - The node to transform + * @param mapping - Object mapping old account names to new account names + * @returns The transformed account node + */ +export function renameAccountTransform( + node: Node, + mapping: Record, +): AccountNode { + assertIsNode(node, "accountNode"); + const newName = mapping[node.name]; + if (!newName) { + return node; + } + return { + ...node, + name: camelCase(newName), + }; +} + +/** + * Creates a visitor that renames accounts in a Codama IDL. + * + * @param mapping - Object mapping old account names to new account names + * @returns A root node visitor that renames accounts + * + * @example + * ```typescript + * const visitor = renameAccountsVisitor({ + * "userAccount": "user", + * "configAccount": "config" + * }); + * codama.update(visitor); + * ``` + */ +export function renameAccountsVisitor( + mapping: Record, +): ReturnType { + return bottomUpTransformerVisitor([ + { + select: "[accountNode]", + transform: (node) => renameAccountTransform(node, mapping), + }, + ]); +} diff --git a/packages/codama-rename-visitor/src/rename-defined-types-visitor.test.ts b/packages/codama-rename-visitor/src/rename-defined-types-visitor.test.ts new file mode 100644 index 00000000..bca8d3eb --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-defined-types-visitor.test.ts @@ -0,0 +1,44 @@ +/// +import { describe, expect, it } from "bun:test"; +import type { ProgramNode, RootNode } from "codama"; +import { + camelCase, + definedTypeNode, + numberTypeNode, + programNode, + publicKeyTypeNode, + rootNode, + visit, +} from "codama"; +import { renameDefinedTypesVisitor } from "./rename-defined-types-visitor.js"; + +describe("renameDefinedTypesVisitor", () => { + it("should rename defined types based on the mapping", () => { + const program: ProgramNode = programNode({ + name: camelCase("testProgram"), + publicKey: "11111111111111111111111111111111", + definedTypes: [ + definedTypeNode({ + name: camelCase("counter"), + type: numberTypeNode("u64"), + }), + definedTypeNode({ + name: camelCase("config"), + type: publicKeyTypeNode(), + }), + ], + }); + + const root = rootNode(program); + const visitor = renameDefinedTypesVisitor({ + counter: "counterAccount", + config: "programConfig", + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const types = updatedRoot.program.definedTypes; + + expect(types[0].name.toString()).toBe("counterAccount"); + expect(types[1].name.toString()).toBe("programConfig"); + }); +}); diff --git a/packages/codama-rename-visitor/src/rename-defined-types-visitor.ts b/packages/codama-rename-visitor/src/rename-defined-types-visitor.ts new file mode 100644 index 00000000..969f279c --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-defined-types-visitor.ts @@ -0,0 +1,59 @@ +import type { DefinedTypeNode, Node } from "codama"; +import { + assertIsNode, + bottomUpTransformerVisitor, + camelCase, + rootNodeVisitor, + visit, +} from "codama"; + +/** + * Transform function that renames a defined type node based on a mapping. + * + * @param node - The node to transform + * @param mapping - Object mapping old defined type names to new defined type names + * @returns The transformed defined type node + */ +export function renameDefinedTypeTransform( + node: Node, + mapping: Record, +): DefinedTypeNode { + assertIsNode(node, "definedTypeNode"); + const newName = mapping[node.name]; + if (!newName) { + return node; + } + return { + ...node, + name: camelCase(newName), + }; +} + +/** + * Creates a visitor that renames defined types in a Codama IDL. + * + * @param mapping - Object mapping old defined type names to new defined type names + * @returns A root node visitor that renames defined types + * + * @example + * ```typescript + * const visitor = renameDefinedTypesVisitor({ + * "counter": "counterAccount", + * "config": "programConfig" + * }); + * codama.update(visitor); + * ``` + */ +export function renameDefinedTypesVisitor( + mapping: Record, +): ReturnType { + return rootNodeVisitor((root) => { + const typeVisitor = bottomUpTransformerVisitor([ + { + select: "[definedTypeNode]", + transform: (node) => renameDefinedTypeTransform(node, mapping), + }, + ]); + return visit(root, typeVisitor); + }); +} diff --git a/packages/codama-rename-visitor/src/rename-instructions-visitor.test.ts b/packages/codama-rename-visitor/src/rename-instructions-visitor.test.ts new file mode 100644 index 00000000..705353d3 --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-instructions-visitor.test.ts @@ -0,0 +1,83 @@ +/// +import { describe, expect, it } from "bun:test"; +import type { ProgramNode, RootNode } from "codama"; +import { + camelCase, + instructionAccountNode, + instructionNode, + programNode, + rootNode, + visit, +} from "codama"; +import { renameInstructionsVisitor } from "./rename-instructions-visitor.js"; + +describe("renameInstructionsVisitor", () => { + it("should rename instructions based on the mapping", () => { + const program: ProgramNode = programNode({ + name: camelCase("testProgram"), + publicKey: "11111111111111111111111111111111", + instructions: [ + instructionNode({ + name: camelCase("transfer"), + accounts: [ + instructionAccountNode({ + name: camelCase("source"), + isWritable: true, + isSigner: false, + }), + instructionAccountNode({ + name: camelCase("destination"), + isWritable: true, + isSigner: false, + }), + ], + }), + instructionNode({ + name: camelCase("mint"), + accounts: [ + instructionAccountNode({ + name: camelCase("mint"), + isWritable: true, + isSigner: false, + }), + ], + }), + ], + }); + + const root = rootNode(program); + const visitor = renameInstructionsVisitor({ + transfer: "transferTokens", + mint: "mintNft", + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const instructions = updatedRoot.program.instructions; + + expect(instructions[0].name.toString()).toBe("transferTokens"); + expect(instructions[1].name.toString()).toBe("mintNft"); + }); + + it("should leave unmapped instructions unchanged", () => { + const program: ProgramNode = programNode({ + name: camelCase("testProgram"), + publicKey: "11111111111111111111111111111111", + instructions: [ + instructionNode({ + name: camelCase("burn"), + accounts: [], + }), + ], + }); + + const root = rootNode(program); + const visitor = renameInstructionsVisitor({ + transfer: "transferTokens", + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const instructions = updatedRoot.program.instructions; + + expect(instructions[0].name.toString()).toBe("burn"); + }); +}); diff --git a/packages/codama-rename-visitor/src/rename-instructions-visitor.ts b/packages/codama-rename-visitor/src/rename-instructions-visitor.ts new file mode 100644 index 00000000..5210aa06 --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-instructions-visitor.ts @@ -0,0 +1,50 @@ +import type { InstructionNode, Node, NodeKind, Visitor } from "codama"; +import { assertIsNode, bottomUpTransformerVisitor, camelCase } from "codama"; + +/** + * Transform function that renames an instruction node based on a mapping. + * + * @param node - The node to transform + * @param mapping - Object mapping old instruction names to new instruction names + * @returns The transformed instruction node + */ +export function renameInstructionTransform( + node: Node, + mapping: Record, +): InstructionNode { + assertIsNode(node, "instructionNode"); + const newName = mapping[node.name]; + if (!newName) { + return node; + } + return { + ...node, + name: camelCase(newName), + }; +} + +/** + * Creates a visitor that renames instructions in a Codama IDL. + * + * @param mapping - Object mapping old instruction names to new instruction names + * @returns A root node visitor that renames instructions + * + * @example + * ```typescript + * const visitor = renameInstructionsVisitor({ + * "transfer": "transferTokens", + * "mint": "mintNft" + * }); + * codama.update(visitor); + * ``` + */ +export function renameInstructionsVisitor< + TNodeKind extends NodeKind = NodeKind, +>(mapping: Record): Visitor { + return bottomUpTransformerVisitor([ + { + select: "[instructionNode]", + transform: (node) => renameInstructionTransform(node, mapping), + }, + ]); +} diff --git a/packages/codama-rename-visitor/src/rename-visitor.test.ts b/packages/codama-rename-visitor/src/rename-visitor.test.ts new file mode 100644 index 00000000..eb317400 --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-visitor.test.ts @@ -0,0 +1,175 @@ +/// +import { describe, expect, it } from "bun:test"; +import type { ProgramNode, RootNode } from "codama"; +import { + camelCase, + definedTypeNode, + instructionNode, + numberTypeNode, + programNode, + rootNode, + visit, +} from "codama"; +import { renameVisitor } from "./rename-visitor.js"; + +describe("renameVisitor (program-specific format)", () => { + it("should rename instructions in specific programs", () => { + const quarryMineProgram: ProgramNode = programNode({ + name: camelCase("quarryMine"), + publicKey: "11111111111111111111111111111111", + instructions: [ + instructionNode({ + name: camelCase("claimRewards"), + accounts: [], + }), + instructionNode({ + name: camelCase("stake"), + accounts: [], + }), + ], + }); + + const tokenProgram: ProgramNode = programNode({ + name: camelCase("token"), + publicKey: "22222222222222222222222222222222", + instructions: [ + instructionNode({ + name: camelCase("transfer"), + accounts: [], + }), + instructionNode({ + name: camelCase("mint"), + accounts: [], + }), + ], + }); + + // Create a root with multiple programs + const root = rootNode(quarryMineProgram, [tokenProgram]); + + const visitor = renameVisitor({ + quarryMine: { + instructions: { + claimRewards: "claimRewardsMine", + }, + }, + token: { + instructions: { + transfer: "transferTokens", + mint: "mintNft", + }, + }, + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const quarryInstructions = updatedRoot.program.instructions; + const tokenInstructions = + updatedRoot.additionalPrograms?.[0]?.instructions ?? []; + + expect(quarryInstructions[0].name.toString()).toBe("claimRewardsMine"); + expect(quarryInstructions[1].name.toString()).toBe("stake"); // Unchanged + expect(tokenInstructions[0].name.toString()).toBe("transferTokens"); + expect(tokenInstructions[1].name.toString()).toBe("mintNft"); + }); + + it("should rename defined types in specific programs", () => { + const program: ProgramNode = programNode({ + name: camelCase("myProgram"), + publicKey: "11111111111111111111111111111111", + definedTypes: [ + definedTypeNode({ + name: camelCase("tokenMintedEvent"), + type: numberTypeNode("u64"), + }), + definedTypeNode({ + name: camelCase("counter"), + type: numberTypeNode("u64"), + }), + ], + }); + + const root = rootNode(program); + + const visitor = renameVisitor({ + myProgram: { + definedTypes: { + counter: "counterAccount", + tokenMintedEvent: "nftMintedEvent", + }, + }, + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const types = updatedRoot.program.definedTypes; + + expect(types[0].name.toString()).toBe("nftMintedEvent"); + expect(types[1].name.toString()).toBe("counterAccount"); + }); + + it("should work with Quarry-style program names (camelCase)", () => { + const quarryMergeMineProgram: ProgramNode = programNode({ + name: camelCase("quarryMergeMine"), + publicKey: "QMMD16kjauP5knBwxNUJRZ1Z5o3deBuFrqVjBVmmqto", + instructions: [ + instructionNode({ + name: camelCase("claimRewards"), + accounts: [], + }), + instructionNode({ + name: camelCase("stake"), + accounts: [], + }), + ], + }); + + const root = rootNode(quarryMergeMineProgram); + + const visitor = renameVisitor({ + quarryMergeMine: { + instructions: { + claimRewards: "claimRewardsMergeMine", + }, + }, + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const instructions = updatedRoot.program.instructions; + + expect(instructions[0].name.toString()).toBe("claimRewardsMergeMine"); + expect(instructions[1].name.toString()).toBe("stake"); // Unchanged + }); + + it("should handle mixed program configurations", () => { + const program: ProgramNode = programNode({ + name: camelCase("testProgram"), + publicKey: "11111111111111111111111111111111", + instructions: [ + instructionNode({ + name: camelCase("transfer"), + accounts: [], + }), + ], + definedTypes: [ + definedTypeNode({ + name: camelCase("transferEvent"), + type: numberTypeNode("u64"), + }), + ], + }); + + const root = rootNode(program); + + const visitor = renameVisitor({ + testProgram: { + instructions: { + transfer: "sendTokens", + }, + }, + }); + + const updatedRoot = visit(root, visitor) as RootNode; + const instructions = updatedRoot.program.instructions; + + expect(instructions[0].name.toString()).toBe("sendTokens"); + }); +}); diff --git a/packages/codama-rename-visitor/src/rename-visitor.ts b/packages/codama-rename-visitor/src/rename-visitor.ts new file mode 100644 index 00000000..6d0aacea --- /dev/null +++ b/packages/codama-rename-visitor/src/rename-visitor.ts @@ -0,0 +1,94 @@ +import type { Node } from "codama"; +import { bottomUpTransformerVisitor, rootNodeVisitor, visit } from "codama"; +import { renameAccountTransform } from "./rename-accounts-visitor.js"; +import { renameDefinedTypeTransform } from "./rename-defined-types-visitor.js"; +import { renameInstructionTransform } from "./rename-instructions-visitor.js"; +import type { ProgramRenameOptions } from "./types.js"; + +/** + * Creates a visitor that renames accounts, instructions, and defined types in specific programs. + * This follows the same pattern as addPdasVisitor from Codama. + * + * @param renamesByProgram - Object mapping program names to their rename configurations + * @returns A root node visitor that performs all specified renames + * + * @example + * ```typescript + * const visitor = renameVisitor({ + * quarryMine: { + * instructions: { + * claimRewards: "claimRewardsMine" + * }, + * accounts: { + * miner: "minerAccount" + * } + * }, + * token: { + * instructions: { + * transfer: "transferTokens", + * mint: "mintNft" + * }, + * definedTypes: { + * tokenData: "tokenMetadata" + * } + * } + * }); + * codama.update(visitor); + * ``` + */ +export function renameVisitor( + renamesByProgram: Record, +): ReturnType { + return rootNodeVisitor((root) => { + const transforms: { + select: string; + transform: (node: Node) => Node | null; + }[] = []; + + // Process each program's rename configuration + Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => { + // Add instruction renames for this program + if (renameOptions.instructions) { + Object.entries(renameOptions.instructions).forEach( + ([oldName, newName]) => { + transforms.push({ + select: `[programNode]${programName}.[instructionNode]${oldName}`, + transform: (node) => + renameInstructionTransform(node, { [oldName]: newName }), + }); + }, + ); + } + + if (renameOptions.accounts) { + Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => { + transforms.push({ + select: `[programNode]${programName}.[accountNode]${oldName}`, + transform: (node) => + renameAccountTransform(node, { [oldName]: newName }), + }); + }); + } + + // Add defined type renames for this program + if (renameOptions.definedTypes) { + Object.entries(renameOptions.definedTypes ?? {}).forEach( + ([oldName, newName]) => { + transforms.push({ + select: `[programNode]${programName}.[definedTypeNode]${oldName}`, + transform: (node) => + renameDefinedTypeTransform(node, { [oldName]: newName }), + }); + }, + ); + } + }); + + if (transforms.length === 0) { + return root; + } + + const visitor = bottomUpTransformerVisitor(transforms); + return visit(root, visitor); + }); +} diff --git a/packages/codama-rename-visitor/src/types.ts b/packages/codama-rename-visitor/src/types.ts new file mode 100644 index 00000000..a88b16c5 --- /dev/null +++ b/packages/codama-rename-visitor/src/types.ts @@ -0,0 +1,11 @@ +/** + * Rename mapping for a single program + */ +export interface ProgramRenameOptions { + /** Mapping of old account names to new account names */ + accounts?: Record; + /** Mapping of old instruction names to new instruction names */ + instructions?: Record; + /** Mapping of old defined type names to new defined type names */ + definedTypes?: Record; +} diff --git a/packages/codama-renderers-js-esm/README.md b/packages/codama-renderers-js-esm/README.md index 1495a93e..48675040 100644 --- a/packages/codama-renderers-js-esm/README.md +++ b/packages/codama-renderers-js-esm/README.md @@ -1,17 +1,23 @@ # @macalinao/codama-renderers-js-esm [![npm version](https://img.shields.io/npm/v/@macalinao/codama-renderers-js-esm.svg)](https://www.npmjs.com/package/@macalinao/codama-renderers-js-esm) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-renderers-js-esm.svg)](https://www.npmjs.com/package/@macalinao/codama-renderers-js-esm) ESM-native TypeScript renderer for [Codama](https://github.com/codama-idl/codama) JavaScript code generation. This package extends `@codama/renderers-js` to produce fully ESM-compatible TypeScript/JavaScript code. -## Why This Package Exists +## Used by Coda CLI -While `@codama/renderers-js` generates excellent TypeScript code for Solana programs, the generated output uses CommonJS-style imports that may not work correctly in pure ESM environments. This package addresses several key issues: +This renderer is the default TypeScript renderer used by the [Coda CLI](https://coda.ianm.com): -1. **ESM Module Resolution**: Adds `.js` extensions to all relative imports, which is required for proper ESM module resolution -2. **TypeScript ESM Compatibility**: Ensures generated TypeScript code works correctly with `"type": "module"` in package.json -3. **Production-Ready Code**: Removes Node.js-specific environment checks that may not work in all JavaScript runtimes -4. **Type Safety Improvements**: Enhances type assertions and null checks for better TypeScript strictness +```bash +# Install Coda CLI - includes this ESM renderer by default +bun add -D @macalinao/coda + +# Generate ESM-native TypeScript clients with zero config +coda generate +``` + +Coda provides the easiest way to generate type-safe Solana clients from your Anchor IDLs. Learn more at [coda.ianm.com](https://coda.ianm.com). ## Installation diff --git a/packages/codama-renderers-js-esm/package.json b/packages/codama-renderers-js-esm/package.json index 68fe429b..5e463222 100644 --- a/packages/codama-renderers-js-esm/package.json +++ b/packages/codama-renderers-js-esm/package.json @@ -9,10 +9,12 @@ "license": "Apache-2.0", "keywords": [ "codama", + "coda", "solana", "esm", "typescript", - "code-generation" + "code-generation", + "ian-macalinao" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,9 +43,9 @@ "test": "echo 'No tests yet'" }, "dependencies": { - "@codama/renderers-core": "*", - "@codama/renderers-js": "*", - "codama": "*" + "@codama/renderers-core": "catalog:", + "@codama/renderers-js": "catalog:", + "codama": "catalog:" }, "devDependencies": { "@macalinao/eslint-config": "catalog:", diff --git a/packages/codama-renderers-js-esm/src/render-esm-typescript-visitor.ts b/packages/codama-renderers-js-esm/src/render-esm-typescript-visitor.ts index 3431a3da..d026a61e 100644 --- a/packages/codama-renderers-js-esm/src/render-esm-typescript-visitor.ts +++ b/packages/codama-renderers-js-esm/src/render-esm-typescript-visitor.ts @@ -1,17 +1,7 @@ -import type { RenderMap } from "@codama/renderers-core"; import { getRenderMapVisitor } from "@codama/renderers-js"; import { rootNodeVisitor, visit } from "codama"; import { ESM_DEPENDENCY_MAP } from "./constants.js"; -function modifyFile( - renderMap: RenderMap, - relativePath: string, - fn: (code: string) => string, -): void { - const code = renderMap.get(relativePath); - renderMap.add(relativePath, fn(code)); -} - /** * Codama visitor for rendering the code to be TypeScript compatible. * @param path @@ -34,36 +24,28 @@ export function renderESMTypeScriptVisitor( "index.ts", index.replace( /(export\s+\*\s+from\s+['"])(\.\/[^'"]+)(['"])/g, - (_, prefix, path, quote) => - `${prefix as string}${path as string}/index.js${quote as string}`, + (_: string, prefix: string, path: string, quote: string) => + `${prefix}${path}/index.js${quote}`, ), ); - modifyFile(renderMap, "shared/index.ts", (code) => { - return code - .replaceAll( - "if (value == null) {", - "if (value === null || value === undefined) {", - ) - .replaceAll("return value[0]", "return value[0] as Address"); - }); - renderMap.mapContent((code) => { const updated = code - .replace(/= 0x([\da-f]+), \/\//g, "= 0x$1; //") + // .replace(/= 0x([\da-f]+), \/\//g, "= 0x$1; //") .replaceAll("process.env.NODE_ENV !== 'production'", "true") - .replaceAll( - "const accountMeta = instruction.accounts![accountIndex]!;", - "const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;", - ) + .replaceAll(";;", ";") // Add return type annotations for functions that return simple types + .replace( + /export const (\w+DISCRIMINATOR)\s*=\s*new Uint8Array\(/g, + "export const $1: ReadonlyUint8Array = new Uint8Array(", + ) .replace( /export function (get\w+DiscriminatorBytes)\(\)\s*{/g, "export function $1(): ReadonlyUint8Array {", ) .replace( /(export\s+\*\s+from\s+['"])(\.\/[^'"]+?)(? `${prefix as string}${path as string}.js'`, + (_: string, prefix: string, path: string) => `${prefix}${path}.js'`, ) .replace(/from\s+['"]\.['"]/g, 'from "./index.js"'); diff --git a/packages/codama-renderers-markdown/README.md b/packages/codama-renderers-markdown/README.md index f712a445..179fc650 100644 --- a/packages/codama-renderers-markdown/README.md +++ b/packages/codama-renderers-markdown/README.md @@ -1,9 +1,46 @@ # @macalinao/codama-renderers-markdown +[![npm version](https://img.shields.io/npm/v/@macalinao/codama-renderers-markdown.svg)](https://www.npmjs.com/package/@macalinao/codama-renderers-markdown) +[![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-renderers-markdown.svg)](https://www.npmjs.com/package/@macalinao/codama-renderers-markdown) + A Codama visitor that renders markdown documentation from Solana program IDLs. +## Live Examples + +See the documentation this package generates in action: + +- **[Quarry Protocol Documentation](https://coda-docs.vercel.app/docs/api/clients/quarry)** - Complete documentation for the Quarry staking protocol, showcasing: + - [60+ Instructions](https://coda-docs.vercel.app/docs/api/clients/quarry/instructions) with full parameter documentation + - [Account structures](https://coda-docs.vercel.app/docs/api/clients/quarry/accounts) with field descriptions + - [PDA derivations](https://coda-docs.vercel.app/docs/api/clients/quarry/pdas) with seed definitions + - [Custom types](https://coda-docs.vercel.app/docs/api/clients/quarry/types) and enums + - [Error codes](https://coda-docs.vercel.app/docs/api/clients/quarry/errors) with messages + +- **[Token Metadata Documentation](https://coda-docs.vercel.app/docs/api/clients/token-metadata)** - Metaplex Token Metadata program documentation + +This documentation is generated automatically from the program IDLs with zero manual editing required. + +## Quick Start with Coda CLI + +The easiest way to use this package is through the [Coda CLI](https://coda.ianm.com), which includes built-in documentation generation: + +```bash +# Install Coda CLI +bun add -D @macalinao/coda + +# Generate both TypeScript client and markdown docs +coda generate --docs + +# Or just generate documentation +coda docs +``` + +Learn more about Coda and its zero-config approach at [coda.ianm.com](https://coda.ianm.com). + ## Installation +If you want to use this package directly: + ```bash npm install @macalinao/codama-renderers-markdown ``` @@ -27,16 +64,24 @@ visit(root, renderMarkdownVisitor("./docs")); ## Features -- Comprehensive documentation for all program components -- Generates documentation for: +- **Comprehensive Documentation**: Generates documentation for: - Accounts with fields and discriminators - Instructions with accounts and arguments - PDAs with seed definitions - Custom types and enums - - Program errors -- Table of contents with links -- TypeScript-style type definitions -- Formatted output with tables and code blocks + - Program errors with codes and messages +- **Structured Output**: + - Table of contents with navigation links + - Organized sections by component type + - Cross-references between related components +- **Developer-Friendly**: + - TypeScript-style type definitions + - Formatted tables for easy scanning + - Code blocks with syntax highlighting support +- **Platform Agnostic**: + - Pure markdown output works anywhere + - Compatible with all major documentation platforms + - No vendor lock-in ## Options @@ -50,6 +95,39 @@ renderMarkdownVisitor(outputDir, { }); ``` +## Integration Examples + +### With Documentation Platforms + +The generated markdown integrates seamlessly with popular documentation platforms: + +```bash +# Generate documentation +npx @macalinao/codama-renderers-markdown ./docs + +# Use with MkDocs +mkdocs build + +# Use with Docusaurus +npm run build + +# Use with VitePress +vitepress build docs +``` + +### CI/CD Integration + +Automatically update documentation on every deployment: + +```yaml +# GitHub Actions example +- name: Generate Program Documentation + run: | + npm run generate-docs + git add docs/ + git commit -m "Update program documentation" +``` + ## License MIT \ No newline at end of file diff --git a/packages/codama-renderers-markdown/package.json b/packages/codama-renderers-markdown/package.json index 97790420..0343335d 100644 --- a/packages/codama-renderers-markdown/package.json +++ b/packages/codama-renderers-markdown/package.json @@ -2,14 +2,20 @@ "name": "@macalinao/codama-renderers-markdown", "version": "0.1.1", "description": "Codama visitor for rendering markdown documentation from IDL", + "keywords": [ + "coda", + "codama", + "solana", + "markdown", + "documentation", + "ian-macalinao" + ], "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, - "main": "./dist/index.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", "type": "module", @@ -23,22 +29,22 @@ "clean": "rm -fr dist/", "lint": "eslint --ext js,ts,tsx src", "lint:fix": "eslint --ext js,ts,tsx src --fix", - "test": "bun test", - "test:watch": "bun test --watch" + "test": "bun test src/", + "test:watch": "bun test src/ --watch" }, "dependencies": { - "@codama/errors": "^1.0.2", - "@codama/nodes": "^1.0.2", - "@codama/renderers-core": "^1.0.2", - "@codama/visitors-core": "^1.0.2", - "codama": "^1.0.2", - "prettier": "^3.0.0" + "@codama/errors": "catalog:", + "@codama/nodes": "catalog:", + "@codama/renderers-core": "catalog:", + "@codama/visitors-core": "catalog:", + "codama": "catalog:", + "prettier": "^3.6.2" }, "devDependencies": { - "@macalinao/eslint-config": "^5.0.1", - "@macalinao/tsconfig": "^3.2.3", - "@types/bun": "^1.1.0", - "typescript": "^5.5.4" + "@macalinao/eslint-config": "catalog:", + "@macalinao/tsconfig": "catalog:", + "@types/bun": "catalog:", + "typescript": "catalog:" }, "repository": { "type": "git", diff --git a/packages/codama-renderers-markdown/src/render-markdown-visitor.ts b/packages/codama-renderers-markdown/src/render-markdown-visitor.ts index c9510c60..3fd6339e 100644 --- a/packages/codama-renderers-markdown/src/render-markdown-visitor.ts +++ b/packages/codama-renderers-markdown/src/render-markdown-visitor.ts @@ -1,3 +1,4 @@ +import type { RootNode } from "@codama/nodes"; import { getAllPrograms } from "@codama/nodes"; import { RenderMap } from "@codama/renderers-core"; import { @@ -21,7 +22,7 @@ export function renderMarkdownVisitor( visit(root, getRecordLinkablesVisitor(linkables)); const map = new RenderMap(); - const programs = getAllPrograms(root); + const programs = getAllPrograms(root as unknown as RootNode); // Generate markdown for each program for (const program of programs) { diff --git a/packages/codama-renderers-markdown/src/renderers/renderError.test.ts b/packages/codama-renderers-markdown/src/renderers/renderError.test.ts index 16cf4c83..05ad0282 100644 --- a/packages/codama-renderers-markdown/src/renderers/renderError.test.ts +++ b/packages/codama-renderers-markdown/src/renderers/renderError.test.ts @@ -15,7 +15,7 @@ describe("renderError", () => { const markdown = renderError(error); expect(markdown).toBe( - "- **insufficientFunds** (Code: 1001 / `1001` / `0x3e9`) -- Insufficient funds for operation", + "- **1001 - InsufficientFunds**: Insufficient funds for operation *(Hex: `0x3e9`)*", ); }); }); diff --git a/packages/codama-renderers-markdown/src/renderers/renderError.ts b/packages/codama-renderers-markdown/src/renderers/renderError.ts index 9e891caa..8e082f2e 100644 --- a/packages/codama-renderers-markdown/src/renderers/renderError.ts +++ b/packages/codama-renderers-markdown/src/renderers/renderError.ts @@ -1,13 +1,11 @@ import type { ErrorNode } from "@codama/nodes"; +import { pascalCase } from "@codama/nodes"; export function renderError(error: ErrorNode): string { // Convert error code to hex with 0x prefix const hexCode = `0x${error.code.toString(16).toLowerCase()}`; - const errorCode = String(error.code); - const paddedCode = errorCode.padStart(3, "0"); - // Format: - **Name** (Code: decimal / `xxx` / `0xHEX`) -- Message - const errorLine = `- **${error.name}** (Code: ${errorCode} / \`${paddedCode}\` / \`${hexCode}\`) -- ${error.message}`; + const errorLine = `- **${error.code.toString(10)} - ${pascalCase(error.name)}**: ${error.message} *(Hex: \`${hexCode}\`)*`; return errorLine; } diff --git a/packages/codama-renderers-markdown/src/renderers/renderProgram.test.ts b/packages/codama-renderers-markdown/src/renderers/renderProgram.test.ts index 66ba9a6e..63fbfe1d 100644 --- a/packages/codama-renderers-markdown/src/renderers/renderProgram.test.ts +++ b/packages/codama-renderers-markdown/src/renderers/renderProgram.test.ts @@ -76,7 +76,7 @@ describe("renderProgram", () => { expect(formatted).toContain("### initializeMint"); expect(formatted).toContain("## Errors"); expect(formatted).toContain( - "- **invalidMint** (Code: 0 / `000` / `0x0`) -- Invalid mint", + "- **0 - InvalidMint**: Invalid mint _(Hex: `0x0`)_", ); }); diff --git a/packages/codama-renderers-markdown/src/renderers/renderProgram.ts b/packages/codama-renderers-markdown/src/renderers/renderProgram.ts index d50b7cfd..25ed359a 100644 --- a/packages/codama-renderers-markdown/src/renderers/renderProgram.ts +++ b/packages/codama-renderers-markdown/src/renderers/renderProgram.ts @@ -86,7 +86,7 @@ export function renderProgram( lines.push("- [Instructions](#instructions)"); for (const instruction of instructions) { lines.push( - ` - [${instruction.name}](#${instruction.name.replace(/_/g, "-")}-1)`, + ` - [${instruction.name}](#${instruction.name.replace(/_/g, "-")})`, ); } } @@ -94,14 +94,14 @@ export function renderProgram( if (pdas.length > 0) { lines.push("- [PDAs](#pdas)"); for (const pda of pdas) { - lines.push(` - [${pda.name}](#${pda.name.replace(/_/g, "-")}-2)`); + lines.push(` - [${pda.name}](#${pda.name.replace(/_/g, "-")})`); } } if (types.length > 0) { lines.push("- [Types](#types)"); for (const type of types) { - lines.push(` - [${type.name}](#${type.name.replace(/_/g, "-")}-3)`); + lines.push(` - [${type.name}](#${type.name.replace(/_/g, "-")})`); } }