From c54b306be4243888a8e2535c0b74a0883160aa67 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Mon, 18 Sep 2023 14:29:02 +0300 Subject: [PATCH 1/4] int --- .../ethereum/makerdao/abi/cdpManager.json | 571 ++++++++ .../ethereum/makerdao/abi/ilkRegistry.json | 855 +++++++++++ .../ethereum/makerdao/abi/mcdMonitorV2.json | 1251 +++++++++++++++++ .../providers/ethereum/makerdao/data.json | 7 - .../providers/ethereum/makerdao/index.ts | 316 +++-- .../ethereum/makerdao/maker-mcd.json | 40 - .../providers/ethereum/makerdao/makerdao.json | 5 - .../ethereum/makerdao/makerdao_log.json | 4 - 8 files changed, 2866 insertions(+), 183 deletions(-) create mode 100644 src/factory/providers/ethereum/makerdao/abi/cdpManager.json create mode 100644 src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json create mode 100644 src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json delete mode 100644 src/factory/providers/ethereum/makerdao/data.json delete mode 100644 src/factory/providers/ethereum/makerdao/maker-mcd.json delete mode 100644 src/factory/providers/ethereum/makerdao/makerdao.json delete mode 100644 src/factory/providers/ethereum/makerdao/makerdao_log.json diff --git a/src/factory/providers/ethereum/makerdao/abi/cdpManager.json b/src/factory/providers/ethereum/makerdao/abi/cdpManager.json new file mode 100644 index 00000000..22b140ee --- /dev/null +++ b/src/factory/providers/ethereum/makerdao/abi/cdpManager.json @@ -0,0 +1,571 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "vat_", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": true, + "inputs": [ + { + "indexed": true, + "internalType": "bytes4", + "name": "sig", + "type": "bytes4" + }, + { + "indexed": true, + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg1", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg2", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LogNote", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "own", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + } + ], + "name": "NewCdp", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "ok", + "type": "uint256" + } + ], + "name": "cdpAllow", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cdpCan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "cdpi", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "count", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + } + ], + "name": "enter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "first", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "flux", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "flux", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "dink", + "type": "int256" + }, + { + "internalType": "int256", + "name": "dart", + "type": "int256" + } + ], + "name": "frob", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "give", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "ilks", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "last", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "list", + "outputs": [ + { + "internalType": "uint256", + "name": "prev", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "next", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rad", + "type": "uint256" + } + ], + "name": "move", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "usr", + "type": "address" + } + ], + "name": "open", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "owns", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "quit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "cdpSrc", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cdpDst", + "type": "uint256" + } + ], + "name": "shift", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "ok", + "type": "uint256" + } + ], + "name": "urnAllow", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "urnCan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "urns", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vat", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json b/src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json new file mode 100644 index 00000000..fb2822b9 --- /dev/null +++ b/src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json @@ -0,0 +1,855 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "vat_", + "type": "address" + }, + { + "internalType": "address", + "name": "dog_", + "type": "address" + }, + { + "internalType": "address", + "name": "cat_", + "type": "address" + }, + { + "internalType": "address", + "name": "spot_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "AddIlk", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "usr", + "type": "address" + } + ], + "name": "Deny", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "data", + "type": "address" + } + ], + "name": "File", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "data", + "type": "address" + } + ], + "name": "File", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "name": "File", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "string", + "name": "data", + "type": "string" + } + ], + "name": "File", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "NameError", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "usr", + "type": "address" + } + ], + "name": "Rely", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "RemoveIlk", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "SymbolError", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "UpdateIlk", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "adapter", + "type": "address" + } + ], + "name": "add", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cat", + "outputs": [ + { + "internalType": "contract CatLike", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "class", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "count", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "dec", + "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": [], + "name": "dog", + "outputs": [ + { + "internalType": "contract DogLike", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "data", + "type": "uint256" + } + ], + "name": "file", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "data", + "type": "string" + } + ], + "name": "file", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "data", + "type": "address" + } + ], + "name": "file", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "what", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "data", + "type": "address" + } + ], + "name": "file", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "gem", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "pos", + "type": "uint256" + } + ], + "name": "get", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "ilkData", + "outputs": [ + { + "internalType": "uint96", + "name": "pos", + "type": "uint96" + }, + { + "internalType": "address", + "name": "join", + "type": "address" + }, + { + "internalType": "address", + "name": "gem", + "type": "address" + }, + { + "internalType": "uint8", + "name": "dec", + "type": "uint8" + }, + { + "internalType": "uint96", + "name": "class", + "type": "uint96" + }, + { + "internalType": "address", + "name": "pip", + "type": "address" + }, + { + "internalType": "address", + "name": "xlip", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "info", + "outputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "class", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dec", + "type": "uint256" + }, + { + "internalType": "address", + "name": "gem", + "type": "address" + }, + { + "internalType": "address", + "name": "pip", + "type": "address" + }, + { + "internalType": "address", + "name": "join", + "type": "address" + }, + { + "internalType": "address", + "name": "xlip", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "join", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "list", + "outputs": [ + { + "internalType": "bytes32[]", + "name": "", + "type": "bytes32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "end", + "type": "uint256" + } + ], + "name": "list", + "outputs": [ + { + "internalType": "bytes32[]", + "name": "", + "type": "bytes32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "pip", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "pos", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_ilk", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_join", + "type": "address" + }, + { + "internalType": "address", + "name": "_gem", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_dec", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_class", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_pip", + "type": "address" + }, + { + "internalType": "address", + "name": "_xlip", + "type": "address" + }, + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "name": "put", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + } + ], + "name": "rely", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "remove", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "removeAuth", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "spot", + "outputs": [ + { + "internalType": "contract SpotLike", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "update", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vat", + "outputs": [ + { + "internalType": "contract VatLike", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "wards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ilk", + "type": "bytes32" + } + ], + "name": "xlip", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json b/src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json new file mode 100644 index 00000000..1c79b582 --- /dev/null +++ b/src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json @@ -0,0 +1,1251 @@ +[ + { + "constant": true, + "inputs": [], + "name": "WETH_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "CDAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_method", + "type": "uint8" + }, + { + "name": "_cdpId", + "type": "uint256" + }, + { + "name": "_nextPrice", + "type": "uint256" + } + ], + "name": "canCall", + "outputs": [ + { + "name": "", + "type": "bool" + }, + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SAVINGS_LOGGER_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_data", + "type": "uint256[6]" + }, + { + "name": "_nextPrice", + "type": "uint256" + }, + { + "name": "_joinAddr", + "type": "address" + }, + { + "name": "_exchangeAddress", + "type": "address" + }, + { + "name": "_callData", + "type": "bytes" + } + ], + "name": "repayFor", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BOOST_GAS_COST", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PIP_INTERFACE_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "setOwnerByAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "KYBER_ETH_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "OTC_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_gasAmount", + "type": "uint256" + } + ], + "name": "calcGasCost", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "IDAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "spotter", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_ilk", + "type": "bytes32" + } + ], + "name": "getPrice", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "GAS_TOKEN_INTERFACE_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vat", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "VOX_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "REPAY_GAS_COST", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MANAGER_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MONITOR_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ETH2DAI_WRAPPER", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "manager", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_method", + "type": "uint8" + }, + { + "name": "_cdpId", + "type": "uint256" + }, + { + "name": "_nextPrice", + "type": "uint256" + } + ], + "name": "ratioGoodAfter", + "outputs": [ + { + "name": "", + "type": "bool" + }, + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_gasCost", + "type": "uint256" + } + ], + "name": "changeRepayGasCost", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "STUPID_EXCHANGE", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "monitorProxyContract", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIGRATION_ACTIONS_PROXY", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SPOTTER_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BOOST_GAS_TOKEN", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PROXY_REGISTRY_INTERFACE_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_caller", + "type": "address" + } + ], + "name": "addCaller", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "subscriptionsContract", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PROXY_ACTIONS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MKR_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_data", + "type": "uint256[6]" + }, + { + "name": "_nextPrice", + "type": "uint256" + }, + { + "name": "_joinAddr", + "type": "address" + }, + { + "name": "_exchangeAddress", + "type": "address" + }, + { + "name": "_callData", + "type": "bytes" + } + ], + "name": "boostFor", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "FACTORY_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "LOGGER_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SAVER_EXCHANGE_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAKER_DAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_tokenAddress", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferERC20", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DISCOUNT_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "REPAY_GAS_TOKEN", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "approvedCallers", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_admin", + "type": "address" + } + ], + "name": "setAdminByAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "AUTOMATIC_LOGGER_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_gasCost", + "type": "uint256" + } + ], + "name": "changeBoostGasCost", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "JUG_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "NEW_CDAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "KYBER_WRAPPER", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SUBSCRIPTION_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "NEW_IDAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "COMPOUND_DAI_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_cdpId", + "type": "uint256" + } + ], + "name": "getOwner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_cdpId", + "type": "uint256" + }, + { + "name": "_ilk", + "type": "bytes32" + } + ], + "name": "getCdpInfo", + "outputs": [ + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UNISWAP_FACTORY", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "OASIS_WRAPPER", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PETH_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "KYBER_INTERFACE", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "VAT_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DAI_JOIN_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_cdpId", + "type": "uint256" + }, + { + "name": "_nextPrice", + "type": "uint256" + } + ], + "name": "getRatio", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERC20_PROXY_0X", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "WALLET_ID", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SOLO_MARGIN_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "automaticSaverProxyAddress", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UNISWAP_WRAPPER", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_admin", + "type": "address" + } + ], + "name": "setAdminByOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_GAS_PRICE", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferEth", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_caller", + "type": "address" + } + ], + "name": "removeCaller", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_gasAmount", + "type": "uint256" + }, + { + "name": "_isRepay", + "type": "bool" + } + ], + "name": "changeGasTokenAmount", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "TUB_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ETH_JOIN_ADDRESS", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "logger", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SCD_MCD_MIGRATION", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "name": "_monitorProxy", + "type": "address" + }, + { + "name": "_subscriptions", + "type": "address" + }, + { + "name": "_automaticSaverProxyAddress", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + } +] \ No newline at end of file diff --git a/src/factory/providers/ethereum/makerdao/data.json b/src/factory/providers/ethereum/makerdao/data.json deleted file mode 100644 index cf26b0d6..00000000 --- a/src/factory/providers/ethereum/makerdao/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", - "name": "Maker", - "symbol": "MKR", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/0f/mkr_small.png" -} \ No newline at end of file diff --git a/src/factory/providers/ethereum/makerdao/index.ts b/src/factory/providers/ethereum/makerdao/index.ts index 780764d9..714ceb28 100644 --- a/src/factory/providers/ethereum/makerdao/index.ts +++ b/src/factory/providers/ethereum/makerdao/index.ts @@ -1,157 +1,219 @@ +import fetch from 'node-fetch'; import BigNumber from 'bignumber.js'; -import ERC20_ABI from '../../../../constants/abi/erc20.json'; -import MakerSCDConstants from './makerdao.json'; -import MakerMCDConstants from './maker-mcd.json'; import formatter from '../../../../util/formatter'; import util from '../../../../util/blockchainUtil'; import basicUtil from '../../../../util/basicUtil'; import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; -import { log } from '../../../../util/logger/logger'; +import ERC20_ABI from '../../../../constants/abi/erc20.json'; +import CDP_MANAGER_ABI from './abi/cdpManager.json'; +import IKL_REGISTRY_ABI from './abi/ilkRegistry.json'; +import MCD_MONITOR_V2 from './abi/mcdMonitorV2.json'; -async function getJoins(block, chain, provider, web3) { - const relyTopic = - '0x65fae35e00000000000000000000000000000000000000000000000000000000'; +const START_BLOCK = 14583413; +const BLOCK_LIMIT = 10000; - // get list of auths - let offset = 100000; - const stored_log = await basicUtil.readFromCache( - 'makerdao_log.json', - chain, - provider, - ); - console.log(stored_log); - let i = Math.max(MakerMCDConstants.STARTBLOCK, Number(stored_log.block) || 0); - const logs = stored_log.data || []; - - for (;;) { - console.log(i); - if (i > block) { - break; - } - try { - const seperatedLogs = await web3.eth.getPastLogs({ - fromBlock: i, - toBlock: Math.min(i + offset, block), - topics: [relyTopic], - address: MakerMCDConstants.VAT, - }); - const tokens = seperatedLogs.map( - (log) => `0x${log.topics[1].substr(26)}`, +// TO DO MOVE TO STORAGE +const API_URL = ''; +const CONTRACTS = { + AutomationV1Contract: '0x6E87a7A0A03E51A741075fDf4D1FCce39a4Df01b', + McdMonitorV2: '0xa59d5E94BFE605A9a4aC7e02f5380e02061c8dd2', + CdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39', + IlkRegistry: '0x5a464c28d19848f44199d003bef5ecc87d090f87', +}; + +const LOGS_TOPIC = { + TriggerAdded: + '0xcb616360dd177f28577e33576c8ac7ffcc1008cba7ac2323e0b2f170faf60bd2', + TriggerExecuted: + '0xc10f224f2f1ceab5e36f97effaa05c4b75eccbecd77b65bfb20c484de9096cdd', + TriggerRemoved: + '0xb4a1fc324bd863f8cd42582bebf2ce7f2d309c6a84bf371f28e069f95a4fa9e1', +}; + +async function getAutomationCdpIdList(block, chain, provider, web3) { + let cache: { + start: number; + cdpIdList: number[]; + } = { start: START_BLOCK, cdpIdList: [] }; + try { + cache = await basicUtil.readFromCache('cache.json', chain, provider); + } catch {} + + const cdpIdList = new Set(cache.cdpIdList); + + const triggerEvents = []; + for ( + let i = Math.max(cache.start, START_BLOCK); + i < block; + i += BLOCK_LIMIT + ) { + console.log('loop', i); + const [triggerAddedLogs, triggerRemovedLogs, triggerExecutedLogs] = + await Promise.all( + Object.keys(LOGS_TOPIC).map((key) => + util.getLogs( + i, + Math.min(i + BLOCK_LIMIT, block), + LOGS_TOPIC[key], + CONTRACTS.AutomationV1Contract, + web3, + ), + ), ); - tokens.forEach((token) => { - if (!logs.includes(token)) { - logs.push(token); - } - }); - i += offset; - if (offset < 20) { - offset += 2; - } else if (offset < 200) { - offset += 20; - } else if (offset < 2000) { - offset += 200; - } else { - offset += 2000; - } - } catch (e) { - if (offset > 2000) { - offset -= 2000; - } else if (offset > 200) { - offset -= 200; - } else if (offset > 20) { - offset -= 20; - } else if (offset > 2) { - offset -= 2; - } else { - break; - } - } + + triggerAddedLogs.output.forEach((log) => { + const trigger = new BigNumber( + `0x${log.topics[1].substring(26, 66)}`, + ).toFixed(); + const cdp = new BigNumber( + `0x${log.topics[3].substring(26, 66)}`, + ).toFixed(); + const action = `triggerAdded`; + + triggerEvents.push({ cdp, trigger, action }); + }); + + triggerRemovedLogs.output.forEach((log) => { + const trigger = new BigNumber( + `0x${log.topics[2].substring(26, 66)}`, + ).toFixed(); + const cdp = new BigNumber( + `0x${log.topics[1].substring(26, 66)}`, + ).toFixed(); + const action = `triggerRemoved`; + + triggerEvents.push({ cdp, trigger, action }); + }); + + triggerExecutedLogs.output.forEach((log) => { + const trigger = new BigNumber( + `0x${log.topics[1].substring(26, 66)}`, + ).toFixed(); + const cdp = new BigNumber( + `0x${log.topics[2].substring(26, 66)}`, + ).toFixed(); + const action = `triggerExecuted`; + + triggerEvents.push({ cdp, trigger, action }); + }); } - const log_data = { - block: undefined, - data: undefined, - }; - log_data.block = Math.max(Number(stored_log.block) || 0, block); - log_data.data = []; - - const ilkResults = await util.executeCallOfMultiTargets( - logs, - MakerMCDConstants.abi, - 'ilk', - [], - block, - chain, - web3, - ); - ilkResults.forEach((result, index) => { - if (result) { - log_data.data.push(logs[index]); + triggerEvents.sort((a, b) => a.trigger - b.trigger); + + triggerEvents.forEach((event) => { + const { cdp, action } = event; + if (action === 'triggerAdded') { + cdpIdList.add(cdp); + } else if (action === 'triggerRemoved' || action === 'triggerExecuted') { + cdpIdList.delete(cdp); } }); - await basicUtil.saveIntoCache(log_data, 'makerdao_log.json', chain, provider); - return log_data.data; + cache.start = block; + cache.cdpIdList = Array.from(cdpIdList); + await basicUtil.saveIntoCache(cache, 'cache.json', chain, provider); + + return cdpIdList; } async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; - const balances = {}; + let balances = {}; + if (block < START_BLOCK) { + return { balances }; + } - const scdContract = new web3.eth.Contract( - ERC20_ABI, - MakerSCDConstants.WETH_ADDRESS, + const confirmedSummerFiMakerVaults = await fetch(API_URL).then((res) => + res.json(), ); - balances[MakerSCDConstants.WETH_ADDRESS] = new BigNumber( - await scdContract.methods - .balanceOf(MakerSCDConstants.TUB_ADDRESS) - .call(null, block), + + const confirmedSummerFiMakerVaultsArray = [ + ...Object.keys(confirmedSummerFiMakerVaults), + ]; + const confirmedSummerFiMakerVaultsSet = new Set( + confirmedSummerFiMakerVaultsArray, ); - if (block >= MakerMCDConstants.STARTBLOCK) { - let joins = await getJoins(block, chain, provider, web3); + const cdpIdList = await getAutomationCdpIdList(block, chain, provider, web3); - let gemResults = await util.executeCallOfMultiTargets( - joins, - MakerMCDConstants.abi, - 'gem', - [], - block, - chain, - web3, - ); + [...cdpIdList].forEach((cdpId) => { + confirmedSummerFiMakerVaultsSet.delete(cdpId.toString()); + }); + + const filteredVaultsList = [...confirmedSummerFiMakerVaultsSet].filter( + (i) => { + const [startBlock] = confirmedSummerFiMakerVaults[i]; + return block > startBlock; + }, + ); + + const cdpIds = [...new Set(filteredVaultsList)]; - joins = joins.filter((_, index) => gemResults[index]); - gemResults = gemResults.filter((_, index) => gemResults[index]); - const balanceResults = await util.getTokenBalancesOfHolders( - joins, - gemResults, + const ilkNames = await util.executeMultiCallsOfTarget( + CONTRACTS.CdpManager, + CDP_MANAGER_ABI, + 'ilks', + cdpIds, + block, + chain, + web3, + ); + + const cdpIlkIds = {}; + ilkNames.forEach((val, idx) => (cdpIlkIds[cdpIds[idx]] = val)); + const ilkIds = [...new Set(ilkNames)]; + const tokens = ( + await util.executeMultiCallsOfTarget( + CONTRACTS.IlkRegistry, + IKL_REGISTRY_ABI, + 'info', + ilkIds, block, chain, web3, - ); - - formatter.sumMultiBalanceOf(balances, balanceResults); - - try { - const pie = await new web3.eth.Contract( - MakerMCDConstants.abi, - MakerMCDConstants.POT, - ).methods - .Pie() - .call(null, block); - balances[MakerMCDConstants.DAI] = balances[MakerMCDConstants.DAI] - ? balances[MakerMCDConstants.DAI].plus(new BigNumber(pie)) - : new BigNumber(pie); - } catch (e) { - log.error({ - message: e?.message || '', - stack: e?.stack || '', - detail: `Error: Failed to get Pie ethereum/makerdao`, - endpoint: 'tvl', - }); + ) + ).map((i) => i[4]); + const decimals = await util.executeCallOfMultiTargets( + tokens, + ERC20_ABI, + 'decimals', + [], + block, + chain, + web3, + ); + + const collData = await util.executeMultiCallsOfTarget( + CONTRACTS.McdMonitorV2, + MCD_MONITOR_V2, + 'getCdpInfo', + filteredVaultsList.map((i) => [i, cdpIlkIds[i]]), + block, + chain, + web3, + ); + collData.forEach((coll, i) => { + const idx = ilkIds.indexOf(ilkNames[i]); + if (idx === -1) { + return; } - } + balances[String(tokens[idx]).toLowerCase()] = BigNumber( + balances[tokens[idx].toLowerCase()] || 0, + ).plus(coll['0'] / 10 ** (18 - decimals[idx])); + }); + + const tokenBalances = {}; + Object.keys(balances).forEach(function (key) { + tokenBalances[key] = BigNumber(balances[key]); + }); + + balances = await util.convertToUnderlyings( + tokenBalances, + block, + chain, + provider, + web3, + ); formatter.convertBalancesToFixed(balances); return { balances }; diff --git a/src/factory/providers/ethereum/makerdao/maker-mcd.json b/src/factory/providers/ethereum/makerdao/maker-mcd.json deleted file mode 100644 index 6f870322..00000000 --- a/src/factory/providers/ethereum/makerdao/maker-mcd.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "KOVANVAT": "0xba987bdb501d131f766fee8180da5d81b34b69d9", - "KOVANPOT": "0xea190dbdc7adf265260ec4da6e9675fd4f5a78bb", - "KOVANJUG": "0xcbb7718c9f39d05aeede1c472ca8bf804b2f1ead", - "KOVANSTARTBLOCK": 14764534, - "VAT": "0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b", - "POT": "0x197e90f9fad81970ba7976f33cbd77088e5d7cf7", - "JUG": "0x19c0976f590d67707e62397c87829d896dc0f1f1", - "DAI": "0x6b175474e89094c44da98b954eedeac495271d0f", - "STARTBLOCK": 8928152, - "abi": [ - { - "constant": true, - "inputs": [], - "name": "ilk", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "gem", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "Pie", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - } - ] -} diff --git a/src/factory/providers/ethereum/makerdao/makerdao.json b/src/factory/providers/ethereum/makerdao/makerdao.json deleted file mode 100644 index 65545187..00000000 --- a/src/factory/providers/ethereum/makerdao/makerdao.json +++ /dev/null @@ -1,5 +0,0 @@ - { - "TUB_ADDRESS": "0x448a5065aebb8e423f0896e6c5d525c040f59af3", - "DAI_ADDRESS": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359", - "WETH_ADDRESS": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" -} diff --git a/src/factory/providers/ethereum/makerdao/makerdao_log.json b/src/factory/providers/ethereum/makerdao/makerdao_log.json deleted file mode 100644 index 21fe7a1c..00000000 --- a/src/factory/providers/ethereum/makerdao/makerdao_log.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "block": null, - "data": null -} From d97692834d76a8761420642f19aa3e1ddd8facb5 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Mon, 18 Sep 2023 16:01:37 +0300 Subject: [PATCH 2/4] gUni --- .../providers/ethereum/makerdao/abi/gUni.json | 1150 +++++++++++++++++ .../providers/ethereum/makerdao/index.ts | 99 +- 2 files changed, 1244 insertions(+), 5 deletions(-) create mode 100644 src/factory/providers/ethereum/makerdao/abi/gUni.json diff --git a/src/factory/providers/ethereum/makerdao/abi/gUni.json b/src/factory/providers/ethereum/makerdao/abi/gUni.json new file mode 100644 index 00000000..ea2ba4d4 --- /dev/null +++ b/src/factory/providers/ethereum/makerdao/abi/gUni.json @@ -0,0 +1,1150 @@ +[ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_gelato", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "burnAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidityBurned", + "type": "uint128" + } + ], + "name": "Burned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "feesEarned0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feesEarned1", + "type": "uint256" + } + ], + "name": "FeesEarned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidityMinted", + "type": "uint128" + } + ], + "name": "Minted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newManager", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "int24", + "name": "lowerTick_", + "type": "int24" + }, + { + "indexed": false, + "internalType": "int24", + "name": "upperTick_", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidityBefore", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidityAfter", + "type": "uint128" + } + ], + "name": "Rebalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "managerFee", + "type": "uint16" + } + ], + "name": "SetManagerFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdminTreasury", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdminTreasury", + "type": "address" + } + ], + "name": "UpdateAdminTreasury", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "gelatoRebalanceBPS", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "gelatoWithdrawBPS", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "gelatoSlippageBPS", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "gelatoSlippageInterval", + "type": "uint32" + } + ], + "name": "UpdateGelatoParams", + "type": "event" + }, + { + "inputs": [], + "name": "GELATO", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "burnAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "liquidityBurned", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "newLowerTick", + "type": "int24" + }, + { + "internalType": "int24", + "name": "newUpperTick", + "type": "int24" + }, + { + "internalType": "uint160", + "name": "swapThresholdPrice", + "type": "uint160" + }, + { + "internalType": "uint256", + "name": "swapAmountBPS", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + } + ], + "name": "executiveRebalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoBalance0", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoBalance1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoFeeBPS", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoRebalanceBPS", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoSlippageBPS", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoSlippageInterval", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gelatoWithdrawBPS", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Max", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Max", + "type": "uint256" + } + ], + "name": "getMintAmounts", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPositionID", + "outputs": [ + { + "internalType": "bytes32", + "name": "positionID", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getUnderlyingBalances", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0Current", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Current", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtRatioX96", + "type": "uint160" + } + ], + "name": "getUnderlyingBalancesAtPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0Current", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Current", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "_pool", + "type": "address" + }, + { + "internalType": "uint16", + "name": "_managerFeeBPS", + "type": "uint16" + }, + { + "internalType": "int24", + "name": "_lowerTick", + "type": "int24" + }, + { + "internalType": "int24", + "name": "_upperTick", + "type": "int24" + }, + { + "internalType": "address", + "name": "_manager_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "_managerFeeBPS", + "type": "uint16" + } + ], + "name": "initializeManagerFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lowerTick", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "manager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "managerBalance0", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "managerBalance1", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "managerFeeBPS", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "managerTreasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "liquidityMinted", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pool", + "outputs": [ + { + "internalType": "contract IUniswapV3Pool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "swapThresholdPrice", + "type": "uint160" + }, + { + "internalType": "uint256", + "name": "swapAmountBPS", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "paymentToken", + "type": "address" + } + ], + "name": "rebalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Owed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Owed", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "uniswapV3MintCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "newRebalanceBPS", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "newWithdrawBPS", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "newSlippageBPS", + "type": "uint16" + }, + { + "internalType": "uint32", + "name": "newSlippageInterval", + "type": "uint32" + }, + { + "internalType": "address", + "name": "newTreasury", + "type": "address" + } + ], + "name": "updateGelatoParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "upperTick", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeToken", + "type": "address" + } + ], + "name": "withdrawGelatoBalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeToken", + "type": "address" + } + ], + "name": "withdrawManagerBalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/factory/providers/ethereum/makerdao/index.ts b/src/factory/providers/ethereum/makerdao/index.ts index 714ceb28..698abc8e 100644 --- a/src/factory/providers/ethereum/makerdao/index.ts +++ b/src/factory/providers/ethereum/makerdao/index.ts @@ -7,19 +7,20 @@ import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; import ERC20_ABI from '../../../../constants/abi/erc20.json'; import CDP_MANAGER_ABI from './abi/cdpManager.json'; import IKL_REGISTRY_ABI from './abi/ilkRegistry.json'; -import MCD_MONITOR_V2 from './abi/mcdMonitorV2.json'; +import MCD_MONITOR_V2_ABI from './abi/mcdMonitorV2.json'; +import G_UNI_ABI from './abi/gUni.json'; const START_BLOCK = 14583413; const BLOCK_LIMIT = 10000; -// TO DO MOVE TO STORAGE -const API_URL = ''; +const API_URL = process.env.SUMMERFI_CONFIRMED_VAULTS_API; const CONTRACTS = { AutomationV1Contract: '0x6E87a7A0A03E51A741075fDf4D1FCce39a4Df01b', McdMonitorV2: '0xa59d5E94BFE605A9a4aC7e02f5380e02061c8dd2', CdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39', IlkRegistry: '0x5a464c28d19848f44199d003bef5ecc87d090f87', }; +const G_UNI_DAI_USDC_ADDRESS = '0x50379f632ca68d36e50cfbc8f78fe16bd1499d1e'; const LOGS_TOPIC = { TriggerAdded: @@ -47,7 +48,6 @@ async function getAutomationCdpIdList(block, chain, provider, web3) { i < block; i += BLOCK_LIMIT ) { - console.log('loop', i); const [triggerAddedLogs, triggerRemovedLogs, triggerExecutedLogs] = await Promise.all( Object.keys(LOGS_TOPIC).map((key) => @@ -116,6 +116,91 @@ async function getAutomationCdpIdList(block, chain, provider, web3) { return cdpIdList; } +async function automationTvl(cdpIdList, balances, block, chain, web3) { + const cdpIds = [...cdpIdList]; + + const ilkNames = await util.executeMultiCallsOfTarget( + CONTRACTS.CdpManager, + CDP_MANAGER_ABI, + 'ilks', + cdpIds, + block, + chain, + web3, + ); + + const cdpIlkIds = {}; + ilkNames.forEach((val, idx) => (cdpIlkIds[cdpIds[idx]] = val)); + const ilkIds = [...new Set(ilkNames)]; + const tokens = ( + await util.executeMultiCallsOfTarget( + CONTRACTS.IlkRegistry, + IKL_REGISTRY_ABI, + 'info', + ilkIds, + block, + chain, + web3, + ) + ).map((i) => i[4]); + const decimals = await util.executeCallOfMultiTargets( + tokens, + ERC20_ABI, + 'decimals', + [], + block, + chain, + web3, + ); + + const collData = await util.executeMultiCallsOfTarget( + CONTRACTS.McdMonitorV2, + MCD_MONITOR_V2_ABI, + 'getCdpInfo', + cdpIds.map((i) => [i, cdpIlkIds[i]]), + block, + chain, + web3, + ); + collData.forEach((coll, i) => { + const idx = ilkIds.indexOf(ilkNames[i]); + balances[String(tokens[idx]).toLowerCase()] = BigNumber( + balances[tokens[idx].toLowerCase()] || 0, + ).plus(coll['0'] / 10 ** (18 - decimals[idx])); + }); +} + +async function convertGUniToUnderlyings(balances, block, chain, web3) { + if (balances[G_UNI_DAI_USDC_ADDRESS]) { + const [totalSupply, underlyingBalances, token0, token1] = await Promise.all( + await util.executeDifferentCallsOfTarget( + G_UNI_DAI_USDC_ADDRESS, + G_UNI_ABI, + ['totalSupply', 'getUnderlyingBalances', 'token0', 'token1'], + [[], [], [], []], + block, + chain, + web3, + ), + ); + + const ratio = new BigNumber(balances[G_UNI_DAI_USDC_ADDRESS]).dividedBy( + totalSupply, + ); + balances[token0.toLowerCase()] = BigNumber( + balances[token0.toLowerCase()] || 0, + ).plus( + new BigNumber(underlyingBalances.amount0Current).multipliedBy(ratio), + ); + balances[token1.toLowerCase()] = BigNumber( + balances[token1.toLowerCase()] || 0, + ).plus( + new BigNumber(underlyingBalances.amount1Current).multipliedBy(ratio), + ); + delete balances[G_UNI_DAI_USDC_ADDRESS]; + } +} + async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; let balances = {}; @@ -185,7 +270,7 @@ async function tvl(params: ITvlParams): Promise> { const collData = await util.executeMultiCallsOfTarget( CONTRACTS.McdMonitorV2, - MCD_MONITOR_V2, + MCD_MONITOR_V2_ABI, 'getCdpInfo', filteredVaultsList.map((i) => [i, cdpIlkIds[i]]), block, @@ -202,6 +287,10 @@ async function tvl(params: ITvlParams): Promise> { ).plus(coll['0'] / 10 ** (18 - decimals[idx])); }); + await automationTvl(cdpIdList, balances, block, chain, web3); + + await convertGUniToUnderlyings(balances, block, chain, web3); + const tokenBalances = {}; Object.keys(balances).forEach(function (key) { tokenBalances[key] = BigNumber(balances[key]); From 154b76a3231d6b707739aaaa130fc59453e45418 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Mon, 18 Sep 2023 16:07:46 +0300 Subject: [PATCH 3/4] Update .env.dev --- .env.dev | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.dev b/.env.dev index 8627f8da..102f1254 100644 --- a/.env.dev +++ b/.env.dev @@ -16,6 +16,7 @@ STACKS_NODE_URL=https://stacks-node-api.mainnet.stacks.co TEZOS_NODE_URL=https://rpc.tzstats.com CRONOS_NODE_URL=https://cronos.blockpi.network/v1/rpc/public ARBITRUM_NODE_URL=https://arb-mainnet-public.unifra.io +ZKSYNC-ERA_NODE_URL=https://mainnet.era.zksync.io ELYSIUM_NODE_URL=https://rpc.elysiumchain.tech ##======================== LOGSTASH ======================== LOGSTASH_PORT= From 5004a0ad5b7fa7a05e522176105b01a04e2391cf Mon Sep 17 00:00:00 2001 From: Mantas S Date: Mon, 18 Sep 2023 16:09:07 +0300 Subject: [PATCH 4/4] rename --- .../providers/ethereum/{makerdao => summerfi}/abi/cdpManager.json | 0 .../providers/ethereum/{makerdao => summerfi}/abi/gUni.json | 0 .../ethereum/{makerdao => summerfi}/abi/ilkRegistry.json | 0 .../ethereum/{makerdao => summerfi}/abi/mcdMonitorV2.json | 0 src/factory/providers/ethereum/{makerdao => summerfi}/index.ts | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/factory/providers/ethereum/{makerdao => summerfi}/abi/cdpManager.json (100%) rename src/factory/providers/ethereum/{makerdao => summerfi}/abi/gUni.json (100%) rename src/factory/providers/ethereum/{makerdao => summerfi}/abi/ilkRegistry.json (100%) rename src/factory/providers/ethereum/{makerdao => summerfi}/abi/mcdMonitorV2.json (100%) rename src/factory/providers/ethereum/{makerdao => summerfi}/index.ts (100%) diff --git a/src/factory/providers/ethereum/makerdao/abi/cdpManager.json b/src/factory/providers/ethereum/summerfi/abi/cdpManager.json similarity index 100% rename from src/factory/providers/ethereum/makerdao/abi/cdpManager.json rename to src/factory/providers/ethereum/summerfi/abi/cdpManager.json diff --git a/src/factory/providers/ethereum/makerdao/abi/gUni.json b/src/factory/providers/ethereum/summerfi/abi/gUni.json similarity index 100% rename from src/factory/providers/ethereum/makerdao/abi/gUni.json rename to src/factory/providers/ethereum/summerfi/abi/gUni.json diff --git a/src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json b/src/factory/providers/ethereum/summerfi/abi/ilkRegistry.json similarity index 100% rename from src/factory/providers/ethereum/makerdao/abi/ilkRegistry.json rename to src/factory/providers/ethereum/summerfi/abi/ilkRegistry.json diff --git a/src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json b/src/factory/providers/ethereum/summerfi/abi/mcdMonitorV2.json similarity index 100% rename from src/factory/providers/ethereum/makerdao/abi/mcdMonitorV2.json rename to src/factory/providers/ethereum/summerfi/abi/mcdMonitorV2.json diff --git a/src/factory/providers/ethereum/makerdao/index.ts b/src/factory/providers/ethereum/summerfi/index.ts similarity index 100% rename from src/factory/providers/ethereum/makerdao/index.ts rename to src/factory/providers/ethereum/summerfi/index.ts