Integration Guide
Developer guide for integrating with the Elara protocol on-chain and off-chain.
Prerequisites
All mint and redeem operations require:
KYC approval — both
msg.senderandrecipientmust be approved inKYCRegistryToken support — the collateral token must be registered in
TokenRegistrywith the target operation (mint/redeem) enabledERC20 approval — caller must approve
Vaultto 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
Redeeming elUSD
Staking elUSD
Monitoring Events
Key events to index for a complete protocol view:
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
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?