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

Integration Guide

Developer guide for integrating with the Elara protocol on-chain and off-chain.

Prerequisites

All mint and redeem operations require:

  1. KYC approval — both msg.sender and recipient must be approved in KYCRegistry

  2. Token support — the collateral token must be registered in TokenRegistry with the target operation (mint/redeem) enabled

  3. ERC20 approval — caller must approve Vault to spend the input token before calling

Reading Protocol State

IVault vault = IVault(VAULT_ADDRESS);
ITokenRegistry registry = ITokenRegistry(TOKEN_REGISTRY_ADDRESS);
IKYCRegistry kyc = IKYCRegistry(KYC_REGISTRY_ADDRESS);
IElUSDStake staking = IElUSDStake(STAKING_ADDRESS);

// Check KYC
bool approved = kyc.isKycApproved(userAddress);

// Get token config
ITokenRegistry.TokenConfig memory config = registry.getTokenConfig(USDC);

// Preview mint before executing
(uint256 netAmount, uint256 fee, uint256 elUSDOut) = vault.previewMint(USDC, 1000e6);

// Preview redeem
(uint256 tokenOut, uint256 redeemFee, bool willQueue) = vault.previewRedeem(USDC, 1000e18);

// Check staking state
uint256 price    = staking.sharePrice();    // elUSD per sElUSD (1e18 scale)
uint256 totalBal = staking.totalElUSD();
const vault = new ethers.Contract(VAULT_ADDRESS, IVault_ABI, provider);
const kyc   = new ethers.Contract(KYC_ADDRESS, IKYCRegistry_ABI, provider);

const isApproved = await kyc.isKycApproved(userAddress);

const [netAmount, fee, elUSDOut] = await vault.previewMint(USDC_ADDRESS, parseUnits("1000", 6));
const [tokenOut, redeemFee, willQueue] = await vault.previewRedeem(USDC_ADDRESS, parseEther("1000"));

Minting elUSD

1

Approve Vault to spend collateral

2
3

Execute mint

Emits: Minted(minter, recipient, token, tokenAmountIn, elUSDAmountOut, fee)

recipient may differ from msg.sender — both must pass KYC. This enables custodians to mint on behalf of clients.

Redeeming elUSD

1

Approve Vault to spend elUSD

2

Preview the redemption

If willBeQueued == true, the redemption will not settle immediately. Plan accordingly.

3

Execute redeem

Always emits: RedeemQueued(redemptionId, ...) Also emits (instant only): RedeemSettled(redemptionId, ...)

4

Settle a queued redemption (if needed)

Open to anyone (PUBLIC_ROLE). Reverts with InsufficientLiquidity if withdrawWallet still lacks funds.

Staking elUSD

Monitoring Events

Key events to index for a complete protocol view:

Event
Contract
When

Minted

Vault

elUSD issued

RedeemQueued

Vault

Redemption initiated (always)

RedeemSettled

Vault

Redemption completed

YieldMintedToStaking

Vault

Yield distributed

Staked

ElUSDStake

User staked elUSD

Unstaked

ElUSDStake

User unstaked

YieldReceived

ElUSDStake

Share price update

KycGranted / KycRevoked

KYCRegistry

Compliance events

AccountBlockStatusChanged

ElUSD

Account blocked/unblocked

Checking Queued Redemptions

Common Revert Reasons

Revert
Cause

KycRequired(addr)

addr not approved in KYCRegistry

MintDisabled(token)

Token's isMintEnabled is false

RedeemDisabled(token)

Token's isRedeemEnabled is false

AmountBelowMinimum

Passed zero amount

InsufficientLiquidity

Trying to settle but withdrawWallet lacks funds

InvalidRedemption(id)

Redemption ID doesn't exist or already settled

See Error Reference for the complete list.

Last updated

Was this helpful?