UNPKG

@dolomite-exchange/dolomite-margin

Version:

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

893 lines (892 loc) 192 kB
{ "contractName": "AAVECopyCatStableCoinInterestSetter", "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\":\"AAVECopyCatStableCoinInterestSetter.sol\"},\"userdoc\":{\"methods\":{},\"notice\":\"Copies AAVE's interest rate model on Arbitrum for stable 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/AAVECopyCatStableCoinInterestSetter.sol\":\"AAVECopyCatStableCoinInterestSetter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatStableCoinInterestSetter.sol\":{\"keccak256\":\"0xee874e28797dbffa1ea4c8c469acae5997a84490caba1322ecdc4af8f3fd045e\",\"urls\":[\"bzz-raw://966b49a5a1a3e2a67d54b960aeeb74e80f8d1240b27600a0356c8e99ddcfa2c4\",\"dweb:/ipfs/QmVdrKo88LtHy7rNTFgKEUK1cDJUFYCSGD3eGQWcfX12zh\"]},\"/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": "0x608060405234801561001057600080fd5b5061062c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e8177dcf14610030575b600080fd5b61004361003e3660046103c5565b610059565b6040516100509190610539565b60405180910390f35b61006161039c565b8261007b57506040805160208101909152600081526101d5565b816100aa5760405180602001604052806301e13380670de0b6b3a7640000816100a057fe5b04905290506101d5565b60006100d4836100c886670de0b6b3a764000063ffffffff6101dc16565b9063ffffffff61024216565b9050670de0b6b3a764000081106101115760405180602001604052806301e13380670de0b6b3a76400008161010557fe5b048152509150506101d5565b670c7d713b49da000081111561019a57600061015f67016345785d8a00006100c861014a85670c7d713b49da000063ffffffff61028416565b670d529ae9e86000009063ffffffff6101dc16565b9050604051806020016040528061018e6301e133806100c8668e1bc9bf040000866102c690919063ffffffff16565b815250925050506101d5565b6040805160208101909152806101cf6301e133806100c8670c7d713b49da000081668e1bc9bf0400008863ffffffff6101dc16565b90529150505b9392505050565b6000826101eb5750600061023c565b828202828482816101f857fe5b0414610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610529565b60405180910390fd5b90505b92915050565b600061023983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610305565b600061023983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610356565b600082820183811015610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610519565b60008183610340576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b50600083858161034c57fe5b0495945050505050565b60008184841115610394576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b505050900390565b6040518060200160405280600081525090565b803561023c816105c9565b803561023c816105e0565b6000806000606084860312156103da57600080fd5b60006103e686866103af565b93505060206103f7868287016103ba565b9250506040610408868287016103ba565b9150509250925092565b600061041d82610547565b610427818561054b565b9350610437818560208601610575565b610440816105a1565b9093019392505050565b6000610457601b8361054b565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061049060218361054b565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b805160208301906104f384826104f9565b50505050565b61050281610572565b82525050565b602080825281016102398184610412565b6020808252810161023c8161044a565b6020808252810161023c81610483565b6020810161023c82846104e2565b5190565b90815260200190565b600073ffffffffffffffffffffffffffffffffffffffff821661023c565b90565b60005b83811015610590578181015183820152602001610578565b838111156104f35750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b6105d281610554565b81146105dd57600080fd5b50565b6105d28161057256fea365627a7a72315820ba3cf14b76137f7df90cfffdf5f59d219eb6d89edbcfa48a1a8381767dc2c25f6c6578706572696d656e74616cf564736f6c63430005100040", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e8177dcf14610030575b600080fd5b61004361003e3660046103c5565b610059565b6040516100509190610539565b60405180910390f35b61006161039c565b8261007b57506040805160208101909152600081526101d5565b816100aa5760405180602001604052806301e13380670de0b6b3a7640000816100a057fe5b04905290506101d5565b60006100d4836100c886670de0b6b3a764000063ffffffff6101dc16565b9063ffffffff61024216565b9050670de0b6b3a764000081106101115760405180602001604052806301e13380670de0b6b3a76400008161010557fe5b048152509150506101d5565b670c7d713b49da000081111561019a57600061015f67016345785d8a00006100c861014a85670c7d713b49da000063ffffffff61028416565b670d529ae9e86000009063ffffffff6101dc16565b9050604051806020016040528061018e6301e133806100c8668e1bc9bf040000866102c690919063ffffffff16565b815250925050506101d5565b6040805160208101909152806101cf6301e133806100c8670c7d713b49da000081668e1bc9bf0400008863ffffffff6101dc16565b90529150505b9392505050565b6000826101eb5750600061023c565b828202828482816101f857fe5b0414610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610529565b60405180910390fd5b90505b92915050565b600061023983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610305565b600061023983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610356565b600082820183811015610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610519565b60008183610340576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b50600083858161034c57fe5b0495945050505050565b60008184841115610394576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102309190610508565b505050900390565b6040518060200160405280600081525090565b803561023c816105c9565b803561023c816105e0565b6000806000606084860312156103da57600080fd5b60006103e686866103af565b93505060206103f7868287016103ba565b9250506040610408868287016103ba565b9150509250925092565b600061041d82610547565b610427818561054b565b9350610437818560208601610575565b610440816105a1565b9093019392505050565b6000610457601b8361054b565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061049060218361054b565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f81527f7700000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b805160208301906104f384826104f9565b50505050565b61050281610572565b82525050565b602080825281016102398184610412565b6020808252810161023c8161044a565b6020808252810161023c81610483565b6020810161023c82846104e2565b5190565b90815260200190565b600073ffffffffffffffffffffffffffffffffffffffff821661023c565b90565b60005b83811015610590578181015183820152602001610578565b838111156104f35750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b6105d281610554565b81146105dd57600080fd5b50565b6105d28161057256fea365627a7a72315820ba3cf14b76137f7df90cfffdf5f59d219eb6d89edbcfa48a1a8381767dc2c25f6c6578706572696d656e74616cf564736f6c63430005100040", "sourceMap": "1149:1625:8:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1149:1625:8;;;;;;;", "deployedSourceMap": "1149:1625:8:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1149:1625:8;;;;;;;;;;;;;;;;;;;1539:1233;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;1690:20;;:::i;:::-;1730:15;1726:259;;-1:-1:-1;1768:54:8;;;;;;;;;-1:-1:-1;1768:54:8;;1761:61;;1726:259;1843:15;1839:146;;1881:93;;;;;;;;1423:18;1291:4;1920:39;;;;;;1881:93;;1874:100;-1:-1:-1;1874:100:8;;1839:146;1995:19;2017:51;2057:10;2017:35;:10;1291:4;2017:35;:14;:35;:::i;:::-;:39;:51;:39;:51;:::i;:::-;1995:73;;1291:4;2082:11;:34;2078:688;;2139:93;;;;;;;;1423:18;1291:4;2178:39;;;;;;2139:93;;;2132:100;;;;;2078:688;1335:4;2253:11;:28;2249:517;;;2366:21;2390:72;1376:4;2390:55;2413:31;:11;1335:4;2413:31;:15;:31;:::i;:::-;1485:5;;2390:55;:22;:55;:::i;:72::-;2366:96;;2483:108;;;;;;;;2522:54;1423:18;2522:31;1528:4;2522:13;:17;;:31;;;;:::i;:54::-;2483:108;;;2476:115;;;;;;2249:517;2629:126;;;;;;;;;;2668:72;1423:18;2668:49;1335:4;2668:49;1528:4;2685:11;2668:29;:16;:29;:::i;:72::-;2629:126;;2622:133;-1:-1:-1;;1539:1233:8;;;;;;:::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;1149:1625:8:-;;;;;;;;;;;;;;:::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 AAVECopyCatStableCoinInterestSetter.sol\n * @author Dolomite\n *\n * @notice Copies AAVE's interest rate model on Arbitrum for stable coins up until 90% utilization (since Dolomite's\n * markets are smaller). After 90% utilization, scales up to 100% APR.\n */\ncontract AAVECopyCatStableCoinInterestSetter 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_SIX_PERCENT = 96e16;\n uint256 constant FOUR_PERCENT = 4e16;\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 4% + linear progress to 100% APR\n uint256 interestToAdd = NINETY_SIX_PERCENT.mul(utilization.sub(NINETY_PERCENT)).div(TEN_PERCENT);\n return Interest.Rate({\n value: interestToAdd.add(FOUR_PERCENT).div(SECONDS_IN_A_YEAR)\n });\n } else {\n return Interest.Rate({\n value: FOUR_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/AAVECopyCatStableCoinInterestSetter.sol", "ast": { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/external/interestsetters/AAVECopyCatStableCoinInterestSetter.sol", "exportedSymbols": { "AAVECopyCatStableCoinInterestSetter": [ 3344 ] }, "id": 3345, "nodeType": "SourceUnit", "nodes": [ { "id": 3207, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "595:23:8" }, { "id": 3208, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "619:33:8" }, { "absolutePath": "@openzeppelin/contracts/math/SafeMath.sol", "file": "@openzeppelin/contracts/math/SafeMath.sol", "id": 3210, "nodeType": "ImportDirective", "scope": 3345, "sourceUnit": 37366, "src": "654:69:8", "symbolAliases": [ { "foreign": 3209, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IInterestSetter.sol", "file": "../../protocol/interfaces/IInterestSetter.sol", "id": 3212, "nodeType": "ImportDirective", "scope": 3345, "sourceUnit": 24790, "src": "724:80:8", "symbolAliases": [ { "foreign": 3211, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol", "file": "../../protocol/lib/Interest.sol", "id": 3214, "nodeType": "ImportDirective", "scope": 3345, "sourceUnit": 27751, "src": "805:59:8", "symbolAliases": [ { "foreign": 3213, "local": null } ], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 3215, "name": "IInterestSetter", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 24789, "src": "1197:15:8", "typeDescriptions": { "typeIdentifier": "t_contract$_IInterestSetter_$24789", "typeString": "contract IInterestSetter" } }, "id": 3216, "nodeType": "InheritanceSpecifier", "src": "1197:15:8" } ], "contractDependencies": [ 24789 ], "contractKind": "contract", "documentation": "@title AAVECopyCatStableCoinInterestSetter.sol\n@author Dolomite\n * @notice Copies AAVE's interest rate model on Arbitrum for stable coins up until 90% utilization (since Dolomite's\n markets are smaller). After 90% utilization, scales up to 100% APR.", "fullyImplemented": true, "id": 3344, "linearizedBaseContracts": [ 3344, 24789 ], "name": "AAVECopyCatStableCoinInterestSetter", "nodeType": "ContractDefinition", "nodes": [ { "id": 3219, "libraryName": { "contractScope": null, "id": 3217, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 37365, "src": "1225:8:8", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$37365", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "1219:27:8", "typeName": { "id": 3218, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1238:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "constant": true, "id": 3222, "name": "ONE_HUNDRED_PERCENT", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1252:43:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3220, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1252:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "31653138", "id": 3221, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1291:4:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000_by_1", "typeString": "int_const 1000000000000000000" }, "value": "1e18" }, "visibility": "internal" }, { "constant": true, "id": 3225, "name": "NINETY_PERCENT", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1301:38:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3223, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1301:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "39653137", "id": 3224, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1335:4:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_900000000000000000_by_1", "typeString": "int_const 900000000000000000" }, "value": "9e17" }, "visibility": "internal" }, { "constant": true, "id": 3228, "name": "TEN_PERCENT", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1345:35:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3226, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1345:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "31653137", "id": 3227, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1376:4:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_100000000000000000_by_1", "typeString": "int_const 100000000000000000" }, "value": "1e17" }, "visibility": "internal" }, { "constant": true, "id": 3237, "name": "SECONDS_IN_A_YEAR", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1386:55:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3229, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1386:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_31536000_by_1", "typeString": "int_const 31536000" }, "id": 3236, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_86400_by_1", "typeString": "int_const 86400" }, "id": 3234, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_3600_by_1", "typeString": "int_const 3600" }, "id": 3232, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "3630", "id": 3230, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1423:2:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_60_by_1", "typeString": "int_const 60" }, "value": "60" }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "3630", "id": 3231, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1428:2:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_60_by_1", "typeString": "int_const 60" }, "value": "60" }, "src": "1423:7:8", "typeDescriptions": { "typeIdentifier": "t_rational_3600_by_1", "typeString": "int_const 3600" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "3234", "id": 3233, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1433:2:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_24_by_1", "typeString": "int_const 24" }, "value": "24" }, "src": "1423:12:8", "typeDescriptions": { "typeIdentifier": "t_rational_86400_by_1", "typeString": "int_const 86400" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "hexValue": "333635", "id": 3235, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1438:3:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_365_by_1", "typeString": "int_const 365" }, "value": "365" }, "src": "1423:18:8", "typeDescriptions": { "typeIdentifier": "t_rational_31536000_by_1", "typeString": "int_const 31536000" } }, "visibility": "internal" }, { "constant": true, "id": 3240, "name": "NINETY_SIX_PERCENT", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1447:43:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3238, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1447:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "3936653136", "id": 3239, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1485:5:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_960000000000000000_by_1", "typeString": "int_const 960000000000000000" }, "value": "96e16" }, "visibility": "internal" }, { "constant": true, "id": 3243, "name": "FOUR_PERCENT", "nodeType": "VariableDeclaration", "scope": 3344, "src": "1496:36:8", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3241, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1496:7:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "hexValue": "34653136", "id": 3242, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1528:4:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_40000000000000000_by_1", "typeString": "int_const 40000000000000000" }, "value": "4e16" }, "visibility": "internal" }, { "body": { "id": 3342, "nodeType": "Block", "src": "1716:1056:8", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3256, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3254, "name": "_borrowWei", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3247, "src": "1730:10:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 3255, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1744:1:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1730:15:8", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3265, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3263, "name": "_supplyWei", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3249, "src": "1843:10:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 3264, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1857:1:8", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1843:15:8", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 3274, "nodeType": "IfStatement", "src": "1839:146:8", "trueBody": { "id": 3273, "nodeType": "Block", "src": "1860:125:8", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 3270, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 3268, "name": "ONE_HUNDRED_PERCENT", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3222, "src": "1920:19:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "id": 3269, "name": "SECONDS_IN_A_YEAR", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3237, "src": "1942:17:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "1920:39:8", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "id": 3266, "name": "Interest", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 27750, "src": "1881:8:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Interest_$27750_$", "typeString": "type(library Interest)" } }, "id": 3267, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "Rate", "nodeType": "MemberAccess", "referencedDeclaration": 27464, "src": "1881:13:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Rate_$27464_storage_ptr_$", "typeString": "type(struct Interest.Rate storage pointer)" } }, "id": 3271, "isConstant": false, "isLValue": false, "isPure": true, "kind": "structConstructorCall", "lValueRequested": false, "names": [ "value" ], "nodeType": "FunctionCall", "src": "1881:93:8", "typeDescriptions": { "typeIdentifier": "t_struct$_Rate_$27464_memory", "typeString": "struct Interest.Rate memory" } }, "functionReturnParameters": 3253, "id": 3272, "nodeType": "Return", "src": "1874:100:8" } ] } }, "id": 3275, "nodeType": "IfStatement", "src": "1726:259:8", "trueBody": { "id": 3262, "nodeType": "Block", "src": "1747:86:8", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 3259, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1806:1:8", "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": 3257, "name": "Interest", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 27750, "src": "1768:8:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Interest_$27750_$", "typeString": "type(library Interest)" } }, "id": 3258, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "Rate", "nodeType": "MemberAccess", "referencedDeclaration": 27464, "src": "1768:13:8", "typeDescriptions": { "typeIdentifier": "t_type$_t_struct$_Rate_$27464_storage_ptr_$", "typeString": "type(struct Interest.Rate storage pointer)" } }, "id": 3260, "isConstant": false, "isLValue": false, "isPure": true, "kind": "structConstructorCall", "lValueRequested": false, "names": [ "value" ], "nodeType": "FunctionCall", "src": "1768:54:8", "typeDescriptions": { "typeIdentifier": "t_struct$_Rate_$27464_memory", "typeString": "struct Interest.Rate memory" } }, "functionReturnParameters": 3253, "id": 3261, "nodeType": "Return", "src": "1761:61:8" } ] } }, { "assignments": [ 3277 ], "declarations": [ { "constant": false, "id": 3277, "name": "utilization", "nodeType": "VariableDeclaration", "scope": 3342, "src": "1995:19:8", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 3276,