[
    {
        "inputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "constructor"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "user",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "lender",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "collateralToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "newPrincipal",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "newCollateral",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "interestRate",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "interestDuration",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "collateralToLoanRate",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "currentMargin",
                "type": "uint256"
            }
        ],
        "name": "Borrow",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "delegator",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "delegated",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "bool",
                "name": "isActive",
                "type": "bool"
            }
        ],
        "name": "DelegatedManagerSet",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": false,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "depositAmount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "rate",
                "type": "uint256"
            }
        ],
        "name": "DepositCollateral",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "receiver",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "token",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "feeRebatePercent",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "basisPoint",
                "type": "uint256"
            }
        ],
        "name": "EarnReward",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "receiver",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "token",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "feeRebatePercent",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "basisPoint",
                "type": "uint256"
            }
        ],
        "name": "EarnRewardFail",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "user",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "sourceToken",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "destToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "sourceAmount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "destAmount",
                "type": "uint256"
            }
        ],
        "name": "ExternalSwap",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "sourceToken",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "destToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "borrower",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "sourceAmount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "destAmount",
                "type": "uint256"
            }
        ],
        "name": "LoanSwap",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "previousOwner",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "OwnershipTransferred",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "payer",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "token",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "PayBorrowingFee",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "interestToken",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "lender",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "effectiveInterest",
                "type": "uint256"
            }
        ],
        "name": "PayInterestTransfer",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "payer",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "token",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "PayLendingFee",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "payer",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "token",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "PayTradingFee",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "prevModuleContractAddress",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "newModuleContractAddress",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "module",
                "type": "bytes32"
            }
        ],
        "name": "ProtocolModuleContractReplaced",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "user",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "lender",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "collateralToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "positionSize",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "borrowedAmount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "interestRate",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "settlementDate",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "entryPrice",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "entryLeverage",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "currentLeverage",
                "type": "uint256"
            }
        ],
        "name": "Trade",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "asset",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "from",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "VaultDeposit",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "asset",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "to",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "VaultWithdraw",
        "type": "event"
    },
    {
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "fallback"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "admin",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "affiliateFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "affiliateRewardsHeld",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "affiliateTradingTokenFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "affiliatesReferrerBalances",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "affiliatesUserReferrer",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "borrowerNonce",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            },
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            }
        ],
        "name": "borrowerOrders",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "lockedAmount",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestRate",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "minLoanTerm",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "maxLoanTerm",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "createdTimestamp",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "expirationTimestamp",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "borrowingFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "borrowingFeeTokensHeld",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "borrowingFeeTokensPaid",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            },
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "delegatedManagers",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "internalType": "uint256",
                "name": "depositAmount",
                "type": "uint256"
            }
        ],
        "name": "depositCollateral",
        "outputs": [],
        "payable": true,
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "internalType": "uint256",
                "name": "depositAmount",
                "type": "uint256"
            },
            {
                "internalType": "bool",
                "name": "useCollateral",
                "type": "bool"
            },
            {
                "internalType": "bytes",
                "name": "",
                "type": "bytes"
            }
        ],
        "name": "extendLoanDuration",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "secondsExtended",
                "type": "uint256"
            }
        ],
        "payable": true,
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "feeRebatePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "feesController",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "uint256",
                "name": "start",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "count",
                "type": "uint256"
            },
            {
                "internalType": "bool",
                "name": "unsafeOnly",
                "type": "bool"
            }
        ],
        "name": "getActiveLoans",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "bytes32",
                        "name": "loanId",
                        "type": "bytes32"
                    },
                    {
                        "internalType": "address",
                        "name": "loanToken",
                        "type": "address"
                    },
                    {
                        "internalType": "address",
                        "name": "collateralToken",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "principal",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "collateral",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestOwedPerDay",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestDepositRemaining",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startRate",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maintenanceMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "currentMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLoanTerm",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "endTimestamp",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLiquidatable",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxSeizable",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LoanMaintenance.LoanReturnData[]",
                "name": "loansData",
                "type": "tuple[]"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "lender",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            }
        ],
        "name": "getLenderInterestData",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "interestPaid",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestPaidDate",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestOwedPerDay",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestUnPaid",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestFeePercent",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "principalTotal",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            }
        ],
        "name": "getLoan",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "bytes32",
                        "name": "loanId",
                        "type": "bytes32"
                    },
                    {
                        "internalType": "address",
                        "name": "loanToken",
                        "type": "address"
                    },
                    {
                        "internalType": "address",
                        "name": "collateralToken",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "principal",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "collateral",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestOwedPerDay",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestDepositRemaining",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startRate",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maintenanceMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "currentMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLoanTerm",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "endTimestamp",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLiquidatable",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxSeizable",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LoanMaintenance.LoanReturnData",
                "name": "loanData",
                "type": "tuple"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            }
        ],
        "name": "getLoanInterestData",
        "outputs": [
            {
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "interestOwedPerDay",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestDepositTotal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestDepositRemaining",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "user",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "start",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "count",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "loanType",
                "type": "uint256"
            },
            {
                "internalType": "bool",
                "name": "isLender",
                "type": "bool"
            },
            {
                "internalType": "bool",
                "name": "unsafeOnly",
                "type": "bool"
            }
        ],
        "name": "getUserLoans",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "bytes32",
                        "name": "loanId",
                        "type": "bytes32"
                    },
                    {
                        "internalType": "address",
                        "name": "loanToken",
                        "type": "address"
                    },
                    {
                        "internalType": "address",
                        "name": "collateralToken",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "principal",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "collateral",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestOwedPerDay",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "interestDepositRemaining",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startRate",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "startMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maintenanceMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "currentMargin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLoanTerm",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "endTimestamp",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxLiquidatable",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "maxSeizable",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LoanMaintenance.LoanReturnData[]",
                "name": "loansData",
                "type": "tuple[]"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "address",
                "name": "target",
                "type": "address"
            }
        ],
        "name": "initialize",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "isOwner",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "lenderInterest",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "principalTotal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "owedPerDay",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "owedTotal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "paidTotal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "updatedTimestamp",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            },
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            }
        ],
        "name": "lenderOrders",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "lockedAmount",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestRate",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "minLoanTerm",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "maxLoanTerm",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "createdTimestamp",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "expirationTimestamp",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "lendingFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "lendingFeeTokensHeld",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "lendingFeeTokensPaid",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "liquidationIncentivePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            }
        ],
        "name": "loanInterest",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "owedPerDay",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "depositTotal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "updatedTimestamp",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            }
        ],
        "name": "loanParams",
        "outputs": [
            {
                "internalType": "bytes32",
                "name": "id",
                "type": "bytes32"
            },
            {
                "internalType": "bool",
                "name": "active",
                "type": "bool"
            },
            {
                "internalType": "address",
                "name": "owner",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "collateralToken",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "minInitialMargin",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "maintenanceMargin",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "maxLoanTerm",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "loanPoolToUnderlying",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "",
                "type": "bytes32"
            }
        ],
        "name": "loans",
        "outputs": [
            {
                "internalType": "bytes32",
                "name": "id",
                "type": "bytes32"
            },
            {
                "internalType": "bytes32",
                "name": "loanParamsId",
                "type": "bytes32"
            },
            {
                "internalType": "bytes32",
                "name": "pendingTradesId",
                "type": "bytes32"
            },
            {
                "internalType": "bool",
                "name": "active",
                "type": "bool"
            },
            {
                "internalType": "uint256",
                "name": "principal",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "collateral",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "startTimestamp",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "endTimestamp",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "startMargin",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "startRate",
                "type": "uint256"
            },
            {
                "internalType": "address",
                "name": "borrower",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "lender",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "lockedSOVAddress",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "bytes4",
                "name": "",
                "type": "bytes4"
            }
        ],
        "name": "logicTargets",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "maxDisagreement",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "maxSwapSize",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "minReferralsToPayout",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "owner",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "pause",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "priceFeeds",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "protocolAddress",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "protocolTokenAddress",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "protocolTokenHeld",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "protocolTokenPaid",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "internalType": "address",
                "name": "receiver",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "withdrawAmount",
                "type": "uint256"
            }
        ],
        "name": "reduceLoanDuration",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "secondsReduced",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "rolloverBaseReward",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "rolloverFlexFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "sourceBuffer",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "sovTokenAddress",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "sovrynSwapContractRegistryAddress",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "specialRebates",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "supportedTokens",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "swapsImpl",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "tradingFeePercent",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "tradingFeeTokensHeld",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "tradingFeeTokensPaid",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "transferOwnership",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "underlyingToLoanPool",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "name": "userNotFirstTradeFlag",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "address",
                "name": "loanToken",
                "type": "address"
            }
        ],
        "name": "withdrawAccruedInterest",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": false,
        "inputs": [
            {
                "internalType": "bytes32",
                "name": "loanId",
                "type": "bytes32"
            },
            {
                "internalType": "address",
                "name": "receiver",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "withdrawAmount",
                "type": "uint256"
            }
        ],
        "name": "withdrawCollateral",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "actualWithdrawAmount",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "wrbtcToken",
        "outputs": [
            {
                "internalType": "contract IWrbtcERC20",
                "name": "",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }
]
