Goerli Testnet

Contract

0xB82a29C9a83C52AbBc61327296B4Bb4Fa52050dA
Source Code

Overview

ETH Balance

0 ETH

Multi Chain

Multichain Addresses

N/A
Transaction Hash
Method
Block
From
To
Value
0x6080604083765042023-01-25 23:19:12316 days 4 hrs ago1674688752IN
 Create: GhoDiscountRateStrategy
0 ETH0.00009410.50000002

Latest 25 internal transactions (View All)

Advanced mode:
Parent Txn Hash Block From To Value
101364842023-12-01 3:04:367 days 36 mins ago1701399876
0xB82a29...a52050dA
0 ETH
100730552023-11-19 21:51:2418 days 5 hrs ago1700430684
0xB82a29...a52050dA
0 ETH
100675082023-11-18 22:40:3619 days 5 hrs ago1700347236
0xB82a29...a52050dA
0 ETH
100674992023-11-18 22:38:3619 days 5 hrs ago1700347116
0xB82a29...a52050dA
0 ETH
100654962023-11-18 14:19:1219 days 13 hrs ago1700317152
0xB82a29...a52050dA
0 ETH
100614542023-11-17 21:21:4820 days 6 hrs ago1700256108
0xB82a29...a52050dA
0 ETH
100609142023-11-17 19:09:0020 days 8 hrs ago1700248140
0xB82a29...a52050dA
0 ETH
99985822023-11-06 22:36:1231 days 5 hrs ago1699310172
0xB82a29...a52050dA
0 ETH
99859732023-11-04 17:48:4833 days 9 hrs ago1699120128
0xB82a29...a52050dA
0 ETH
99788842023-11-03 11:35:3634 days 16 hrs ago1699011336
0xB82a29...a52050dA
0 ETH
99747522023-11-02 17:38:2435 days 10 hrs ago1698946704
0xB82a29...a52050dA
0 ETH
99747062023-11-02 17:26:3635 days 10 hrs ago1698945996
0xB82a29...a52050dA
0 ETH
99685272023-11-01 13:29:1236 days 14 hrs ago1698845352
0xB82a29...a52050dA
0 ETH
99674462023-11-01 8:48:0036 days 18 hrs ago1698828480
0xB82a29...a52050dA
0 ETH
99674392023-11-01 8:46:0036 days 18 hrs ago1698828360
0xB82a29...a52050dA
0 ETH
99469552023-10-28 18:03:3640 days 9 hrs ago1698516216
0xB82a29...a52050dA
0 ETH
99035352023-10-21 3:26:4848 days 14 mins ago1697858808
0xB82a29...a52050dA
0 ETH
98821402023-10-17 11:43:4851 days 15 hrs ago1697543028
0xB82a29...a52050dA
0 ETH
98734152023-10-15 23:39:2453 days 4 hrs ago1697413164
0xB82a29...a52050dA
0 ETH
98678172023-10-15 0:25:2454 days 3 hrs ago1697329524
0xB82a29...a52050dA
0 ETH
98551752023-10-12 19:08:0056 days 8 hrs ago1697137680
0xB82a29...a52050dA
0 ETH
98537092023-10-12 12:49:0056 days 14 hrs ago1697114940
0xB82a29...a52050dA
0 ETH
98531932023-10-12 10:30:1256 days 17 hrs ago1697106612
0xB82a29...a52050dA
0 ETH
97895812023-10-01 7:08:4867 days 20 hrs ago1696144128
0xB82a29...a52050dA
0 ETH
97843462023-09-30 8:44:2468 days 18 hrs ago1696063464
0xB82a29...a52050dA
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GhoDiscountRateStrategy

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 2 of 3 : GhoDiscountRateStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {WadRayMath} from '@aave/core-v3/contracts/protocol/libraries/math/WadRayMath.sol';
import {IGhoDiscountRateStrategy} from '../tokens/interfaces/IGhoDiscountRateStrategy.sol';

/**
 * @title GhoDiscountRateStrategy contract
 * @author Aave
 * @notice Implements the calculation of the discount rate depending on the current strategy
 */
contract GhoDiscountRateStrategy is IGhoDiscountRateStrategy {
  using WadRayMath for uint256;

  /**
   * @dev Amount of debt that is entitled to get a discount per unit of discount token
   * Expressed with the number of decimals of the discount token
   */
  uint256 public constant GHO_DISCOUNTED_PER_DISCOUNT_TOKEN = 100e18;

  /**
   * @dev Percentage of discount to apply to the part of the debt that is entitled to get a discount
   * Expressed in bps, a value of 2000 results in 20.00%
   */
  uint256 public constant DISCOUNT_RATE = 2000;

  /**
   * @dev Minimum balance amount of discount token to be entitled to a discount
   * Expressed with the number of decimals of the discount token
   */
  uint256 public constant MIN_DISCOUNT_TOKEN_BALANCE = 1e18;

  /**
   * @dev Minimum balance amount of debt token to be entitled to a discount
   * Expressed with the number of decimals of the debt token
   */
  uint256 public constant MIN_DEBT_TOKEN_BALANCE = 1e18;

  /// @inheritdoc IGhoDiscountRateStrategy
  function calculateDiscountRate(uint256 debtBalance, uint256 discountTokenBalance)
    external
    pure
    override
    returns (uint256)
  {
    if (discountTokenBalance < MIN_DISCOUNT_TOKEN_BALANCE || debtBalance < MIN_DEBT_TOKEN_BALANCE) {
      return 0;
    } else {
      uint256 discountedBalance = discountTokenBalance.wadMul(GHO_DISCOUNTED_PER_DISCOUNT_TOKEN);
      if (discountedBalance >= debtBalance) {
        return DISCOUNT_RATE;
      } else {
        return (discountedBalance * DISCOUNT_RATE) / debtBalance;
      }
    }
  }
}

File 2 of 3 : WadRayMath.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

/**
 * @title WadRayMath library
 * @author Aave
 * @notice Provides functions to perform calculations with Wad and Ray units
 * @dev Provides mul and div function for wads (decimal numbers with 18 digits of precision) and rays (decimal numbers
 * with 27 digits of precision)
 * @dev Operations are rounded. If a value is >=.5, will be rounded up, otherwise rounded down.
 */
library WadRayMath {
  // HALF_WAD and HALF_RAY expressed with extended notation as constant with operations are not supported in Yul assembly
  uint256 internal constant WAD = 1e18;
  uint256 internal constant HALF_WAD = 0.5e18;

  uint256 internal constant RAY = 1e27;
  uint256 internal constant HALF_RAY = 0.5e27;

  uint256 internal constant WAD_RAY_RATIO = 1e9;

  /**
   * @dev Multiplies two wad, rounding half up to the nearest wad
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Wad
   * @param b Wad
   * @return c = a*b, in wad
   */
  function wadMul(uint256 a, uint256 b) internal pure returns (uint256 c) {
    // to avoid overflow, a <= (type(uint256).max - HALF_WAD) / b
    assembly {
      if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_WAD), b))))) {
        revert(0, 0)
      }

      c := div(add(mul(a, b), HALF_WAD), WAD)
    }
  }

  /**
   * @dev Divides two wad, rounding half up to the nearest wad
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Wad
   * @param b Wad
   * @return c = a/b, in wad
   */
  function wadDiv(uint256 a, uint256 b) internal pure returns (uint256 c) {
    // to avoid overflow, a <= (type(uint256).max - halfB) / WAD
    assembly {
      if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), WAD))))) {
        revert(0, 0)
      }

      c := div(add(mul(a, WAD), div(b, 2)), b)
    }
  }

  /**
   * @notice Multiplies two ray, rounding half up to the nearest ray
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Ray
   * @param b Ray
   * @return c = a raymul b
   */
  function rayMul(uint256 a, uint256 b) internal pure returns (uint256 c) {
    // to avoid overflow, a <= (type(uint256).max - HALF_RAY) / b
    assembly {
      if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_RAY), b))))) {
        revert(0, 0)
      }

      c := div(add(mul(a, b), HALF_RAY), RAY)
    }
  }

  /**
   * @notice Divides two ray, rounding half up to the nearest ray
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Ray
   * @param b Ray
   * @return c = a raydiv b
   */
  function rayDiv(uint256 a, uint256 b) internal pure returns (uint256 c) {
    // to avoid overflow, a <= (type(uint256).max - halfB) / RAY
    assembly {
      if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), RAY))))) {
        revert(0, 0)
      }

      c := div(add(mul(a, RAY), div(b, 2)), b)
    }
  }

  /**
   * @dev Casts ray down to wad
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Ray
   * @return b = a converted to wad, rounded half up to the nearest wad
   */
  function rayToWad(uint256 a) internal pure returns (uint256 b) {
    assembly {
      b := div(a, WAD_RAY_RATIO)
      let remainder := mod(a, WAD_RAY_RATIO)
      if iszero(lt(remainder, div(WAD_RAY_RATIO, 2))) {
        b := add(b, 1)
      }
    }
  }

  /**
   * @dev Converts wad up to ray
   * @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
   * @param a Wad
   * @return b = a converted in ray
   */
  function wadToRay(uint256 a) internal pure returns (uint256 b) {
    // to avoid overflow, b/WAD_RAY_RATIO == a
    assembly {
      b := mul(a, WAD_RAY_RATIO)

      if iszero(eq(div(b, WAD_RAY_RATIO), a)) {
        revert(0, 0)
      }
    }
  }
}

File 3 of 3 : IGhoDiscountRateStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title IGhoDiscountRateStrategy
 * @author Aave
 * @notice Defines the basic interface of the GhoDiscountRateStrategy
 */
interface IGhoDiscountRateStrategy {
  /**
   * @notice Calculates the discount rate depending on the debt and discount token balances
   * @param debtBalance The debt balance of the user
   * @param discountTokenBalance The discount token balance of the user
   * @return The discount rate, as a percentage - the maximum can be 10000 = 100.00%
   */
  function calculateDiscountRate(uint256 debtBalance, uint256 discountTokenBalance)
    external
    view
    returns (uint256);
}

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

Contract ABI

[{"inputs":[],"name":"DISCOUNT_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GHO_DISCOUNTED_PER_DISCOUNT_TOKEN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DEBT_TOKEN_BALANCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DISCOUNT_TOKEN_BALANCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"debtBalance","type":"uint256"},{"internalType":"uint256","name":"discountTokenBalance","type":"uint256"}],"name":"calculateDiscountRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

608060405234801561001057600080fd5b50610275806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806393adbec51161005057806393adbec51461009d57806398c4f4381461006c578063b510c589146100b057600080fd5b80633454274e1461006c578063771a73af1461008d575b600080fd5b61007b670de0b6b3a764000081565b60405190815260200160405180910390f35b61007b68056bc75e2d6310000081565b61007b6100ab36600461017e565b6100b9565b61007b6107d081565b6000670de0b6b3a76400008210806100d85750670de0b6b3a764000083105b156100e557506000610129565b60006100fa8368056bc75e2d6310000061012f565b905083811061010e576107d0915050610129565b8361011b6107d0836101a0565b6101259190610204565b9150505b92915050565b600081157ffffffffffffffffffffffffffffffffffffffffffffffffff90fa4a62c4dffff8390048411151761016457600080fd5b50670de0b6b3a764000091026706f05b59d3b20000010490565b6000806040838503121561019157600080fd5b50508035926020909101359150565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156101ff577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500290565b60008261023a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea2646970667358221220a00641264fd36cc505ec400bf5303839770a61429c058682dc23afa6750a037464736f6c634300080a0033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100675760003560e01c806393adbec51161005057806393adbec51461009d57806398c4f4381461006c578063b510c589146100b057600080fd5b80633454274e1461006c578063771a73af1461008d575b600080fd5b61007b670de0b6b3a764000081565b60405190815260200160405180910390f35b61007b68056bc75e2d6310000081565b61007b6100ab36600461017e565b6100b9565b61007b6107d081565b6000670de0b6b3a76400008210806100d85750670de0b6b3a764000083105b156100e557506000610129565b60006100fa8368056bc75e2d6310000061012f565b905083811061010e576107d0915050610129565b8361011b6107d0836101a0565b6101259190610204565b9150505b92915050565b600081157ffffffffffffffffffffffffffffffffffffffffffffffffff90fa4a62c4dffff8390048411151761016457600080fd5b50670de0b6b3a764000091026706f05b59d3b20000010490565b6000806040838503121561019157600080fd5b50508035926020909101359150565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156101ff577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500290565b60008261023a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea2646970667358221220a00641264fd36cc505ec400bf5303839770a61429c058682dc23afa6750a037464736f6c634300080a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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.