For the complete documentation index, see llms.txt. This page is also available as Markdown.

Smart Contract Integration

Overview

Learn how to integrate with the Sierra's vaults directly through their respective smart contract.

Sierra's vaults, like SIERRA and SPLUS, are deployed on Ethereum mainnet. Lenders deposit USDC and receive vault tokens, then redeem them for USDC by requesting a withdrawal and claiming it once processed. The vault is permissionless, any wallet can interact with the smart contract to make deposits and withdrawals.

On-chain integrations are read and write. For vault-level reporting data such as APY, TVL and reserve allocations, see the API Integration page.

Terminology

Sierra Vault tokens implement many of the ERC-4626 and ERC-20 standards. In some cases, the terminology used in the product differs from the code. The main differences are:

Term in Code
Display Name

Pool

Vault

Shares

Vault Tokens (i.e. SPLUS or SIERRA)

Assets

USDC

Redeem / Redemption

Withdrawal

uuid

Withdrawal Request ID

Decimals / Formatting

The contract returns numerical values that should be converted using the following conventions to calculate the display value. All amounts you pass to the contract use the same base units.

Type
Decimals
Example in Code
Example in Display

assets

6

1000000

1 USDC

shares

6

1000000

1 Vault Token

Exchange Rate

18

1000261149376738066

1.000261

Getting Started

Sierra Vaults are built on permissionless smart contracts that anyone can read from or build against. Start by viewing the verified contract on Etherscan, which lists every function and the source code.

Item
Value

Network

Ethereum Mainnet

Vault Address

SIERRA: 0xBcEb5f6877d979EC621AE694dA1102CB95691aD3

SPLUS: 0x7706b1a531A7A8cB4c26D24CDc9ae4094a3e0302

Vault Token

SIERRA or SPLUS (ERC-20)

Liquidity Asset

USDC. Call asset() for its contract address

Note: Sierra Vault Tokens implements the OpenZeppelin ERC-1967 Upgradeable Beacon Proxy pattern. Always send calls to the vault address above, and use Read as Proxy and Write as Proxy on Etherscan for the current function list.

Using Etherscan:

  1. Open the vault on Etherscan and select Contract.

  2. Read as Proxy: expand a function, enter inputs and select Query. No wallet is needed. Values reflect the latest block.

  3. Write as Proxy: select Connect to Web3, connect your wallet, enter inputs in base units, select Write and confirm. You pay gas in ETH.

  4. Transactions shows each call by method (Deposit, Request Redeem, Claim). Events shows decoded events, including the uuid of each withdrawal request.

Important Functions:

As a Lender, there are only a handful of functions you will ever need to call: deposit to make an investment, requestRedeem to request a withdrawal, claim to collect it, and the read functions under Query Data to check balances. The contract also has administrative functions, such as setting the exchange rate and processing withdrawals. These are restricted to the Sierra Protocol team, and a call to them from a Lender wallet reverts.

Make Investments

Note: SPLUS is permissionless, so no whitelisting is required. You need USDC in your wallet and enough ETH to pay for gas. Restricted Addresses cannot interact with the vault.

To make an investment, you must first call the following function on the USDC contract to create a spending allowance for the vault.

...where spender is the Vault address and amount is the number of assets you'd like to deposit (6 decimals).

Once the allowance is approved, call the following function on the vault...

...where assets is the number of assets you'd like to deposit (6 decimals) and lender is your wallet address, which must be the wallet sending the transaction. It will return the number of vault tokens minted (6 decimals), at the current exchange rate. To estimate this first, call convertToShares(assets). The vault emits an event PoolDeposit.

Request Withdrawals

Withdrawals are a two-step process: you request a withdrawal, then claim the USDC once Sierra has processed it. To make a withdrawal request, you must call the following function.

...where shares is the number of vault tokens you wish to redeem (6 decimals). It will return the net withdrawal request amount in assets (6 decimals), after the redemption fees. The gross amount is emitted as assets in RedeemRequested, and the fee as fee in RedeemRequestClaimMode (also readable via withdrawExtra(uuid).fee).

Note: each request has an ID, uuid, emitted in the RedeemRequested(lender, assets, shares, uuid) event. Save it: you need it to claim.

The USDC amount is set at the exchange rate when you make the request, and any withdrawal fee (see withdrawExtra(uuid).fee) is deducted when you claim. Requested vault tokens stay in your balance but are reserved and cannot be transferred.

Claim Withdrawals

To check whether a request is ready to claim, call...

Once it returns true, call the following function from the wallet that made the request...

...where uuid is the withdrawal request ID. The vault sends the USDC, less any withdrawal fee, to your wallet, burns the redeemed vault tokens and emits RedeemClaimed.

Withdrawal Lifecycle

A withdrawal moves from requested to claimable to claimed. You act at the first and last steps.

Watch for ClaimsOpened, or poll isClaimable(uuid), to know when to claim.

Query Data

All position and vault data can be read from the contract. Anyone can call these functions; no wallet or API token is needed. Values reflect the latest block; for a past block, query an archive node at that block number.

Get Balances

Functions
Returns
Units

balanceOf(address account)

Vault tokens held, including any reserved for open requests

6 Decimals

assetBalanceOf(address lender)

Those vault tokens valued in assets at the current exchange rate

6 Decimals

exchangeRate()

Assets per vault token at the current block

18 Decimals

convertToAssets(uint256 shares) / convertToShares(uint256 assets)

Convert between vault tokens and assets at the current exchange rate

6 Decimals

Get Account Overview

To get a full summary for a wallet, you can call the following function...

and it will return the following data:

To track a wallet's open withdrawal requests, filter RedeemRequested events by lender, then call isClaimable(uuid) for each.

Get Vault Overview State

To get the current state of the vault, you can call the following function...

and it will return the following data:

Common Errors

Error
Likely Cause

USDC transfer revert

USDC allowance or balance is lower than the deposit

PoolInvalidState

lender is not the sending wallet, or the vault is not accepting deposits or requests

PoolPaused

The vault is paused

ZeroAmount/InvalidAccess

The amount is zero or too small to convert

DailyMintLimitExceeded

The vault's daily deposit limit has been reached; try again the next day

RedeemExceedsBalance

The request is larger than your unreserved vault tokens

RedeemBelowMinimum

The request is below the minimum withdrawal amount

TooManyOpenRequests / InvalidRedemptions

The vault, or your wallet, has reached its limit of open requests, respectively.

NotClaimable

The request has not been processed yet

NotClaimant

The claim was not sent from the wallet that made the request

RedemptionNotFound

The uuid is wrong, or the request was already claimed or cancelled

BlacklistedAddress

The wallet is restricted from using the vault

Events

Event
Emitted When
Key Field

PoolDeposit

A deposit is made

lender, assets, shares

RedeemRequested

A withdrawal request is created

lender, assets, shares, uuid

ClaimsOpened

Requests made before a cut-off block become claimable

uuid, cutoffBlock, assetsOpened

RedeemClaimed

A request is claimed

lender, shares, assets, fee, uuid, fundsDestination

RedeemCancelled

A request is cancelled

lender, shares, assets, uuid

ExchangeRateSet

The exchange rate is updated

_exchangeRate, interestRate

Transfer

Vault tokens are minted, burned or transferred

from, to, value

Last updated