Contract 0x4B58bbB4Ff947315b558904fDcEbbdA65b9523aD

Contract Overview

Balance:
0 Ether
Txn Hash Method
Block
From
To
Value
0xda01943db72cf0d83b2c6cec6feb06186783b1ea0fd7049f2e6fd7255d2bf60eAccept Ownership243386242021-04-19 21:37:2028 days 22 hrs ago0x73570075092502472e4b61a7058df1a4a1db12f2 IN  0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether0.0000219761
0x04ca909baf18e58df6cde3cccc5a8c978379459c4a126f22f10a3669dcd8886cNominate New Own...243376892021-04-19 20:34:0428 days 23 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether0.0000447711
0xe1300d249c2258160084a17c7613b84a7328c9ec506d3969aa03b0b72531e628Set Associated C...229977072021-01-13 15:48:20125 days 4 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether0.0000596542
0x7f33eb42c10a41d16df58aac8b45f26a63d946ab440d68a6896cf423201cee530x60806040229977052021-01-13 15:48:04125 days 4 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  Contract Creation0 Ether0.0016135542
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x633e591d258a7d7a75d51dc9c77888bbb1664b37fd16f7938ce2690cc34d4f09248678902021-05-16 10:33:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x633e591d258a7d7a75d51dc9c77888bbb1664b37fd16f7938ce2690cc34d4f09248678902021-05-16 10:33:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x633e591d258a7d7a75d51dc9c77888bbb1664b37fd16f7938ce2690cc34d4f09248678902021-05-16 10:33:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe52e01e346623b75bebd861fffd55517a78f958d5b8433c5e999e893ec6aed83248678752021-05-16 10:32:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe52e01e346623b75bebd861fffd55517a78f958d5b8433c5e999e893ec6aed83248678752021-05-16 10:32:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe52e01e346623b75bebd861fffd55517a78f958d5b8433c5e999e893ec6aed83248678752021-05-16 10:32:402 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x3e6284ed8a41e752523f6923da178d6495f7c18a6feccc9d1119f3f9af45b4c9248678582021-05-16 10:31:322 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x3e6284ed8a41e752523f6923da178d6495f7c18a6feccc9d1119f3f9af45b4c9248678582021-05-16 10:31:322 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x3e6284ed8a41e752523f6923da178d6495f7c18a6feccc9d1119f3f9af45b4c9248678582021-05-16 10:31:322 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xd7863a30ab9d911f64e15aff63d9208957fdf6469435fa39b18e3747d51b7e3f248678512021-05-16 10:31:042 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xd7863a30ab9d911f64e15aff63d9208957fdf6469435fa39b18e3747d51b7e3f248678512021-05-16 10:31:042 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xd7863a30ab9d911f64e15aff63d9208957fdf6469435fa39b18e3747d51b7e3f248678512021-05-16 10:31:042 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe09fa5c4e275729b6b4b18050cf7b349d8733f158aabd929b1fd7c05bb57e757248678422021-05-16 10:30:282 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe09fa5c4e275729b6b4b18050cf7b349d8733f158aabd929b1fd7c05bb57e757248678422021-05-16 10:30:282 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0xe09fa5c4e275729b6b4b18050cf7b349d8733f158aabd929b1fd7c05bb57e757248678422021-05-16 10:30:282 days 10 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x37825717354997d9409621fe92b7eaff6abbe608df310f6c727fc8ca6f82ab96246538862021-05-04 17:26:0814 days 3 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x37825717354997d9409621fe92b7eaff6abbe608df310f6c727fc8ca6f82ab96246538862021-05-04 17:26:0814 days 3 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x37825717354997d9409621fe92b7eaff6abbe608df310f6c727fc8ca6f82ab96246538862021-05-04 17:26:0814 days 3 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x8ffbc17ac7e400eac8a319a879e7accb04bfbffeeaa77717c1119a64ab5e3bd4243013792021-04-17 18:36:1631 days 1 hr ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x8ffbc17ac7e400eac8a319a879e7accb04bfbffeeaa77717c1119a64ab5e3bd4243013792021-04-17 18:36:1631 days 1 hr ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x8ffbc17ac7e400eac8a319a879e7accb04bfbffeeaa77717c1119a64ab5e3bd4243013792021-04-17 18:36:1631 days 1 hr ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x5904b4f34e22de7597b71106f5a809638327fbf55b522b1dc6a4154059181ab8243013472021-04-17 18:33:2431 days 2 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x5904b4f34e22de7597b71106f5a809638327fbf55b522b1dc6a4154059181ab8243013472021-04-17 18:33:2431 days 2 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x5904b4f34e22de7597b71106f5a809638327fbf55b522b1dc6a4154059181ab8243013472021-04-17 18:33:2431 days 2 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
0x0d5b15dd9cf163e154da2834edb5f18a5b042387cc4d5304aaaf859463316cc9243013242021-04-17 18:31:2431 days 2 hrs ago 0xdfd01d828d34982dfe882b9fdc6dc17fcca33c25 0x4b58bbb4ff947315b558904fdcebbda65b9523ad0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Similar Match)
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0x04C3f6207BE48De777967eB1886469E4E268FE07

Contract Name:
CollateralState

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
/**
 *Submitted for verification at Etherscan.io on 2021-01-13
*/

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Synthetix: CollateralState.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/CollateralState.sol
* Docs: https://docs.synthetix.io/contracts/CollateralState
*
* Contract Dependencies: 
*	- ICollateralLoan
*	- Owned
*	- State
* Libraries: 
*	- SafeDecimalMath
*	- SafeMath
*
* MIT License
* ===========
*
* Copyright (c) 2021 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/



pragma solidity ^0.5.16;


// https://docs.synthetix.io/contracts/source/contracts/owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}


// Inheritance


// https://docs.synthetix.io/contracts/source/contracts/state
contract State is Owned {
    // the address of the contract that can modify variables
    // this can only be changed by the owner of this contract
    address public associatedContract;

    constructor(address _associatedContract) internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");

        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== SETTERS ========== */

    // Change the associated contract to a new address
    function setAssociatedContract(address _associatedContract) external onlyOwner {
        associatedContract = _associatedContract;
        emit AssociatedContractUpdated(_associatedContract);
    }

    /* ========== MODIFIERS ========== */

    modifier onlyAssociatedContract {
        require(msg.sender == associatedContract, "Only the associated contract can perform this action");
        _;
    }

    /* ========== EVENTS ========== */

    event AssociatedContractUpdated(address associatedContract);
}


pragma experimental ABIEncoderV2;


interface ICollateralLoan {
    struct Loan {
        // ID for the loan
        uint id;
        //  Acccount that created the loan
        address payable account;
        //  Amount of collateral deposited
        uint collateral;
        // The synth that was borowed
        bytes32 currency;
        //  Amount of synths borrowed
        uint amount;
        // Indicates if the position was short sold
        bool short;
        // interest amounts accrued
        uint accruedInterest;
        // last interest index
        uint interestIndex;
        // time of last interaction.
        uint lastInteraction;
    }
}


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // 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-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0, "SafeMath: modulo by zero");
        return a % b;
    }
}


// Libraries


// https://docs.synthetix.io/contracts/source/libraries/safedecimalmath
library SafeDecimalMath {
    using SafeMath for uint;

    /* Number of decimal places in the representations. */
    uint8 public constant decimals = 18;
    uint8 public constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint public constant UNIT = 10**uint(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
    uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);

    /**
     * @return Provides an interface to UNIT.
     */
    function unit() external pure returns (uint) {
        return UNIT;
    }

    /**
     * @return Provides an interface to PRECISE_UNIT.
     */
    function preciseUnit() external pure returns (uint) {
        return PRECISE_UNIT;
    }

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y) / UNIT;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of the specified precision unit.
     *
     * @dev The operands should be in the form of a the specified unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function _multiplyDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a precise unit.
     *
     * @dev The operands should be in the precise unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a standard unit.
     *
     * @dev The operands should be in the standard unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint x, uint y) internal pure returns (uint) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * decimal in the precision unit specified in the parameter.
     *
     * @dev y is divided after the product of x and the specified precision unit
     * is evaluated, so the product of x and the specified precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function _divideDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        uint resultTimesTen = x.mul(precisionUnit * 10).div(y);

        if (resultTimesTen % 10 >= 5) {
            resultTimesTen += 10;
        }

        return resultTimesTen / 10;
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * standard precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and the standard precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * high precision decimal.
     *
     * @dev y is divided after the product of x and the high precision unit
     * is evaluated, so the product of x and the high precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
        uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }
}


// Inheritance


// Libraries


contract CollateralState is Owned, State, ICollateralLoan {
    using SafeMath for uint;
    using SafeDecimalMath for uint;

    mapping(address => Loan[]) public loans;

    constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}

    /* ========== VIEWS ========== */
    // If we do not find the loan, this returns a struct with 0'd values.
    function getLoan(address account, uint256 loanID) external view returns (Loan memory) {
        Loan[] memory accountLoans = loans[account];
        for (uint i = 0; i < accountLoans.length; i++) {
            if (accountLoans[i].id == loanID) {
                return (accountLoans[i]);
            }
        }
    }

    function getNumLoans(address account) external view returns (uint numLoans) {
        return loans[account].length;
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    function createLoan(Loan memory loan) public onlyAssociatedContract {
        loans[loan.account].push(loan);
    }

    function updateLoan(Loan memory loan) public onlyAssociatedContract {
        Loan[] storage accountLoans = loans[loan.account];
        for (uint i = 0; i < accountLoans.length; i++) {
            if (accountLoans[i].id == loan.id) {
                loans[loan.account][i] = loan;
            }
        }
    }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_associatedContract","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"associatedContract","type":"address"}],"name":"AssociatedContractUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"associatedContract","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"internalType":"struct ICollateralLoan.Loan","name":"loan","type":"tuple"}],"name":"createLoan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"loanID","type":"uint256"}],"name":"getLoan","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"internalType":"struct ICollateralLoan.Loan","name":"","type":"tuple"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getNumLoans","outputs":[{"internalType":"uint256","name":"numLoans","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"loans","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_associatedContract","type":"address"}],"name":"setAssociatedContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"bytes32","name":"currency","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"short","type":"bool"},{"internalType":"uint256","name":"accruedInterest","type":"uint256"},{"internalType":"uint256","name":"interestIndex","type":"uint256"},{"internalType":"uint256","name":"lastInteraction","type":"uint256"}],"internalType":"struct ICollateralLoan.Loan","name":"loan","type":"tuple"}],"name":"updateLoan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162000f6c38038062000f6c83398101604081905262000034916200015a565b80826001600160a01b038116620000685760405162461bcd60e51b81526004016200005f9062000267565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0383161781556040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91620000b59184906200022f565b60405180910390a1506000546001600160a01b0316620000e95760405162461bcd60e51b81526004016200005f9062000255565b600280546001600160a01b0319166001600160a01b0383161790556040517f73f20cff579e8a4086fa607db83867595f1b6a798e718c0bfa0b94a404128e0390620001369083906200021f565b60405180910390a1505050620002c2565b80516200015481620002a8565b92915050565b600080604083850312156200016e57600080fd5b60006200017c858562000147565b92505060206200018f8582860162000147565b9150509250929050565b620001a48162000294565b82525050565b620001a48162000282565b6000620001c460118362000279565b7013dddb995c881b5d5cdd081899481cd95d607a1b815260200192915050565b6000620001f360198362000279565b7f4f776e657220616464726573732063616e6e6f74206265203000000000000000815260200192915050565b60208101620001548284620001aa565b604081016200023f828562000199565b6200024e6020830184620001aa565b9392505050565b602080825281016200015481620001b5565b602080825281016200015481620001e4565b90815260200190565b60006001600160a01b03821662000154565b600062000154826000620001548262000282565b620002b38162000282565b8114620002bf57600080fd5b50565b610c9a80620002d26000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c806379ba50971161007157806379ba50971461011a5780638da5cb5b1461012257806398c61c371461012a578063a1c5158614610152578063aefc4ccb14610172578063e0b6adbc1461017a576100a9565b80631627540c146100ae57806344dce41c146100c357806352f445ca146100d657806353a47bb7146100e95780635c33120414610107575b600080fd5b6100c16100bc36600461088c565b61019a565b005b6100c16100d13660046108ec565b6101f8565b6100c16100e436600461088c565b610352565b6100f16103a5565b6040516100fe9190610adc565b60405180910390f35b6100c16101153660046108ec565b6103b4565b6100c161048d565b6100f1610529565b61013d6101383660046108b2565b610538565b6040516100fe99989796959493929190610b59565b6101656101603660046108b2565b6105ad565b6040516100fe9190610b3c565b6100f16106e4565b61018d61018836600461088c565b6106f3565b6040516100fe9190610b4b565b6101a261070e565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906101ed908390610adc565b60405180910390a150565b6002546001600160a01b0316331461022b5760405162461bcd60e51b815260040161022290610b2c565b60405180910390fd5b6020808201516001600160a01b03166000908152600390915260408120905b815481101561034d57826000015182828154811061026457fe5b906000526020600020906009020160000154141561034557826003600085602001516001600160a01b03166001600160a01b0316815260200190815260200160002082815481106102b157fe5b6000918252602091829020835160099290920201908155908201516001820180546001600160a01b0319166001600160a01b0390921691909117905560408201516002820155606082015160038201556080820151600482015560a082015160058201805460ff191691151591909117905560c0820151600682015560e08201516007820155610100909101516008909101555b60010161024a565b505050565b61035a61070e565b600280546001600160a01b0319166001600160a01b0383161790556040517f73f20cff579e8a4086fa607db83867595f1b6a798e718c0bfa0b94a404128e03906101ed908390610adc565b6001546001600160a01b031681565b6002546001600160a01b031633146103de5760405162461bcd60e51b815260040161022290610b2c565b602081810180516001600160a01b03908116600090815260038085526040808320805460018082018355918552969093208751600990970201958655935191850180546001600160a01b03191692909316919091179091559083015160028301556060830151908201556080820151600482015560a082015160058201805460ff191691151591909117905560c0820151600682015560e0820151600782015561010090910151600890910155565b6001546001600160a01b031633146104b75760405162461bcd60e51b815260040161022290610b0c565b6000546001546040517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c926104fa926001600160a01b0391821692911690610aea565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6000546001600160a01b031681565b6003602052816000526040600020818154811061055157fe5b60009182526020909120600990910201805460018201546002830154600384015460048501546005860154600687015460078801546008909801549699506001600160a01b03909516975092959194909360ff90931692919089565b6105b561073a565b6001600160a01b0383166000908152600360209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610683576000848152602090819020604080516101208101825260098602909201805483526001808201546001600160a01b0316848601526002820154928401929092526003810154606084015260048101546080840152600581015460ff16151560a0840152600681015460c0840152600781015460e08401526008015461010083015290835290920191016105ed565b509293506000925050505b81518110156106db57838282815181106106a457fe5b60200260200101516000015114156106d3578181815181106106c257fe5b6020026020010151925050506106de565b60010161068e565b50505b92915050565b6002546001600160a01b031681565b6001600160a01b031660009081526003602052604090205490565b6000546001600160a01b031633146107385760405162461bcd60e51b815260040161022290610b1c565b565b6040518061012001604052806000815260200160006001600160a01b031681526020016000815260200160008019168152602001600081526020016000151581526020016000815260200160008152602001600081525090565b80356106de81610c2e565b80356106de81610c45565b80356106de81610c4e565b600061012082840312156107c857600080fd5b6107d3610120610bdf565b905060006107e184846107aa565b82525060206107f284848301610794565b6020830152506040610806848285016107aa565b604083015250606061081a848285016107aa565b606083015250608061082e848285016107aa565b60808301525060a06108428482850161079f565b60a08301525060c0610856848285016107aa565b60c08301525060e061086a848285016107aa565b60e08301525061010061087f848285016107aa565b6101008301525092915050565b60006020828403121561089e57600080fd5b60006108aa8484610794565b949350505050565b600080604083850312156108c557600080fd5b60006108d18585610794565b92505060206108e2858286016107aa565b9150509250929050565b600061012082840312156108ff57600080fd5b60006108aa84846107b5565b61091481610c0f565b82525050565b61091481610c1a565b61091481610c1f565b6000610939603583610c06565b7f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7581527402063616e20616363657074206f776e65727368697605c1b602082015260400192915050565b6000610990602f83610c06565b7f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726681526e37b936903a3434b99030b1ba34b7b760891b602082015260400192915050565b60006109e1603483610c06565b7f4f6e6c7920746865206173736f63696174656420636f6e74726163742063616e815273103832b93337b936903a3434b99030b1ba34b7b760611b602082015260400192915050565b8051610120830190610a3c8482610923565b506020820151610a4f602085018261090b565b506040820151610a626040850182610923565b506060820151610a756060850182610923565b506080820151610a886080850182610923565b5060a0820151610a9b60a085018261091a565b5060c0820151610aae60c0850182610923565b5060e0820151610ac160e0850182610923565b50610100820151610ad6610100850182610923565b50505050565b602081016106de828461090b565b60408101610af8828561090b565b610b05602083018461090b565b9392505050565b602080825281016106de8161092c565b602080825281016106de81610983565b602080825281016106de816109d4565b61012081016106de8284610a2a565b602081016106de8284610923565b6101208101610b68828c610923565b610b75602083018b61090b565b610b82604083018a610923565b610b8f6060830189610923565b610b9c6080830188610923565b610ba960a083018761091a565b610bb660c0830186610923565b610bc360e0830185610923565b610bd1610100830184610923565b9a9950505050505050505050565b60405181810167ffffffffffffffff81118282101715610bfe57600080fd5b604052919050565b90815260200190565b60006106de82610c22565b151590565b90565b6001600160a01b031690565b610c3781610c0f565b8114610c4257600080fd5b50565b610c3781610c1a565b610c3781610c1f56fea365627a7a72315820013790680977a1d5d556326b132fbc33c26b7a3445eb646fe167987d94f609726c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882

Library Used

SafeDecimalMath : 0x1a60e2e2a8be0bc2b6381dd31fd3fd5f9a28de4c

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading