@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
1,030 lines (1,029 loc) • 398 kB
JSON
{
"contractName": "Interest",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"author\":\"dYdX * Library for managing the interest rate and interest indexes of DolomiteMargin\",\"methods\":{},\"title\":\"Interest\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol\":\"Interest\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol\":{\"keccak256\":\"0xd9a348c2b1eec076609ba12bbec6b9c2e4ea135790a7ef4f5411feb050af2144\",\"urls\":[\"bzz-raw://d5bcff29e47d5cd02d7a9966e9f44c46ccbb4f0e4adfc4b0b86646880677db39\",\"dweb:/ipfs/QmRKfJD4FFM1AvTynSFNx1NcDg94o9SAcjz7dvMaJCfecp\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":{\"keccak256\":\"0x53f205f6a779d579be29faa9412c806a892b3e605fff092dfd9d14d936fa019f\",\"urls\":[\"bzz-raw://0ff936f89602a63b8e6a4eb4ce8f87673c0f45b7ce29694920905a3f0b5a6a69\",\"dweb:/ipfs/QmbYME9BeEvPC1ndV8EaUDX5fDMghLc3rocNUxFtgHmg8m\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol\":{\"keccak256\":\"0x141a0ecb4a746f0e5767df4b99dbe33c6362df507ae9d5c02da1c1c17bc26df3\",\"urls\":[\"bzz-raw://9ff03e64a8ce5231acde07788624bf8c7a8ff55d90b157fa32f62fa887a0eff0\",\"dweb:/ipfs/QmUVxxWeE954RDXbmHJAYnHsXcit6rSXGqZUigu8t9oH2z\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Require.sol\":{\"keccak256\":\"0x05a2a90b41b6a5f42f0a72da63d015fb0b406a9ba2172823352e522e8bf3a606\",\"urls\":[\"bzz-raw://19883f0c6d33266f756ec5c3d17539524aa24b993c46c33f8400801d09373a6c\",\"dweb:/ipfs/QmYX2fwK3vQQDSZLMrc5wMfeb8RWrcC9CGX8XECLty8QDk\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Time.sol\":{\"keccak256\":\"0x87ee8d3c1d6e315a116426d8c8fc6f083e220fd14dda27fad4e8d7cab3dc7305\",\"urls\":[\"bzz-raw://7c20f2c52da682c3b5917fb6a19e81f43699b1d13c62b569ed723f34da72e766\",\"dweb:/ipfs/QmbXWYXi67nHBVNDKYUpo2E9ZaEVcHLvmXQkpYLMm1d5Vm\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":{\"keccak256\":\"0xe1bab8c8799d83e86c7a49aaf815d8e3bc8d09562d46d44d921500db5e98de0e\",\"urls\":[\"bzz-raw://8ea3d0cc4fdab6dd9bba545a792170f939b342d8d1a7051c1c6365009af72658\",\"dweb:/ipfs/QmaLJgbavu88eEit6JPqfWnw6NmGBDZfveMXxumgWywBFG\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]}},\"version\":1}",
"bytecode": "0x60636023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a7231582011381e96ea1d93138099318433e824603721f252bc32c4c3c1e1e01048ee72f56c6578706572696d656e74616cf564736f6c63430005100040",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea365627a7a7231582011381e96ea1d93138099318433e824603721f252bc32c4c3c1e1e01048ee72f56c6578706572696d656e74616cf564736f6c63430005100040",
"sourceMap": "1037:5149:97:-;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24",
"deployedSourceMap": "1037:5149:97:-;;;;;;;;",
"source": "/*\n\n Copyright 2019 dYdX Trading Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.5.7;\npragma experimental ABIEncoderV2;\n\nimport { SafeMath } from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport { Decimal } from \"./Decimal.sol\";\nimport { DolomiteMarginMath } from \"./DolomiteMarginMath.sol\";\nimport { Time } from \"./Time.sol\";\nimport { Types } from \"./Types.sol\";\n\n\n/**\n * @title Interest\n * @author dYdX\n *\n * Library for managing the interest rate and interest indexes of DolomiteMargin\n */\nlibrary Interest {\n using DolomiteMarginMath for uint256;\n using SafeMath for uint256;\n\n // ============ Constants ============\n\n bytes32 private constant FILE = \"Interest\";\n uint64 constant BASE = 10**18;\n\n // ============ Structs ============\n\n struct Rate {\n uint256 value;\n }\n\n struct Index {\n uint112 borrow;\n uint112 supply;\n uint32 lastUpdate;\n }\n\n // ============ Library Functions ============\n\n /**\n * Get a new market Index based on the old index and market interest rate.\n * Calculate interest for borrowers by using the formula rate * time. Approximates\n * continuously-compounded interest when called frequently, but is much more\n * gas-efficient to calculate. For suppliers, the interest rate is adjusted by the earningsRate,\n * then prorated across all suppliers.\n *\n * @param index The old index for a market\n * @param rate The current interest rate of the market\n * @param totalPar The total supply and borrow par values of the market\n * @param earningsRate The portion of the interest that is forwarded to the suppliers\n * @return The updated index for a market\n */\n function calculateNewIndex(\n Index memory index,\n Rate memory rate,\n Types.TotalPar memory totalPar,\n Decimal.D256 memory earningsRate\n )\n internal\n view\n returns (Index memory)\n {\n (\n Types.Wei memory supplyWei,\n Types.Wei memory borrowWei\n ) = totalParToWei(totalPar, index);\n\n // get interest increase for borrowers\n uint32 currentTime = Time.currentTime();\n uint256 borrowInterest = rate.value.mul(uint256(currentTime).sub(index.lastUpdate));\n\n // get interest increase for suppliers\n uint256 supplyInterest;\n if (Types.isZero(supplyWei)) {\n supplyInterest = 0;\n } else {\n supplyInterest = Decimal.mul(borrowInterest, earningsRate);\n if (borrowWei.value < supplyWei.value) {\n // scale down the interest by the amount being supplied. Why? Because interest is only being paid on\n // the borrowWei, which means it's split amongst all of the supplyWei. Scaling it down normalizes it\n // for the suppliers to share what's being paid by borrowers\n supplyInterest = DolomiteMarginMath.getPartial(supplyInterest, borrowWei.value, supplyWei.value);\n }\n }\n assert(supplyInterest <= borrowInterest);\n\n return Index({\n borrow: DolomiteMarginMath.getPartial(index.borrow, borrowInterest, BASE).add(index.borrow).to112(),\n supply: DolomiteMarginMath.getPartial(index.supply, supplyInterest, BASE).add(index.supply).to112(),\n lastUpdate: currentTime\n });\n }\n\n function newIndex()\n internal\n view\n returns (Index memory)\n {\n return Index({\n borrow: BASE,\n supply: BASE,\n lastUpdate: Time.currentTime()\n });\n }\n\n /*\n * Convert a principal amount to a token amount given an index.\n */\n function parToWei(\n Types.Par memory input,\n Index memory index\n )\n internal\n pure\n returns (Types.Wei memory)\n {\n uint256 inputValue = uint256(input.value);\n if (input.sign) {\n return Types.Wei({\n sign: true,\n value: inputValue.getPartialRoundHalfUp(index.supply, BASE)\n });\n } else {\n return Types.Wei({\n sign: false,\n value: inputValue.getPartialRoundHalfUp(index.borrow, BASE)\n });\n }\n }\n\n /*\n * Convert a token amount to a principal amount given an index.\n */\n function weiToPar(\n Types.Wei memory input,\n Index memory index\n )\n internal\n pure\n returns (Types.Par memory)\n {\n if (input.sign) {\n return Types.Par({\n sign: true,\n value: input.value.getPartialRoundHalfUp(BASE, index.supply).to128()\n });\n } else {\n return Types.Par({\n sign: false,\n value: input.value.getPartialRoundHalfUp(BASE, index.borrow).to128()\n });\n }\n }\n\n /*\n * Convert the total supply and borrow principal amounts of a market to total supply and borrow\n * token amounts.\n */\n function totalParToWei(\n Types.TotalPar memory totalPar,\n Index memory index\n )\n internal\n pure\n returns (Types.Wei memory, Types.Wei memory)\n {\n Types.Par memory supplyPar = Types.Par({\n sign: true,\n value: totalPar.supply\n });\n Types.Par memory borrowPar = Types.Par({\n sign: false,\n value: totalPar.borrow\n });\n Types.Wei memory supplyWei = parToWei(supplyPar, index);\n Types.Wei memory borrowWei = parToWei(borrowPar, index);\n return (supplyWei, borrowWei);\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol",
"exportedSymbols": {
"Interest": [
27750
]
},
"id": 27751,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 27436,
"literals": [
"solidity",
"^",
"0.5",
".7"
],
"nodeType": "PragmaDirective",
"src": "603:23:97"
},
{
"id": 27437,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "627:33:97"
},
{
"absolutePath": "@openzeppelin/contracts/math/SafeMath.sol",
"file": "@openzeppelin/contracts/math/SafeMath.sol",
"id": 27439,
"nodeType": "ImportDirective",
"scope": 27751,
"sourceUnit": 37366,
"src": "662:69:97",
"symbolAliases": [
{
"foreign": 27438,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol",
"file": "./Decimal.sol",
"id": 27441,
"nodeType": "ImportDirective",
"scope": 27751,
"sourceUnit": 26024,
"src": "732:40:97",
"symbolAliases": [
{
"foreign": 27440,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol",
"file": "./DolomiteMarginMath.sol",
"id": 27443,
"nodeType": "ImportDirective",
"scope": 27751,
"sourceUnit": 26239,
"src": "773:62:97",
"symbolAliases": [
{
"foreign": 27442,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Time.sol",
"file": "./Time.sol",
"id": 27445,
"nodeType": "ImportDirective",
"scope": 27751,
"sourceUnit": 30730,
"src": "836:34:97",
"symbolAliases": [
{
"foreign": 27444,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Types.sol",
"file": "./Types.sol",
"id": 27447,
"nodeType": "ImportDirective",
"scope": 27751,
"sourceUnit": 31362,
"src": "871:36:97",
"symbolAliases": [
{
"foreign": 27446,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Interest\n@author dYdX\n * Library for managing the interest rate and interest indexes of DolomiteMargin",
"fullyImplemented": true,
"id": 27750,
"linearizedBaseContracts": [
27750
],
"name": "Interest",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 27450,
"libraryName": {
"contractScope": null,
"id": 27448,
"name": "DolomiteMarginMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 26238,
"src": "1066:18:97",
"typeDescriptions": {
"typeIdentifier": "t_contract$_DolomiteMarginMath_$26238",
"typeString": "library DolomiteMarginMath"
}
},
"nodeType": "UsingForDirective",
"src": "1060:37:97",
"typeName": {
"id": 27449,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1089:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"id": 27453,
"libraryName": {
"contractScope": null,
"id": 27451,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37365,
"src": "1108:8:97",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$37365",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "1102:27:97",
"typeName": {
"id": 27452,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1121:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"constant": true,
"id": 27456,
"name": "FILE",
"nodeType": "VariableDeclaration",
"scope": 27750,
"src": "1179:42:97",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 27454,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1179:7:97",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "496e746572657374",
"id": 27455,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1211:10:97",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_a9e726a46bb6b75baa5e96d97ac792fcb6c8bafb4da60c63703a1462f1ea04e0",
"typeString": "literal_string \"Interest\""
},
"value": "Interest"
},
"visibility": "private"
},
{
"constant": true,
"id": 27461,
"name": "BASE",
"nodeType": "VariableDeclaration",
"scope": 27750,
"src": "1227:29:97",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
},
"typeName": {
"id": 27457,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1227:6:97",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
},
"id": 27460,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "3130",
"id": 27458,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1250:2:97",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_10_by_1",
"typeString": "int_const 10"
},
"value": "10"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "3138",
"id": 27459,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1254:2:97",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_18_by_1",
"typeString": "int_const 18"
},
"value": "18"
},
"src": "1250:6:97",
"typeDescriptions": {
"typeIdentifier": "t_rational_1000000000000000000_by_1",
"typeString": "int_const 1000000000000000000"
}
},
"visibility": "internal"
},
{
"canonicalName": "Interest.Rate",
"id": 27464,
"members": [
{
"constant": false,
"id": 27463,
"name": "value",
"nodeType": "VariableDeclaration",
"scope": 27464,
"src": "1327:13:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 27462,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1327:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Rate",
"nodeType": "StructDefinition",
"scope": 27750,
"src": "1305:42:97",
"visibility": "public"
},
{
"canonicalName": "Interest.Index",
"id": 27471,
"members": [
{
"constant": false,
"id": 27466,
"name": "borrow",
"nodeType": "VariableDeclaration",
"scope": 27471,
"src": "1376:14:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 27465,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1376:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27468,
"name": "supply",
"nodeType": "VariableDeclaration",
"scope": 27471,
"src": "1400:14:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
},
"typeName": {
"id": 27467,
"name": "uint112",
"nodeType": "ElementaryTypeName",
"src": "1400:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint112",
"typeString": "uint112"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27470,
"name": "lastUpdate",
"nodeType": "VariableDeclaration",
"scope": 27471,
"src": "1424:17:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"typeName": {
"id": 27469,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "1424:6:97",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Index",
"nodeType": "StructDefinition",
"scope": 27750,
"src": "1353:95:97",
"visibility": "public"
},
{
"body": {
"id": 27591,
"nodeType": "Block",
"src": "2513:1420:97",
"statements": [
{
"assignments": [
27487,
27489
],
"declarations": [
{
"constant": false,
"id": 27487,
"name": "supplyWei",
"nodeType": "VariableDeclaration",
"scope": 27591,
"src": "2537:26:97",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei"
},
"typeName": {
"contractScope": null,
"id": 27486,
"name": "Types.Wei",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 31149,
"src": "2537:9:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_storage_ptr",
"typeString": "struct Types.Wei"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 27489,
"name": "borrowWei",
"nodeType": "VariableDeclaration",
"scope": 27591,
"src": "2577:26:97",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei"
},
"typeName": {
"contractScope": null,
"id": 27488,
"name": "Types.Wei",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 31149,
"src": "2577:9:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_storage_ptr",
"typeString": "struct Types.Wei"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 27494,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27491,
"name": "totalPar",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27477,
"src": "2630:8:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_TotalPar_$30885_memory_ptr",
"typeString": "struct Types.TotalPar memory"
}
},
{
"argumentTypes": null,
"id": 27492,
"name": "index",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27473,
"src": "2640:5:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Index_$27471_memory_ptr",
"typeString": "struct Interest.Index memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_struct$_TotalPar_$30885_memory_ptr",
"typeString": "struct Types.TotalPar memory"
},
{
"typeIdentifier": "t_struct$_Index_$27471_memory_ptr",
"typeString": "struct Interest.Index memory"
}
],
"id": 27490,
"name": "totalParToWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27749,
"src": "2616:13:97",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_struct$_TotalPar_$30885_memory_ptr_$_t_struct$_Index_$27471_memory_ptr_$returns$_t_struct$_Wei_$31149_memory_ptr_$_t_struct$_Wei_$31149_memory_ptr_$",
"typeString": "function (struct Types.TotalPar memory,struct Interest.Index memory) pure returns (struct Types.Wei memory,struct Types.Wei memory)"
}
},
"id": 27493,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2616:30:97",
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_struct$_Wei_$31149_memory_ptr_$_t_struct$_Wei_$31149_memory_ptr_$",
"typeString": "tuple(struct Types.Wei memory,struct Types.Wei memory)"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "2523:123:97"
},
{
"assignments": [
27496
],
"declarations": [
{
"constant": false,
"id": 27496,
"name": "currentTime",
"nodeType": "VariableDeclaration",
"scope": 27591,
"src": "2704:18:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
},
"typeName": {
"id": 27495,
"name": "uint32",
"nodeType": "ElementaryTypeName",
"src": "2704:6:97",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 27500,
"initialValue": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"id": 27497,
"name": "Time",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 30729,
"src": "2725:4:97",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Time_$30729_$",
"typeString": "type(library Time)"
}
},
"id": 27498,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "currentTime",
"nodeType": "MemberAccess",
"referencedDeclaration": 30728,
"src": "2725:16:97",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_view$__$returns$_t_uint32_$",
"typeString": "function () view returns (uint32)"
}
},
"id": 27499,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2725:18:97",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "2704:39:97"
},
{
"assignments": [
27502
],
"declarations": [
{
"constant": false,
"id": 27502,
"name": "borrowInterest",
"nodeType": "VariableDeclaration",
"scope": 27591,
"src": "2753:22:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 27501,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "2753:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 27514,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27510,
"name": "index",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27473,
"src": "2818:5:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Index_$27471_memory_ptr",
"typeString": "struct Interest.Index memory"
}
},
"id": 27511,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "lastUpdate",
"nodeType": "MemberAccess",
"referencedDeclaration": 27470,
"src": "2818:16:97",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27507,
"name": "currentTime",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27496,
"src": "2801:11:97",
"typeDescriptions": {
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint32",
"typeString": "uint32"
}
],
"id": 27506,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "2793:7:97",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_uint256_$",
"typeString": "type(uint256)"
},
"typeName": "uint256"
},
"id": 27508,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2793:20:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 27509,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sub",
"nodeType": "MemberAccess",
"referencedDeclaration": 37221,
"src": "2793:24:97",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 27512,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2793:42:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
],
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 27503,
"name": "rate",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27475,
"src": "2778:4:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Rate_$27464_memory_ptr",
"typeString": "struct Interest.Rate memory"
}
},
"id": 27504,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": 27463,
"src": "2778:10:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 27505,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "mul",
"nodeType": "MemberAccess",
"referencedDeclaration": 37282,
"src": "2778:14:97",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 27513,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2778:58:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "2753:83:97"
},
{
"assignments": [
27516
],
"declarations": [
{
"constant": false,
"id": 27516,
"name": "supplyInterest",
"nodeType": "VariableDeclaration",
"scope": 27591,
"src": "2894:22:97",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 27515,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "2894:7:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 27517,
"initialValue": null,
"nodeType": "VariableDeclarationStatement",
"src": "2894:22:97"
},
{
"condition": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27520,
"name": "supplyWei",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27487,
"src": "2943:9:97",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_struct$_Wei_$31149_memory_ptr",
"typeString": "struct Types.Wei memory"
}
],
"expression": {
"argumentTypes": null,
"id": 27518,
"name": "Types",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 31361,
"src": "2930:5:97",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_Types_$31361_$",
"typeString": "type(library Types)"
}
},
"id": 27519,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "isZero",
"nodeType": "MemberAccess",
"referencedDeclaration": 31360,
"src": "2930:12:97",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_struct$_Wei_$31149_memory_ptr_$returns$_t_bool_$",
"typeString": "function (struct Types.Wei memory) pure returns (bool)"
}
},
"id": 27521,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "2930:23:97",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": {
"id": 27553,
"nodeType": "Block",
"src": "3004:575:97",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 27533,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 27527,
"name": "supplyInterest",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27516,
"src": "3018:14:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 27530,
"name": "borrowInterest",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 27502,
"src": "3047:14:97",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
{
"argumentTypes": null,