Testing & Debugging

This guide explains how to test and debug Tydro integrations effectively.

Testing

There are two main ways to test with Tydro:

  1. Using a testnet

  2. Creating fork networks

Testnet

Tydro is available on the Sepolia testnet. You can connect to the Sepolia market through the Tydro app by enabling testnet mode in the top-right corner.

To get started:

  1. Open the Sepolia test market in the Tydro app.

  2. Use the Faucet tab to claim test tokens available in the market.

  3. Supply those tokens into the protocol.

  4. Try operations such as borrowing, repaying, and withdrawing to confirm functionality.

Fork Networks

A fork network replicates the state of a live chain, letting you test in a controlled sandbox that mirrors mainnet conditions. This is useful for scenarios that depend on deployed contracts or existing liquidity.

Popular tools for forking include:

  • Tenderly: transaction simulations, debugging, and dashboards

  • Foundry: modular toolkit for smart contract development

  • Hardhat: local Ethereum development environment

On a fork, you can fund your account by impersonating an address that holds tokens (findable via block explorers) and transferring assets.

Connecting a Fork to the UI

The Tydro app can also connect directly to a forked network. This requires setting specific variables through the browser console. See the integration guide for full instructions.

Debugging

When working with Tydro contracts, you may hit errors or failed transactions. This section covers error codes, debugging tools, and common issues.

Error Codes

Tydro uses dedicated error codes to explain why a transaction reverted. Each protocol version defines them in its own Errors.sol file.

  • Tydro V3 Error Codes: Errors.sol

  • Tydro V2 Error Codes: Errors.sol

Understanding these codes is essential for resolving failures.

Debugging Tools

  • Tenderly: Simulate transactions by providing to, from, data, and value. Step through execution, see error codes, and review stack traces.

  • Hardhat: Run a local chain, fork mainnet, log from Solidity, and inspect detailed stack traces.

  • Foundry: Portable toolkit with forge for testing/debugging contracts and simulating transactions.

Understanding “Gas Estimation Failed”

This error means the transaction would revert if executed. To debug:

  1. Collect the transaction’s to, from, data, and value.

  2. Simulate the call using Tenderly, Hardhat, or Foundry.

  3. Identify the specific error code or exception.

  4. Trace the call stack to pinpoint the issue.

Common Errors

Pool Interactions

  • Token Approval: Before supplying or repaying, you must approve the Tydro Pool to transfer your ERC-20 tokens. Call approve() on the token contract with the Pool as spender.

  • Insufficient Collateral: Borrowing requires enough collateral at or above the required Loan-to-Value (LTV). Supply additional assets or check your ratios.

  • Borrow Cap Reached: If an asset’s borrow cap is maxed out, no new borrows are possible until positions are repaid or more liquidity is supplied.

Loan To Value = 0% (LTV0)

If a reserve’s LTV is set to 0%, the asset behaves differently:

  • It does not contribute to borrowing power.

  • It cannot be enabled as collateral.

  • If received via transfer, it won’t auto-enable as collateral.

  • To withdraw other assets, you must first disable LTV0 assets as collateral (via Pool.setUserUseReserveAsCollateral) or fully withdraw them.

WrappedTokenGateway

When dealing with ETH in Tydro, the WrappedTokenGateway handles wrapping/unwrapping ETH into WETH. Common issues include:

  • Not sending ETH along with a deposit transaction

  • Calling the wrong function for wrapping/unwrapping

Check the WrappedTokenGateway docs for full usage and potential revert cases.

Last updated