From e102d819a06b3df572f6fe45eabc330918892f30 Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Fri, 10 Apr 2026 15:56:28 +0300 Subject: [PATCH] change dashboard table Signed-off-by: Uncle Fatso --- package.json | 2 +- src/abi/GhostGatekeeper.json | 1 + .../TreasuryDashboard/TreasuryDashboard.jsx | 3 +- .../components/ProtocolDetails.jsx | 137 ++++++++++++++++++ src/hooks/staking/index.js | 42 +++++- 5 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 src/abi/GhostGatekeeper.json create mode 100644 src/containers/TreasuryDashboard/components/ProtocolDetails.jsx diff --git a/package.json b/package.json index 37bdfb5..552782a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.7.13", + "version": "0.7.14", "type": "module", "scripts": { "dev": "vite", diff --git a/src/abi/GhostGatekeeper.json b/src/abi/GhostGatekeeper.json new file mode 100644 index 0000000..251d846 --- /dev/null +++ b/src/abi/GhostGatekeeper.json @@ -0,0 +1 @@ +{"abi":[{"type":"constructor","inputs":[{"name":"_staking","type":"address","internalType":"address"},{"name":"_ghostedSupply","type":"uint256","internalType":"uint256"},{"name":"_existential","type":"uint256","internalType":"uint256"},{"name":"_deployedAt","type":"uint48","internalType":"uint48"},{"name":"_amountIn","type":"uint104","internalType":"uint104"},{"name":"_amountOut","type":"uint104","internalType":"uint104"}],"stateMutability":"nonpayable"},{"type":"function","name":"DIVISOR","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"existentialDeposit","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"ghost","inputs":[{"name":"receiver","type":"bytes32","internalType":"bytes32"},{"name":"amount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"ghostedSupply","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"materialize","inputs":[{"name":"receiver","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"rx","type":"uint256","internalType":"uint256"},{"name":"s","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"metadata","inputs":[],"outputs":[{"name":"","type":"tuple","internalType":"struct IGatekeeperMetadata.GatekeeperMetadata","components":[{"name":"deployedAt","type":"uint48","internalType":"uint48"},{"name":"amountIn","type":"uint104","internalType":"uint104"},{"name":"amountOut","type":"uint104","internalType":"uint104"}]}],"stateMutability":"view"},{"type":"function","name":"rotate","inputs":[{"name":"aggregatedPublicKey","type":"uint256","internalType":"uint256"},{"name":"rx","type":"uint256","internalType":"uint256"},{"name":"s","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"staking","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"event","name":"Ghosted","inputs":[{"name":"receiver","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"amount","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Materialized","inputs":[{"name":"receiver","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Rotated","inputs":[{"name":"aggregatedPublicKey","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"error","name":"AlreadyExecuted","inputs":[]},{"type":"error","name":"NonExistentAmount","inputs":[]},{"type":"error","name":"NotStaking","inputs":[]},{"type":"error","name":"WrongSignature","inputs":[]}],"bytecode":{"object":"0x60a060405234801561000f575f80fd5b506040516107e73803806107e783398101604081905261002e916100cf565b5f939093556001939093556001600160a01b039093166080526040805160608101825265ffffffffffff9094168085526001600160681b039384166020860181905292909316930183905260028054600160981b9094026001600160981b0366010000000000009093026001600160981b0319909516909317939093171617905561014c565b80516001600160681b03811681146100ca575f80fd5b919050565b5f805f805f8060c087890312156100e4575f80fd5b86516001600160a01b03811681146100fa575f80fd5b809650506020870151945060408701519350606087015165ffffffffffff81168114610124575f80fd5b9250610132608088016100b4565b915061014060a088016100b4565b90509295509295509295565b6080516106756101725f395f818161019601528181610211015261036501526106755ff3fe608060405234801561000f575f80fd5b5060043610610085575f3560e01c8063392f37e911610058578063392f37e9146100d65780634cf088d9146101915780638bfc9a94146101dd578063f9f2efa5146101e6575f80fd5b806312935d13146100895780632168a42b1461009e5780633410fe6e146100b15780633432dbc7146100ce575b5f80fd5b61009c610097366004610533565b6101f9565b005b61009c6100ac366004610583565b6102de565b6100bb620f424081565b6040519081526020015b60405180910390f35b6100bb5f5481565b610150604080516060810182525f8082526020820181905291810191909152506040805160608101825260025465ffffffffffff811682526cffffffffffffffffffffffffff6601000000000000820481166020840152730100000000000000000000000000000000000000909104169181019190915290565b60408051825165ffffffffffff1681526020808401516cffffffffffffffffffffffffff9081169183019190915292820151909216908201526060016100c5565b6101b87f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100c5565b6100bb60015481565b61009c6101f43660046105ac565b61034d565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610268576040517f890fec5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610272828261049d565b6040517f46b3650b213ce5f43bd41e24103118598a3c7b5efdb8e65ba518fbd32e1eb4e3808252600482018690526024820185905260449091206040517f356a441800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102e8828261049d565b6040517f3852f4b083ca330e912d0b6247247a2bb72266ff9c5a0f58802a0826cd5441838082526004820185905260249091206040517f356a441800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146103bc576040517f890fec5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f548110156103f7576040517fb1193e4d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060015f828254610408919061062c565b90915550506002805482919060069061043b908490660100000000000090046cffffffffffffffffffffffffff166105ff565b92506101000a8154816cffffffffffffffffffffffffff02191690836cffffffffffffffffffffffffff16021790555080827f7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a660405160405180910390a35050565b5f82815260046020908152604080832084845290915290205460ff16156104f0576040517f0dc1019700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f918252600460209081526040808420928452919052902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b5f805f8060808587031215610546575f80fd5b843573ffffffffffffffffffffffffffffffffffffffff81168114610569575f80fd5b966020860135965060408601359560600135945092505050565b5f805f60608486031215610595575f80fd5b505081359360208301359350604090920135919050565b5f80604083850312156105bd575f80fd5b50508035926020909101359150565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b6cffffffffffffffffffffffffff818116838216019080821115610625576106256105cc565b5092915050565b808201808211156105f9576105f96105cc56fea2646970667358221220d0232bbad486f58145b1d7f4b3ada8ceadba5d25c96888306b079365a416152364736f6c63430008140033","sourceMap":"191:3340:58:-:0;;;651:464;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;850:18;:33;;;;893:13;:30;;;;-1:-1:-1;;;;;933:18:58;;;;;973:135;;;;;;;;;;;;;;;-1:-1:-1;;;;;973:135:58;;;;;;;;;;;;;;;;;;961:9;:147;;-1:-1:-1;;;961:147:58;;;-1:-1:-1;;;;;961:147:58;;;;-1:-1:-1;;;;;;961:147:58;;;;;;;;;;;;;;191:3340;;14:177:85;93:13;;-1:-1:-1;;;;;135:31:85;;125:42;;115:70;;181:1;178;171:12;115:70;14:177;;;:::o;196:754::-;310:6;318;326;334;342;350;403:3;391:9;382:7;378:23;374:33;371:53;;;420:1;417;410:12;371:53;446:16;;-1:-1:-1;;;;;491:31:85;;481:42;;471:70;;537:1;534;527:12;471:70;560:5;550:15;;;605:2;594:9;590:18;584:25;574:35;;649:2;638:9;634:18;628:25;618:35;;698:2;687:9;683:18;677:25;746:14;737:7;733:28;724:7;721:41;711:69;;776:1;773;766:12;711:69;799:7;-1:-1:-1;825:50:85;870:3;855:19;;825:50;:::i;:::-;815:60;;894:50;939:3;928:9;924:19;894:50;:::i;:::-;884:60;;196:754;;;;;;;;:::o;:::-;191:3340:58;;;;;;;;;;;;;;;;;;;;;;","linkReferences":{}},"deployedBytecode":{"object":"0x608060405234801561000f575f80fd5b5060043610610085575f3560e01c8063392f37e911610058578063392f37e9146100d65780634cf088d9146101915780638bfc9a94146101dd578063f9f2efa5146101e6575f80fd5b806312935d13146100895780632168a42b1461009e5780633410fe6e146100b15780633432dbc7146100ce575b5f80fd5b61009c610097366004610533565b6101f9565b005b61009c6100ac366004610583565b6102de565b6100bb620f424081565b6040519081526020015b60405180910390f35b6100bb5f5481565b610150604080516060810182525f8082526020820181905291810191909152506040805160608101825260025465ffffffffffff811682526cffffffffffffffffffffffffff6601000000000000820481166020840152730100000000000000000000000000000000000000909104169181019190915290565b60408051825165ffffffffffff1681526020808401516cffffffffffffffffffffffffff9081169183019190915292820151909216908201526060016100c5565b6101b87f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100c5565b6100bb60015481565b61009c6101f43660046105ac565b61034d565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610268576040517f890fec5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610272828261049d565b6040517f46b3650b213ce5f43bd41e24103118598a3c7b5efdb8e65ba518fbd32e1eb4e3808252600482018690526024820185905260449091206040517f356a441800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102e8828261049d565b6040517f3852f4b083ca330e912d0b6247247a2bb72266ff9c5a0f58802a0826cd5441838082526004820185905260249091206040517f356a441800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146103bc576040517f890fec5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f548110156103f7576040517fb1193e4d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060015f828254610408919061062c565b90915550506002805482919060069061043b908490660100000000000090046cffffffffffffffffffffffffff166105ff565b92506101000a8154816cffffffffffffffffffffffffff02191690836cffffffffffffffffffffffffff16021790555080827f7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a660405160405180910390a35050565b5f82815260046020908152604080832084845290915290205460ff16156104f0576040517f0dc1019700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f918252600460209081526040808420928452919052902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b5f805f8060808587031215610546575f80fd5b843573ffffffffffffffffffffffffffffffffffffffff81168114610569575f80fd5b966020860135965060408601359560600135945092505050565b5f805f60608486031215610595575f80fd5b505081359360208301359350604090920135919050565b5f80604083850312156105bd575f80fd5b50508035926020909101359150565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b6cffffffffffffffffffffffffff818116838216019080821115610625576106256105cc565b5092915050565b808201808211156105f9576105f96105cc56fea2646970667358221220d0232bbad486f58145b1d7f4b3ada8ceadba5d25c96888306b079365a416152364736f6c63430008140033","sourceMap":"191:3340:58:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1600:812;;;;;;:::i;:::-;;:::i;:::-;;2418:619;;;;;;:::i;:::-;;:::i;253:37::-;;287:3;253:37;;;;;1000:25:85;;;988:2;973:18;253:37:58;;;;;;;;297:42;;;;;;1121:103;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;1201:16:58;;;;;;;;1208:9;1201:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1121:103;;;;;1278:13:85;;1293:14;1274:34;1256:53;;1356:4;1344:17;;;1338:24;1381:28;1447:21;;;1425:20;;;1418:51;;;;1517:17;;;1511:24;1507:33;;;1485:20;;;1478:63;1244:2;1229:18;1121:103:58;1036:511:85;388:32:58;;;;;;;;1728:42:85;1716:55;;;1698:74;;1686:2;1671:18;388:32:58;1552:226:85;345:37:58;;;;;;1230:364;;;;;;:::i;:::-;;:::i;1600:812::-;1748:10;:21;1762:7;1748:21;;1744:46;;1778:12;;;;;;;;;;;;;;1744:46;1800:33;1827:2;1831:1;1800:26;:33::i;:::-;1986:4;1980:11;1869:41;2004:21;;;2054:1;2045:11;;2038:29;;;2096:2;2087:12;;2080:28;;;2147:2;2132:18;;;2218:16;;;;;;;;;;;;;;2418:619;2544:33;2571:2;2575:1;2544:26;:33::i;:::-;2717:4;2711:11;2613:28;2735:21;;;2785:1;2776:11;;2769:40;;;2848:2;2833:18;;;2919:16;;;;;;;;;;;;;;1230:364;1311:10;:21;1325:7;1311:21;;1307:46;;1341:12;;;;;;;;;;;;;;1307:46;1376:18;;1367:6;:27;1363:59;;;1403:19;;;;;;;;;;;;;;1363:59;1449:6;1432:13;;:23;;;;;;;:::i;:::-;;;;-1:-1:-1;;1465:9:58;:37;;1495:6;;1465:9;:18;;:37;;1495:6;;1465:37;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;1580:6;1570:8;1562:25;;;;;;;;;;1230:364;;:::o;3043:185::-;3124:24;;;;:20;:24;;;;;;;;:27;;;;;;;;;;;3120:57;;;3160:17;;;;;;;;;;;;;;3120:57;3187:24;;;;:20;:24;;;;;;;;:27;;;;;;;;:34;;;;3217:4;3187:34;;;3043:185::o;14:514:85:-;100:6;108;116;124;177:3;165:9;156:7;152:23;148:33;145:53;;;194:1;191;184:12;145:53;233:9;220:23;283:42;276:5;272:54;265:5;262:65;252:93;;341:1;338;331:12;252:93;364:5;416:2;401:18;;388:32;;-1:-1:-1;467:2:85;452:18;;439:32;;518:2;503:18;490:32;;-1:-1:-1;14:514:85;-1:-1:-1;;;14:514:85:o;533:316::-;610:6;618;626;679:2;667:9;658:7;654:23;650:32;647:52;;;695:1;692;685:12;647:52;-1:-1:-1;;718:23:85;;;788:2;773:18;;760:32;;-1:-1:-1;839:2:85;824:18;;;811:32;;533:316;-1:-1:-1;533:316:85:o;1783:248::-;1851:6;1859;1912:2;1900:9;1891:7;1887:23;1883:32;1880:52;;;1928:1;1925;1918:12;1880:52;-1:-1:-1;;1951:23:85;;;2021:2;2006:18;;;1993:32;;-1:-1:-1;1783:248:85:o;2036:184::-;2088:77;2085:1;2078:88;2185:4;2182:1;2175:15;2209:4;2206:1;2199:15;2327:18;2225:128;;;;:::o;2358:191::-;2426:28;2474:10;;;2486;;;2470:27;;2509:11;;;2506:37;;;2523:18;;:::i;:::-;2506:37;2358:191;;;;:::o;2554:125::-;2619:9;;;2640:10;;;2637:36;;;2653:18;;:::i","linkReferences":{},"immutableReferences":{"48576":[{"start":406,"length":32},{"start":529,"length":32},{"start":869,"length":32}]}},"methodIdentifiers":{"DIVISOR()":"3410fe6e","existentialDeposit()":"3432dbc7","ghost(bytes32,uint256)":"f9f2efa5","ghostedSupply()":"8bfc9a94","materialize(address,uint256,uint256,uint256)":"12935d13","metadata()":"392f37e9","rotate(uint256,uint256,uint256)":"2168a42b","staking()":"4cf088d9"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_staking\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_ghostedSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_existential\",\"type\":\"uint256\"},{\"internalType\":\"uint48\",\"name\":\"_deployedAt\",\"type\":\"uint48\"},{\"internalType\":\"uint104\",\"name\":\"_amountIn\",\"type\":\"uint104\"},{\"internalType\":\"uint104\",\"name\":\"_amountOut\",\"type\":\"uint104\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NonExistentAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotStaking\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongSignature\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Ghosted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Materialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"aggregatedPublicKey\",\"type\":\"uint256\"}],\"name\":\"Rotated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DIVISOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"existentialDeposit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ghost\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ghostedSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"s\",\"type\":\"uint256\"}],\"name\":\"materialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"metadata\",\"outputs\":[{\"components\":[{\"internalType\":\"uint48\",\"name\":\"deployedAt\",\"type\":\"uint48\"},{\"internalType\":\"uint104\",\"name\":\"amountIn\",\"type\":\"uint104\"},{\"internalType\":\"uint104\",\"name\":\"amountOut\",\"type\":\"uint104\"}],\"internalType\":\"struct IGatekeeperMetadata.GatekeeperMetadata\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"aggregatedPublicKey\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"s\",\"type\":\"uint256\"}],\"name\":\"rotate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"staking\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/Gatekeeper.sol\":\"Gatekeeper\"},\"evmVersion\":\"shanghai\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[\":@openzeppelin-contracts-5.0.2/=dependencies/@openzeppelin-contracts-5.0.2/\",\":@openzeppelin-contracts/=dependencies/@openzeppelin-contracts-5.0.2/\",\":@uniswap-v2-core-1.0.1/=dependencies/@uniswap-v2-core-1.0.1/contracts/\",\":@uniswap-v2-core/=dependencies/@uniswap-v2-core-1.0.1/contracts/\",\":@uniswap-v2-periphery-1.1.0-beta.0/=dependencies/@uniswap-v2-periphery-1.1.0-beta.0/contracts/\",\":@uniswap/=dependencies/@uniswap-v2-periphery-1.1.0-beta.0/node_modules/@uniswap/\",\":forge-std-1.9.2/=dependencies/forge-std-1.9.2/\",\":forge-std/=lib/forge-std/src/\"]},\"sources\":{\"src/Gatekeeper.sol\":{\"keccak256\":\"0x071489d9a0b52be659f6f071e26a98733ebae60c9bc2b3521cbd3b246b7f7475\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d65403d0789d8e58fafb2db962373d044eb8994692e0ac1a6b71d46c1caa4261\",\"dweb:/ipfs/QmTX4CsaZF7ttYAve7D8mMxqR4u5c2AH3opnguwNQgLeh9\"]},\"src/interfaces/IGatekeeper.sol\":{\"keccak256\":\"0x8be80370a24fe00c955710e10831033cd55aa9c87ed6d1cf9e30f017151cf4c1\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6218f96399aa7e5458d7933207b837cdcfe6f7c2d18de8131a9b537bc1898ab7\",\"dweb:/ipfs/QmNZNnyBYHKj5QNHGVTHpY8aD3TcNnjutXGVriNDy2Yp89\"]},\"src/interfaces/IGatekeeperMetadata.sol\":{\"keccak256\":\"0x9372ef25ece6c5a2f678a27d5cc841b6fefa94511db67911632730867015fb1a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://62f406bafcf16a4f62d865fb6788c93866cfe3a3f8d61e219a3246d979a1de00\",\"dweb:/ipfs/QmVszkBTNMaP9wJ7QQgRSBxugGG3wJoQgBnhe9nmEtoHRb\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.20+commit.a1b79de6"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_staking","type":"address"},{"internalType":"uint256","name":"_ghostedSupply","type":"uint256"},{"internalType":"uint256","name":"_existential","type":"uint256"},{"internalType":"uint48","name":"_deployedAt","type":"uint48"},{"internalType":"uint104","name":"_amountIn","type":"uint104"},{"internalType":"uint104","name":"_amountOut","type":"uint104"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"type":"error","name":"AlreadyExecuted"},{"inputs":[],"type":"error","name":"NonExistentAmount"},{"inputs":[],"type":"error","name":"NotStaking"},{"inputs":[],"type":"error","name":"WrongSignature"},{"inputs":[{"internalType":"bytes32","name":"receiver","type":"bytes32","indexed":true},{"internalType":"uint256","name":"amount","type":"uint256","indexed":true}],"type":"event","name":"Ghosted","anonymous":false},{"inputs":[{"internalType":"address","name":"receiver","type":"address","indexed":true},{"internalType":"uint256","name":"amount","type":"uint256","indexed":true}],"type":"event","name":"Materialized","anonymous":false},{"inputs":[{"internalType":"uint256","name":"aggregatedPublicKey","type":"uint256","indexed":true}],"type":"event","name":"Rotated","anonymous":false},{"inputs":[],"stateMutability":"view","type":"function","name":"DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"existentialDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function","name":"ghost"},{"inputs":[],"stateMutability":"view","type":"function","name":"ghostedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rx","type":"uint256"},{"internalType":"uint256","name":"s","type":"uint256"}],"stateMutability":"nonpayable","type":"function","name":"materialize"},{"inputs":[],"stateMutability":"view","type":"function","name":"metadata","outputs":[{"internalType":"struct IGatekeeperMetadata.GatekeeperMetadata","name":"","type":"tuple","components":[{"internalType":"uint48","name":"deployedAt","type":"uint48"},{"internalType":"uint104","name":"amountIn","type":"uint104"},{"internalType":"uint104","name":"amountOut","type":"uint104"}]}]},{"inputs":[{"internalType":"uint256","name":"aggregatedPublicKey","type":"uint256"},{"internalType":"uint256","name":"rx","type":"uint256"},{"internalType":"uint256","name":"s","type":"uint256"}],"stateMutability":"nonpayable","type":"function","name":"rotate"},{"inputs":[],"stateMutability":"view","type":"function","name":"staking","outputs":[{"internalType":"address","name":"","type":"address"}]}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin-contracts-5.0.2/=dependencies/@openzeppelin-contracts-5.0.2/","@openzeppelin-contracts/=dependencies/@openzeppelin-contracts-5.0.2/","@uniswap-v2-core-1.0.1/=dependencies/@uniswap-v2-core-1.0.1/contracts/","@uniswap-v2-core/=dependencies/@uniswap-v2-core-1.0.1/contracts/","@uniswap-v2-periphery-1.1.0-beta.0/=dependencies/@uniswap-v2-periphery-1.1.0-beta.0/contracts/","@uniswap/=dependencies/@uniswap-v2-periphery-1.1.0-beta.0/node_modules/@uniswap/","forge-std-1.9.2/=dependencies/forge-std-1.9.2/","forge-std/=lib/forge-std/src/"],"optimizer":{"enabled":true,"runs":10000},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/Gatekeeper.sol":"Gatekeeper"},"evmVersion":"shanghai","libraries":{}},"sources":{"src/Gatekeeper.sol":{"keccak256":"0x071489d9a0b52be659f6f071e26a98733ebae60c9bc2b3521cbd3b246b7f7475","urls":["bzz-raw://d65403d0789d8e58fafb2db962373d044eb8994692e0ac1a6b71d46c1caa4261","dweb:/ipfs/QmTX4CsaZF7ttYAve7D8mMxqR4u5c2AH3opnguwNQgLeh9"],"license":"MIT"},"src/interfaces/IGatekeeper.sol":{"keccak256":"0x8be80370a24fe00c955710e10831033cd55aa9c87ed6d1cf9e30f017151cf4c1","urls":["bzz-raw://6218f96399aa7e5458d7933207b837cdcfe6f7c2d18de8131a9b537bc1898ab7","dweb:/ipfs/QmNZNnyBYHKj5QNHGVTHpY8aD3TcNnjutXGVriNDy2Yp89"],"license":"MIT"},"src/interfaces/IGatekeeperMetadata.sol":{"keccak256":"0x9372ef25ece6c5a2f678a27d5cc841b6fefa94511db67911632730867015fb1a","urls":["bzz-raw://62f406bafcf16a4f62d865fb6788c93866cfe3a3f8d61e219a3246d979a1de00","dweb:/ipfs/QmVszkBTNMaP9wJ7QQgRSBxugGG3wJoQgBnhe9nmEtoHRb"],"license":"MIT"}},"version":1},"id":58} \ No newline at end of file diff --git a/src/containers/TreasuryDashboard/TreasuryDashboard.jsx b/src/containers/TreasuryDashboard/TreasuryDashboard.jsx index 69f5026..8ea1f00 100644 --- a/src/containers/TreasuryDashboard/TreasuryDashboard.jsx +++ b/src/containers/TreasuryDashboard/TreasuryDashboard.jsx @@ -12,6 +12,7 @@ import { CurrentIndex, } from "./components/Metric"; import TokenInfo from "./components/TokenInfo"; +import ProtocolDetails from "./components/ProtocolDetails"; import Paper from "../../components/Paper/Paper"; import PageTitle from "../../components/PageTitle/PageTitle"; @@ -60,7 +61,7 @@ const MetricsDashboard = ({ chainId }) => { - + diff --git a/src/containers/TreasuryDashboard/components/ProtocolDetails.jsx b/src/containers/TreasuryDashboard/components/ProtocolDetails.jsx new file mode 100644 index 0000000..f2f8509 --- /dev/null +++ b/src/containers/TreasuryDashboard/components/ProtocolDetails.jsx @@ -0,0 +1,137 @@ +import { useMemo } from "react"; +import { Grid, Box, Typography } from "@mui/material"; +import { useConfig } from "wagmi"; +import { useNavigate, createSearchParams } from "react-router-dom"; + +import { formatNumber } from "../../../helpers"; +import { useEpoch, useGatekeeperApy } from "../../../hooks/staking"; +import { useTokenSymbol, useBalance, useCirculatingSupply } from "../../../hooks/tokens"; +import { SecondaryButton } from "../../../components/Button"; +import { DecimalBigNumber } from "../../../helpers/DecimalBigNumber"; + +import { GATEKEEPER_ADDRESSES, EMPTY_ADDRESS } from "../../../constants/addresses"; + +const ProtocolDetail = ({ isMobileScreen, theme, name, sideName, url, urlParams, description }) => { + const navigate = useNavigate(); + return ( + + + + + {name} + + + {sideName} + + + <> + + + {description} + + + + + urlParams + ? navigate({ + pathname: url, + search: urlParams.toString() + }) + : navigate(url, { replace: true }) + } + fullWidth + > + {name} + + + + + + ) +} + +const ProtocolDetails = ({ chainId, isMobileScreen, theme, }) => { + const config = useConfig(); + const nativeSymbol = config?.getClient()?.chain?.nativeCurrency?.symbol; + const networkName = config?.getClient()?.chain?.name; + + const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO"); + const { symbol: csprSymbol } = useTokenSymbol(chainId, "CSPR"); + const { contractAddress: ftsoAddress } = useBalance(chainId, "FTSO", EMPTY_ADDRESS); + + const circulatingSupply = useCirculatingSupply(chainId, "STNK"); + const gatekeepedApy = useGatekeeperApy(chainId); + const { epoch } = useEpoch(chainId); + + const apyInner = useMemo(() => { + let apy = Infinity; + if (circulatingSupply._value > 0n) { + const value = epoch.distribute.div(circulatingSupply); + apy = 100 * (Math.pow(1 + parseFloat(value.toString()), 1095) - 1); + if (apy === 0) apy = Infinity; + } + return apy; + }, [circulatingSupply, epoch]); + + const bridgeNumbers = useMemo(() => { + const connectedNetworks = Object.keys(GATEKEEPER_ADDRESSES).length; + const number = 1 + connectedNetworks * 3; + return `(${number}, ${number})`; + }, [chainId]); + + return ( + + + + + + + + + + + + ) +} + +export default ProtocolDetails; diff --git a/src/hooks/staking/index.js b/src/hooks/staking/index.js index 2d25137..a5ad3e6 100644 --- a/src/hooks/staking/index.js +++ b/src/hooks/staking/index.js @@ -5,12 +5,52 @@ import toast from "react-hot-toast"; import { config } from "../../config"; import { isNetworkLegacyType } from "../../constants"; -import { STAKING_ADDRESSES } from "../../constants/addresses"; +import { STAKING_ADDRESSES, GATEKEEPER_ADDRESSES } from "../../constants/addresses"; import { abi as StakingAbi } from "../../abi/GhostStaking.json"; +import { abi as GatekeeperAbi } from "../../abi/GhostGatekeeper.json"; import { shorten } from "../../helpers"; import { DecimalBigNumber } from "../../helpers/DecimalBigNumber"; +export const useGatekeeperApy = (chainId) => { + const { data: gatekeeper, refetch } = useReadContract({ + abi: StakingAbi, + address: STAKING_ADDRESSES[chainId], + functionName: "gatekeeper", + scopeKey: `gatekeeper-${chainId}`, + chainId: chainId, + }); + + const { data: metadata, error } = useReadContract({ + abi: GatekeeperAbi, + address: GATEKEEPER_ADDRESSES[chainId], + functionName: "gatekeeperMetadata", + scopeKey: `gatekeeperMetadata-${chainId}`, + chainId: chainId, + }); + + const amountIn = new DecimalBigNumber(metadata?.amountIn ?? 0n, 18); + const amountOut = new DecimalBigNumber(metadata?.amountOut ?? 0n, 18); + + const deployedAt = metadata?.deployedAt ?? 0; + const unixSeconds = Math.floor(Date.now() / 1000); + const power = 365 * 86400 / (unixSeconds - deployedAt); + + const feeIn = new DecimalBigNumber(6900n, 2); + const feeOut = new DecimalBigNumber(6900n, 2); + const stakeRatio = new DecimalBigNumber(69000n, 3); + + const numerator = amountIn.mul(feeIn).add(amountOut.mul(feeOut)); + const denominator = amountIn.mul(stakeRatio).sub(amountOut.mul(stakeRatio)); + + if (denominator?.toString() === "0") { + return 1; + } + + const result = Number(numerator.div(denominator).toString()); + return Math.pow(1 + result, power); +} + export const useCurrentIndex = (chainId) => { const { data: index, refetch } = useReadContract({ abi: StakingAbi,