From fe9df9a5ea9ccb892b6e1776c301d53ea0aded6a Mon Sep 17 00:00:00 2001 From: Onno Visser <23527729+onnovisser@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:42:10 +0200 Subject: [PATCH] multicall --- .../utils/tinlake/abis/NAVFeed_V1.abi.json | 542 --------------- .../utils/tinlake/abis/NAVFeed_V2.abi.json | 616 ------------------ .../utils/tinlake/abis/NAVFeed_V3.abi.json | 405 ------------ .../src/utils/tinlake/abis/Pile.abi.json | 321 --------- .../utils/tinlake/fetchFromTinlakeSubgraph.ts | 2 +- .../src/utils/tinlake/useTinlakePools.ts | 153 ++--- centrifuge-app/src/utils/usePools.ts | 2 +- centrifuge-js/src/modules/pools.ts | 2 +- 8 files changed, 58 insertions(+), 1985 deletions(-) delete mode 100644 centrifuge-app/src/utils/tinlake/abis/NAVFeed_V1.abi.json delete mode 100644 centrifuge-app/src/utils/tinlake/abis/NAVFeed_V2.abi.json delete mode 100644 centrifuge-app/src/utils/tinlake/abis/NAVFeed_V3.abi.json delete mode 100644 centrifuge-app/src/utils/tinlake/abis/Pile.abi.json diff --git a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V1.abi.json b/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V1.abi.json deleted file mode 100644 index ab71eb536d..0000000000 --- a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V1.abi.json +++ /dev/null @@ -1,542 +0,0 @@ -[ - { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Deny", - "type": "event" - }, - { - "anonymous": true, - "inputs": [ - { "indexed": true, "internalType": "bytes4", "name": "sig", "type": "bytes4" }, - { "indexed": true, "internalType": "address", "name": "guy", "type": "address" }, - { "indexed": true, "internalType": "bytes32", "name": "foo", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "bar", "type": "bytes32" }, - { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" }, - { "indexed": false, "internalType": "bytes", "name": "fax", "type": "bytes" } - ], - "name": "LogNote", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Rely", - "type": "event" - }, - { - "inputs": [], - "name": "NullDate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WRITE_OFF_PHASE_A", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WRITE_OFF_PHASE_B", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "approximatedNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "borrow", - "outputs": [{ "internalType": "uint256", "name": "navIncrease", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "borrowEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "borrowed", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "buckets", - "outputs": [ - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "uint256", "name": "next", "type": "uint256" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "uint256", "name": "normalizedBlockTimestamp", "type": "uint256" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" } - ], - "name": "calcDiscount", - "outputs": [{ "internalType": "uint256", "name": "result", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" }, - { "internalType": "uint256", "name": "recoveryRatePD_", "type": "uint256" } - ], - "name": "calcFutureValue", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "calcTotalDiscount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "calcUpdateNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "ceiling", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "ceilingRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "interestBearingAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" } - ], - "name": "chargeInterest", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "compounding", - "outputs": [ - { "internalType": "uint256", "name": "", "type": "uint256" }, - { "internalType": "uint256", "name": "", "type": "uint256" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "currentCeiling", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], - "name": "dateBucket", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "deny", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "contractName", "type": "bytes32" }, - { "internalType": "address", "name": "addr", "type": "address" } - ], - "name": "depend", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "discountRate", - "outputs": [{ "internalType": "uint256", "name": "value", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "done", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" }, - { "internalType": "uint256", "name": "recoveryRatePD_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "firstBucket", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "futureValue", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { "inputs": [], "name": "init", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [], - "name": "lastBucket", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "maturityDate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "clone_", "type": "address" }, - { "internalType": "uint256", "name": "riskGroupCount", "type": "uint256" }, - { "internalType": "address", "name": "oracle", "type": "address" }, - { "internalType": "uint256", "name": "loanCount", "type": "uint256" }, - { "internalType": "uint256", "name": "writeOffCount", "type": "uint256" }, - { "internalType": "address", "name": "pile_", "type": "address" }, - { "internalType": "address", "name": "shelf_", "type": "address" } - ], - "name": "migrate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "migratedFrom", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "registry", "type": "address" }, - { "internalType": "uint256", "name": "tokenId", "type": "uint256" } - ], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "nftValues", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rdiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "recoveryRatePD", - "outputs": [{ "internalType": "uint256", "name": "value", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "rely", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "repay", - "outputs": [{ "internalType": "uint256", "name": "navDecrease", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "risk", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rmul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "n", "type": "uint256" }, - { "internalType": "uint256", "name": "base", "type": "uint256" } - ], - "name": "rpow", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeAdd", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeDiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeMul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeSub", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "threshold", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "thresholdRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "toAmount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "toPie", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "totalValue", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], - "name": "uniqueDayTimestamp", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "unlockEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "wards", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "writeOffs", - "outputs": [ - { "internalType": "uint256", "name": "rateGroup", "type": "uint256" }, - { - "components": [{ "internalType": "uint256", "name": "value", "type": "uint256" }], - "internalType": "struct FixedPoint.Fixed27", - "name": "percentage", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V2.abi.json b/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V2.abi.json deleted file mode 100644 index ac54ee18ef..0000000000 --- a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V2.abi.json +++ /dev/null @@ -1,616 +0,0 @@ -[ - { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Deny", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Rely", - "type": "event" - }, - { - "inputs": [], - "name": "WRITEOFF_RATE_GROUP_START", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "borrow", - "outputs": [{ "internalType": "uint256", "name": "navIncrease", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "", "type": "uint256" } - ], - "name": "borrowEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "borrowed", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "buckets", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "discountRate", "type": "uint256" }, - { "internalType": "uint256", "name": "fv", "type": "uint256" }, - { "internalType": "uint256", "name": "normalizedBlockTimestamp", "type": "uint256" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" } - ], - "name": "calcDiscount", - "outputs": [{ "internalType": "uint256", "name": "result", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loanInterestRate", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" }, - { "internalType": "uint256", "name": "recoveryRatePD_", "type": "uint256" } - ], - "name": "calcFutureValue", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "calcUpdateNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "ceiling", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "riskID", "type": "uint256" }], - "name": "ceilingRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "interestBearingAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" } - ], - "name": "chargeInterest", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "compounding", - "outputs": [ - { "internalType": "uint256", "name": "", "type": "uint256" }, - { "internalType": "uint256", "name": "", "type": "uint256" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentPVs", - "outputs": [ - { "internalType": "uint256", "name": "totalDiscount", "type": "uint256" }, - { "internalType": "uint256", "name": "overdue", "type": "uint256" }, - { "internalType": "uint256", "name": "writeOffs", "type": "uint256" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "currentValidWriteOffGroup", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentWriteOffs", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "deny", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "contractName", "type": "bytes32" }, - { "internalType": "address", "name": "addr", "type": "address" } - ], - "name": "depend", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "details", - "outputs": [ - { "internalType": "uint128", "name": "nftValues", "type": "uint128" }, - { "internalType": "uint128", "name": "futureValue", "type": "uint128" }, - { "internalType": "uint128", "name": "maturityDate", "type": "uint128" }, - { "internalType": "uint128", "name": "risk", "type": "uint128" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "discountRate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "maturityDate_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" }, - { "internalType": "uint256", "name": "writeOffPercentage_", "type": "uint256" }, - { "internalType": "uint256", "name": "overdueDays_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" }, - { "internalType": "uint256", "name": "recoveryRatePD_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "futureValue", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "isLoanWrittenOff", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastNAVUpdate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "latestDiscount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "latestNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "loanDetails", - "outputs": [ - { "internalType": "uint128", "name": "borrowed", "type": "uint128" }, - { "internalType": "bool", "name": "authWriteOff", "type": "bool" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "lockEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "maturityDate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "registry", "type": "address" }, - { "internalType": "uint256", "name": "tokenId", "type": "uint256" } - ], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "nftValues", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "overdueLoans", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "writeOffGroupIndex_", "type": "uint256" } - ], - "name": "overrideWriteOff", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "pile", - "outputs": [{ "internalType": "contract PileLike_1", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rdiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "reCalcNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "reCalcTotalDiscount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "riskID", "type": "uint256" }], - "name": "recoveryRatePD", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "rely", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "repay", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "repayEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "risk", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "riskGroup", - "outputs": [ - { "internalType": "uint128", "name": "ceilingRatio", "type": "uint128" }, - { "internalType": "uint128", "name": "thresholdRatio", "type": "uint128" }, - { "internalType": "uint128", "name": "recoveryRatePD", "type": "uint128" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rmul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "n", "type": "uint256" }, - { "internalType": "uint256", "name": "base", "type": "uint256" } - ], - "name": "rpow", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeAdd", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeDiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeMul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeSub", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "secureSub", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "shelf", - "outputs": [{ "internalType": "contract ShelfLike_1", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "threshold", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "riskID", "type": "uint256" }], - "name": "thresholdRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "toAmount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "toPie", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], - "name": "uniqueDayTimestamp", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "unlockEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "wards", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "writeOff", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "writeOffGroups", - "outputs": [ - { "internalType": "uint128", "name": "percentage", "type": "uint128" }, - { "internalType": "uint128", "name": "overdueDays", "type": "uint128" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "zeroPV", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - } -] diff --git a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V3.abi.json b/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V3.abi.json deleted file mode 100644 index f703c99d10..0000000000 --- a/centrifuge-app/src/utils/tinlake/abis/NAVFeed_V3.abi.json +++ /dev/null @@ -1,405 +0,0 @@ -[ - { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Deny", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "indexed": false, "internalType": "address", "name": "addr", "type": "address" } - ], - "name": "Depend", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "indexed": false, "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "rate_", "type": "uint256" } - ], - "name": "File", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": true, "internalType": "address", "name": "usr", "type": "address" }], - "name": "Rely", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "nftID", "type": "bytes32" }, - { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "Update", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "bytes32", "name": "nftID", "type": "bytes32" }, - { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "risk", "type": "uint256" } - ], - "name": "Update", - "type": "event" - }, - { - "inputs": [], - "name": "WRITEOFF_RATE_GROUP", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "borrow", - "outputs": [{ "internalType": "uint256", "name": "navIncrease", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "", "type": "uint256" } - ], - "name": "borrowEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "borrowed", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "calcUpdateNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "ceiling", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "riskID", "type": "uint256" }], - "name": "ceilingRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "deny", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "contractName", "type": "bytes32" }, - { "internalType": "address", "name": "addr", "type": "address" } - ], - "name": "depend", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "name": "details", - "outputs": [ - { "internalType": "uint128", "name": "nftValues", "type": "uint128" }, - { "internalType": "uint128", "name": "risk", "type": "uint128" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "name", "type": "bytes32" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" }, - { "internalType": "uint256", "name": "thresholdRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "ceilingRatio_", "type": "uint256" }, - { "internalType": "uint256", "name": "rate_", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "isLoanWrittenOff", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastNAVUpdate", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "latestNAV", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "loanDetails", - "outputs": [{ "internalType": "uint128", "name": "borrowed", "type": "uint128" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "lockEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "registry", "type": "address" }, - { "internalType": "uint256", "name": "tokenId", "type": "uint256" } - ], - "name": "nftID", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "nftValues", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pile", - "outputs": [{ "internalType": "contract PileLike", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rdiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "rely", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "repay", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "repayEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes32", "name": "nft_", "type": "bytes32" }], - "name": "risk", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "riskGroup", - "outputs": [ - { "internalType": "uint128", "name": "ceilingRatio", "type": "uint128" }, - { "internalType": "uint128", "name": "thresholdRatio", "type": "uint128" }, - { "internalType": "uint128", "name": "recoveryRatePD", "type": "uint128" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rmul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeAdd", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeDiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeMul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeSub", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "shelf", - "outputs": [{ "internalType": "contract ShelfLike", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "threshold", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "riskID", "type": "uint256" }], - "name": "thresholdRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], - "name": "uniqueDayTimestamp", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "unlockEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "uint256", "name": "risk_", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes32", "name": "nftID_", "type": "bytes32" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "wards", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "writeOff", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "zeroPV", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - } -] diff --git a/centrifuge-app/src/utils/tinlake/abis/Pile.abi.json b/centrifuge-app/src/utils/tinlake/abis/Pile.abi.json deleted file mode 100644 index 3e33642e88..0000000000 --- a/centrifuge-app/src/utils/tinlake/abis/Pile.abi.json +++ /dev/null @@ -1,321 +0,0 @@ -[ - { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, - { - "anonymous": true, - "inputs": [ - { "indexed": true, "internalType": "bytes4", "name": "sig", "type": "bytes4" }, - { "indexed": true, "internalType": "address", "name": "guy", "type": "address" }, - { "indexed": true, "internalType": "bytes32", "name": "foo", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "bar", "type": "bytes32" }, - { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" }, - { "indexed": false, "internalType": "bytes", "name": "fax", "type": "bytes" } - ], - "name": "LogNote", - "type": "event" - }, - { - "constant": false, - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "accrue", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "newRate", "type": "uint256" } - ], - "name": "changeRate", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "interestBearingAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" } - ], - "name": "chargeInterest", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint256", "name": "lastUpdated", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "compounding", - "outputs": [ - { "internalType": "uint256", "name": "", "type": "uint256" }, - { "internalType": "uint256", "name": "", "type": "uint256" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }], - "name": "debt", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "currencyAmount", "type": "uint256" } - ], - "name": "decDebt", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "deny", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "uint256", "name": "rate", "type": "uint256" }], - "name": "drip", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "bytes32", "name": "what", "type": "bytes32" }, - { "internalType": "uint256", "name": "rate", "type": "uint256" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "file", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "currencyAmount", "type": "uint256" } - ], - "name": "incDebt", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "loanRates", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "pie", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "uint256", "name": "rate", "type": "uint256" }], - "name": "rateDebt", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "rates", - "outputs": [ - { "internalType": "uint256", "name": "pie", "type": "uint256" }, - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" }, - { "internalType": "uint48", "name": "lastUpdated", "type": "uint48" }, - { "internalType": "uint256", "name": "fixedRate", "type": "uint256" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rdiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }], - "name": "rely", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "rmul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "n", "type": "uint256" }, - { "internalType": "uint256", "name": "base", "type": "uint256" } - ], - "name": "rpow", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeAdd", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeDiv", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeMul", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "x", "type": "uint256" }, - { "internalType": "uint256", "name": "y", "type": "uint256" } - ], - "name": "safeSub", - "outputs": [{ "internalType": "uint256", "name": "z", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "uint256", "name": "loan", "type": "uint256" }, - { "internalType": "uint256", "name": "rate", "type": "uint256" } - ], - "name": "setRate", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "pie", "type": "uint256" } - ], - "name": "toAmount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "uint256", "name": "chi", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "toPie", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "total", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "wards", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] diff --git a/centrifuge-app/src/utils/tinlake/fetchFromTinlakeSubgraph.ts b/centrifuge-app/src/utils/tinlake/fetchFromTinlakeSubgraph.ts index 3378d4d225..e27af32aee 100644 --- a/centrifuge-app/src/utils/tinlake/fetchFromTinlakeSubgraph.ts +++ b/centrifuge-app/src/utils/tinlake/fetchFromTinlakeSubgraph.ts @@ -1,4 +1,4 @@ -export async function fetchFromTinlakeSubgraph(query: string, variables?: unknown) { +export async function fetchFromTinlakeSubgraph(query: string, variables?: object) { const response = await fetch(import.meta.env.REACT_APP_TINLAKE_SUBGRAPH_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/centrifuge-app/src/utils/tinlake/useTinlakePools.ts b/centrifuge-app/src/utils/tinlake/useTinlakePools.ts index fbf9d499cd..cc1a5d6478 100644 --- a/centrifuge-app/src/utils/tinlake/useTinlakePools.ts +++ b/centrifuge-app/src/utils/tinlake/useTinlakePools.ts @@ -10,18 +10,12 @@ import { } from '@centrifuge/centrifuge-js' import { useCentrifuge } from '@centrifuge/centrifuge-react' import { BigNumber } from '@ethersproject/bignumber' -import { Contract } from '@ethersproject/contracts' -import { InfuraProvider } from '@ethersproject/providers' import BN from 'bn.js' import * as React from 'react' import { useQuery } from 'react-query' import { lastValueFrom } from 'rxjs' import { ethConfig } from '../../config' import { Dec } from '../Decimal' -import feedv1Abi from './abis/NAVFeed_V1.abi.json' -import feedv2Abi from './abis/NAVFeed_V2.abi.json' -import feedv3Abi from './abis/NAVFeed_V3.abi.json' -import pileAbi from './abis/Pile.abi.json' import { currencies } from './currencies' import { Call, multicall } from './multicall' import { Fixed27Base } from './ratios' @@ -145,55 +139,27 @@ export function useTinlakePools(suspense = false) { suspense, }) } - export function useTinlakeLoans(poolId: string) { - const tinlakePools = useTinlakePools() + const tinlakePools = useTinlakePools(true) const pool = tinlakePools?.data?.pools?.find((p) => p.id.toLowerCase() === poolId.toLowerCase()) return useQuery( - ['tinlakePoolLoans', poolId, pool], + ['tinlakePoolLoans', poolId.toLowerCase()], async () => { const loans = await getTinlakeLoans(poolId) + const writeOffPercentages = await getWriteOffPercentages(pool!, loans) - const writeOffPercentagePromises = loans.map(async (loan) => { - if (pool) { - const writeOffPercentage = await getWriteOffPercentage(pool, loan.index) - - if (writeOffPercentage.isZero()) { - return { - loanId: loan.index, - percentage: '0', - } - } - - return { - loanId: loan.index, - percentage: writeOffPercentage.div(new BN(10).pow(new BN(25))).toString(), - } - } - - return { - loanId: loan.index, - percentage: '0', - } - }) - - const writeOffPercentage = (await Promise.all(writeOffPercentagePromises)).reduce((acc, curr) => { - acc[curr.loanId] = curr.percentage - return acc - }, {} as { [key: number]: string }) - - return loans.map((loan) => ({ + return loans.map((loan, i) => ({ asset: { nftId: loan.nftId, - collectionId: loan.pool.id, + collectionId: poolId, }, id: loan.index.toString(), originationDate: loan.financingDate ? new Date(Number(loan.financingDate) * 1000).toISOString() : null, outstandingDebt: new CurrencyBalance(loan.debt, 18), presentValue: new CurrencyBalance(loan.debt, 18), - poolId: loan.pool.id, + poolId, pricing: { maturityDate: Number(loan.maturityDate) ? new Date(Number(loan.maturityDate) * 1000).toISOString() : null, interestRate: new Rate( @@ -201,8 +167,8 @@ export function useTinlakeLoans(poolId: string) { ), ceiling: new CurrencyBalance(loan.ceiling, 18), }, - status: getTinlakeLoanStatus(loan, writeOffPercentage[loan.index]), - writeOffPercentage: writeOffPercentage[loan.index], + status: getTinlakeLoanStatus(loan, writeOffPercentages[i]), + writeOffPercentage: writeOffPercentages[i], totalBorrowed: new CurrencyBalance(loan.borrowsAggregatedAmount, 18), totalRepaid: new CurrencyBalance(loan.repaysAggregatedAmount, 18), dateClosed: loan.closed ? new Date(Number(loan.closed) * 1000).toISOString() : 0, @@ -264,8 +230,8 @@ export type TinlakePool = Omit ({ + target: pool.addresses.FEED, + call: ['writeOffGroups(uint256)(uint128,uint128)', i], + returns: [[`groups[${i}].percentage`, toBN], [`groups[${i}].overdueDays`]], + })) try { - const group = await navFeed.writeOffGroups(i) - groups.push(group) - i += 1 - } catch (e) { - return groups - } + const data = await multicall<{ groups: { percentage: BN; overdueDays: number }[] }>(calls) + writeOffGroups.push(...data.groups) + } catch {} } - return groups -} - -export async function getWriteOffPercentage(pool: TinlakePool, loanId: number): Promise { - const feedAbi = (() => { - if (pool.versions?.FEED === 2) { - return feedv2Abi - } - if (pool.versions?.FEED === 3) { - return feedv3Abi - } - return feedv1Abi - })() - const provider = new InfuraProvider() - const pile = new Contract(pool.addresses.PILE, pileAbi, provider) - const navFeed = new Contract(pool.addresses.FEED, feedAbi, provider) - - const loanRate = await pile.loanRates(loanId) - - if (loanRate.lt(1000)) { - return new BN(0) + const rateCalls: Call[] = loans.map((loan, i) => ({ + target: pool.addresses.PILE, + call: ['loanRates(uint256)(uint256)', loan.index], + returns: [[`rates[${i}]`, (val) => val.toNumber()]], + })) + + const loanRates = await multicall<{ rates: number[]; groups: any }>(rateCalls) + + if (writeOffGroups.length) { + const percentages = loans.map((_, i) => { + if (loanRates.rates[i] < 1000) return new Rate(0) + const rate = loanRates.rates[i] - 1000 + const group = writeOffGroups[rate] + return group.percentage ? new Rate(Rate.fromFloat(1).sub(group.percentage)) : new Rate(0) + }) + return percentages } - - if (navFeed.writeOffs) { - const writeOffGroup = loanRate.sub(1000) - const { percentage } = await navFeed.writeOffs(writeOffGroup.toString()) - - return Rate.fromFloat(1).sub(new BN(percentage.toString())) - } else if (navFeed.writeOffGroups) { - const writeOffGroups = await getWriteOffGroups(pool) - let { percentage } = writeOffGroups[loanRate.sub(1000).toNumber()] - if (percentage) { - percentage = Rate.fromFloat(1).sub(new BN(percentage.toString())) - - return percentage - } - - return new BN(0) + if (!pool.versions?.FEED || pool.versions.FEED === 1) { + const calls = loans + .map((_, i) => ({ + target: pool.addresses.FEED, + call: ['writeOffs(uint256)(uint256,uint256)', loanRates.rates[i] - 1000], + returns: [[''], [`percentages[${i}]`, toBN]], + })) + .filter((_, i) => loanRates.rates[i] >= 1000) as Call[] + + const { percentages } = await multicall<{ percentages: BN[] }>(calls) + return loans.map((_, i) => { + return percentages?.[i] ? new Rate(Rate.fromFloat(1).sub(percentages[i])) : new Rate(0) + }) } - return new BN(0) + return loans.map(() => new Rate(0)) } async function getPools(pools: IpfsPools): Promise<{ pools: TinlakePool[] }> { @@ -871,3 +824,7 @@ interface State { } submissionPeriod: boolean } + +function toBN(val: BigNumber) { + return new BN(val.toString()) +} diff --git a/centrifuge-app/src/utils/usePools.ts b/centrifuge-app/src/utils/usePools.ts index 4ad8882b95..116ec7bfb9 100644 --- a/centrifuge-app/src/utils/usePools.ts +++ b/centrifuge-app/src/utils/usePools.ts @@ -100,7 +100,7 @@ export function useAverageAmount(poolId: string) { if (loan.status !== 'Active') return sum return sum.add(loan.presentValue.toDecimal()) }, Dec(0)) - .div(loans.filter((loan) => loan.status === 'Active').length) + .div((loans as Loan[]).filter((loan) => loan.status === 'Active').length) } export function useBorrowerAssetTransactions(poolId: string, assetId: string, from?: Date, to?: Date) { diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 85e290bbe0..08c96dc096 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -420,7 +420,7 @@ export type TinlakeLoan = { totalBorrowed: CurrencyBalance totalRepaid: CurrencyBalance originationDate: string - writeOffPercentage: string + writeOffPercentage: Rate } // transformed type for UI