logo

Learn About Hastra

Hastra ETH Programmatic Integration Guide

This guide explains the programmatic lifecycle utilizing Hastra on ETH. For partners, this process converts liquid capital USDC into wYLDS, which can then be used to participate in PRIME

1. The Asset Lifecycle: USDC → wYLDS

When a team "mints" on Hastra, they are locking USDC to receive wYLDS (Wrapped YLDS).
  • wYLDS is the primary yield-bearing vault token on Ethereum.
  • It acts as a 1:1 receipt (initially) for the USDC held in the vault.
  • Context: Unlike a simple swap, this "Deposit" moves funds into a vault.

Programmatic Mint (USDC to wYLDS)

TypeScript
// 1. Grant the Vault permission to pull your USDC
await usdc.approve(vaultAddress, amount);
// 2. Deposit USDC to receive wYLDS
// The 'receiver' address will hold the wYLDS tokens
await vault.deposit(amount, receiverAddress);

2. The Rewards Lifecycle: wYLDS → PRIME

PRIME represents your position in the equivalent Democratized Prime pool.
  • Context: Your "Yield" (the growth of your investment) is tracked via Merkle Proofs.
  • Mechanism: Periodically, an "Epoch" is created. You provide a proof to the contract to "claim" your growth.
  • Result: Claiming rewards results in redeeming PRIME and receiving back more wYLDS depending on the interest earned.

Claiming Rewards/PRIME Incentives

TypeScript
// This is how you 'unlock' the yield generated by the vault assets
await vault.claimRewards(epochIndex, rewardAmount, epochTimestamp, merkleProof);

3. The Redemption Lifecycle: wYLDS → USDC

Returning to USDC is a two-step "Request/Fulfill" process.

Phase 1: The "Unbonding" Request (RequestRedeem)

  • What happens: You commit to burning your wYLDS shares.
  • Status: Your shares are moved into a "Pending" state. They no longer earn yield, but they are not yet USDC.
  • Context: This is the "Unbonding Period." It allows processes to complete to fulfill sending the appropriate amount of USDC.
TypeScript
// Triggers the transition from wYLDS back toward USDC
await vault.requestRedeem(wYLDS_Amount);

Phase 2: The "Pending" Check

Teams must monitor their pending status. A redemption remains in pending until the Redeem Vault is liquid.
TypeScript
const status = await vault.pendingRedemptions(userAddress);
// If status.shares > 0, the request is active but not yet finalized.

Phase 3: Finalization (CompleteRedeem)

  • What happens: Backend processes trigger the final transfer.
  • Result: wYLDS is burned, and USDC is sent to the user's wallet.
  • Context: If a team is integrating "programmatically," they should listen for the RedemptionCompleted event to notify their internal accounting that the USDC has arrived.

4. Troubleshooting for "programmatically" Teams

Without a GUI, teams need to know exactly why a transaction failed.
Scenario
Programmatic Check
Logic/Context
Mint Fails
vault.isWhitelisted(addr)
Most institutional vaults require your address to be added to the allowlist first.
Redeem Fails
vault.paused()
If a de-peg or exploit is detected, redemptions are paused.
Redeem Stays Pending
usdc.balanceOf(redeemVault)
The vault may be waiting for funds to enter the payout pool.
Claim Fails
vault.isClaimed(epoch, addr)
You cannot claim the same rewards twice for the same epoch.

Key Events to Monitor

For a full-cycle automated system, your backend should index:
  1. Deposit: Confirmation that USDC is now wYLDS.
  1. RedemptionRequested: Confirmation that the exit clock has started.
  1. RedemptionCompleted: Confirmation that USDC is back in the wallet.
  1. RewardsEpochCreated: Signal that a new claim is available.
Powered by Notaku