SDK

The Onyx SDK is a TypeScript library for interacting with the Enzyme Onyx protocol - an Ethereum-based platform for decentralized on-chain asset management. This SDK provides tools for building depositor-facing interfaces and vault administration applications.

Installation

Install the Onyx SDK and its peer dependencies using your preferred package manager:

pnpm add @enzymefinance/onyx-sdk
pnpm add @enzymefinance/onyx-environment @enzymefinance/onyx-abis viem

Note: @enzymefinance/onyx-environment, @enzymefinance/onyx-abis, and viem are peer dependencies that must be installed alongside the main SDK package.

Prerequisites

  • Node.js 18 or later

  • TypeScript 5.0 or later

  • Basic understanding of Ethereum and smart contracts

  • Familiarity with Viemarrow-up-right (the underlying Ethereum client library)

Supported Networks

The Onyx SDK supports the following networks:

  • Ethereum Mainnet (Chain ID: 1)

  • Arbitrum (Chain ID: 42161)

  • Base (Chain ID: 8453)

  • Plume (Chain ID: 98866)

For deployed contract addresses on each network, see Contract Addressesarrow-up-right.

Quick Start

Set up a Viem client to interact with the blockchain:

Depositor Actions

These are the primary actions for building depositor-facing interfaces (subscriptions and redemptions).

Note: The addresses required below (deposit queue, redeem queue, shares contract) can be retrieved from the Onyx APIarrow-up-right or your vault's configuration. Similarly, after submitting a deposit or redemption request, you can retrieve your request ID either by parsing the transaction receipt events (shown below) or by querying the API for your pending requests.

Controller vs Owner: In deposit/redeem requests, controller is the address authorized to cancel the request, while owner is the address that will receive the shares (for deposits) or redeemed assets (for redemptions). These can be the same address.

Approve Tokens

Before depositing, approve the deposit queue to spend your tokens:

Request Deposit

Submit a deposit request to the queue:

Cancel Deposit

Cancel a pending deposit request.

Note: A pending deposit request can only be cancelled after the queue's minimum request duration has elapsed. The contract stores a canCancelTime for each request; calling cancelDeposit before that time reverts with MinRequestDurationNotElapsed. Check whether a request is cancellable by fetching it with getDepositRequest and comparing canCancelTime to the current block timestamp.

Check Deposit Status

Query the status of a deposit request:

Request Redemption

Submit a redemption request:

Cancel Redemption

Cancel a pending redemption request.

Note: A pending redemption request can only be cancelled after the queue's minimum request duration has elapsed. The contract stores a canCancelTime for each request; calling cancelRedeem before that time reverts with MinRequestDurationNotElapsed. Check whether a request is cancellable by fetching it with getRedeemRequest and comparing canCancelTime to the current block timestamp.

Check Redemption Status

Query the status of a redemption request:

Read Share Balance and Price

Query fund share information:

Admin Actions

These actions are for vault admins to configure and administer funds.

Get Network Environment

Use the environment package to get deployment addresses and configurations:

Execute Deposit Requests

Process pending deposit requests:

Execute Redemption Requests

Process pending redemption requests:

Configure Fees

Set up fund fees:

Manage Deposit Allowlist

Control who can deposit:

Update Valuations

Update asset prices and share value:

TypeScript Support

The SDK is built with TypeScript and provides full type safety:

Common Patterns

Transaction Simulation

Before sending transactions, simulate them to catch errors:

Batch Operations

Use Promise.all for multiple read operations:


This SDK is under active development. APIs may change between versions. Always check the changelog before upgrading.

Last updated

Was this helpful?