UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

893 lines 191 kB
{ "contractName": "AAVECopyCatAltCoinInterestSetter", "abi": [ { "constant": true, "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "uint256", "name": "_borrowWei", "type": "uint256" }, { "internalType": "uint256", "name": "_supplyWei", "type": "uint256" } ], "name": "getInterestRate", "outputs": [ { "components": [ { "internalType": "uint256", "name": "value", "type": "uint256" } ], "internalType": "struct Interest.Rate", "name": "", "type": "tuple" } ], "payable": false, "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_borrowWei\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_supplyWei\",\"type\":\"uint256\"}],\"name\":\"getInterestRate\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"struct Interest.Rate\",\"name\":\"\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Dolomite\",\"methods\":{},\"title\":\"AAVECopyCatAltCoinInterestSetter.sol\"},\"userdoc\":{\"methods\":{},\"notice\":\"Copies AAVE's interest rate model on Arbitrum for alt coins up until 90% utilization (since Dolomite's markets are smaller). After 90% utilization, scales up to 100% APR.\"}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatAltCoinInterestSetter.sol\":\"AAVECopyCatAltCoinInterestSetter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatAltCoinInterestSetter.sol\":{\"keccak256\":\"0xfcf13048be4b7a2c9eb8c3657f90a05f3aaaa1e60c52fbc1883e0ce0ffa0a5b6\",\"urls\":[\"bzz-raw://9cc875f6be6394e5ccf2190d04e0321d425d51d342fe9f0317fbaaee35af90e8\",\"dweb:/ipfs/QmNMtxHefwBmPCdKKBqjvPxSrEmo6UFFbV9fNGWRtYL3vM\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IInterestSetter.sol\":{\"keccak256\":\"0x546825f65490a30e29d0f6446acec49c1e895ce6b33d48ca5c05092725a63a57\",\"urls\":[\"bzz-raw://6ad3013aed985bdf6e6234ae0f7f37e6bba76c3470c33bfa24678cf19b3b412c\",\"dweb:/ipfs/QmfYaSBzxGpgiHoR7ontMJY66S5L26XwkLYoEuzsEjpbQH\"]},\"/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": "0x608060405234801561001057600080fd5b5061062c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e8177dcf14610030575b600080fd5b61004361003e3660046103c5565b610059565b6040516100509190610539565b60405180910390f35b61006161039c565b8261007b57506040805160208101909152600081526101d5565b816100aa5760405180602001604052806301e13380670de0b6b3a7640000816100a057fe5b04905290506101d5565b60006100d4836100c886670de0b6b3a764000063ffffffff6101dc16565b9063ffffffff61024216565b9050670de0b6b3a764000081106101115760405180602001604052806301e13380670de0b6b3a76400008161010557fe5b048152509150506101d5565b670c7d713b49da000081111561019a57600061015f67016345785d8a00006100c861014a85670c7d713b49da000063ffffffff61028416565b670ce80612991d00009063ffffffff6101dc16565b9050604051806020016040528061018e6301e133806100c866f8b0a10e470000866102c690919063ffffffff16565b815250925050506101d5565b6040805160208101909152806101cf6301e133806100c8670c7d713b49da00008166f8b0a10e4700008863ffffffff6101dc16565b90529150505b9392505050565b6000826101eb5750600061023c565b828202828482816101f857fe5b0414610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610529565b60405180910390fd5b90505b92915050565b600061023983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610305565b600061023983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610356565b600082820183811015610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610519565b60008183610340576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b50600083858161034c57fe5b0495945050505050565b60008184841115610394576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b505050900390565b6040518060200160405280600081525090565b803561023c816105c9565b803561023c816105e0565b6000806000606084860312156103da57600080fd5b60006103e686866103af565b93505060206103f7868287016103ba565b9250506040610408868287016103ba565b9150509250925092565b600061041d82610547565b610427818561054b565b9350610437818560208601610575565b610440816105a1565b9093019392505050565b6000610457601b8361054b565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061049060218361054b565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b805160208301906104f384826104f9565b50505050565b61050281610572565b82525050565b602080825281016102398184610412565b6020808252810161023c8161044a565b6020808252810161023c81610483565b6020810161023c82846104e2565b5190565b90815260200190565b600073ffffffffffffffffffffffffffffffffffffffff821661023c565b90565b60005b83811015610590578181015183820152602001610578565b838111156104f35750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b6105d281610554565b81146105dd57600080fd5b50565b6105d28161057256fea365627a7a72315820a0dcf42ab44cb835ca3f34bc02618aeac84b875cf2c842034d1a7e2c0651ad096c6578706572696d656e74616cf564736f6c63430005100040", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e8177dcf14610030575b600080fd5b61004361003e3660046103c5565b610059565b6040516100509190610539565b60405180910390f35b61006161039c565b8261007b57506040805160208101909152600081526101d5565b816100aa5760405180602001604052806301e13380670de0b6b3a7640000816100a057fe5b04905290506101d5565b60006100d4836100c886670de0b6b3a764000063ffffffff6101dc16565b9063ffffffff61024216565b9050670de0b6b3a764000081106101115760405180602001604052806301e13380670de0b6b3a76400008161010557fe5b048152509150506101d5565b670c7d713b49da000081111561019a57600061015f67016345785d8a00006100c861014a85670c7d713b49da000063ffffffff61028416565b670ce80612991d00009063ffffffff6101dc16565b9050604051806020016040528061018e6301e133806100c866f8b0a10e470000866102c690919063ffffffff16565b815250925050506101d5565b6040805160208101909152806101cf6301e133806100c8670c7d713b49da00008166f8b0a10e4700008863ffffffff6101dc16565b90529150505b9392505050565b6000826101eb5750600061023c565b828202828482816101f857fe5b0414610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610529565b60405180910390fd5b90505b92915050565b600061023983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610305565b600061023983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610356565b600082820183811015610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610519565b60008183610340576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b50600083858161034c57fe5b0495945050505050565b60008184841115610394576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b505050900390565b6040518060200160405280600081525090565b803561023c816105c9565b803561023c816105e0565b6000806000606084860312156103da57600080fd5b60006103e686866103af565b93505060206103f7868287016103ba565b9250506040610408868287016103ba565b9150509250925092565b600061041d82610547565b610427818561054b565b9350610437818560208601610575565b610440816105a1565b9093019392505050565b6000610457601b8361054b565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061049060218361054b565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b805160208301906104f384826104f9565b50505050565b61050281610572565b82525050565b602080825281016102398184610412565b6020808252810161023c8161044a565b6020808252810161023c81610483565b6020810161023c82846104e2565b5190565b90815260200190565b600073ffffffffffffffffffffffffffffffffffffffff821661023c565b90565b60005b83811015610590578181015183820152602001610578565b838111156104f35750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b6105d281610554565b81146105dd57600080fd5b50565b6105d28161057256fea365627a7a72315820a0dcf42ab44cb835ca3f34bc02618aeac84b875cf2c842034d1a7e2c0651ad096c6578706572696d656e74616cf564736f6c63430005100040", "sourceMap": "1143:1628:7:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1143:1628:7;;;;;;;", "deployedSourceMap": "1143:1628:7:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1143:1628:7;;;;;;;;;;;;;;;;;;;1533:1236;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;1684:20;;:::i;:::-;1724:15;1720:258;;-1:-1:-1;1762:54:7;;;;;;;;;-1:-1:-1;1762:54:7;;1755:61;;1720:258;1837:15;1833:145;;1875:92;;;;;;;;1414:18;1282:4;1913:39;;;;;;1875:92;;1868:99;-1:-1:-1;1868:99:7;;1833:145;1988:19;2010:51;2050:10;2010:35;:10;1282:4;2010:35;:14;:35;:::i;:::-;:39;:51;:39;:51;:::i;:::-;1988:73;;1282:4;2075:11;:34;2071:692;;2132:93;;;;;;;;1414:18;1282:4;2171:39;;;;;;2132:93;;;2125:100;;;;;2071:692;1326:4;2246:11;:28;2242:521;;;2359:21;2383:74;1367:4;2383:57;2408:31;:11;1326:4;2408:31;:15;:31;:::i;:::-;1478:5;;2383:57;:24;:57;:::i;:74::-;2359:98;;2478:109;;;;;;;;2517:55;1414:18;2517:32;1522:4;2517:13;:17;;:32;;;;:::i;:55::-;2478:109;;;2471:116;;;;;;2242:521;2625:127;;;;;;;;;;2664:73;1414:18;2664:50;1326:4;2664:50;1522:4;2682:11;2664:30;:17;:30;:::i;:73::-;2625:127;;2618:134;-1:-1:-1;;1533:1236:7;;;;;;:::o;2159:459:150:-;2217:7;2458:6;2454:45;;-1:-1:-1;2487:1:150;2480:8;;2454:45;2521:5;;;2525:1;2521;:5;:1;2544:5;;;;;:10;2536:56;;;;;;;;;;;;;;;;;;;;;;2610:1;-1:-1:-1;2159:459:150;;;;;:::o;3073:130::-;3131:7;3157:39;3161:1;3164;3157:39;;;;;;;;;;;;;;;;;:3;:39::i;1274:134::-;1332:7;1358:43;1362:1;1365;1358:43;;;;;;;;;;;;;;;;;:3;:43::i;834:176::-;892:7;923:5;;;946:6;;;;938:46;;;;;;;;;;;;;3718:338;3804:7;3904:12;3897:5;3889:28;;;;;;;;;;;;;;;;3927:9;3943:1;3939;:5;;;;;;;3718:338;-1:-1:-1;;;;;3718:338:150:o;1732:187::-;1818:7;1853:12;1845:6;;;;1837:29;;;;;;;;;;;;;;;-1:-1:-1;;;1888:5:150;;;1732:187::o;1143:1628:7:-;;;;;;;;;;;;;;:::o;5:130:-1:-;72:20;;97:33;72:20;97:33;;142:130;209:20;;234:33;209:20;234:33;;279:491;;;;417:2;405:9;396:7;392:23;388:32;385:2;;;433:1;430;423:12;385:2;468:1;485:53;530:7;510:9;485:53;;;475:63;;447:97;575:2;593:53;638:7;629:6;618:9;614:22;593:53;;;583:63;;554:98;683:2;701:53;746:7;737:6;726:9;722:22;701:53;;;691:63;;662:98;379:391;;;;;;777:347;;889:39;922:5;889:39;;;940:71;1004:6;999:3;940:71;;;933:78;;1016:52;1061:6;1056:3;1049:4;1042:5;1038:16;1016:52;;;1089:29;1111:6;1089:29;;;1080:39;;;;869:255;-1:-1;;;869:255;1132:327;;1292:67;1356:2;1351:3;1292:67;;;1392:29;1372:50;;1450:2;1441:12;;1278:181;-1:-1;;1278:181;1468:370;;1628:67;1692:2;1687:3;1628:67;;;1728:34;1708:55;;1797:3;1792:2;1783:12;;1776:25;1829:2;1820:12;;1614:224;-1:-1;;1614:224;1897:319;2103:23;;2036:4;2027:14;;;2132:63;2031:3;2103:23;2132:63;;;2056:145;2009:207;;;;2223:103;2296:24;2314:5;2296:24;;;2291:3;2284:37;2278:48;;;2333:301;2471:2;2485:47;;;2456:18;;2546:78;2456:18;2610:6;2546:78;;2641:407;2832:2;2846:47;;;2817:18;;2907:131;2817:18;2907:131;;3055:407;3246:2;3260:47;;;3231:18;;3321:131;3231:18;3321:131;;3469:305;3633:2;3618:18;;3647:117;3622:9;3737:6;3647:117;;3781:122;3869:12;;3840:63;3911:163;4014:19;;;4063:4;4054:14;;4007:67;4082:91;;4253:42;4242:54;;4144:24;4225:76;4308:72;4370:5;4353:27;4388:268;4453:1;4460:101;4474:6;4471:1;4468:13;4460:101;;;4541:11;;;4535:18;4522:11;;;4515:39;4496:2;4489:10;4460:101;;;4576:6;4573:1;4570:13;4567:2;;;-1:-1;;4641:1;4623:16;;4616:27;4437:219;4664:97;4752:2;4732:14;4748:7;4728:28;;4712:49;4769:117;4838:24;4856:5;4838:24;;;4831:5;4828:35;4818:2;;4877:1;4874;4867:12;4818:2;4812:74;;4893:117;4962:24;4980:5;4962:24;", "source": "/*\n\n Copyright 2023 Dolomite.\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 { IInterestSetter } from \"../../protocol/interfaces/IInterestSetter.sol\";\nimport { Interest } from \"../../protocol/lib/Interest.sol\";\n\n\n/**\n * @title AAVECopyCatAltCoinInterestSetter.sol\n * @author Dolomite\n *\n * @notice Copies AAVE's interest rate model on Arbitrum for alt coins up until 90% utilization (since Dolomite's\n * markets are smaller). After 90% utilization, scales up to 100% APR.\n */\ncontract AAVECopyCatAltCoinInterestSetter is IInterestSetter {\n using SafeMath for uint256;\n\n uint256 constant ONE_HUNDRED_PERCENT = 1e18;\n uint256 constant NINETY_PERCENT = 9e17;\n uint256 constant TEN_PERCENT = 1e17;\n uint256 constant SECONDS_IN_A_YEAR = 60 * 60 * 24 * 365;\n uint256 constant NINETY_THREE_PERCENT = 93e16;\n uint256 constant SEVEN_PERCENT = 7e16;\n\n function getInterestRate(\n address /* token */,\n uint256 _borrowWei,\n uint256 _supplyWei\n )\n external\n view\n returns (Interest.Rate memory)\n {\n if (_borrowWei == 0) {\n return Interest.Rate({\n value: 0\n });\n } else if (_supplyWei == 0) {\n return Interest.Rate({\n value: ONE_HUNDRED_PERCENT / SECONDS_IN_A_YEAR\n });\n }\n\n uint256 utilization = _borrowWei.mul(ONE_HUNDRED_PERCENT).div(_supplyWei);\n if (utilization >= ONE_HUNDRED_PERCENT) {\n return Interest.Rate({\n value: ONE_HUNDRED_PERCENT / SECONDS_IN_A_YEAR\n });\n } else if (utilization > NINETY_PERCENT) {\n // interest is equal to 7% + linear progress to 100% APR\n uint256 interestToAdd = NINETY_THREE_PERCENT.mul(utilization.sub(NINETY_PERCENT)).div(TEN_PERCENT);\n return Interest.Rate({\n value: interestToAdd.add(SEVEN_PERCENT).div(SECONDS_IN_A_YEAR)\n });\n } else {\n return Interest.Rate({\n value: SEVEN_PERCENT.mul(utilization).div(NINETY_PERCENT).div(SECONDS_IN_A_YEAR)\n });\n }\n }\n}\n", "sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatAltCoinInterestSetter.sol", "ast": { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatAltCoinInterestSetter.sol", "exportedSymbols": { "AAVECopyCatAltCoinInterestSetter": [ 3205 ] }, "id": 3206, "nodeType": "SourceUnit", "nodes": [ { "id": 3068, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "595:23:7" }, { "id": 3069, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "619:33:7" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 3071, "nodeType": "ImportDirective", "scope": 3206, "sourceUnit": 37366, "src": "654:69:7", "symbolAliases": [ { "foreign": 3070, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IInterestSetter.sol", "file": "../../protocol/interfaces/IInterestSetter.sol", "id": 3073, "nodeType": "ImportDirective", "scope": 3206, "sourceUnit": 24790, "src": "724:80:7", "symbolAliases": [ { "foreign": 3072, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol", "file": "../../protocol/lib/Interest.sol", "id": 3075, "nodeType": "ImportDirective", "scope": 3206, "sourceUnit": 27751, "src": "805:59:7", "symbolAliases": [ { "foreign": 3074, "local": null } ], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 3076, "name": "IInterestSetter", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 24789, "src": "1188:15:7", "typeDescriptions": { "typeIdentifier": "t_contract$_IInterestSetter_$24789", "typeString": "contract IInterestSetter" } }, "id": 3077, "nodeType": "InheritanceSpecifier", "src": "1188:15:7" } ], "contractDependencies": [ 24789 ], "contractKind": "contract", "documentation": "@title AAVECopyCatAltCoinInterestSetter.sol\n@author Dolomite\n * @notice Copies AAVE's interest rate model on Arbitrum for alt coins up until 90% utilization (since Dolomite's\n markets are smaller). After 90% utilization, scales up to 100% APR.", "fullyImplemented": true, "id": 3205, "linearizedBaseContracts": [ 3205, 24789 ], "name": "AAVECopyCatAltCoinInterestSetter", "nodeType": "ContractDefinition", "nodes": [ { "id": 3080, "libraryName": { "contractScope": null, "id": 3078, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 37365, "src": "1216:8:7", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$37365", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "1210:27:7", "typeName": { "id": 3079, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1229:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "constant": true, "id": 3083, "name": "ONE_HUNDRED_PERCENT", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1243:43:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3081, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1243:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "31653138", "id": 3082, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1282:4:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" }, "value": "1e18" }, "visibility": "internal" }, { "constant": true, "id": 3086, "name": "NINETY_PERCENT", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1292:38:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3084, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1292:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "39653137", "id": 3085, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1326:4:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_900000000000000000_by_1", "typeString": "int_const 900000000000000000" }, "value": "9e17" }, "visibility": "internal" }, { "constant": true, "id": 3089, "name": "TEN_PERCENT", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1336:35:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3087, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1336:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "31653137", "id": 3088, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1367:4:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_100000000000000000_by_1", "typeString": "int_const 100000000000000000" }, "value": "1e17" }, "visibility": "internal" }, { "constant": true, "id": 3098, "name": "SECONDS_IN_A_YEAR", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1377:55:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3090, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1377:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_31536000_by_1", "typeString": "int_const 31536000" }, "id": 3097, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_86400_by_1", "typeString": "int_const 86400" }, "id": 3095, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_3600_by_1", "typeString": "int_const 3600" }, "id": 3093, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "3630", "id": 3091, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1414:2:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_60_by_1", "typeString": "int_const 60" }, "value": "60" }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "3630", "id": 3092, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1419:2:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_60_by_1", "typeString": "int_const 60" }, "value": "60" }, "src": "1414:7:7", "typeDescriptions": { "typeIdentifier": "t_rational_3600_by_1", "typeString": "int_const 3600" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "3234", "id": 3094, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1424:2:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_24_by_1", "typeString": "int_const 24" }, "value": "24" }, "src": "1414:12:7", "typeDescriptions": { "typeIdentifier": "t_rational_86400_by_1", "typeString": "int_const 86400" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "333635", "id": 3096, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1429:3:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_365_by_1", "typeString": "int_const 365" }, "value": "365" }, "src": "1414:18:7", "typeDescriptions": { "typeIdentifier": "t_rational_31536000_by_1", "typeString": "int_const 31536000" } }, "visibility": "internal" }, { "constant": true, "id": 3101, "name": "NINETY_THREE_PERCENT", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1438:45:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3099, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1438:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "3933653136", "id": 3100, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1478:5:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_930000000000000000_by_1", "typeString": "int_const 930000000000000000" }, "value": "93e16" }, "visibility": "internal" }, { "constant": true, "id": 3104, "name": "SEVEN_PERCENT", "nodeType": "VariableDeclaration", "scope": 3205, "src": "1489:37:7", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3102, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1489:7:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "37653136", "id": 3103, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1522:4:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_70000000000000000_by_1", "typeString": "int_const 70000000000000000" }, "value": "7e16" }, "visibility": "internal" }, { "body": { "id": 3203, "nodeType": "Block", "src": "1710:1059:7", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3117, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3115, "name": "_borrowWei", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3108, "src": "1724:10:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 3116, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1738:1:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1724:15:7", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3126, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3124, "name": "_supplyWei", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3110, "src": "1837:10:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 3125, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1851:1:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1837:15:7", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 3135, "nodeType": "IfStatement", "src": "1833:145:7", "trueBody": { "id": 3134, "nodeType": "Block", "src": "1854:124:7", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3131, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3129, "name": "ONE_HUNDRED_PERCENT", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3083, "src": "1913:19:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "id": 3130, "name": "SECONDS_IN_A_YEAR", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3098, "src": "1935:17:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1913:39:7", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "id": 3127, "name": "Interest", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 27750, "src": "1875:8:7", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Interest_$27750_$", "typeString": "type(library Interest)" } }, "id": 3128, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "Rate", "nodeType": "MemberAccess", "referencedDeclaration": 27464, "src": "1875:13:7", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Rate_$27464_storage_ptr_$", "typeString": "type(struct Interest.Rate storage pointer)" } }, "id": 3132, "isConstant": false, "isLValue": false, "isPure": true, "kind": "structConstructorCall", "lValueRequested": false, "names": [ "value" ], "nodeType": "FunctionCall", "src": "1875:92:7", "typeDescriptions": { "typeIdentifier": "t_struct$_Rate_$27464_memory", "typeString": "struct Interest.Rate memory" } }, "functionReturnParameters": 3114, "id": 3133, "nodeType": "Return", "src": "1868:99:7" } ] } }, "id": 3136, "nodeType": "IfStatement", "src": "1720:258:7", "trueBody": { "id": 3123, "nodeType": "Block", "src": "1741:86:7", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 3120, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1800:1:7", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "expression": { "argumentTypes": null, "id": 3118, "name": "Interest", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 27750, "src": "1762:8:7", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Interest_$27750_$", "typeString": "type(library Interest)" } }, "id": 3119, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "Rate", "nodeType": "MemberAccess", "referencedDeclaration": 27464, "src": "1762:13:7", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Rate_$27464_storage_ptr_$", "typeString": "type(struct Interest.Rate storage pointer)" } }, "id": 3121, "isConstant": false, "isLValue": false, "isPure": true, "kind": "structConstructorCall", "lValueRequested": false, "names": [ "value" ], "nodeType": "FunctionCall", "src": "1762:54:7", "typeDescriptions": { "typeIdentifier": "t_struct$_Rate_$27464_memory", "typeString": "struct Interest.Rate memory" } }, "functionReturnParameters": 3114, "id": 3122, "nodeType": "Return", "src": "1755:61:7" } ] } }, { "assignments": [ 3138 ], "declarations": [ { "constant": false, "id": 3138, "name": "utilization", "nodeType": "VariableDeclaration", "scope": 3203, "src": "1988:19:7", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3137, "name": "uint256