HYPE Price: $25.10 (+0.85%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

> 10 Internal Transactions found.

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
251226292026-01-21 3:03:525 days ago1768964632
0x0590aAB2...b509213a9
0 HYPE
251226292026-01-21 3:03:525 days ago1768964632
0x0590aAB2...b509213a9
0 HYPE
251226292026-01-21 3:03:525 days ago1768964632
0x0590aAB2...b509213a9
0 HYPE
251226292026-01-21 3:03:525 days ago1768964632
0x0590aAB2...b509213a9
0 HYPE
251085932026-01-20 23:13:466 days ago1768950826
0x0590aAB2...b509213a9
0 HYPE
251085932026-01-20 23:13:466 days ago1768950826
0x0590aAB2...b509213a9
0 HYPE
251085932026-01-20 23:13:466 days ago1768950826
0x0590aAB2...b509213a9
0 HYPE
251085932026-01-20 23:13:466 days ago1768950826
0x0590aAB2...b509213a9
0 HYPE
249370482026-01-19 0:21:338 days ago1768782093
0x0590aAB2...b509213a9
0 HYPE
249370482026-01-19 0:21:338 days ago1768782093
0x0590aAB2...b509213a9
0 HYPE
249370482026-01-19 0:21:338 days ago1768782093
0x0590aAB2...b509213a9
0 HYPE
249370482026-01-19 0:21:338 days ago1768782093
0x0590aAB2...b509213a9
0 HYPE
249203622026-01-18 19:48:008 days ago1768765680
0x0590aAB2...b509213a9
0 HYPE
249203622026-01-18 19:48:008 days ago1768765680
0x0590aAB2...b509213a9
0 HYPE
249203622026-01-18 19:48:008 days ago1768765680
0x0590aAB2...b509213a9
0 HYPE
249203622026-01-18 19:48:008 days ago1768765680
0x0590aAB2...b509213a9
0 HYPE
249203012026-01-18 19:47:008 days ago1768765620
0x0590aAB2...b509213a9
0 HYPE
249203012026-01-18 19:47:008 days ago1768765620
0x0590aAB2...b509213a9
0 HYPE
249203012026-01-18 19:47:008 days ago1768765620
0x0590aAB2...b509213a9
0 HYPE
249203012026-01-18 19:47:008 days ago1768765620
0x0590aAB2...b509213a9
0 HYPE
249202402026-01-18 19:46:008 days ago1768765560
0x0590aAB2...b509213a9
0 HYPE
249202402026-01-18 19:46:008 days ago1768765560
0x0590aAB2...b509213a9
0 HYPE
249202402026-01-18 19:46:008 days ago1768765560
0x0590aAB2...b509213a9
0 HYPE
249202402026-01-18 19:46:008 days ago1768765560
0x0590aAB2...b509213a9
0 HYPE
249201792026-01-18 19:45:008 days ago1768765500
0x0590aAB2...b509213a9
0 HYPE
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DefaultReserveInterestRateStrategy

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 1000 runs

Other Settings:
shanghai EvmVersion, GNU AGPLv3 license
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

import {MathOperations} from "../libraries/math/MathOperations.sol";
import {IReserveInterestRateStrategy} from "../../interfaces/IReserveInterestRateStrategy.sol";
import {WadRayMath} from "../libraries/math/WadRayMath.sol";
import {PercentageMath} from "../libraries/math/PercentageMath.sol";
import {ILendingPoolAddressesProvider} from "../../interfaces/ILendingPoolAddressesProvider.sol";
import {ILendingRateOracle} from "../../interfaces/ILendingRateOracle.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title DefaultReserveInterestRateStrategy contract
 * @notice Implements the calculation of the interest rates depending on the reserve state
 * @dev The model of interest rate is based on 2 slopes, one before the `OPTIMAL_UTILIZATION_RATE`
 * point of utilization and another from that one to 100%
 * - An instance of this same contract, can't be used across different Aave markets, due to the caching
 *   of the LendingPoolAddressesProvider
 * @author Aave
 **/
contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
	using WadRayMath for uint256;
	using MathOperations for uint256;
	using PercentageMath for uint256;

	/**
	 * @dev this constant represents the utilization rate at which the pool aims to obtain most competitive borrow rates.
	 * Expressed in ray
	 **/
	uint256 public immutable OPTIMAL_UTILIZATION_RATE;

	/**
	 * @dev This constant represents the excess utilization rate above the optimal. It's always equal to
	 * 1-optimal utilization rate. Added as a constant here for gas optimizations.
	 * Expressed in ray
	 **/

	uint256 public immutable EXCESS_UTILIZATION_RATE;

	ILendingPoolAddressesProvider public immutable addressesProvider;

	// Base variable borrow rate when Utilization rate = 0. Expressed in ray
	uint256 internal immutable _baseVariableBorrowRate;

	// Slope of the variable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray
	uint256 internal immutable _variableRateSlope1;

	// Slope of the variable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray
	uint256 internal immutable _variableRateSlope2;

	// Slope of the stable interest curve when utilization rate > 0 and <= OPTIMAL_UTILIZATION_RATE. Expressed in ray
	uint256 internal immutable _stableRateSlope1;

	// Slope of the stable interest curve when utilization rate > OPTIMAL_UTILIZATION_RATE. Expressed in ray
	uint256 internal immutable _stableRateSlope2;

	constructor(
		ILendingPoolAddressesProvider provider,
		uint256 optimalUtilizationRate_,
		uint256 baseVariableBorrowRate_,
		uint256 variableRateSlope1_,
		uint256 variableRateSlope2_,
		uint256 stableRateSlope1_,
		uint256 stableRateSlope2_
	) {
		OPTIMAL_UTILIZATION_RATE = optimalUtilizationRate_;
		EXCESS_UTILIZATION_RATE = WadRayMath.ray().sub(optimalUtilizationRate_);
		addressesProvider = provider;
		_baseVariableBorrowRate = baseVariableBorrowRate_;
		_variableRateSlope1 = variableRateSlope1_;
		_variableRateSlope2 = variableRateSlope2_;
		_stableRateSlope1 = stableRateSlope1_;
		_stableRateSlope2 = stableRateSlope2_;
	}

	function variableRateSlope1() external view returns (uint256) {
		return _variableRateSlope1;
	}

	function variableRateSlope2() external view returns (uint256) {
		return _variableRateSlope2;
	}

	function stableRateSlope1() external view returns (uint256) {
		return _stableRateSlope1;
	}

	function stableRateSlope2() external view returns (uint256) {
		return _stableRateSlope2;
	}

	function baseVariableBorrowRate() external view returns (uint256) {
		return _baseVariableBorrowRate;
	}

	function getMaxVariableBorrowRate() external view returns (uint256) {
		return _baseVariableBorrowRate.add(_variableRateSlope1).add(_variableRateSlope2);
	}

	/**
	 * @dev Calculates the interest rates depending on the reserve's state and configurations
	 * @param reserve The address of the reserve
	 * @param liquidityAdded The liquidity added during the operation
	 * @param liquidityTaken The liquidity taken during the operation
	 * @param totalStableDebt The total borrowed from the reserve a stable rate
	 * @param totalVariableDebt The total borrowed from the reserve at a variable rate
	 * @param averageStableBorrowRate The weighted average of all the stable rate loans
	 * @param reserveFactor The reserve portion of the interest that goes to the treasury of the market
	 * @return The liquidity rate, the stable borrow rate and the variable borrow rate
	 **/
	function calculateInterestRates(
		address reserve,
		address aToken,
		uint256 liquidityAdded,
		uint256 liquidityTaken,
		uint256 totalStableDebt,
		uint256 totalVariableDebt,
		uint256 averageStableBorrowRate,
		uint256 reserveFactor
	) external view returns (uint256, uint256, uint256) {
		uint256 availableLiquidity = IERC20(reserve).balanceOf(aToken);
		//avoid stack too deep
		availableLiquidity = availableLiquidity.add(liquidityAdded).sub(liquidityTaken);

		return
			calculateInterestRates(
				reserve,
				availableLiquidity,
				totalStableDebt,
				totalVariableDebt,
				averageStableBorrowRate,
				reserveFactor
			);
	}

	struct CalcInterestRatesLocalVars {
		uint256 totalDebt;
		uint256 currentVariableBorrowRate;
		uint256 currentStableBorrowRate;
		uint256 currentLiquidityRate;
		uint256 utilizationRate;
	}

	/**
	 * @dev Calculates the interest rates depending on the reserve's state and configurations.
	 * NOTE This function is kept for compatibility with the previous DefaultInterestRateStrategy interface.
	 * New protocol implementation uses the new calculateInterestRates() interface
	 * @param reserve The address of the reserve
	 * @param availableLiquidity The liquidity available in the corresponding aToken
	 * @param totalStableDebt The total borrowed from the reserve a stable rate
	 * @param totalVariableDebt The total borrowed from the reserve at a variable rate
	 * @param averageStableBorrowRate The weighted average of all the stable rate loans
	 * @param reserveFactor The reserve portion of the interest that goes to the treasury of the market
	 * @return The liquidity rate, the stable borrow rate and the variable borrow rate
	 **/
	function calculateInterestRates(
		address reserve,
		uint256 availableLiquidity,
		uint256 totalStableDebt,
		uint256 totalVariableDebt,
		uint256 averageStableBorrowRate,
		uint256 reserveFactor
	) public view returns (uint256, uint256, uint256) {
		CalcInterestRatesLocalVars memory vars;

		vars.totalDebt = totalStableDebt.add(totalVariableDebt);
		vars.currentVariableBorrowRate = 0;
		vars.currentStableBorrowRate = 0;
		vars.currentLiquidityRate = 0;

		vars.utilizationRate = vars.totalDebt == 0 ? 0 : vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));

		vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle()).getMarketBorrowRate(
			reserve
		);

		if (vars.utilizationRate > OPTIMAL_UTILIZATION_RATE) {
			uint256 excessUtilizationRateRatio = vars.utilizationRate.sub(OPTIMAL_UTILIZATION_RATE).rayDiv(
				EXCESS_UTILIZATION_RATE
			);

			vars.currentStableBorrowRate = vars.currentStableBorrowRate.add(_stableRateSlope1).add(
				_stableRateSlope2.rayMul(excessUtilizationRateRatio)
			);

			vars.currentVariableBorrowRate = _baseVariableBorrowRate.add(_variableRateSlope1).add(
				_variableRateSlope2.rayMul(excessUtilizationRateRatio)
			);
		} else {
			vars.currentStableBorrowRate = vars.currentStableBorrowRate.add(
				_stableRateSlope1.rayMul(vars.utilizationRate.rayDiv(OPTIMAL_UTILIZATION_RATE))
			);
			vars.currentVariableBorrowRate = _baseVariableBorrowRate.add(
				vars.utilizationRate.rayMul(_variableRateSlope1).rayDiv(OPTIMAL_UTILIZATION_RATE)
			);
		}

		vars.currentLiquidityRate = _getOverallBorrowRate(
			totalStableDebt,
			totalVariableDebt,
			vars.currentVariableBorrowRate,
			averageStableBorrowRate
		).rayMul(vars.utilizationRate).percentMul(PercentageMath.PERCENTAGE_FACTOR.sub(reserveFactor));

		return (vars.currentLiquidityRate, vars.currentStableBorrowRate, vars.currentVariableBorrowRate);
	}

	/**
	 * @dev Calculates the overall borrow rate as the weighted average between the total variable debt and total stable debt
	 * @param totalStableDebt The total borrowed from the reserve a stable rate
	 * @param totalVariableDebt The total borrowed from the reserve at a variable rate
	 * @param currentVariableBorrowRate The current variable borrow rate of the reserve
	 * @param currentAverageStableBorrowRate The current weighted average of all the stable rate loans
	 * @return The weighted averaged borrow rate
	 **/
	function _getOverallBorrowRate(
		uint256 totalStableDebt,
		uint256 totalVariableDebt,
		uint256 currentVariableBorrowRate,
		uint256 currentAverageStableBorrowRate
	) internal pure returns (uint256) {
		uint256 totalDebt = totalStableDebt.add(totalVariableDebt);

		if (totalDebt == 0) return 0;

		uint256 weightedVariableRate = totalVariableDebt.wadToRay().rayMul(currentVariableBorrowRate);

		uint256 weightedStableRate = totalStableDebt.wadToRay().rayMul(currentAverageStableBorrowRate);

		uint256 overallBorrowRate = weightedVariableRate.add(weightedStableRate).rayDiv(totalDebt.wadToRay());

		return overallBorrowRate;
	}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

/**
 * @title LendingPoolAddressesProvider contract
 * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles
 * - Acting also as factory of proxies and admin of those, so with right to change its implementations
 * - Owned by the Aave Governance
 * @author Aave
 **/
interface ILendingPoolAddressesProvider {
	event MarketIdSet(string newMarketId);
	event LendingPoolUpdated(address indexed newAddress);
	event ConfigurationAdminUpdated(address indexed newAddress);
	event EmergencyAdminUpdated(address indexed newAddress);
	event LendingPoolConfiguratorUpdated(address indexed newAddress);
	event LendingPoolCollateralManagerUpdated(address indexed newAddress);
	event PriceOracleUpdated(address indexed newAddress);
	event LendingRateOracleUpdated(address indexed newAddress);
	event ProxyCreated(bytes32 id, address indexed newAddress);
	event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);

	function getMarketId() external view returns (string memory);

	function setMarketId(string calldata marketId) external;

	function setAddress(bytes32 id, address newAddress) external;

	function setAddressAsProxy(bytes32 id, address impl) external;

	function getAddress(bytes32 id) external view returns (address);

	function getLendingPool() external view returns (address);

	function setLendingPoolImpl(address pool) external;

	function getLendingPoolConfigurator() external view returns (address);

	function setLendingPoolConfiguratorImpl(address configurator) external;

	function getLendingPoolCollateralManager() external view returns (address);

	function setLendingPoolCollateralManager(address manager) external;

	function getPoolAdmin() external view returns (address);

	function setPoolAdmin(address admin) external;

	function getEmergencyAdmin() external view returns (address);

	function setEmergencyAdmin(address admin) external;

	function getPriceOracle() external view returns (address);

	function setPriceOracle(address priceOracle) external;

	function getLendingRateOracle() external view returns (address);

	function setLendingRateOracle(address lendingRateOracle) external;

	function getLiquidationFeeTo() external view returns (address);

	function setLiquidationFeeTo(address liquidationFeeTo) external;
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

/**
 * @title ILendingRateOracle interface
 * @notice Interface for the Aave borrow rate oracle. Provides the average market borrow rate to be used as a base for the stable borrow rate calculations
 **/

interface ILendingRateOracle {
	/**
    @dev returns the market borrow rate in ray
    **/
	function getMarketBorrowRate(address asset) external view returns (uint256);

	/**
    @dev sets the market borrow rate. Rate value must be in ray
    **/
	function setMarketBorrowRate(address asset, uint256 rate) external;
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

/**
 * @title IReserveInterestRateStrategyInterface interface
 * @dev Interface for the calculation of the interest rates
 * @author Aave
 */
interface IReserveInterestRateStrategy {
	function baseVariableBorrowRate() external view returns (uint256);

	function getMaxVariableBorrowRate() external view returns (uint256);

	function calculateInterestRates(
		address reserve,
		uint256 availableLiquidity,
		uint256 totalStableDebt,
		uint256 totalVariableDebt,
		uint256 averageStableBorrowRate,
		uint256 reserveFactor
	) external view returns (uint256, uint256, uint256);

	function calculateInterestRates(
		address reserve,
		address aToken,
		uint256 liquidityAdded,
		uint256 liquidityTaken,
		uint256 totalStableDebt,
		uint256 totalVariableDebt,
		uint256 averageStableBorrowRate,
		uint256 reserveFactor
	) external view returns (uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate);
}

File 7 of 10 : Errors.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

/**
 * @title Errors library
 * @author Aave
 * @notice Defines the error messages emitted by the different contracts of the Aave protocol
 * @dev Error messages prefix glossary:
 *  - VL = ValidationLogic
 *  - MATH = Math libraries
 *  - CT = Common errors between tokens (AToken, VariableDebtToken and StableDebtToken)
 *  - AT = AToken
 *  - SDT = StableDebtToken
 *  - VDT = VariableDebtToken
 *  - LP = LendingPool
 *  - LPAPR = LendingPoolAddressesProviderRegistry
 *  - LPC = LendingPoolConfiguration
 *  - RL = ReserveLogic
 *  - LPCM = LendingPoolCollateralManager
 *  - P = Pausable
 */
library Errors {
	//common errors
	string public constant CALLER_NOT_POOL_ADMIN = "33"; // 'The caller must be the pool admin'
	string public constant BORROW_ALLOWANCE_NOT_ENOUGH = "59"; // User borrows on behalf, but allowance are too small

	//contract specific errors
	string public constant VL_INVALID_AMOUNT = "1"; // 'Amount must be greater than 0'
	string public constant VL_NO_ACTIVE_RESERVE = "2"; // 'Action requires an active reserve'
	string public constant VL_RESERVE_FROZEN = "3"; // 'Action cannot be performed because the reserve is frozen'
	string public constant VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = "4"; // 'The current liquidity is not enough'
	string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = "5"; // 'User cannot withdraw more than the available balance'
	string public constant VL_TRANSFER_NOT_ALLOWED = "6"; // 'Transfer cannot be allowed.'
	string public constant VL_BORROWING_NOT_ENABLED = "7"; // 'Borrowing is not enabled'
	string public constant VL_INVALID_INTEREST_RATE_MODE_SELECTED = "8"; // 'Invalid interest rate mode selected'
	string public constant VL_COLLATERAL_BALANCE_IS_0 = "9"; // 'The collateral balance is 0'
	string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = "10"; // 'Health factor is lesser than the liquidation threshold'
	string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = "11"; // 'There is not enough collateral to cover a new borrow'
	string public constant VL_STABLE_BORROWING_NOT_ENABLED = "12"; // stable borrowing not enabled
	string public constant VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = "13"; // collateral is (mostly) the same currency that is being borrowed
	string public constant VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = "14"; // 'The requested amount is greater than the max loan size in stable rate mode
	string public constant VL_NO_DEBT_OF_SELECTED_TYPE = "15"; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
	string public constant VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = "16"; // 'To repay on behalf of an user an explicit amount to repay is needed'
	string public constant VL_NO_STABLE_RATE_LOAN_IN_RESERVE = "17"; // 'User does not have a stable rate loan in progress on this reserve'
	string public constant VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = "18"; // 'User does not have a variable rate loan in progress on this reserve'
	string public constant VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = "19"; // 'The underlying balance needs to be greater than 0'
	string public constant VL_DEPOSIT_ALREADY_IN_USE = "20"; // 'User deposit is already being used as collateral'
	string public constant LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = "21"; // 'User does not have any stable rate loan for this reserve'
	string public constant LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = "22"; // 'Interest rate rebalance conditions were not met'
	string public constant LP_LIQUIDATION_CALL_FAILED = "23"; // 'Liquidation call failed'
	string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = "24"; // 'There is not enough liquidity available to borrow'
	string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = "25"; // 'The requested amount is too small for a FlashLoan.'
	string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = "26"; // 'The actual balance of the protocol is inconsistent'
	string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = "27"; // 'The caller of the function is not the lending pool configurator'
	string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = "28";
	string public constant CT_CALLER_MUST_BE_LENDING_POOL = "29"; // 'The caller of this function must be a lending pool'
	string public constant CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = "30"; // 'User cannot give allowance to himself'
	string public constant CT_TRANSFER_AMOUNT_NOT_GT_0 = "31"; // 'Transferred amount needs to be greater than zero'
	string public constant RL_RESERVE_ALREADY_INITIALIZED = "32"; // 'Reserve has already been initialized'
	string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = "34"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_ATOKEN_POOL_ADDRESS = "35"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = "36"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = "37"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = "38"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = "39"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = "40"; // 'The liquidity of the reserve needs to be 0'
	string public constant LPC_INVALID_CONFIGURATION = "75"; // 'Invalid risk parameters for the reserve'
	string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = "76"; // 'The caller must be the emergency admin'
	string public constant LPAPR_PROVIDER_NOT_REGISTERED = "41"; // 'Provider is not registered'
	string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = "42"; // 'Health factor is not below the threshold'
	string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = "43"; // 'The collateral chosen cannot be liquidated'
	string public constant LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = "44"; // 'User did not borrow the specified currency'
	string public constant LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = "45"; // "There isn't enough liquidity available to liquidate"
	string public constant LPCM_NO_ERRORS = "46"; // 'No errors'
	string public constant LP_INVALID_FLASHLOAN_MODE = "47"; //Invalid flashloan mode selected
	string public constant MATH_MULTIPLICATION_OVERFLOW = "48";
	string public constant MATH_ADDITION_OVERFLOW = "49";
	string public constant MATH_DIVISION_BY_ZERO = "50";
	string public constant RL_LIQUIDITY_INDEX_OVERFLOW = "51"; //  Liquidity index overflows uint128
	string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = "52"; //  Variable borrow index overflows uint128
	string public constant RL_LIQUIDITY_RATE_OVERFLOW = "53"; //  Liquidity rate overflows uint128
	string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = "54"; //  Variable borrow rate overflows uint128
	string public constant RL_STABLE_BORROW_RATE_OVERFLOW = "55"; //  Stable borrow rate overflows uint128
	string public constant CT_INVALID_MINT_AMOUNT = "56"; //invalid amount to mint
	string public constant LP_FAILED_REPAY_WITH_COLLATERAL = "57";
	string public constant CT_INVALID_BURN_AMOUNT = "58"; //invalid amount to burn
	string public constant LP_FAILED_COLLATERAL_SWAP = "60";
	string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = "61";
	string public constant LP_REENTRANCY_NOT_ALLOWED = "62";
	string public constant LP_CALLER_MUST_BE_AN_ATOKEN = "63";
	string public constant LP_IS_PAUSED = "64"; // 'Pool is paused'
	string public constant LP_NO_MORE_RESERVES_ALLOWED = "65";
	string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = "66";
	string public constant RC_INVALID_LTV = "67";
	string public constant RC_INVALID_LIQ_THRESHOLD = "68";
	string public constant RC_INVALID_LIQ_BONUS = "69";
	string public constant RC_INVALID_DECIMALS = "70";
	string public constant RC_INVALID_RESERVE_FACTOR = "71";
	string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = "72";
	string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = "73";
	string public constant LP_INCONSISTENT_PARAMS_LENGTH = "74";
	string public constant UL_INVALID_INDEX = "77";
	string public constant LP_NOT_CONTRACT = "78";
	string public constant SDT_STABLE_DEBT_OVERFLOW = "79";
	string public constant SDT_BURN_EXCEEDS_BALANCE = "80";

	enum CollateralManagerErrors {
		NO_ERROR,
		NO_COLLATERAL_AVAILABLE,
		COLLATERAL_CANNOT_BE_LIQUIDATED,
		CURRRENCY_NOT_BORROWED,
		HEALTH_FACTOR_ABOVE_THRESHOLD,
		NOT_ENOUGH_LIQUIDITY,
		NO_ACTIVE_RESERVE,
		HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD,
		INVALID_EQUAL_ASSETS_TO_SWAP,
		FROZEN_RESERVE
	}
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

import "@openzeppelin/contracts/utils/math/Math.sol";

library MathOperations {
	using Math for uint256;

	error MathError();

	function add(uint256 a, uint256 b) internal pure returns (uint256 result) {
		bool success;
		(success, result) = a.tryAdd(b);
		require(success, MathError());
	}

	function sub(uint256 a, uint256 b) internal pure returns (uint256 result) {
		bool success;
		(success, result) = a.trySub(b);
		require(success, MathError());
	}

	function mul(uint256 a, uint256 b) internal pure returns (uint256 result) {
		bool success;
		(success, result) = a.tryMul(b);
		require(success, MathError());
	}

	function div(uint256 a, uint256 b) internal pure returns (uint256 result) {
		bool success;
		(success, result) = a.tryDiv(b);
		require(success, MathError());
	}
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

import {Errors} from "../helpers/Errors.sol";

/**
 * @title PercentageMath library
 * @author Aave
 * @notice Provides functions to perform percentage calculations
 * @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR
 * @dev Operations are rounded half up
 **/

library PercentageMath {
	uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals
	uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2;

	/**
	 * @dev Executes a percentage multiplication
	 * @param value The value of which the percentage needs to be calculated
	 * @param percentage The percentage of the value to be calculated
	 * @return The percentage of value
	 **/
	function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) {
		if (value == 0 || percentage == 0) {
			return 0;
		}

		require(value <= (type(uint256).max - HALF_PERCENT) / percentage, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR;
	}

	/**
	 * @dev Executes a percentage division
	 * @param value The value of which the percentage needs to be calculated
	 * @param percentage The percentage of the value to be calculated
	 * @return The value divided the percentage
	 **/
	function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) {
		require(percentage != 0, Errors.MATH_DIVISION_BY_ZERO);
		uint256 halfPercentage = percentage / 2;

		require(value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage;
	}
}

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.27;

import {Errors} from "../helpers/Errors.sol";

/**
 * @title WadRayMath library
 * @author Aave
 * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
 **/

library WadRayMath {
	uint256 internal constant WAD = 1e18;
	uint256 internal constant halfWAD = WAD / 2;

	uint256 internal constant RAY = 1e27;
	uint256 internal constant halfRAY = RAY / 2;

	uint256 internal constant WAD_RAY_RATIO = 1e9;

	/**
	 * @return One ray, 1e27
	 **/
	function ray() internal pure returns (uint256) {
		return RAY;
	}

	/**
	 * @return One wad, 1e18
	 **/

	function wad() internal pure returns (uint256) {
		return WAD;
	}

	/**
	 * @return Half ray, 1e27/2
	 **/
	function halfRay() internal pure returns (uint256) {
		return halfRAY;
	}

	/**
	 * @return Half ray, 1e18/2
	 **/
	function halfWad() internal pure returns (uint256) {
		return halfWAD;
	}

	/**
	 * @dev Multiplies two wad, rounding half up to the nearest wad
	 * @param a Wad
	 * @param b Wad
	 * @return The result of a*b, in wad
	 **/
	function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
		if (a == 0 || b == 0) {
			return 0;
		}

		require(a <= (type(uint256).max - halfWAD) / b, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (a * b + halfWAD) / WAD;
	}

	/**
	 * @dev Divides two wad, rounding half up to the nearest wad
	 * @param a Wad
	 * @param b Wad
	 * @return The result of a/b, in wad
	 **/
	function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
		require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
		uint256 halfB = b / 2;

		require(a <= (type(uint256).max - halfB) / WAD, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (a * WAD + halfB) / b;
	}

	/**
	 * @dev Multiplies two ray, rounding half up to the nearest ray
	 * @param a Ray
	 * @param b Ray
	 * @return The result of a*b, in ray
	 **/
	function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
		if (a == 0 || b == 0) {
			return 0;
		}

		require(a <= (type(uint256).max - halfRAY) / b, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (a * b + halfRAY) / RAY;
	}

	/**
	 * @dev Divides two ray, rounding half up to the nearest ray
	 * @param a Ray
	 * @param b Ray
	 * @return The result of a/b, in ray
	 **/
	function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
		require(b != 0, Errors.MATH_DIVISION_BY_ZERO);
		uint256 halfB = b / 2;

		require(a <= (type(uint256).max - halfB) / RAY, Errors.MATH_MULTIPLICATION_OVERFLOW);

		return (a * RAY + halfB) / b;
	}

	/**
	 * @dev Casts ray down to wad
	 * @param a Ray
	 * @return a casted to wad, rounded half up to the nearest wad
	 **/
	function rayToWad(uint256 a) internal pure returns (uint256) {
		uint256 halfRatio = WAD_RAY_RATIO / 2;
		uint256 result = halfRatio + a;
		require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW);

		return result / WAD_RAY_RATIO;
	}

	/**
	 * @dev Converts wad up to ray
	 * @param a Wad
	 * @return a converted in ray
	 **/
	function wadToRay(uint256 a) internal pure returns (uint256) {
		uint256 result = a * WAD_RAY_RATIO;
		require(result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW);
		return result;
	}
}

Settings
{
  "evmVersion": "shanghai",
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "remappings": [],
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract ILendingPoolAddressesProvider","name":"provider","type":"address"},{"internalType":"uint256","name":"optimalUtilizationRate_","type":"uint256"},{"internalType":"uint256","name":"baseVariableBorrowRate_","type":"uint256"},{"internalType":"uint256","name":"variableRateSlope1_","type":"uint256"},{"internalType":"uint256","name":"variableRateSlope2_","type":"uint256"},{"internalType":"uint256","name":"stableRateSlope1_","type":"uint256"},{"internalType":"uint256","name":"stableRateSlope2_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"MathError","type":"error"},{"inputs":[],"name":"EXCESS_UTILIZATION_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPTIMAL_UTILIZATION_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addressesProvider","outputs":[{"internalType":"contract ILendingPoolAddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseVariableBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reserve","type":"address"},{"internalType":"address","name":"aToken","type":"address"},{"internalType":"uint256","name":"liquidityAdded","type":"uint256"},{"internalType":"uint256","name":"liquidityTaken","type":"uint256"},{"internalType":"uint256","name":"totalStableDebt","type":"uint256"},{"internalType":"uint256","name":"totalVariableDebt","type":"uint256"},{"internalType":"uint256","name":"averageStableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"reserveFactor","type":"uint256"}],"name":"calculateInterestRates","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reserve","type":"address"},{"internalType":"uint256","name":"availableLiquidity","type":"uint256"},{"internalType":"uint256","name":"totalStableDebt","type":"uint256"},{"internalType":"uint256","name":"totalVariableDebt","type":"uint256"},{"internalType":"uint256","name":"averageStableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"reserveFactor","type":"uint256"}],"name":"calculateInterestRates","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxVariableBorrowRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stableRateSlope1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stableRateSlope2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"variableRateSlope1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"variableRateSlope2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

6101803461016957601f610dda38819003918201601f19168301916001600160401b0383118484101761016d5780849260e094604052833981010312610169578051906001600160a01b038216820361016957602081015191604082015160608301519060808401519261008060c060a08701519601519680608052610181565b901561015a5760a05260c05260e05261010052610120526101405261016052604051610c2990816101b1823960805181818161016701526105c7015260a0518181816103e50152610605015260c05181818160f2015261052f015260e05181818161012d0152818161021e015281816106b401526107ce0152610100518181816101fd015281816102880152818161069301526107a2015261012051818181610244015281816102c201526106db01526101405181818161041d01528181610634015261077501526101605181818160ac015261065f0152f35b632158dc8960e21b5f5260045ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b906b033b2e3c9fd0803ce800000082116101a9576001916b033b2e3c9fd0803ce80000000390565b5f9150819056fe6080806040526004361015610012575f80fd5b5f3560e01c9081630bdf953f146104085750806317319873146103ce57806329db497d146102e557806365614f81146102ab5780637b832f581461027157806380031e37146101e35780639584df281461018a578063a15f30ac14610150578063b258954414610116578063c72c4d10146100d35763ccab01a314610095575f80fd5b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b5f80fd5b346100cf575f3660031901126100cf5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf5760c03660031901126100cf576101df6101c26101a9610440565b60a435906084359060643590604435906024359061048c565b604080519384526020840192909252908201529081906060820190565b0390f35b346100cf575f3660031901126100cf5760206102696102427f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610898565b7f000000000000000000000000000000000000000000000000000000000000000090610898565b604051908152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf576101003660031901126100cf576102ff610440565b6024356001600160a01b0381168091036100cf57604051907f70a0823100000000000000000000000000000000000000000000000000000000825260048201526020816024816001600160a01b0386165afa9081156103c3575f9161038f575b6101df6101c260e43560c43560a435608435886103896064356103846044358c610898565b6108ab565b9061048c565b90506020813d6020116103bb575b816103aa60209383610456565b810103126100cf57516101df61035f565b3d915061039d565b6040513d5f823e3d90fd5b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf575f3660031901126100cf576020907f00000000000000000000000000000000000000000000000000000000000000008152f35b600435906001600160a01b03821682036100cf57565b90601f8019910116810190811067ffffffffffffffff82111761047857604052565b634e487b7160e01b5f52604160045260245ffd5b929593949190946040519060a0820182811067ffffffffffffffff821117610478576040525f825260208201975f895260408301955f875260608401985f8a5260808501945f86526104de8488610898565b8091525f8c525f89525f8b5280155f146108805750505f5b8452604051907f3618abba0000000000000000000000000000000000000000000000000000000082526020826004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9182156103c3575f92610835575b506001600160a01b0360246020928260405195869485937fbb85c0bb000000000000000000000000000000000000000000000000000000008552166004840152165afa9081156103c3575f916107f9575b50916107189461070a928461071296958a528551907f0000000000000000000000000000000000000000000000000000000000000000918281115f1461075b57505061062a6106036106ff9288516108ab565b7f000000000000000000000000000000000000000000000000000000000000000090610982565b6106896106598c517f000000000000000000000000000000000000000000000000000000000000000090610898565b610683837f0000000000000000000000000000000000000000000000000000000000000000610a41565b90610898565b8b526106836106d87f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610898565b917f0000000000000000000000000000000000000000000000000000000000000000610a41565b8c525b8b5191610ace565b905190610a41565b91610b7f565b90156107335761072791610b1a565b80935251925191929190565b7f85637224000000000000000000000000000000000000000000000000000000005f5260045ffd5b916107996107cc92610683610773846107f297610982565b7f0000000000000000000000000000000000000000000000000000000000000000610a41565b8c526107c788517f000000000000000000000000000000000000000000000000000000000000000090610a41565b610982565b7f0000000000000000000000000000000000000000000000000000000000000000610898565b8c52610702565b91939290506020823d60201161082d575b8161081760209383610456565b810103126100cf579051919290916107186105b0565b3d915061080a565b9091506020813d602011610878575b8161085160209383610456565b810103126100cf57516001600160a01b03811681036100cf57906001600160a01b0361055f565b3d9150610844565b61088d8161089393610898565b90610982565b6104f6565b906108a291610b67565b91901561073357565b906108a291610b93565b156108bd5750565b604051907f08c379a000000000000000000000000000000000000000000000000000000000825260206004830152818151918260248301525f5b838110610918575050815f6044809484010152601f80199101168101030190fd5b602082820181015160448784010152859350016108f7565b811561093a570490565b634e487b7160e01b5f52601260045260245ffd5b8181029291811591840414171561096157565b634e487b7160e01b5f52601160045260245ffd5b9190820180921161096157565b906109c6604051610994604082610456565b600281527f353000000000000000000000000000000000000000000000000000000000000060208201528215156108b5565b8060011c91610a036040516109dc604082610456565b6002815261068760f31b60208201526b033b2e3c9fd0803ce80000008519048311156108b5565b6b033b2e3c9fd0803ce80000008102908082046b033b2e3c9fd0803ce8000000149015171561096157610a3e92610a3991610975565b610930565b90565b80158015610ac6575b610ac0576b019d971e4fe8401e7400000091801561093a57610aa491610a9f826b019d971e4fe8401e74000000190460405190610a88604083610456565b6002825261068760f31b60208301528311156108b5565b61094e565b908101809111610961576b033b2e3c9fd0803ce8000000900490565b50505f90565b508115610a4a565b91929092610adc8484610898565b928315610b115761068361088d93610b00610b05610b0b95610b00610a3e9a610bab565b610a41565b93610bab565b91610bab565b50505050505f90565b80158015610b5f575b610ac05761138891801561093a57610b4d91610a9f82611388190460405190610a88604083610456565b90810180911161096157612710900490565b508115610b23565b91908201918210610b785760019190565b5f91508190565b906127108211610b78576001916127100390565b9190828111610ba3576001920390565b505f91508190565b633b9aca00810290808204633b9aca00148115171561096157610a3e9060405190610bd7604083610456565b6002825261068760f31b6020830152633b9aca008404146108b556fea26469706673582212201ac698b5759fa4b51887e26195c1536dbd64a1745ca5373c47d2e080c1b8a8db64736f6c634300081b003300000000000000000000000007093ca1e6c8c03ff77dea07532f738d88de1d7500000000000000000000000000000000000000000219aada9b14535aca0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000422ca8b0a00a42500000000000000000000000000000000000000000000000033b2e3c9fd0803ce800000000000000000000000000000000000000000000000052b7d2dcc80cd2e40000000000000000000000000000000000000000000000033b2e3c9fd0803ce8000000

Deployed Bytecode

0x6080806040526004361015610012575f80fd5b5f3560e01c9081630bdf953f146104085750806317319873146103ce57806329db497d146102e557806365614f81146102ab5780637b832f581461027157806380031e37146101e35780639584df281461018a578063a15f30ac14610150578063b258954414610116578063c72c4d10146100d35763ccab01a314610095575f80fd5b346100cf575f3660031901126100cf5760206040517f0000000000000000000000000000000000000000033b2e3c9fd0803ce80000008152f35b5f80fd5b346100cf575f3660031901126100cf5760206040516001600160a01b037f00000000000000000000000007093ca1e6c8c03ff77dea07532f738d88de1d75168152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000219aada9b14535aca0000008152f35b346100cf5760c03660031901126100cf576101df6101c26101a9610440565b60a435906084359060643590604435906024359061048c565b604080519384526020840192909252908201529081906060820190565b0390f35b346100cf575f3660031901126100cf5760206102696102427f000000000000000000000000000000000000000000422ca8b0a00a42500000007f0000000000000000000000000000000000000000000000000000000000000000610898565b7f0000000000000000000000000000000000000000033b2e3c9fd0803ce800000090610898565b604051908152f35b346100cf575f3660031901126100cf5760206040517f000000000000000000000000000000000000000000422ca8b0a00a42500000008152f35b346100cf575f3660031901126100cf5760206040517f0000000000000000000000000000000000000000033b2e3c9fd0803ce80000008152f35b346100cf576101003660031901126100cf576102ff610440565b6024356001600160a01b0381168091036100cf57604051907f70a0823100000000000000000000000000000000000000000000000000000000825260048201526020816024816001600160a01b0386165afa9081156103c3575f9161038f575b6101df6101c260e43560c43560a435608435886103896064356103846044358c610898565b6108ab565b9061048c565b90506020813d6020116103bb575b816103aa60209383610456565b810103126100cf57516101df61035f565b3d915061039d565b6040513d5f823e3d90fd5b346100cf575f3660031901126100cf5760206040517f00000000000000000000000000000000000000000121836204bc2ce21e0000008152f35b346100cf575f3660031901126100cf576020907f00000000000000000000000000000000000000000052b7d2dcc80cd2e40000008152f35b600435906001600160a01b03821682036100cf57565b90601f8019910116810190811067ffffffffffffffff82111761047857604052565b634e487b7160e01b5f52604160045260245ffd5b929593949190946040519060a0820182811067ffffffffffffffff821117610478576040525f825260208201975f895260408301955f875260608401985f8a5260808501945f86526104de8488610898565b8091525f8c525f89525f8b5280155f146108805750505f5b8452604051907f3618abba0000000000000000000000000000000000000000000000000000000082526020826004816001600160a01b037f00000000000000000000000007093ca1e6c8c03ff77dea07532f738d88de1d75165afa9182156103c3575f92610835575b506001600160a01b0360246020928260405195869485937fbb85c0bb000000000000000000000000000000000000000000000000000000008552166004840152165afa9081156103c3575f916107f9575b50916107189461070a928461071296958a528551907f00000000000000000000000000000000000000000219aada9b14535aca000000918281115f1461075b57505061062a6106036106ff9288516108ab565b7f00000000000000000000000000000000000000000121836204bc2ce21e00000090610982565b6106896106598c517f00000000000000000000000000000000000000000052b7d2dcc80cd2e400000090610898565b610683837f0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000610a41565b90610898565b8b526106836106d87f000000000000000000000000000000000000000000422ca8b0a00a42500000007f0000000000000000000000000000000000000000000000000000000000000000610898565b917f0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000610a41565b8c525b8b5191610ace565b905190610a41565b91610b7f565b90156107335761072791610b1a565b80935251925191929190565b7f85637224000000000000000000000000000000000000000000000000000000005f5260045ffd5b916107996107cc92610683610773846107f297610982565b7f00000000000000000000000000000000000000000052b7d2dcc80cd2e4000000610a41565b8c526107c788517f000000000000000000000000000000000000000000422ca8b0a00a425000000090610a41565b610982565b7f0000000000000000000000000000000000000000000000000000000000000000610898565b8c52610702565b91939290506020823d60201161082d575b8161081760209383610456565b810103126100cf579051919290916107186105b0565b3d915061080a565b9091506020813d602011610878575b8161085160209383610456565b810103126100cf57516001600160a01b03811681036100cf57906001600160a01b0361055f565b3d9150610844565b61088d8161089393610898565b90610982565b6104f6565b906108a291610b67565b91901561073357565b906108a291610b93565b156108bd5750565b604051907f08c379a000000000000000000000000000000000000000000000000000000000825260206004830152818151918260248301525f5b838110610918575050815f6044809484010152601f80199101168101030190fd5b602082820181015160448784010152859350016108f7565b811561093a570490565b634e487b7160e01b5f52601260045260245ffd5b8181029291811591840414171561096157565b634e487b7160e01b5f52601160045260245ffd5b9190820180921161096157565b906109c6604051610994604082610456565b600281527f353000000000000000000000000000000000000000000000000000000000000060208201528215156108b5565b8060011c91610a036040516109dc604082610456565b6002815261068760f31b60208201526b033b2e3c9fd0803ce80000008519048311156108b5565b6b033b2e3c9fd0803ce80000008102908082046b033b2e3c9fd0803ce8000000149015171561096157610a3e92610a3991610975565b610930565b90565b80158015610ac6575b610ac0576b019d971e4fe8401e7400000091801561093a57610aa491610a9f826b019d971e4fe8401e74000000190460405190610a88604083610456565b6002825261068760f31b60208301528311156108b5565b61094e565b908101809111610961576b033b2e3c9fd0803ce8000000900490565b50505f90565b508115610a4a565b91929092610adc8484610898565b928315610b115761068361088d93610b00610b05610b0b95610b00610a3e9a610bab565b610a41565b93610bab565b91610bab565b50505050505f90565b80158015610b5f575b610ac05761138891801561093a57610b4d91610a9f82611388190460405190610a88604083610456565b90810180911161096157612710900490565b508115610b23565b91908201918210610b785760019190565b5f91508190565b906127108211610b78576001916127100390565b9190828111610ba3576001920390565b505f91508190565b633b9aca00810290808204633b9aca00148115171561096157610a3e9060405190610bd7604083610456565b6002825261068760f31b6020830152633b9aca008404146108b556fea26469706673582212201ac698b5759fa4b51887e26195c1536dbd64a1745ca5373c47d2e080c1b8a8db64736f6c634300081b0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000007093ca1e6c8c03ff77dea07532f738d88de1d7500000000000000000000000000000000000000000219aada9b14535aca0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000422ca8b0a00a42500000000000000000000000000000000000000000000000033b2e3c9fd0803ce800000000000000000000000000000000000000000000000052b7d2dcc80cd2e40000000000000000000000000000000000000000000000033b2e3c9fd0803ce8000000

-----Decoded View---------------
Arg [0] : provider (address): 0x07093CA1E6c8c03Ff77dea07532F738d88De1D75
Arg [1] : optimalUtilizationRate_ (uint256): 650000000000000000000000000
Arg [2] : baseVariableBorrowRate_ (uint256): 0
Arg [3] : variableRateSlope1_ (uint256): 80000000000000000000000000
Arg [4] : variableRateSlope2_ (uint256): 1000000000000000000000000000
Arg [5] : stableRateSlope1_ (uint256): 100000000000000000000000000
Arg [6] : stableRateSlope2_ (uint256): 1000000000000000000000000000

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000007093ca1e6c8c03ff77dea07532f738d88de1d75
Arg [1] : 00000000000000000000000000000000000000000219aada9b14535aca000000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 000000000000000000000000000000000000000000422ca8b0a00a4250000000
Arg [4] : 0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000
Arg [5] : 00000000000000000000000000000000000000000052b7d2dcc80cd2e4000000
Arg [6] : 0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000


Block Transaction Gas Used Reward
view all blocks ##produced##

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.