Contract 0x45C1D1793C040DC0dCba10cB1064fDdd1a4Af14b

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x25ec05aabc15d1272a2698cb8a7e7aa570570ec967194eee3c001fa97e8187f90x60806040206557322021-10-31 14:57:41400 days 51 mins ago0xb98d4d4e205aff4d4755e9df19bd0b8bd4e0f148 IN  Create: ProviderGeist0 FTM0.153591357586
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x5023476f5260bfc0209a5ee6bf5cd59cece0a796f314b35b1be622f08ecc68eb515958002022-11-29 9:25:296 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token9 FTM
0xbe120649703c51d0030fc00cecc6aebbff3e19c7a5a0674203346481cbb6df44515351572022-11-28 5:26:347 days 10 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token21 FTM
0xc2e191fbdd898639b806a7a2e353acabc2d6dd096629de1f40032cebe3a38500513375732022-11-23 11:01:0912 days 4 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token29,292.339363001715592665 FTM
0x712de2549085641aaea4989665dc0451771d83d23a1674d253a2e44f5a6242b7387910402022-05-22 7:46:54197 days 8 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token500 FTM
0x1b9fdee97660189caaea7938fef03bdab0c7dc02fc104693d090efbce3b3639a387812162022-05-22 4:37:35197 days 11 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token10 FTM
0x403ca3e0545d85262128be6e226f43999ae5adac37dab93f80fbfe3e254eb5a2387805932022-05-22 4:24:08197 days 11 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token50 FTM
0xc1425991aa210baf57994a39236e63520ddceec595e326739cc870306e30bf07387688752022-05-22 0:34:41197 days 15 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token2 FTM
0xb1e80f13dd1bed781fc2705782d2cac8d840a3e9775b59081467299bdcbae2fe387686742022-05-22 0:30:42197 days 15 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token6 FTM
0xcccde02be365e97203666d103244a15a45d23b692b11e017b2db21af9febfe00387685932022-05-22 0:29:16197 days 15 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token8.298833 FTM
0xbd80e6b03c92694fc8c321e44aa2d2a72935406c9e9df06db33fd2c39059a2c9387685662022-05-22 0:28:49197 days 15 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token10 FTM
0xb3f6934f5d4837ee123b9eda48484163ee9b748b5844c6286378ae8afd63c419387277042022-05-21 10:39:39198 days 5 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token65 FTM
0x9c8762a12b416f2e4fea6b6fa967538e969255be1b920652a5a4cb659804f386387235422022-05-21 9:20:43198 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,400 FTM
0x0c15dffc3100f078c6b47b8057e0828c90988f1e85f2d566096ea97534cc48e5387233802022-05-21 9:17:40198 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,400 FTM
0xd5cf82527ee08b8a5f63368eb3ca35a423d1bc2845ab81a0f45abd26c067ff89387232592022-05-21 9:15:08198 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,400 FTM
0x18fbd51e9fec1fee87d3eee12e9a7c87f0c3e3123d8a0b5918953f903822289e387151322022-05-21 6:46:04198 days 9 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,200 FTM
0xe8b7a33a754dcdff07ee62d2a218ecf8b5ab0417b861349eeea969dd220bb74f387149662022-05-21 6:43:00198 days 9 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,200 FTM
0xd5d8709088868da514c26cbccce0afad499363fdb9381874f030e7c2bd4dd798387146812022-05-21 6:38:01198 days 9 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3,200 FTM
0xb815cd392769f4f8591fea20f038526143241d51e2e87ce59f91c583500487b1386931972022-05-20 23:42:57198 days 16 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token3 FTM
0x09a81e8c5b94f2174dbd3f77bb1c91578e748eb54594a07a0aa12fb5eb968ffe386930482022-05-20 23:40:24198 days 16 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token1 FTM
0x266d432b366c61e84cb3dc8a840deba64b23f609d280c877a925f98a6ef92815386664562022-05-20 15:13:24199 days 36 mins ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token300 FTM
0xa0026dc753b0e10fc83ac5f938443775be3dbb6f039843e94ff4be4e5cfbf0f9386604452022-05-20 13:15:15199 days 2 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token70 FTM
0xebf389db1589051eb34517ce52da06cd4d7e2e1c4764a21df68d56198c17a1ed386511482022-05-20 9:58:23199 days 5 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token2,400 FTM
0x436f385cd5341da1ee0644e0351c3e473260e1d106fc225db2297122903370de386483272022-05-20 9:02:25199 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token2,400 FTM
0x85ae0594fcd7b99ac15180ba8b7bfe461be4921b18bd126cedf769e8e3e41012386479532022-05-20 8:55:33199 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token2,400 FTM
0x8f9f0f73d51cbba8ae2db65ce70843dd89d837da5b13e57f02508d0b7c9749fd386477912022-05-20 8:51:55199 days 6 hrs ago Fuji DAO: Provider Geist Fantom Finance: Wrapped Fantom Token2,400 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ProviderGeist

Compiler Version
v0.8.0+commit.c7dfd78e

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 12 : ProviderGeist.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "../../interfaces/IProvider.sol";
import "../../interfaces/IUnwrapper.sol";
import "../../interfaces/IVault.sol";
import "../../interfaces/IWETH.sol";
import "../../interfaces/aave/IAaveDataProvider.sol";
import "../../interfaces/aave/IAaveLendingPool.sol";
import "../../interfaces/aave/IAaveLendingPoolProvider.sol";
import "../libraries/LibUniversalERC20FTM.sol";

contract ProviderGeist is IProvider {
  using LibUniversalERC20FTM for IERC20;

  function _getAaveProvider() internal pure returns (IAaveLendingPoolProvider) {
    return IAaveLendingPoolProvider(0x6c793c628Fe2b480c5e6FB7957dDa4b9291F9c9b);
  }

  function _getAaveDataProvider() internal pure returns (IAaveDataProvider) {
    return IAaveDataProvider(0xf3B0611e2E4D2cd6aB4bb3e01aDe211c3f42A8C3);
  }

  function _getWftmAddr() internal pure returns (address) {
    return 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;
  }

  function _getFtmAddr() internal pure returns (address) {
    return 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
  }

  function _getUnwrapper() internal pure returns(address) {
    return 0xee94A39D185329d8c46dEA726E01F91641E57346;
  }

  /**
   * @dev Return the borrowing rate of ETH/ERC20_Token.
   * @param _asset to query the borrowing rate.
   */
  function getBorrowRateFor(address _asset) external view override returns (uint256) {
    IAaveDataProvider aaveData = _getAaveDataProvider();

    (, , , , uint256 variableBorrowRate, , , , , ) = IAaveDataProvider(aaveData).getReserveData(
      _asset == _getFtmAddr() ? _getWftmAddr() : _asset
    );

    return variableBorrowRate;
  }

  /**
   * @dev Return borrow balance of FTM/ERC20_Token.
   * @param _asset token address to query the balance.
   */
  function getBorrowBalance(address _asset) external view override returns (uint256) {
    IAaveDataProvider aaveData = _getAaveDataProvider();

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    (, , uint256 variableDebt, , , , , , ) = aaveData.getUserReserveData(_tokenAddr, msg.sender);

    return variableDebt;
  }

  /**
   * @dev Return borrow balance of FTM/ERC20_Token.
   * @param _asset token address to query the balance.
   * @param _who address of the account.
   */
  function getBorrowBalanceOf(address _asset, address _who)
    external
    view
    override
    returns (uint256)
  {
    IAaveDataProvider aaveData = _getAaveDataProvider();

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    (, , uint256 variableDebt, , , , , , ) = aaveData.getUserReserveData(_tokenAddr, _who);

    return variableDebt;
  }

  /**
   * @dev Return deposit balance of FTM/ERC20_Token.
   * @param _asset token address to query the balance.
   */
  function getDepositBalance(address _asset) external view override returns (uint256) {
    IAaveDataProvider aaveData = _getAaveDataProvider();

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    (uint256 atokenBal, , , , , , , , ) = aaveData.getUserReserveData(_tokenAddr, msg.sender);

    return atokenBal;
  }

  /**
   * @dev Deposit FTM/ERC20_Token.
   * @param _asset token address to deposit.(For FTM: 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)
   * @param _amount token amount to deposit.
   */
  function deposit(address _asset, uint256 _amount) external payable override {
    IAaveLendingPool aave = IAaveLendingPool(_getAaveProvider().getLendingPool());

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    // convert FTM to WFTM
    if (isFtm) IWETH(_tokenAddr).deposit{ value: _amount }();

    IERC20(_tokenAddr).univApprove(address(aave), _amount);

    aave.deposit(_tokenAddr, _amount, address(this), 0);

    aave.setUserUseReserveAsCollateral(_tokenAddr, true);
  }

  /**
   * @dev Borrow FTM/ERC20_Token.
   * @param _asset token address to borrow.(For FTM: 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)
   * @param _amount token amount to borrow.
   */
  function borrow(address _asset, uint256 _amount) external payable override {
    IAaveLendingPool aave = IAaveLendingPool(_getAaveProvider().getLendingPool());

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    aave.borrow(_tokenAddr, _amount, 2, 0, address(this));

    // convert WFTM to FTM
    if (isFtm)  {
      address unwrapper = _getUnwrapper();
      IERC20(_tokenAddr).univTransfer(payable(unwrapper), _amount);
      IUnwrapper(unwrapper).withdraw(_amount);
    }
  }

  /**
   * @dev Withdraw FTM/ERC20_Token.
   * @param _asset token address to withdraw.
   * @param _amount token amount to withdraw.
   */
  function withdraw(address _asset, uint256 _amount) external payable override {
    IAaveLendingPool aave = IAaveLendingPool(_getAaveProvider().getLendingPool());

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    aave.withdraw(_tokenAddr, _amount, address(this));

    // convert WFTM to FTM
    if (isFtm)  {
      address unwrapper = _getUnwrapper();
      IERC20(_tokenAddr).univTransfer(payable(unwrapper), _amount);
      IUnwrapper(unwrapper).withdraw(_amount);
    }
  }

  /**
   * @dev Payback borrowed FTM/ERC20_Token.
   * @param _asset token address to payback.
   * @param _amount token amount to payback.
   */

  function payback(address _asset, uint256 _amount) external payable override {
    IAaveLendingPool aave = IAaveLendingPool(_getAaveProvider().getLendingPool());

    bool isFtm = _asset == _getFtmAddr();
    address _tokenAddr = isFtm ? _getWftmAddr() : _asset;

    // convert FTM to WFTM
    if (isFtm) IWETH(_tokenAddr).deposit{ value: _amount }();

    IERC20(_tokenAddr).univApprove(address(aave), _amount);

    aave.repay(_tokenAddr, _amount, 2, address(this));
  }
}

File 2 of 12 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

    /**
     * @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);
}

File 3 of 12 : IProvider.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IProvider {
  //Basic Core Functions

  function deposit(address _collateralAsset, uint256 _collateralAmount) external payable;

  function borrow(address _borrowAsset, uint256 _borrowAmount) external payable;

  function withdraw(address _collateralAsset, uint256 _collateralAmount) external payable;

  function payback(address _borrowAsset, uint256 _borrowAmount) external payable;

  // returns the borrow annualized rate for an asset in ray (1e27)
  //Example 8.5% annual interest = 0.085 x 10^27 = 85000000000000000000000000 or 85*(10**24)
  function getBorrowRateFor(address _asset) external view returns (uint256);

  function getBorrowBalance(address _asset) external view returns (uint256);

  function getDepositBalance(address _asset) external view returns (uint256);

  function getBorrowBalanceOf(address _asset, address _who) external returns (uint256);
}

File 4 of 12 : IUnwrapper.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IUnwrapper {
  function withdraw(uint256 amount) external;
}

File 5 of 12 : IVault.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IVault {
  // Events

  // Log Users Deposit
  event Deposit(address indexed userAddrs, address indexed asset, uint256 amount);
  // Log Users withdraw
  event Withdraw(address indexed userAddrs, address indexed asset, uint256 amount);
  // Log Users borrow
  event Borrow(address indexed userAddrs, address indexed asset, uint256 amount);
  // Log Users debt repay
  event Payback(address indexed userAddrs, address indexed asset, uint256 amount);

  // Log New active provider
  event SetActiveProvider(address providerAddr);
  // Log Switch providers
  event Switch(
    address fromProviderAddrs,
    address toProviderAddr,
    uint256 debtamount,
    uint256 collattamount
  );

  // Core Vault Functions

  function deposit(uint256 _collateralAmount) external payable;

  function withdraw(int256 _withdrawAmount) external;

  function withdrawLiq(int256 _withdrawAmount) external;

  function borrow(uint256 _borrowAmount) external;

  function payback(int256 _repayAmount) external payable;

  function paybackLiq(address[] memory _users, uint256 _repayAmount) external payable;

  function executeSwitch(
    address _newProvider,
    uint256 _flashLoanDebt,
    uint256 _fee
  ) external payable;

  //Getter Functions

  function activeProvider() external view returns (address);

  function borrowBalance(address _provider) external view returns (uint256);

  function depositBalance(address _provider) external view returns (uint256);

  function userDebtBalance(address _user) external view returns (uint256);

  function userProtocolFee(address _user) external view returns (uint256);

  function userDepositBalance(address _user) external view returns (uint256);

  function getNeededCollateralFor(uint256 _amount, bool _withFactors)
    external
    view
    returns (uint256);

  function getLiquidationBonusFor(uint256 _amount) external view returns (uint256);

  function getProviders() external view returns (address[] memory);

  function fujiERC1155() external view returns (address);

  //Setter Functions

  function setActiveProvider(address _provider) external;

  function updateF1155Balances() external;

  function protocolFee() external view returns (uint64, uint64);
}

File 6 of 12 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IWETH {
  function approve(address, uint256) external;

  function deposit() external payable;

  function withdraw(uint256) external;
}

File 7 of 12 : IAaveDataProvider.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IAaveDataProvider {
  function getReserveTokensAddresses(address _asset)
    external
    view
    returns (
      address aTokenAddress,
      address stableDebtTokenAddress,
      address variableDebtTokenAddress
    );

  function getUserReserveData(address _asset, address _user)
    external
    view
    returns (
      uint256 currentATokenBalance,
      uint256 currentStableDebt,
      uint256 currentVariableDebt,
      uint256 principalStableDebt,
      uint256 scaledVariableDebt,
      uint256 stableBorrowRate,
      uint256 liquidityRate,
      uint40 stableRateLastUpdated,
      bool usageAsCollateralEnabled
    );

  function getReserveData(address _asset)
    external
    view
    returns (
      uint256 availableLiquidity,
      uint256 totalStableDebt,
      uint256 totalVariableDebt,
      uint256 liquidityRate,
      uint256 variableBorrowRate,
      uint256 stableBorrowRate,
      uint256 averageStableBorrowRate,
      uint256 liquidityIndex,
      uint256 variableBorrowIndex,
      uint40 lastUpdateTimestamp
    );
}

File 8 of 12 : IAaveLendingPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IAaveLendingPool {
  function flashLoan(
    address receiverAddress,
    address[] calldata assets,
    uint256[] calldata amounts,
    uint256[] calldata modes,
    address onBehalfOf,
    bytes calldata params,
    uint16 referralCode
  ) external;

  function deposit(
    address _asset,
    uint256 _amount,
    address _onBehalfOf,
    uint16 _referralCode
  ) external;

  function withdraw(
    address _asset,
    uint256 _amount,
    address _to
  ) external;

  function borrow(
    address _asset,
    uint256 _amount,
    uint256 _interestRateMode,
    uint16 _referralCode,
    address _onBehalfOf
  ) external;

  function repay(
    address _asset,
    uint256 _amount,
    uint256 _rateMode,
    address _onBehalfOf
  ) external;

  function setUserUseReserveAsCollateral(address _asset, bool _useAsCollateral) external;
}

File 9 of 12 : IAaveLendingPoolProvider.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IAaveLendingPoolProvider {
  function getLendingPool() external view returns (address);
}

File 10 of 12 : LibUniversalERC20FTM.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

library LibUniversalERC20FTM {
  using SafeERC20 for IERC20;

  IERC20 private constant _FTM_ADDRESS = IERC20(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF);
  IERC20 private constant _ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000);

  function isFTM(IERC20 token) internal pure returns (bool) {
    return (token == _ZERO_ADDRESS || token == _FTM_ADDRESS);
  }

  function univBalanceOf(IERC20 token, address account) internal view returns (uint256) {
    if (isFTM(token)) {
      return account.balance;
    } else {
      return token.balanceOf(account);
    }
  }

  function univTransfer(
    IERC20 token,
    address payable to,
    uint256 amount
  ) internal {
    if (amount > 0) {
      if (isFTM(token)) {
        (bool sent, ) = to.call{ value: amount }("");
        require(sent, "Failed to send Ether");
      } else {
        token.safeTransfer(to, amount);
      }
    }
  }

  function univApprove(
    IERC20 token,
    address to,
    uint256 amount
  ) internal {
    require(!isFTM(token), "Approve called on ETH");

    if (amount == 0) {
      token.safeApprove(to, 0);
    } else {
      uint256 allowance = token.allowance(address(this), to);
      if (allowance < amount) {
        if (allowance > 0) {
          token.safeApprove(to, 0);
        }
        token.safeApprove(to, amount);
      }
    }
  }
}

File 11 of 12 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 12 of 12 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getBorrowBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_who","type":"address"}],"name":"getBorrowBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getBorrowRateFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getDepositBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"payback","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"}]

608060405234801561001057600080fd5b506115dc806100206000396000f3fe60806040526004361061007b5760003560e01c80637d6af0791161004e5780637d6af079146100f1578063ed05ae7814610111578063f17cca4a14610131578063f3fef3a3146101515761007b565b806335ed8ab81461008057806347e7ef24146100955780634b8a3529146100a857806351724377146100bb575b600080fd5b61009361008e3660046110ed565b610164565b005b6100936100a33660046110ed565b61030b565b6100936100b63660046110ed565b6104f3565b3480156100c757600080fd5b506100db6100d63660046110b5565b6106ce565b6040516100e89190611559565b60405180910390f35b3480156100fd57600080fd5b506100db61010c36600461107d565b6107a7565b34801561011d57600080fd5b506100db61012c36600461107d565b610881565b34801561013d57600080fd5b506100db61014c36600461107d565b610959565b61009361015f3660046110ed565b610a24565b600061016e610b21565b6001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101a657600080fd5b505afa1580156101ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101de9190611099565b905060006101ea610b39565b6001600160a01b0316846001600160a01b031614905060008161020d5784610215565b610215610b44565b9050811561027257806001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b15801561025857600080fd5b505af115801561026c573d6000803e3d6000fd5b50505050505b6102866001600160a01b0382168486610b5c565b6040517f573ade810000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063573ade81906102d29084908890600290309060040161130b565b600060405180830381600087803b1580156102ec57600080fd5b505af1158015610300573d6000803e3d6000fd5b505050505050505050565b6000610315610b21565b6001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561034d57600080fd5b505afa158015610361573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103859190611099565b90506000610391610b39565b6001600160a01b0316846001600160a01b03161490506000816103b457846103bc565b6103bc610b44565b9050811561041957806001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b1580156103ff57600080fd5b505af1158015610413573d6000803e3d6000fd5b50505050505b61042d6001600160a01b0382168486610b5c565b6040517fe8eda9df0000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063e8eda9df90610479908490889030906000906004016112de565b600060405180830381600087803b15801561049357600080fd5b505af11580156104a7573d6000803e3d6000fd5b50506040517f5a3b74b90000000000000000000000000000000000000000000000000000000081526001600160a01b0386169250635a3b74b991506102d2908490600190600401611287565b60006104fd610b21565b6001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561053557600080fd5b505afa158015610549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056d9190611099565b90506000610579610b39565b6001600160a01b0316846001600160a01b031614905060008161059c57846105a4565b6105a4610b44565b6040517fa415bcad0000000000000000000000000000000000000000000000000000000081529091506001600160a01b0384169063a415bcad906105f690849088906002906000903090600401611336565b600060405180830381600087803b15801561061057600080fd5b505af1158015610624573d6000803e3d6000fd5b5050505081156106c7576000610638610c6b565b905061064e6001600160a01b0383168287610c83565b6040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b03821690632e1a7d4d90610693908890600401611559565b600060405180830381600087803b1580156106ad57600080fd5b505af11580156106c1573d6000803e3d6000fd5b50505050505b5050505050565b6000806106d9610d2d565b905060006106e5610b39565b6001600160a01b0316856001600160a01b03161490506000816107085785610710565b610710610b44565b90506000836001600160a01b03166328dd2d0183886040518363ffffffff1660e01b815260040161074292919061126d565b6101206040518083038186803b15801561075b57600080fd5b505afa15801561076f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079391906111c4565b50949e9d5050505050505050505050505050565b6000806107b2610d2d565b905060006107be610b39565b6001600160a01b0316846001600160a01b03161490506000816107e157846107e9565b6107e9610b44565b90506000836001600160a01b03166328dd2d0183336040518363ffffffff1660e01b815260040161081b92919061126d565b6101206040518083038186803b15801561083457600080fd5b505afa158015610848573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086c91906111c4565b50949b5050505050505050505050505b919050565b60008061088c610d2d565b90506000610898610b39565b6001600160a01b0316846001600160a01b03161490506000816108bb57846108c3565b6108c3610b44565b90506000836001600160a01b03166328dd2d0183336040518363ffffffff1660e01b81526004016108f592919061126d565b6101206040518083038186803b15801561090e57600080fd5b505afa158015610922573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094691906111c4565b50969d9c50505050505050505050505050565b600080610964610d2d565b90506000816001600160a01b03166335ea6a7561097f610b39565b6001600160a01b0316866001600160a01b03161461099d57856109a5565b6109a5610b44565b6040518263ffffffff1660e01b81526004016109c19190611259565b6101406040518083038186803b1580156109da57600080fd5b505afa1580156109ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a12919061114a565b50939c9b505050505050505050505050565b6000610a2e610b21565b6001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6657600080fd5b505afa158015610a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9e9190611099565b90506000610aaa610b39565b6001600160a01b0316846001600160a01b0316149050600081610acd5784610ad5565b610ad5610b44565b6040517f69328dec0000000000000000000000000000000000000000000000000000000081529091506001600160a01b038416906369328dec906105f6908490889030906004016112bb565b736c793c628fe2b480c5e6fb7957dda4b9291f9c9b90565b6001600160a01b0390565b7321be370d5312f44cb42ce377bc9b8a0cef1a4c8390565b610b6583610d45565b15610b8b5760405162461bcd60e51b8152600401610b8290611431565b60405180910390fd5b80610baa57610ba56001600160a01b038416836000610d6b565b610c66565b604051636eb1769f60e11b81526000906001600160a01b0385169063dd62ed3e90610bdb903090879060040161126d565b60206040518083038186803b158015610bf357600080fd5b505afa158015610c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b9190611132565b905081811015610c64578015610c5057610c506001600160a01b038516846000610d6b565b610c646001600160a01b0385168484610d6b565b505b505050565b73ee94a39d185329d8c46dea726e01f91641e5734690565b8015610c6657610c9283610d45565b15610d19576000826001600160a01b031682604051610cb090611256565b60006040518083038185875af1925050503d8060008114610ced576040519150601f19603f3d011682016040523d82523d6000602084013e610cf2565b606091505b5050905080610d135760405162461bcd60e51b8152600401610b829061139d565b50610c66565b610c666001600160a01b0384168383610e92565b73f3b0611e2e4d2cd6ab4bb3e01ade211c3f42a8c390565b60006001600160a01b0382161580610d6557506001600160a01b03828116145b92915050565b801580610df35750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90610da1903090869060040161126d565b60206040518083038186803b158015610db957600080fd5b505afa158015610dcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df19190611132565b155b610e0f5760405162461bcd60e51b8152600401610b82906114fc565b610c668363095ea7b360e01b8484604051602401610e2e9291906112a2565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610eb1565b610c668363a9059cbb60e01b8484604051602401610e2e9291906112a2565b6000610f06826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610f409092919063ffffffff16565b805190915015610c665780806020019051810190610f249190611118565b610c665760405162461bcd60e51b8152600401610b829061149f565b6060610f4f8484600085610f59565b90505b9392505050565b606082471015610f7b5760405162461bcd60e51b8152600401610b82906113d4565b610f8485611019565b610fa05760405162461bcd60e51b8152600401610b8290611468565b600080866001600160a01b03168587604051610fbc919061123a565b60006040518083038185875af1925050503d8060008114610ff9576040519150601f19603f3d011682016040523d82523d6000602084013e610ffe565b606091505b509150915061100e82828661101f565b979650505050505050565b3b151590565b6060831561102e575081610f52565b82511561103e5782518084602001fd5b8160405162461bcd60e51b8152600401610b82919061136a565b8051801515811461087c57600080fd5b805164ffffffffff8116811461087c57600080fd5b60006020828403121561108e578081fd5b8135610f528161158e565b6000602082840312156110aa578081fd5b8151610f528161158e565b600080604083850312156110c7578081fd5b82356110d28161158e565b915060208301356110e28161158e565b809150509250929050565b600080604083850312156110ff578182fd5b823561110a8161158e565b946020939093013593505050565b600060208284031215611129578081fd5b610f5282611058565b600060208284031215611143578081fd5b5051919050565b6000806000806000806000806000806101408b8d031215611169578586fd5b8a51995060208b0151985060408b0151975060608b0151965060808b0151955060a08b0151945060c08b0151935060e08b015192506101008b015191506111b36101208c01611068565b90509295989b9194979a5092959850565b60008060008060008060008060006101208a8c0312156111e2578485fd5b8951985060208a0151975060408a0151965060608a0151955060808a0151945060a08a0151935060c08a0151925061121c60e08b01611068565b915061122b6101008b01611058565b90509295985092959850929598565b6000825161124c818460208701611562565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039290921682521515602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b03948516815260208101939093529216604082015261ffff909116606082015260800190565b6001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b6001600160a01b0395861681526020810194909452604084019290925261ffff166060830152909116608082015260a00190565b6000602082528251806020840152611389816040850160208701611562565b601f01601f19169190910160400192915050565b60208082526014908201527f4661696c656420746f2073656e64204574686572000000000000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526015908201527f417070726f76652063616c6c6564206f6e204554480000000000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b90815260200190565b60005b8381101561157d578181015183820152602001611565565b83811115610c645750506000910152565b6001600160a01b03811681146115a357600080fd5b5056fea264697066735822122045153479911e3729ebab4fdf58b4c390bcefabb413fabe7eef2e6fdfaec33d7e64736f6c63430008000033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.