diff --git a/deployment/decentralized_network_deployments.csv b/deployment/decentralized_network_deployments.csv new file mode 100644 index 0000000000..4a56802d59 --- /dev/null +++ b/deployment/decentralized_network_deployments.csv @@ -0,0 +1,333 @@ +deployment name,protocol name,protocol type,network,status,slug,query-id +across-v2-arbitrum,across-v2,bridge,arbitrum,prod,across-v2-arbitrum,3rg6ZtwNUMpBrM1uSUtNqcbc6tGfyY2WLheDGSc5qMzX +across-v2-boba,across-v2,bridge,boba,prod,across-v2-boba,4SbLL5ZptwGU9Eor3SaoV3UZw12KPiZRKkwBEbKDenjP +across-v2-ethereum,across-v2,bridge,ethereum,prod,across-v2-ethereum,34kdiaZVpPsStQdsh5xFhrZdsZvZYJGfhJ7SVGWY2Y8g +across-v2-optimism,across-v2,bridge,optimism,prod,across-v2-optimism,GY9s64KVsRkW4Q8pCBKQePyDdcUV1TV1ArWFzvMv2qVb +across-v2-polygon,across-v2,bridge,polygon,prod,across-v2-polygon,8ywQVEAGn6wAGdYa4ofniy52CMsYMHyK6CbBrL4ZE7ks +arbitrum-one-bridge-arbitrum,arbitrum-one-bridge,bridge,arbitrum,prod,arbitrum-one-bridge-arbitrum,2rQHtwHiK2TCB4bQtgLybf8gGHCRVjANPzKTYss7B1n4 +arbitrum-one-bridge-ethereum,arbitrum-one-bridge,bridge,ethereum,prod,arbitrum-one-bridge-ethereum,6XazDBEjAVADSXbiBoXBBVwxTYf4PXRtucxn5vRQFLch +axelar-ethereum,axelar,bridge,ethereum,prod,axelar-ethereum,8u1rrGZY3gjXAAVJidygbpKeHzitrMSQV1RoLAkyd1AA +cbridge-arbitrum,cbridge,bridge,arbitrum,prod,cbridge-arbitrum,FGucK6FiGDyjwA1VDymrCQXgSTdZH7sCrP8HbnwVFatY +cbridge-aurora,cbridge,bridge,aurora,prod,cbridge-aurora,5uW7hwPPaHVEY7qqx5S9CV156YE7Dvjt2AAPiJ4mn12h +cbridge-avalanche,cbridge,bridge,avalanche,prod,cbridge-avalanche,2usVF8JKwgVesvXVkLj2KG6ourAPEVG7GV6j1MtTwhVa +cbridge-boba,cbridge,bridge,boba,prod,cbridge-boba,AZd3VzvnYoxBKAWjbZB4snZgow9SnyTTxaxad3YPxbvh +cbridge-bsc,cbridge,bridge,bsc,prod,cbridge-bsc,9ryiazBA4UJu1g2rbunQ42wqxvhdZP648p2jiBMjcoZc +cbridge-celo,cbridge,bridge,celo,prod,cbridge-celo,Exzi1255D9QkAzLhcS1qrVXVDMdkQvQ6wxRDjpi9uQz6 +cbridge-ethereum,cbridge,bridge,ethereum,prod,cbridge-ethereum,3C9qpsGFHrAnXkmPoeRbMjH9gyTuQskzB29VrrV8NbAN +cbridge-fantom,cbridge,bridge,fantom,prod,cbridge-fantom,Ce9MWULyvFUXRqN7LgehQVy3XBGhxk3qtFJhgznHYY3x +cbridge-gnosis,cbridge,bridge,gnosis,prod,cbridge-gnosis,FdoU8yttG4HUfoYSsP2Qit1UvvVCaZeUDPnMB4nzguNU +cbridge-harmony,cbridge,bridge,harmony,prod,cbridge-harmony,8gXopvmmYABDCCrWuafAkYuRB4bpJ7XcbgGmN8AcMJDg +cbridge-moonbeam,cbridge,bridge,moonbeam,prod,cbridge-moonbeam,6F1ia9A6Vmanbzk2T3EAAev5Q9TKyF1oxu6JiUKbPdnL +cbridge-moonriver,cbridge,bridge,moonriver,prod,cbridge-moonriver,FuFD3UqnCWhQoarNsvdY8AW5exnKXxiizJRXVakvniHX +cbridge-optimism,cbridge,bridge,optimism,prod,cbridge-optimism,GEy4r8C2cMku1TTfjzC751teQZ4dvVxXiW1F6K4fue2K +cbridge-polygon,cbridge,bridge,polygon,prod,cbridge-polygon,8rR3yC5ZPMoUauudfQC4iLJxqf5nCRjZRmYne8tEGrV9 +hop-protocol-arbitrum,hop-protocol,bridge,arbitrum,prod,hop-protocol-arbitrum,4xY1CAbwQA7oq3a78CX8mgKFvMoZzPsv21A92Hm7rEvv +hop-protocol-ethereum,hop-protocol,bridge,ethereum,prod,hop-protocol-ethereum,7YKiuzrmUxTpSN5DddDVFm9FDjQ5387dnEivHHdX9pAc +hop-protocol-optimism,hop-protocol,bridge,optimism,prod,hop-protocol-optimism,KoMGmd2d1VMukusmf98SdWCSKH5ZP5UEUDHKrKpY74D +hop-protocol-polygon,hop-protocol,bridge,polygon,prod,hop-protocol-polygon,iLsL5mqiwjQhdGs3XfYBdLhaKdE4yDR73iTg2PSRr1E +hop-protocol-polygon-zkevm,hop-protocol,bridge,polygon-zkevm,prod,hop-protocol-polygon-zkevm,EkkvCmBiEPiJ5LkaSPxpuAmMouSUN5FZrdrKu7nBY5p9 +hop-protocol-xdai,hop-protocol,bridge,gnosis,prod,hop-protocol-gnosis,DA1WTRx4pbGQdTm1YqRz3MCLiap4cdgK62Q6Bjy99m1y +multichain-arbitrum,multichain,bridge,arbitrum,prod,multichain-arbitrum,579DZmKbpRcdLVBiLyhLEvRQBQ54BA72yDqtSaVSijRs +multichain-avalanche,multichain,bridge,avalanche,prod,multichain-avalanche,28ds2UuXzULQ9XLKFncX1pVL6xTENwKw9VKb7xRXC6mX +multichain-celo,multichain,bridge,celo,prod,multichain-celo,F6Rz64x6iem1VuUNUvzBzH1zzBBZfCA7cpZ91mLySXQY +multichain-ethereum,multichain,bridge,ethereum,prod,multichain-ethereum,GRPErV1E73JGNGGsF2tK4fuuqpvBWpfRBSED8567BAD2 +multichain-fantom,multichain,bridge,fantom,prod,multichain-fantom,B6xbS79Nza7zNjSXu1Bsq2ofpFLhDEW1mpAkECKdQXQc +multichain-gnosis,multichain,bridge,gnosis,prod,multichain-gnosis,E3FsKA2dpjv94tPgMKmyPEa63mUQ611XRrbsgAtzqrCn +multichain-optimism,multichain,bridge,optimism,prod,multichain-optimism,FZkvvW6rZJxJk1E3LqhVWHRAb8oWoWZAX563Y94C6GaF +multichain-polygon,multichain,bridge,polygon,prod,multichain-polygon,AKgq2JRAoRnBE14iDAMN8bqDwwyufpy3AqXuZRKvyZVR +optimism-bridge-v2-ethereum,optimism-bridge-v2,bridge,ethereum,prod,optimism-bridge-v2-ethereum,DCKLUdmvmaX4eNSAouXjxt8yShp28dFKGD763Tb2KibH +optimism-bridge-v2-optimism,optimism-bridge-v2,bridge,optimism,prod,optimism-bridge-v2-optimism,4aUWDFLz4sVYKZDw4JDJLk8vjify1Rqij7UGFozNxA8k +orbit-bsc,orbit,bridge,bsc,prod,orbit-bsc,8XNHKT5X8DgsdL6hKe6tK5FnkBRR4TtS2YH23db5D6VH +orbit-celo,orbit,bridge,celo,prod,orbit-celo,DdGECh8tM63FEsT96AjxfhxkE5wTBeBPdnh3qkUYpcvY +orbit-ethereum,orbit,bridge,ethereum,prod,orbit-ethereum,DpGRvQhDPH3EXRuCjMM7RednJz25Ucm2oYp56Vb4k74F +orbit-polygon,orbit,bridge,polygon,prod,orbit-polygon,FQVKZkxeeqdnGU4a1Qwm5SVu8FxtQVPshzpLBAhMH1V9 +portal-avalanche,portal,bridge,avalanche,prod,portal-avalanche,BV3hShBwZkZM7RL9XPGqZ9JyJcE2vrWqXwFQYTVquH3Z +portal-bsc,portal,bridge,bsc,prod,portal-bsc,FCd8kxMGFkk3AGEHeYRngeHvBsuTpQo7XBLu6XoyDctr +portal-ethereum,portal,bridge,ethereum,prod,portal-ethereum,HxduZZ9fy1shXbo7EAG9W73geBAxzKjVNXgMkxeTJkpX +portal-fantom,portal,bridge,fantom,prod,portal-fantom,3wKUbySRqqBe6bXGWm3aDr9g8fuUoxKMqcdhTGwBGyjG +portal-polygon,portal,bridge,polygon,prod,portal-polygon,4V9sMa8P8vKAccUtR8jP28mBfvtUMip4tVvMBSDC7h3V +stargate-arbitrum,stargate,bridge,arbitrum,prod,stargate-arbitrum,DWo7jrtpTtUM1buqiCUg7j7XUF568qNPBv7FwwDceuxm +stargate-avalanche,stargate,bridge,avalanche,prod,stargate-avalanche,6XypMkQUovcohhVC2XeWgdXeDsBcnL9ynKdLXpXggoHd +stargate-base,stargate,bridge,base,prod,stargate-base,4amk8rvTHgxSobsFKsr5jheHsDzLcwyqc8vHhNC1xhGt +stargate-bsc,stargate,bridge,bsc,prod,stargate-bsc,6sRx6JNkjz66id39jCK3GMiVnPVuyuv2ntwQVpDzmjRF +stargate-ethereum,stargate,bridge,ethereum,prod,stargate-ethereum,G1pPbbMjwCnFiyMherq8wqfMusZDriLMqvGBHLr2wS34 +stargate-fantom,stargate,bridge,fantom,prod,stargate-fantom,2pG7kUAfPhtGyy1StFLhFu8pwTR5kDsCJN9KZjWn9Lnk +stargate-optimism,stargate,bridge,optimism,prod,stargate-optimism,7NAF7ZtNtJiXkfCFkTSAyFbfLLfUFa55UgK5woxPxZ46 +stargate-polygon,stargate,bridge,polygon,prod,stargate-polygon,SitmxEcPXXwo5cFK8Y2FSMZNZNQ4gXcGdWBDqo3A7K6 +dopex-arbitrum,dopex,derivatives-options,arbitrum,prod,dopex-arbitrum,6C7okGPnmQw4eahgvkjzKGqHyXsZBLSWz7BBEyyfe6vB +dopex-polygon,dopex,derivatives-options,polygon,prod,dopex-polygon,nTecf2j4MGgqgJrKTGmvVyWn169py1H9fgvaiN29MVu +opyn-gamma-arbitrum,opyn-gamma,derivatives-options,arbitrum,prod,opyn-gamma-arbitrum,BC766cXkcBxAwQ6LAYnQytdHJLpJX1C1bbrMFhLCHx7C +opyn-gamma-avalanche,opyn-gamma,derivatives-options,avalanche,prod,opyn-gamma-avalanche,3eaTJDJ1Y867jkDMY1iEJJLRZTSREfGZjusgmucptWJE +opyn-gamma-ethereum,opyn-gamma,derivatives-options,ethereum,prod,opyn-gamma-ethereum,3zUv74ekxpiy92MQ2MwemR8fJhjvgyBFaGzQLkYHmaUy +opyn-gamma-polygon,opyn-gamma,derivatives-options,polygon,prod,opyn-gamma-polygon,6WbUbvCBtjhKyf9ddZEfVReHNHHunzspGBp3hFsy1c8P +gains-trade-arbitrum,gains-trade,derivatives-perpfutures,arbitrum,prod,gains-trade-arbitrum,DuPBYBj3nfP3sFiHwkRfTATmA4iSqoPvxBaRXWiwpELk +gains-trade-polygon,gains-trade,derivatives-perpfutures,polygon,prod,gains-trade-polygon,4d1zcsK9f1T2wzZTGZHaLKswbhmKTRWu1yeyX94htoMW +gmx-arbitrum,gmx,derivatives-perpfutures,arbitrum,prod,gmx-arbitrum,DiR5cWwB3pwXXQWWdus7fDLR2mnFRQLiBFsVmHAH9VAs +gmx-avalanche,gmx,derivatives-perpfutures,avalanche,prod,gmx-avalanche,6pXgnXcL6mkXBjKX7NyHN7tCudv2JGFnXZ8wf8WbjPXv +kwenta-optimism,kwenta,derivatives-perpfutures,optimism,prod,kwenta-optimism,5sbJJTTJQQ4kYuVYNBVw9sX8C5juRpVJNLHg7uFugw2e +level-finance-arbitrum,level-finance,derivatives-perpfutures,arbitrum,prod,level-finance-arbitrum,9KPc6WMUXg6mqQ9KbCeosJrgmsZyH97vpFPKwJHkVkui +level-finance-bsc,level-finance,derivatives-perpfutures,bsc,prod,level-finance-bsc,97TRgysfrSPH7sumNXSasdjhKBnDwig2JKE7PwB4W2J8 +mummy-finance-arbitrum,mummy-finance,derivatives-perpfutures,arbitrum,prod,mummy-finance-arbitrum,4Po9haSDCDbQ2XtrSXqT8BNB9H6T7EUAmbAorAzHQi9S +mummy-finance-fantom,mummy-finance,derivatives-perpfutures,fantom,prod,mummy-finance-fantom,FP8YzYVARZ6jEYrciiTEtzrNfug7STzYyUr3fRUjQkEA +mummy-finance-optimism,mummy-finance,derivatives-perpfutures,optimism,prod,mummy-finance-optimism,GvgdFS6dFXCSXwq9PDTdcs5uZzwZYuTrqFjiTRC3jy54 +mux-protocol-arbitrum,mux-protocol,derivatives-perpfutures,arbitrum,prod,mux-protocol-arbitrum,AMh1u4wCbz8Jybs4Nf7uGBdU9dz2C8mJkH1Aocz6HXUf +mux-protocol-avalanche,mux-protocol,derivatives-perpfutures,avalanche,prod,mux-protocol-avalanche,97XbzzGmRpUvHwdZyArbyrZHFnmWU15tC381epA1Fp7H +mux-protocol-bsc,mux-protocol,derivatives-perpfutures,bsc,prod,mux-protocol-bsc,3zRKcHbGqvMe6BG6fiLiaKx3y41ytzjw4jetbh5Q2fx1 +mux-protocol-fantom,mux-protocol,derivatives-perpfutures,fantom,prod,mux-protocol-fantom,46iwTwh5F6yAuKHF9iwFccu9wsYEaXwQCwnj2EjcEgBk +mux-protocol-optimism,mux-protocol,derivatives-perpfutures,optimism,prod,mux-protocol-optimism,7hUM4US9DPz6JqLD6ySqwFmLq4XiAF7cEZLmEesQnYgR +apeswap-bsc,apeswap,dex-amm,bsc,prod,apeswap-bsc,4u1aTvzBMjBdm7aK7uQmjffhoPc6Ceu3w2nTfq6vUQnb +apeswap-polygon,apeswap,dex-amm,polygon,prod,apeswap-polygon,2x478mWv6rECUcJR4VxNxRnuMuRsY22Jxy7xxXJu4Q7F +balancer-v2-ethereum,balancer-v2,dex-amm,ethereum,prod,balancer-v2-ethereum,794H6CNzdGF5YfBK9nPsUgGn7EBbdJSCTjgcKPEPyFnn +bancor-v3-ethereum,bancor-v3,dex-amm,ethereum,prod,bancor-v3-ethereum,4Q4eEMDBjYM8JGsvnWCafFB5wCu6XntmsgxsxwYSnMib +biswap-bsc,biswap,dex-amm,bsc,prod,biswap-bsc,EnAR2ancKqJqpCU6cJ8aq9xHquTSWsK2wQWVfdDSwacN +camelot-v2-arbitrum,camelot-v2,dex-amm,arbitrum,prod,camelot-v2-arbitrum,E6J42xXvRQGsqcMEoWRkdeJjUTsWdcHL8khuFMY6CDAM +curve-finance-aurora,curve-finance,dex-amm,aurora,prod,curve-finance-aurora,9zXFpPQHyTmXXygtNPwjBS6d4SMGzv7qMiha4bJ3fbyB +curve-finance-avalanche,curve-finance,dex-amm,avalanche,prod,curve-finance-avalanche,2Vt8WtdXNZUEeaVtzyEd1dpioJf44nvomzkd4HhubfKS +curve-finance-ethereum,curve-finance,dex-amm,ethereum,prod,curve-finance-ethereum,3fy93eAT56UJsRCEht8iFhfi6wjHWXtZ9dnnbQmvFopF +curve-finance-gnosis,curve-finance,dex-amm,gnosis,prod,curve-finance-gnosis,J8k2z8MhdhABfVZU5HtyRvzCT85bLLF886V4iDpt53Jr +curve-finance-harmony,curve-finance,dex-amm,harmony,prod,curve-finance-harmony,6gnHHn7562tDjCrrnSiMiR1H1NndrannPQ7LcYxMgF9t +curve-finance-optimism,curve-finance,dex-amm,optimism,prod,curve-finance-optimism,CXDZPduZE6nWuWEkSzWkRoJSSJ6CneSqiDxdnhhURShX +ellipsis-finance-bsc,ellipsis-finance,dex-amm,bsc,prod,ellipsis-finance-bsc,3oK7vysHSCqXkQ5L3G6S4ifBG3Xr5mjkEEzZKtGEg5x1 +honeyswap-gnosis,honeyswap,dex-amm,gnosis,prod,honeyswap-gnosis,33aQTj7abtAR5zGcG9JBd1fd1sodgKDjoTsKuA8QrUW7 +honeyswap-polygon,honeyswap,dex-amm,polygon,prod,honeyswap-polygon,7YaQPHXFrPCwbt2MUPQ5N5PgmgMch14Ab5cZVYxvtPgW +mm-finance-polygon,mm-finance,dex-amm,polygon,prod,mm-finance-polygon,7B7R7aie7erfqUijkH2HNQcZ8bK6DpuXJaB5myt6nrs7 +pancakeswap-v3-bsc,pancakeswap-v3,dex-amm,bsc,prod,pancakeswap-v3-bsc,A1BC1hzDsK4NTeXBpKQnDBphngpYZAwDUF7dEBfa3jHK +pancakeswap-v3-ethereum,pancakeswap-v3,dex-amm,ethereum,prod,pancakeswap-v3-ethereum,JAGXF8B14mpB8QGKnwhKTs5JxsQZBJQvbDGFcWwL7gbm +pangolin-avalanche,pangolin,dex-amm,avalanche,prod,pangolin-avalanche,6f3YqP75bLuLZAv7Cm1BohFot17kT3Svekg6giuvaTmg +platypus-finance-avalanche,platypus-finance,dex-amm,avalanche,prod,platypus-finance-avalanche,B35cLTayreXTML6fXPTrFNSYx7mKyDuuV51LjVxWwWjp +saddle-finance-arbitrum,saddle-finance,dex-amm,arbitrum,prod,saddle-finance-arbitrum,H36tAWQeYVioE4hHtaKJEMJMxwzVJWjfg2mimva2wcUj +saddle-finance-ethereum,saddle-finance,dex-amm,ethereum,prod,saddle-finance-ethereum,H36tAWQeYVioE4hHtaKJEMJMxwzVJWjfg2mimva2wcUj +saddle-finance-fantom,saddle-finance,dex-amm,fantom,prod,saddle-finance-fantom,DToFejYjMRXcCrBrsdP9AZGBqwxpEumNHReRTfAmqgeP +saddle-finance-optimism,saddle-finance,dex-amm,optimism,prod,saddle-finance-optimism,CFu1DWY9DyiC25WRmGreowMyuvLB27JfNRCa8rKkTDjK +solarbeam-moonriver,solarbeam,dex-amm,moonriver,prod,solarbeam-moonriver,EoN2oon5KNH6XL1xSQCRsLHFPSZ2xLJD9DApizNtfGWo +spiritswap-fantom,spiritswap,dex-amm,fantom,prod,spiritswap-fantom,ARnDoat2Zyft9miSW8Md6V32nd5YUfngMCDCaNgqLqXv +substream-uniswap-v2-ethereum,uniswap-v2,dex-amm,ethereum,dev,substream-uniswap-v2-ethereum,J2oP9UNBjsnuDDW1fAoHKskyrNLFNBB2badQU6UvEtJp +sushiswap-arbitrum,sushiswap,dex-amm,arbitrum,prod,sushiswap-arbitrum,9tSS5FaePZnjmnXnSKCCqKVLAqA6eGg6jA2oRojsXUbP +sushiswap-avalanche,sushiswap,dex-amm,avalanche,prod,sushiswap-avalanche,4KgG6aek9cEp8MXQZKWCmeJWj5Y77mK9tPRAD1kDQa8Q +sushiswap-bsc,sushiswap,dex-amm,bsc,prod,sushiswap-bsc,7QyoZFgo1bYvTD7bmdBxsjFLjmeDLgBT3nC3H8y6yuKZ +sushiswap-celo,sushiswap,dex-amm,celo,prod,sushiswap-celo,5H97eNhy9fVHcqRXZtCV2UxHG2DbzcFA7yth1TaVZ45x +sushiswap-ethereum,sushiswap,dex-amm,ethereum,prod,sushiswap-ethereum,77jZ9KWeyi3CJ96zkkj5s1CojKPHt6XJKjLFzsDCd8Fd +sushiswap-fantom,sushiswap,dex-amm,fantom,prod,sushiswap-fantom,9wj3CmJFtoe7J25h4t39ioQHXexGe2rbsLfBgLefU7mN +sushiswap-fuse,sushiswap,dex-amm,fuse,prod,sushiswap-fuse,7MhgrLAB5B4D6PLDjF9Stx7fzS54MA3d5oi9dT3fHxbz +sushiswap-gnosis,sushiswap,dex-amm,gnosis,prod,sushiswap-gnosis,GvgkY82DTAkYqRShBbPQMjF1WJyUcknXre3QPWiXrPnS +sushiswap-harmony,sushiswap,dex-amm,harmony,prod,sushiswap-harmony,96NBskquxSxSDV8W42g3nmzECziCvhftSXFFpbY4geaC +sushiswap-moonbeam,sushiswap,dex-amm,moonbeam,prod,sushiswap-moonbeam,8oFzyJBeHoojoe23u3YYNruTZsqgn91q44U8hrFocbtp +sushiswap-moonriver,sushiswap,dex-amm,moonriver,prod,sushiswap-moonriver,EuYBux3ZPq1v3Uipo837WDq6WrK4AB3LGD6w78edRHib +sushiswap-polygon,sushiswap,dex-amm,polygon,prod,sushiswap-polygon,B3Jt84tHJJjanE4W1YijyksTwtm7jqK8KcG5dcoc1ZNF +sushiswap-v3-arbitrum,sushiswap-v3,dex-amm,arbitrum,dev,sushiswap-v3-arbitrum,3oHCddbQGTi42kPZBwyGzD2JzZR33zK2MwXtxAerNJy2 +sushiswap-v3-avalanche,sushiswap-v3,dex-amm,avalanche,dev,sushiswap-v3-avalanche,9WGqYsU8h1KVZeKz32663gFrbjVUNhBgmhRavMFqiSZz +sushiswap-v3-ethereum,sushiswap-v3,dex-amm,ethereum,dev,sushiswap-v3-ethereum,2tGWMrDha4164KkFAfkU3rDCtuxGb4q1emXmFdLLzJ8x +sushiswap-v3-gnosis,sushiswap-v3,dex-amm,gnosis,dev,sushiswap-v3-gnosis,9LC6MvaFHXyY3dmxM7VCwGNA9dvM6g2AuZxEGCyfvck3 +trader-joe-avalanche,trader-joe,dex-amm,avalanche,prod,trader-joe-avalanche,H2VGe2tYavUEosSjomHwxbvCKy3LaNaW8Kjw2KhhHs1K +ubeswap-celo,ubeswap,dex-amm,celo,prod,ubeswap-celo,9WiZHUk2d3rM4sEQ4NSz6ihFRc2zWmPj7yk8w51dNdhT +uniswap-v2-swap-ethereum,uniswap-v2-swap,dex-amm,ethereum,prod,uniswap-v2-swap-ethereum,3onEbd9MLfXTTWAfP91yqsKr7C68VCT2ZiF7EoQiQAFj +uniswap-v3-arbitrum,uniswap-v3,dex-amm,arbitrum,prod,uniswap-v3-arbitrum,FQ6JYszEKApsBpAmiHesRsd9Ygc6mzmpNRANeVQFYoVX +uniswap-v3-base,uniswap-v3,dex-amm,base,prod,uniswap-v3-base,FUbEPQw1oMghy39fwWBFY5fE6MXPXZQtjncQy2cXdrNS +uniswap-v3-bsc,uniswap-v3,dex-amm,bsc,prod,uniswap-v3-bsc,8f1KyiuNYiNGrjagzEVpf6k6KkPG517prtjdrJihgHw +uniswap-v3-celo,uniswap-v3,dex-amm,celo,prod,uniswap-v3-celo,8cLf29KxAedWLVaEqjV8qKomdwwXQxjptBZFrqWNH5u2 +uniswap-v3-ethereum,uniswap-v3,dex-amm,ethereum,prod,uniswap-v3-ethereum,4cKy6QQMc5tpfdx8yxfYeb9TLZmgLQe44ddW1G7NwkA6 +uniswap-v3-optimism,uniswap-v3,dex-amm,optimism,prod,uniswap-v3-optimism,EgnS9YE1avupkvCNj9fHnJxppfEmNNywYJtghqiu2pd9 +uniswap-v3-polygon,uniswap-v3,dex-amm,polygon,prod,uniswap-v3-polygon,BvYimJ6vCLkk63oWZy7WB5cVDTVVMugUAF35RAUZpQXE +velodrome-finance-v1-optimism,velodrome-finance-v1,dex-amm,optimism,prod,velodrome-optimism,7tA4PY1VmbycJeoVtn2mjQK4NbozgwTuZgrxDTxzEDL1 +velodrome-finance-v2-optimism,velodrome-finance-v2,dex-amm,optimism,prod,velodrome-v2-optimism,A4Y1A82YhSLTn998BVVELC8eWzhi992k4ZitByvssxqA +amphor-ethereum,amphor,generic,ethereum,prod,amphor-ethereum,RkDsVce2tRzGWbNAeZJrRy7nLAmMWtxQ6ixerhhw581 +bedrock-unieth-ethereum,bedrock-unieth,generic,ethereum,prod,bedrock-unieth-ethereum,69xran7p1VnLJoLrC7g5jeGTWsEkMD5kNqhYaEPbAzx6 +benqi-staked-avax-avalanche,benqi-staked-avax,generic,avalanche,prod,benqi-staked-avax-avalanche,6vSK9N1NGT65mRgMtNfoxwPkaMJoJBQJA2Z5G1fKEKCu +binance-staked-eth-bsc,binance-staked-eth,generic,bsc,prod,binance-staked-eth-bsc,todo +binance-staked-eth-ethereum,binance-staked-eth,generic,ethereum,prod,binance-staked-eth-ethereum,todo +chainlink-staking-ethereum,chainlink-staking,generic,ethereum,prod,chainlink-staking-ethereum,CEvNvcykaphaHuipRNsP5fd2LE75QLsFtLnofTcf6JZX +coinbase-wrapped-staked-eth-ethereum,coinbase-wrapped-staked-eth,generic,ethereum,prod,coinbase-wsteth-ethereum,4bPFmTTqoKZcQL8DXj8jBbo86pm4RisAQeuGhZKkvA9X +concentrator-ethereum,concentrator,generic,ethereum,prod,concentrator-ethereum,FigcbmZouBnKctj6zqsvp1LhHiV1pZdVQ6ABrA27w3Lk +cygnus-finance-base,cygnus-finance,generic,base,prod,cygnus-finance-base,ELqNv3KbLggc6kN6uoeKvrbfBpbkQbAorZo3FABZJb6A +dinero-pxeth-ethereum,dinero-pxeth,generic,ethereum,prod,dinero-pxeth-ethereum,todo +eigenlayer-ethereum,eigenlayer,generic,ethereum,prod,eigenlayer-ethereum,68g9WSC4QTUJmMpuSbgLNENrcYha4mPmXhWGCoupM7kB +eigenpie-ethereum,eigenpie,generic,ethereum,prod,eigenpie-ethereum,BbkLSUBpyJv8UiCyMyQBGpngz8qfdhx4LJBqFdHqiwhH +etherfi-ethereum,etherfi,generic,ethereum,prod,etherfi-ethereum,GPwCNqJ5aroTtkk48Y57pBjFHVkeYmMzmBpE1a7WF7Hc +frax-ether-staking-arbitrum,frax-ether-staking,generic,arbitrum,prod,frax-ether-staking-arbitrum,FSafXUhkuwqARZNNe82isspkjQJcPK2PrSjQLvNXuakU +frax-ether-staking-bsc,frax-ether-staking,generic,bsc,prod,frax-ether-staking-bsc,A113zHKpiXzugLyKDVknAxjQ6qFSPQwfiGK7rjiuqbcq +frax-ether-staking-ethereum,frax-ether-staking,generic,ethereum,prod,frax-ether-staking-ethereum,FeKHrGeNxVctN6EeAhba2Kv78xNxuEhbRKNECLfVH8z2 +frax-ether-staking-fantom,frax-ether-staking,generic,fantom,prod,frax-ether-staking-fantom,Ba52AgUJfCmWQpBJEwRvygC45iGr9uqnrehpymN2Xmx4 +frax-ether-staking-moonbeam,frax-ether-staking,generic,moonbeam,prod,frax-ether-staking-moonbeam,FhaAErF9146bnqJsQD34zPHNC11quKTuk9HBA7RdGrjz +frax-ether-staking-optimism,frax-ether-staking,generic,optimism,prod,frax-ether-staking-optimism,G9nDvQw6S7LkzNxj7oGFZUsahe3ebpAtEww716kWkfZd +frax-ether-staking-polygon,frax-ether-staking,generic,polygon,prod,frax-ether-staking-polygon,FMkrjPgSyGm2UBFrMqpJVwWgGHLek8U39W1M4R9TfP1T +friend-tech-base,friend-tech,generic,base,prod,friend-tech-base,8fjDwMF5JPXYEg3tU45ttTsnp3mdTQd5efhkHhHGHCKj +gaurda-staking-ethereum,gaurda-staking,generic,ethereum,prod,gaurda-staking-ethereum,todo +gogopool-avalanche,gogopool,generic,avalanche,prod,gogopool-avalanche,todo +hyperlock-finance-blast,hyperlock-finance,generic,blast-mainnet,prod,hyperlock-finance-blast,tXk1UdCXjJkyvBRXvc5KvqGGZVSpdsdPoYrTAemT1kV +karak-arbitrum,karak,generic,arbitrum,prod,karak-arbitrum,7kCkjx6GK67WZrVo54UcLWZ7kBx65TogBW1CD316XZgn +karak-bsc,karak,generic,bsc,prod,karak-bsc,8YGDQQgExT7zLJioLRQdcSQko1qgiCjfwVg7TBV6eR7W +karak-ethereum,karak,generic,ethereum,prod,karak-ethereum,2vzPTkDT2DddrRoXtg25AGK55nviKXeJiG21Cu56nurg +kelp-dao-ethereum,kelp-dao,generic,ethereum,prod,kelp-dao-ethereum,BKAuuey1mAQimbeKHWHQTLkFHeSn4Z9cfSJcHBaYhrV2 +lido-ethereum,lido,generic,ethereum,prod,lido-ethereum,F7qb71hWab6SuRL5sf6LQLTpNahmqMsBnnweYHzLGUyG +liquid-collective-ethereum,liquid-collective,generic,ethereum,prod,liquid-collective-ethereum,4kRPyZuhGgAcjYuVgbR79qm5WQ3TvXeaqVHRHx6MV5U7 +livepeer-arbitrum,livepeer,generic,arbitrum,prod,livepeer-arbitrum,6CdJfr35PDj8AMQikiKGjAUPG2vCu5VLYRawDk8cxwrs +llama-airforce-ethereum,llama-airforce,generic,ethereum,prod,llama-airforce-ethereum,C2EGJcZhx44BMaT9hJ2K2zjPGdYmrnuK7MusKEXaEPPH +lybra-finance-ethereum,lybra-finance,generic,ethereum,prod,lybra-finance-ethereum,2fNZY1J6FzuoHnx8ZTuhiEiM5AhzU3JiC7vp4UqaktSj +mantle-staked-eth-ethereum,mantle-staked-eth,generic,ethereum,prod,mantle-staked-eth-ethereum,VVKZagj4XUyamqXysVBniarN8HMz87DnwkTChuXH18Z +mellow-lrt-ethereum,mellow-lrt,generic,ethereum,prod,mellow-lrt-ethereum,B5asn3DbqssJhSevYyQQUPVrtoXqfnQBqNvp1En52wCY +node-dao-ethereum,node-dao,generic,ethereum,prod,node-dao-ethereum,FfhhdxuMRwc7R2dBZd4MH4NZKRwZm5rqEFzY4XDoEq6x +origin-ether-ethereum,origin-ether,generic,ethereum,prod,origin-ether-ethereum,EYpKTVtNYaVN3LfDi1BCQBxhhUq53BTWcbExDt53cH75 +prime-staked-eth-ethereum,prime-staked-eth,generic,ethereum,prod,prime-staked-eth-ethereum,222GCE8sewRURAfh7meRbkyNE9NNG2HqfVfYmfFg9MkR +puffer-finance-ethereum,puffer-finance,generic,ethereum,prod,puffer-finance-ethereum,F8nUFWAC9vE1gHcUj5ZHXSt53eXo9vRqf2SuCcYVs93S +renzo-arbitrum,renzo,generic,arbitrum,prod,renzo-arbitrum,5P79EkkSDxiXxWgiYcpsvML7Q3MSu64sHi8LF2xVggQz +renzo-base,renzo,generic,base,prod,renzo-base,Atj9RDj7hzmUd6a3PTzpPCpjJPzqMbvPLdxMfF2BFy5B +renzo-blast,renzo,generic,blast-mainnet,prod,renzo-blast,HXWd4suSQ4TztRznBCi1dWdBKrHvkDPZBA2hy5nng1eL +renzo-bsc,renzo,generic,bsc,prod,renzo-bsc,JD3KpTX2bdwVMtZvX3HmPKSGQsVYP8FRkUJs51vZBJPR +renzo-ethereum,renzo,generic,ethereum,prod,renzo-ethereum,91jPrEeA5BPzDHmjKjVwmgDvGEQpAwh5yusTbHCQiQbM +renzo-mode,renzo,generic,mode-mainnet,prod,renzo-mode,AUcw3uDfWmRQDHKgnQ6C7P2139scRwvzMfrJovSGbACW +ring-few-blast,ring-few,generic,blast-mainnet,prod,ring-few-blast,FfTNTmfsJAz1gUqnc3RxGEqyaeMTRdaS4C5bYHAHbzsC +rocket-pool-ethereum,rocket-pool,generic,ethereum,prod,rocket-pool-ethereum,Dtj2HicXKpoUjNB7ffdBkMwt3L9Sz3cbENd67AdHu6Vb +slisbnb-bsc,slisbnb,generic,bsc,prod,slisbnb-bsc,7Ptuvapgqo21jvcH2dquePfmfpEwENFHERN48pKptZf3 +stader-ethereum,stader,generic,mainnet,prod,stader-ethereum,2RLAUqUMvGGFygtuJfmTyeo62zFSJswDZSRMTcu28fSa +stake-link-liquid-ethereum,stake-link-liquid,generic,ethereum,prod,stake-link-liquid-ethereum,todo +stakestone-ethereum,stakestone,generic,ethereum,prod,stakestone-ethereum,Dks14vz78EJf4i5SomNUBcpoLRbFKrAD8imtMdUC37bg +stream-finance-ethereum,stream-finance,generic,ethereum,prod,stream-finance-ethereum,7wzhzJbytdHNsE12B3ascjZKhP8LvoVtuhXqZ97gz2Dr +swell-liquid-staking-ethereum,swell-liquid-staking,generic,ethereum,prod,swell-liquid-staking-ethereum,F8nUFWAC9vE1gHcUj5ZHXSt53eXo9vRqf2SuCcYVs93S +symbiotic-ethereum,symbiotic,generic,ethereum,prod,symbiotic-ethereum,2Bp6ibq6y7LLUoZRi4AfPmDNLrMcM6pKJCbusMPCAvzr +tenderize-v2-arbitrum,tenderize-v2,generic,arbitrum,prod,tenderize-v2-arbitrum,todo +tenderize-v2-ethereum,tenderize-v2,generic,ethereum,prod,tenderize-v2-ethereum,todo +tensorplex-ethereum,tensorplex,generic,ethereum,prod,tensorplex-ethereum,todo +the-graph-arbitrum,the-graph,generic,arbitrum,dev,the-graph-arbitrum,EExUE3FayKraaTteewjxaUpZW4M33j4bsD6pgxNCHnGd +the-graph-ethereum,the-graph,generic,ethereum,prod,the-graph-ethereum,AQHJdvUMkPfSxi6Q2LxXYjWXjGvfCST8DFFYE4VUKtU6 +tornado-cash-classic-bsc,tornado-cash,generic,bsc,prod,tornado-cash-classic-bsc,3wAcWMmwNSv9CVfT4HFFWAvawCq621JPKfg1tniwdW7a +tornado-cash-classic-ethereum,tornado-cash,generic,ethereum,prod,tornado-cash-classic-ethereum,346UaR2Lgxg8yJ2Vq2r8wid1pWaYQNH6N1GmzGCJkHRV +umami-finance-arbitrum,umami-finance,generic,arbitrum,prod,umami-finance-arbitrum,3nfuRKwAnT5xEBtKT9cKhdCp517TDvEqhgY1eDKAtuZi +vaultka-arbitrum,vaultka,generic,arbitrum,prod,vaultka-arbitrum,GerYgkkJgdtE5LoxqiqXrxJzjDrLWixEd7D3aqfDQBxe +zircuit-staking-ethereum,zircuit-staking,generic,ethereum,prod,zircuit-staking-ethereum,AFZyi8H8ASMA3JzBf4d2eG3Ajxtx7mbD1H5G4Bpjn4ZD +aave-governance-ethereum,aave-governance,governance,ethereum,prod,aave-governance,8EBbn3tNayccBZrnW9ae6Q4NLHfVEcozvkB3YAp5Qatr +ampleforth-governance-ethereum,ampleforth-governance,governance,ethereum,prod,ampleforth-governance,B7zUhfTTV7mi2QZgUL661D714NGqeLtk6h3q3Mf2xNNa +angle-governance-ethereum,angle-governance,governance,ethereum,prod,angle-governance,94D1g2jHHqKUS5uhbEPHWyRgfp4bYeZPn5Cr5R3zvoYH +compound-governance-ethereum,compound-governance,governance,ethereum,prod,compound-governance,7nuSuPhUgKSg5uKRh8g5jyjZWE8DnvQw1mQtvDWpxrnh +cryptex-governance-ethereum,cryptex-governance,governance,ethereum,prod,cryptex-governance,AnAnCpeyy2ZbP2BLZw9u7VjGtVtRorvYuGU3vME1na7F +dydx-governance-ethereum,dydx-governance,governance,ethereum,prod,dydx-governance,FFK9Fa8fdBrAugNVFqRZVAtrej7FjsQNq1s9LVBhF4FX +ens-governance-ethereum,ens-governance,governance,ethereum,prod,ens-governance,GyijYxW9yiSRcEd5u2gfquSvneQKi5QuvU3WZgFyfFSn +euler-governance-ethereum,euler-governance,governance,ethereum,prod,euler-governance,F94CS4mephx6noem4KsXxeGDSufCGUH5fXrqUX5ZiFk2 +gitcoin-governance-ethereum,gitcoin-governance,governance,ethereum,prod,gitcoin-governance,By35hUZiWiHNzRsdDnxFU9T47YUNZwPjfhwD1iBbNGQL +hifi-governance-ethereum,hifi-governance,governance,ethereum,prod,hifi-governance,ANAXtqRM9cUySpQZ8xuaFTdu1oFCj4HYaRXXiChTihAM +hop-governance-ethereum,hop-governance,governance,ethereum,prod,hop-governance,9RFPnB3zNjtc7x9kowTyBU2YVGUFSJRe27EBJWLMVgy6 +maker-governance-ethereum,maker-governance,governance,ethereum,prod,maker-governance,FXpCdSzUbRFzovJLW8hrwFXA2E3Bj915w99TtTSMm88p +ousd-governance-ethereum,ousd-governance,governance,ethereum,prod,ousd-governance,BwcFTZJskUwk6WXKteMAEqn6CQFWsPsqq8A8YGcqnWkK +pooltogether-governance-ethereum,pooltogether-governance,governance,ethereum,prod,pooltogether-governance,8rW1keThqpvtoBz7V2iNbo3wqcPCJZTBGuc3frGKbyi2 +radicle-governance-ethereum,radicle-governance,governance,ethereum,prod,radicle-governance,8jQvvEWJffzA48kxnPhuG7dqv4MWwPatVKKbxzr66xiN +rarible-governance-ethereum,rarible-governance,governance,ethereum,prod,rarible-governance,2oGCcncW9v7AAExqpZ9T1W1GecSjGVmi7XGet3P9JiNn +reflexer-governance-ethereum,reflexer-governance,governance,ethereum,prod,reflexer-governance,wWdwntxsEd21qDdhkzDn9ycNs5kvYamkndwv3GwLfPp +silo-governance-ethereum,silo-governance,governance,ethereum,prod,silo-governance,8qztgeMTJrq2kQHK7LzmbmDUpuBvDc6eFASDqN8SJBM5 +threshold-governance-ethereum,threshold-governance,governance,ethereum,prod,threshold-governance,Bk9fLLKttYoM4fE1cXXCq61owGqFtX1RsS8kEtDnDELC +truefi-governance-ethereum,truefi-governance,governance,ethereum,prod,truefi-governance,DbD7U3k8trdQUC2KqC2Fu2WcS42QUZHr2YXJzZXjH719 +uniswap-governance-ethereum,uniswap-governance,governance,ethereum,prod,uniswap-governance,7WXaWRE2GbBpmokFAnQfugpVsC61D9dfR6fHgjQFqpq5 +unlock-governance-ethereum,unlock-governance,governance,ethereum,prod,unlock-governance-ethereum,7ziHxbouaMXhSzxf5nfTXLYYASajU9bTCcxWoTKEAkBe +aave-amm-ethereum,aave-amm,lending,ethereum,prod,aave-amm-ethereum,41ooPWnDYKwckqyG1mvg7ZEndy5zMemXinx6uQxscrBS +aave-arc-ethereum,aave-arc,lending,ethereum,prod,aave-arc-ethereum,5hyqnEzjZbwFBU1rk4JBknCeiF2Mj93qBzsyQfpAa3QA +aave-rwa-ethereum,aave-rwa,lending,ethereum,prod,aave-rwa-ethereum,C8ynQrjVKcmqxb9fWrLvSCBFNf2ChFkxCg7Q8gknJrza +aave-v2-avalanche,aave-v2,lending,avalanche,prod,aave-v2-avalanche,9nh6Ums63wFcoZpmegyPcAFtY3CAzQc3S6cuERALYMqa +aave-v2-ethereum,aave-v2,lending,ethereum,prod,aave-v2-ethereum,C2zniPn45RnLDGzVeGZCx2Sw3GXrbc9gL4ZfL8B8Em2j +aave-v2-polygon,aave-v2,lending,polygon,prod,aave-v2-polygon,GrZQJ7sWdTqiNUD8Vh2THaeBM4wGwiF8mFv9FBfyzwxm +aave-v3-arbitrum,aave-v3,lending,arbitrum,prod,aave-v3-arbitrum,4xyasjQeREe7PxnF6wVdobZvCw5mhoHZq3T7guRpuNPf +aave-v3-avalanche,aave-v3,lending,avalanche,prod,aave-v3-avalanche,72Cez54APnySAn6h8MswzYkwaL9KjvuuKnKArnPJ8yxb +aave-v3-base,aave-v3,lending,base,prod,aave-v3-base,D7mapexM5ZsQckLJai2FawTKXJ7CqYGKM8PErnS3cJi9 +aave-v3-bsc,aave-v3,lending,bsc,prod,aave-v3-bsc,43jbGkvSw55sMvYyF6MZieksmJbajMu3hNGF8PN9ucuP +aave-v3-ethereum,aave-v3,lending,ethereum,prod,aave-v3-ethereum,JCNWRypm7FYwV8fx5HhzZPSFaMxgkPuw4TnR3Gpi81zk +aave-v3-fantom,aave-v3,lending,fantom,prod,aave-v3-fantom,ZcLcVKJNQboeqACXhGuL3WFLBZzf5uUWheNsaFvLph6 +aave-v3-gnosis,aave-v3,lending,gnosis,prod,aave-v3-gnosis,GiNMLDxT1Bdn2dQZxjQLmW24uwpc3geKUBW8RP6oEdg +aave-v3-harmony,aave-v3,lending,harmony,prod,aave-v3-harmony,G1BNHqmteZiUwSEacfXG2nzMm13KLNo5xoxv62ErAyQv +aave-v3-optimism,aave-v3,lending,optimism,prod,aave-v3-optimism,3RWFxWNstn4nP3dXiDfKi9GgBoHx7xzc7APkXs1MLEgi +aave-v3-polygon,aave-v3,lending,polygon,prod,aave-v3-polygon,6yuf1C49aWEscgk5n9D1DekeG1BCk5Z9imJYJT3sVmAT +aave-v3-scroll,aave-v3,lending,scroll,prod,aave-v3-scroll,DkvXMxq1skgSe1ehLHWpiUthHU1znnMDK2SUmj9avhEX +abracadabra-arbitrum,abracadabra,lending,arbitrum,prod,abracadabra-money-arbitrum,3m97d2dJ2pXwPFuiHrm8T37V9TCoAHBpMqRwdguyUZXF +abracadabra-avalanche,abracadabra,lending,avalanche,prod,abracadabra-money-avalanche,3Gkei7B24o9C2bCoAbQpApZqMStPta7oCAnNhmNv5dab +abracadabra-bsc,abracadabra,lending,bsc,prod,abracadabra-money-bsc,6bFCfHn5Uuv5fH7PxKL12dzWh3zz7fkQ46EnMa7nZUj2 +abracadabra-ethereum,abracadabra,lending,ethereum,prod,abracadabra-money-ethereum,GLAu42kvVs7ixfXcmkAsRiS7Xt1NCpgkKsnz3qiriuvV +abracadabra-fantom,abracadabra,lending,fantom,prod,abracadabra-money-fantom,2nxGrxxPShrm49dEWusJjB5dpmonN16JFzLwDrS1pCyq +alpaca-finance-lending-bsc,alpaca-finance-lending,lending,bsc,prod,alpaca-finance-lending-bsc,ED3ayhcLA7h7DCGwbysgcxtfMEcoeYCdMEsdZJeoaUFS +alpaca-finance-lending-fantom,alpaca-finance-lending,lending,fantom,prod,alpaca-finance-lending-fantom,6EfFr7xDpD7LLi1X8Cj9b6ytjFjX3GZYrMrCKomEuCmx +banker-joe-avalanche,banker-joe,lending,avalanche,prod,banker-joe-avalanche,9NjYuG2BFU1BPacNdKymd9eNdfVCaJM6LhsgD8zSQgDK +bastion-protocol-aurora,bastion-protocol,lending,aurora,prod,bastion-protocol-aurora,BD4rW7Ga5YQ3x68tALbi8vsXNodd6LrvFeaVocdJt3bD +benqi-avalanche,benqi,lending,avalanche,prod,benqi-avalanche,8ZjJGsaKea7WwLJPJNdHXPGsvXDe3iq2231aRjgBPisi +burrow-near,burrow,lending,near-mainnet,prod,burrow-near,5W5fhZAq6QABBijKo7wqYps7TLzqAqS2mU1C1rhktvtg +compound-v2-ethereum,compound-v2,lending,ethereum,prod,compound-v2-ethereum,4TbqVA8p2DoBd5qDbPMwmDZv3CsJjWtxo8nVSqF2tA9a +compound-v3-arbitrum,compound-v3,lending,arbitrum,prod,compound-v3-arbitrum,5MjRndNWGhqvNX7chUYLQDnvEgc8DaH8eisEkcJt71SR +compound-v3-base,compound-v3,lending,base,prod,compound-v3-base,AwoxEZbiWLvv6e3QdvdMZw4WDURdGbvPfHmZRc8Dpfz9 +compound-v3-ethereum,compound-v3,lending,ethereum,prod,compound-v3-ethereum,AwoxEZbiWLvv6e3QdvdMZw4WDURdGbvPfHmZRc8Dpfz9 +compound-v3-polygon,compound-v3,lending,polygon,prod,compound-v3-polygon,5wfoWBpfYv59b99wDxJmyFiKBu9brXESeqJAzw8WP5Cz +cream-finance-arbitrum,cream-finance,lending,arbitrum,prod,cream-finance-arbitrum,GzHkVNf7BBqUjV8Sy6U6xUaWdGheFMdin1cB6sNvfdzs +cream-finance-bsc,cream-finance,lending,bsc,prod,cream-finance-bsc,Dd2ak11qC4mS2spUXzJm5v9EtVNJqmBC9rLzbckTwfN1 +cream-finance-ethereum,cream-finance,lending,ethereum,prod,cream-finance-ethereum,43NeT7UTACLUkohKBaG7auvkhsj4Kwux9kNTJr6sFdNe +cream-finance-polygon,cream-finance,lending,polygon,prod,cream-finance-polygon,CBeERkhQNwPwU3jSWdKHeAtPQh4TFucUyUMcqAJk19ij +dforce-arbitrum,dforce,lending,arbitrum,prod,dforce-arbitrum,Dpk4Gen22wxQ3Laojf7DR2me8wGzjaHwjsKAsLf2rCFV +dforce-bsc,dforce,lending,bsc,prod,dforce-bsc,DKu1HqTTi26uLZKAmvDbqyAvcnFAjXEuRJmF35RLpyFg +dforce-ethereum,dforce,lending,ethereum,prod,dforce-ethereum,6PaB6tKFqrL6YoAELEhFGU6Gc39cEynLbo6ETZMF3sCy +dforce-optimism,dforce,lending,optimism,prod,dforce-optimism,6AmkakXwadWiZ2jN7oJcFreWmKG1nZrT5P8om52upYPd +dforce-polygon,dforce,lending,polygon,prod,dforce-polygon,9CFGPWpntYisBp7NpHMrgYzFrBmtVxSw58haGyZ3ewoZ +euler-finance-ethereum,euler-finance,lending,ethereum,prod,euler-finance-ethereum,95nyAWFFaiz6gykko3HtBCyhRuP5vZzuKYsZiLxHxLhr +geist-finance-fantom,geist-finance,lending,fantom,prod,geist-finance-fantom,45LX32kZPBRNiXaBKDrzbCnidoKv3cMEc8cXt3kvPifz +goldfinch-ethereum,goldfinch,lending,ethereum,prod,goldfinch-ethereum,GRwpFCPYyQPdz84sCnKemzrNvgFPuKkFLcRLR6jsRxHr +inverse-finance-ethereum,inverse-finance,lending,ethereum,prod,inverse-finance-ethereum,EXuutY6qkZbXjYeJZdiDBf2imJswTNdfm8YZCqhAthfW +iron-bank-avalanche,iron-bank,lending,avalanche,prod,iron-bank-avalanche,9YiJM9oHy25estSJjB1Z71Hdz5C814R3vDoS2ezpN27C +iron-bank-ethereum,iron-bank,lending,ethereum,prod,iron-bank-ethereum,5YoxED3bbWV9byvn3x3S3ebZ3idrQmQmsJhL5LMyY26v +iron-bank-fantom,iron-bank,lending,fantom,prod,iron-bank-fantom,4dWx6UZNcLEzgtipy45VkgtptYRqoHdZeCGNKxHAxKWo +iron-bank-optimism,iron-bank,lending,optimism,prod,iron-bank-optimism,4WKePP5QfwrW6Hfd8YKWHuivivmdxPubuP45BryeGo4g +kinza-finance-bsc,kinza-finance,lending,bsc,prod,kinza-finance-bsc,435cubRAqNsFYKzyQHRRiHvR7oJjh828r5Aqe4cZC586 +liquity-ethereum,liquity,lending,ethereum,prod,liquity-ethereum,2D2dFCLjUt3MfFgTKW8cBxiRQ3Adss7KUtYh2rTcFVY +makerdao-ethereum,makerdao,lending,ethereum,prod,makerdao-ethereum,8sE6rTNkPhzZXZC6c8UQy2ghFTu5PPdGauwUBm4t7HZ1 +maple-finance-v1-ethereum,maple-finance-v1,lending,ethereum,prod,maple-finance-ethereum,J9dtvE11PWNZH74frWyx9QZonyC1Db2UWDMUegmT3zkG +maple-finance-v2-ethereum,maple-finance-v2,lending,ethereum,prod,maple-finance-v2-ethereum,94swSaaFChsQoZzb9Vc7Lo6FWFV6YZUMNSdFVTMAeRgj +moonwell-base,moonwell,lending,base,prod,moonwell-base,33ex1ExmYQtwGVwri1AP3oMFPGSce6YbocBP7fWbsBrg +moonwell-moonbeam,moonwell,lending,moonbeam,prod,moonwell-moonbeam,DQhrdUHwspQf3hSjDtyfS6uqq9YiKoLF3Ut3U9os2HK +moonwell-moonriver,moonwell,lending,moonriver,prod,moonwell-moonriver,8ayELti1UNCNCWuvwSwapjh4mvvCejeXsk4PmsWBmQ82 +morpho-aave-v2-ethereum,morpho-aave-v2,lending,ethereum,prod,morpho-aave-v2-ethereum,DsznTYxGdsqxWB6a474rSksvB7qWSth5Ff1PcxW28vZy +morpho-aave-v3-ethereum,morpho-aave-v3,lending,ethereum,prod,morpho-aave-v3-ethereum,FKe6ANnWmGPE6hajGLoTgPrVF2jYPHiRu2Jwcg9ZmG9A +morpho-compound-ethereum,morpho-compound,lending,ethereum,prod,morpho-compound-ethereum,9dTy23tkahyiap1THgwnJuMwxNHVnQM57jFQQiUzjcY6 +notional-finance-ethereum,notional-finance,lending,ethereum,dev,notional-finance-ethereum,2t4T7bts8ZQCpGcVq9VSzDyPVCQc5Y7TFwZKfmXKeSVx +pac-finance-blast,pac-finance,lending,blast-mainnet,prod,pac-finance-blast,ERsfyKMQTpTEN6LtyWvFwhDENLf6aAAggbtrNEnFKLpx +qidao-arbitrum,qidao,lending,arbitrum,prod,qidao-arbitrum,Duw2tSACo9uRGFctAGsCc9pF7ZGMyqpjkAHPwm49dZe6 +qidao-avalanche,qidao,lending,avalanche,prod,qidao-avalanche,98GG74FxxsG25Ltd8qvJ9BRfFmQWyN1AkS92MZBG1BsR +qidao-base,qidao,lending,base,prod,qidao-base,9NHJ9k31qaGCYXppm9isJTiEoiB6v3tJDnR6SrQrxcjw +qidao-bsc,qidao,lending,bsc,prod,qidao-bsc,4DcztqYL7UG5bjdisWWvnj3m4NtK5J3bs89scihAkicr +qidao-ethereum,qidao,lending,ethereum,prod,qidao-ethereum,BmQSQaXsivq866kUobQSbyxycjk3D7CiaczKgu3P9ifB +qidao-fantom,qidao,lending,fantom,prod,qidao-fantom,hf51jYbZ9uESiuBabfxf6fRdc22xtmNWX9c3SRrct2q +qidao-gnosis,qidao,lending,gnosis,prod,qidao-gnosis,7vJEsy8pJmRQZQh5kTXNz68SRHXBS859hMq3o5uWF1Ac +qidao-harmony,qidao,lending,harmony,prod,qidao-harmony,DCEQvXCiqtpMybQLL4YAgdCzqHzRH6wFFnCDnnLBBuvf +qidao-moonriver,qidao,lending,moonriver,prod,qidao-moonriver,HzDP5zXKyjnEJP9TnFirk3qA24SUp4AfzKUBSRcBekgz +qidao-optimism,qidao,lending,optimism,prod,qidao-optimism,4JbWxzxBNCpAaVz72Gt2UthgiwcWZQLKDBhmSE7wKY2K +qidao-polygon,qidao,lending,polygon,prod,qidao-polygon,5UxEcMvYW4vVYP81tkPQMAvJv1e4m1xU8BJkDXBnpc6x +radiant-capital-arbitrum,radiant-capital,lending,arbitrum,prod,radiant-capital-arbitrum,5HTkKJNSm72tUGakwj8yroDGHxc6fBhmLaA5oJepZGL3 +radiant-capital-v2-arbitrum,radiant-capital-v2,lending,arbitrum,dev,radiant-capital-v2-arbitrum,2rQAKGJkvkiAXsCjx1n4E3DSgk2b7nCZMtt2BrV5TBgt +radiant-capital-v2-bsc,radiant-capital-v2,lending,bsc,dev,radiant-capital-v2-bsc,cM9BYtdT8aVBX8JEbi9SQjV2Ft8onEh6qwZHxCUyAAh +rari-fuse-arbitrum,rari-fuse,lending,arbitrum,prod,rari-fuse-arbitrum,HnV3fhwsWfmQGdD2AeGzqvRVTDBqnMH74jCsDVq1DXYP +rari-fuse-ethereum,rari-fuse,lending,ethereum,prod,rari-fuse-ethereum,kecp6SPMvbB4GTqg9r5PXvztYriexj5F3ZCaATpjmb2 +scream-fantom,scream,lending,fantom,prod,scream-fantom,Cj3pDoqHgLBntkaXAKMxtJTZr3StxYvVEedTXyJGJoK4 +seamless-protocol-base,seamless-protocol,lending,base,prod,seamless-protocol-base,2u4mWUV4xS19ef1MbnxZHWLLMwdPxtVifH46JbonXwXP +seismic-blast,seismic,lending,blast-mainnet,prod,seismic-blast,d7gMk1zkEyCQuNVeirBYA6keCZv8hTLheCZ4DBCjRfz +sonne-finance-optimism,sonne-finance,lending,optimism,prod,sonne-finance-optimism,DQqb7FiQ1joLhESkAwvAYiuXhwfz4zf6qHmbt7stnec8 +spark-lend-ethereum,spark-lend,lending,ethereum,prod,spark-lend-ethereum,GbKdmBe4ycCYCQLQSjqGg6UHYoYfbyJyq5WrG35pv1si +spark-lend-gnosis,spark-lend,lending,gnosis,prod,spark-lend-gnosis,Bw4RH37UbbGEhHo4FaWwT1dn9QJzm1XSZCyK1cbr6ZKM +truefi-ethereum,truefi,lending,ethereum,prod,truefi-ethereum,39F8fYCvLYmutjqpzEwx3dcEJTtFFVupvBzJqkEzftA7 +uwu-lend-ethereum,uwu-lend,lending,ethereum,prod,uwu-lend-ethereum,CZBD7e8VGvNa6WkBHZAaC688bsZ35UvAM1AuDdVng2aE +venus-protocol-bsc,venus,lending,bsc,prod,venus-protocol-bsc,CwswJ7sfENafqgAYU1upn3hQgoEV2CXXRZRJ7XtgJrKG +vesta-finance-arbitrum,vesta-finance,lending,arbitrum,prod,vesta-finance-arbitrum,zGuPrsVqtY5ehJDCmweb9ZnBrae3tSQWRux8Mz1M4Gn +zerolend-blast,zerolend,lending,blast-mainnet,prod,zerolend-blast,6JP9542ArawumBSYczerbWGu6k7uu3hqk6qJnSkrgTM5 +zerolend-ethereum,zerolend,lending,ethereum,prod,zerolend-ethereum,4Zf4doH54RDit9KVsfCp3MkjrP3szhJZwvw2z5PHczx9 +zerolend-linea,zerolend,lending,linea,prod,zerolend-linea,DLzwo1WFaKy7R7MgQWrnBXr19EbGwPRubu9YmsSmRMfC +zerolend-xlayer,zerolend,lending,xlayer-mainnet,prod,zerolend-xlayer,NRh6ScvPKoieeSH7tRiKyXJ97DR9aYraas8eREPQ8e3 +zerolend-zksync-era,zerolend,lending,zksync-era,prod,zerolend-zksync-era,3CHaJvCkTMqXa4PRKNshVecE9JqgNFCdsXNyGLZXFeM2 +cryptopunks-ethereum,cryptopunks,nft-marketplace,ethereum,prod,cryptopunks-ethereum,HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK +looksrare-ethereum,looksrare,nft-marketplace,ethereum,dev,looksrare-ethereum,FsT2DES8UdhfDkXCtE56h5WCDrrSXrtJiSMgNWvSdyYL +opensea-seaport-ethereum,seaport,nft-marketplace,ethereum,dev,opensea-seaport-ethereum,2GmLsgYGWoFoouZzKjp8biYDkfmeLTkEY3VDQyZqSJHA +opensea-v1-ethereum,opensea-v1,nft-marketplace,ethereum,dev,opensea-v1-ethereum,GSjXo5Vd1EPaMGRJBYe6HoBKv7WSq3miCrRRZJbTCHkT +opensea-v2-ethereum,opensea-v2,nft-marketplace,ethereum,dev,opensea-v2-ethereum,ECtdoov16DUmk5qbhFx4PVVN7vidiNDwzFNsui6FoHEo +x2y2-ethereum,x2y2,nft-marketplace,ethereum,dev,x2y2-ethereum,3cMswgcjkpLmuF99ViQRZfCPRyCsnimqQsR9z6mY5e2i +arrakis-finance-ethereum,arrakis-finance,yield-aggregator,ethereum,prod,arrakis-finance-ethereum,GnroBYmeLLtKuHNyTNS38hzKki5n4CWaHeaMRqZpU4cr +arrakis-finance-optimism,arrakis-finance,yield-aggregator,optimism,prod,arrakis-finance-optimism,6yqMWioX8XNx2aMDYJGnvrVQWNrZfgBzY3ee1RmkXh5Z +arrakis-finance-polygon,arrakis-finance,yield-aggregator,polygon,prod,arrakis-finance-polygon,9YGjubD69wpCHyMMadVJv9eABKKUMWyBGYkZHVFEeWM8 +aura-finance-ethereum,aura-finance,yield-aggregator,ethereum,prod,aura-finance-ethereum,EcNHwEGXq3KW1vCbHHj1iwvtf62ae5kxzEQhKtRqPygt +badgerdao-ethereum,badgerdao,yield-aggregator,ethereum,prod,badgerdao-ethereum,BchjnXAXXV5coiCBMQH4A8yCHXEFX9S88JFF6G3mfem4 +belt-finance-bsc,belt-finance,yield-aggregator,bsc,prod,belt-finance-bsc,9jLaSWECnXdmwDG6zGMR39PqwhscHoiLGoX1mLtHLqWd +convex-finance-ethereum,convex-finance,yield-aggregator,ethereum,prod,convex-finance-ethereum,7rFZ2x6aLQ7EZsNx8F5yenk4xcqwqR3Dynf9rdixCSME +gamma-strategies-ethereum,gamma-strategies,yield-aggregator,ethereum,prod,gamma-ethereum,ANz3TpZdY2syZGQvGA85ANNG7KiSWdPmv55kP4H4sRPJ +gamma-strategies-polygon,gamma-strategies,yield-aggregator,polygon,prod,gamma-polygon,AyxB5Suv1REgRZPUwbgbbqtpwftvTC46dbiHPuBQuF8y +rari-vaults-ethereum,rari-vaults,yield-aggregator,ethereum,prod,rari-vaults-ethereum,Dy1yVPfbS27HTrqEq3nLGFGi3TMYxPzSfY7Zxxj5ZJhf +ribbon-finance-avalanche,ribbon-finance,yield-aggregator,avalanche,prod,ribbon-finance-avalanche,FxhN13aCD2H1f9vagrVueGjHwguZ7JkfuDZrMvKthdk5 +ribbon-finance-ethereum,ribbon-finance,yield-aggregator,ethereum,prod,ribbon-finance-ethereum,Crag42fFb8PrXnbTjHe1UG5KjgzoiUJbqwzJxZ1W8XNJ +vesper-finance-ethereum,vesper-finance,yield-aggregator,ethereum,prod,vesper-ethereum,GQdCg4oR8tFB4tH8svyL1PfgDABKnRXz4GjwFYH68pPG +yearn-v2-arbitrum,yearn-v2,yield-aggregator,arbitrum,prod,yearn-v2-arbitrum,G3JZhmKKHC4mydRzD6kSz5fCWve5WDYYCyTFSJyv3SD5 +yearn-v2-ethereum,yearn-v2,yield-aggregator,ethereum,prod,yearn-v2-ethereum,FDLuaz69DbMADuBjJDEcLnTuPnjhZqNbFVrkNiBLGkEg diff --git a/deployment/deployment.json b/deployment/deployment.json index 5609e3b95c..abeaa8166e 100644 --- a/deployment/deployment.json +++ b/deployment/deployment.json @@ -11781,7 +11781,7 @@ }, "decentralized-network": { "slug": "binance-staked-eth-ethereum", - "query-id": "todo" + "query-id": "EdxuQc4V8zGV9f34KZJhUNmBrfdPWMmbjVTzjUsyJZgd" } } }, @@ -11807,7 +11807,7 @@ }, "decentralized-network": { "slug": "binance-staked-eth-bsc", - "query-id": "todo" + "query-id": "Hfb8J7aNfT8cjgDTYMjWt5Mb7yRtS1CJC4UQeWEfWNsU" } } } @@ -12283,7 +12283,7 @@ }, "decentralized-network": { "slug": "dinero-pxeth-ethereum", - "query-id": "todo" + "query-id": "4WV13q7iDBhFyqprdbFX5eb2h29Qh6c7aVuCjUHX8148" } } } @@ -12317,7 +12317,7 @@ }, "decentralized-network": { "slug": "stake-link-liquid-ethereum", - "query-id": "todo" + "query-id": "AV8BsSRc9oC4dr6yN7wPi4PyXsBnW3oHqbvoKfbEr1XW" } } } @@ -12351,7 +12351,7 @@ }, "decentralized-network": { "slug": "gogopool-avalanche", - "query-id": "todo" + "query-id": "4fD8jH8YUR4HSyQZArgyX5RVvgPLoG6H1stzUeHSNBne" } } } @@ -12385,7 +12385,7 @@ }, "decentralized-network": { "slug": "gaurda-staking-ethereum", - "query-id": "todo" + "query-id": "7Ax8MpZkfR5CnQFKRxUEGG8TuyrW5UwxohXC8opnqZ7j" } } } @@ -12419,7 +12419,7 @@ }, "decentralized-network": { "slug": "tenderize-v2-ethereum", - "query-id": "todo" + "query-id": "7dyhXtGrSebgffTAduYLzbdef1EQwDWEULnVogeTDmfG" } } }, @@ -12445,7 +12445,7 @@ }, "decentralized-network": { "slug": "tenderize-v2-arbitrum", - "query-id": "todo" + "query-id": "Fx59VkMxNeoPDsCaHbjiqq6tmfFzt4LrUEtnAmv7GYrP" } } } @@ -12479,7 +12479,7 @@ }, "decentralized-network": { "slug": "tensorplex-ethereum", - "query-id": "todo" + "query-id": "Fx59VkMxNeoPDsCaHbjiqq6tmfFzt4LrUEtnAmv7GYrP" } } } @@ -12513,7 +12513,7 @@ }, "decentralized-network": { "slug": "paxos-gold-ethereum", - "query-id": "todo" + "query-id": "3GYHnRz961CsPut6udWqaVdDJN7imKZWjBqfyzaAbPri" } } } @@ -12547,7 +12547,7 @@ }, "decentralized-network": { "slug": "tether-gold-ethereum", - "query-id": "todo" + "query-id": "E9VxYW2ULCFGyYGibzbq3NW3LySAwEEvbqTpKuGjTrN3" } } } @@ -12581,7 +12581,7 @@ }, "decentralized-network": { "slug": "aurus-ethereum", - "query-id": "todo" + "query-id": "E9VxYW2ULCFGyYGibzbq3NW3LySAwEEvbqTpKuGjTrN3" } } } @@ -12615,7 +12615,7 @@ }, "decentralized-network": { "slug": "klimadao-polygon", - "query-id": "todo" + "query-id": "6SasXXKVoVSFEJqEGQqUQMEL2nufjaapbNuzE7tDCuu8" } } } @@ -12649,6 +12649,40 @@ }, "decentralized-network": { "slug": "matrixdock-ethereum", + "query-id": "CAKvXVz7dzbF5HH4MVWXi1ozhCm1omWpmYk4n2s56tjJ" + } + } + } + } + }, + "powh3d": { + "schema": "generic", + "base": "powh3d", + "protocol": "powh3d", + "project": "powh3d", + "deployments": { + "powh3d-ethereum": { + "network": "ethereum", + "status": "prod", + "versions": { + "schema": "3.0.0", + "subgraph": "1.0.0", + "methodology": "1.0.0" + }, + "files": { + "template": "powh3d.template.yaml" + }, + "options": { + "prepare:yaml": true, + "prepare:constants": true + }, + "services": { + "hosted-service": { + "slug": "powh3d-ethereum", + "query-id": "powh3d-ethereum" + }, + "decentralized-network": { + "slug": "powh3d-ethereum", "query-id": "todo" } } diff --git a/deployment/produce_decentralized_network_csv.py b/deployment/produce_decentralized_network_csv.py index f965491acd..bb6fb25a90 100644 --- a/deployment/produce_decentralized_network_csv.py +++ b/deployment/produce_decentralized_network_csv.py @@ -1,6 +1,11 @@ import json -import pandas as pd +import os +try: + import pandas as pd +except ImportError: + print("Warning: pandas is not installed. Using built-in CSV writing.") + pd = None def extract_deployment_info(data): rows = [] @@ -28,20 +33,65 @@ def extract_deployment_info(data): # Extract information rows = extract_deployment_info(general_data) -# Create DataFrame -df_general = pd.DataFrame(rows) +if pd is not None: + # Create DataFrame + df_general = pd.DataFrame(rows) -## order by protocol type and deployment name -df_general = df_general.sort_values(by=["protocol type", "deployment name"]) + ## order by protocol type and deployment name + df_general = df_general.sort_values(by=["protocol type", "deployment name"]) -# Save to CSV -csv_file_path_general = "decentralized_network_deployments.csv" -df_general.to_csv(csv_file_path_general, index=False) + # Save to CSV + csv_file_path_general = "decentralized_network_deployments.csv" + df_general.to_csv(csv_file_path_general, index=False) -# Print Deployment Statistics -df_prod = df_general[df_general['status'] == 'prod'] -distinct_protocols = df_prod['protocol name'].nunique() -non_governance_protocols = df_prod[~df_prod['protocol name'].str.contains('governance', case=False, na=False)]['protocol name'].nunique() + # Print Deployment Statistics + df_prod = df_general[df_general['status'] == 'prod'] + distinct_protocols = df_prod['protocol name'].nunique() + non_governance_protocols = df_prod[~df_prod['protocol name'].str.contains('governance', case=False, na=False)]['protocol name'].nunique() + distinct_networks = df_prod['network'].nunique() -print(f"Number of distinct protocols in production: {distinct_protocols}") -print(f"Number of non-governance protocols in production: {non_governance_protocols}") + print(f"Number of distinct protocols in production: {distinct_protocols}") + print(f"Number of non-governance protocols in production: {non_governance_protocols}") + print(f"Number of distinct networks deployed on: {distinct_networks}") + + # Print number of protocols for each type + protocol_type_counts = df_prod.groupby("protocol type")["protocol name"].nunique() + print("\nNumber of protocols for each type:") + for protocol_type, count in protocol_type_counts.items(): + print(f"{protocol_type}: {count}") + +else: + # Fallback to built-in CSV writing and manual counting + import csv + from collections import defaultdict + + with open("decentralized_network_deployments.csv", "w", newline="") as csvfile: + fieldnames = ["deployment name", "protocol name", "protocol type", "network", "status", "slug", "query-id"] + writer = csv.DictWriter(csvfile, fieldnames=fieldnames) + writer.writeheader() + for row in rows: + writer.writerow(row) + + protocol_counts = defaultdict(set) + distinct_protocols = set() + non_governance_protocols = set() + distinct_networks = set() + + for row in rows: + if row["status"] == "prod": + protocol_type = row["protocol type"] + protocol_name = row["protocol name"] + network = row["network"] + protocol_counts[protocol_type].add(protocol_name) + distinct_protocols.add(protocol_name) + distinct_networks.add(network) + if "governance" not in protocol_name.lower(): + non_governance_protocols.add(protocol_name) + + print(f"Number of distinct protocols in production: {len(distinct_protocols)}") + print(f"Number of non-governance protocols in production: {len(non_governance_protocols)}") + print(f"Number of distinct networks deployed on: {len(distinct_networks)}") + + print("\nNumber of protocols for each type:") + for protocol_type, protocols in protocol_counts.items(): + print(f"{protocol_type}: {len(protocols)}") diff --git a/subgraphs/powh3d/.gitignore b/subgraphs/powh3d/.gitignore new file mode 100644 index 0000000000..09140957fa --- /dev/null +++ b/subgraphs/powh3d/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +configure.ts +docs/ +package-lock.json diff --git a/subgraphs/powh3d/README.md b/subgraphs/powh3d/README.md new file mode 100644 index 0000000000..db2896b085 --- /dev/null +++ b/subgraphs/powh3d/README.md @@ -0,0 +1,17 @@ +# Powh 3D Subgraph + +## Methodology v1.0.0 + +## Metrics + +### Usage and Transactions + +### TVL + +### Revenue + +## Useful Links + +- Landing Page: +- Docs: +- Contracts: diff --git a/subgraphs/powh3d/abis/Powh3d/Hourglass.json b/subgraphs/powh3d/abis/Powh3d/Hourglass.json new file mode 100644 index 0000000000..a5fe5b689c --- /dev/null +++ b/subgraphs/powh3d/abis/Powh3d/Hourglass.json @@ -0,0 +1,308 @@ +[ + { + "constant": true, + "inputs": [{ "name": "_customerAddress", "type": "address" }], + "name": "dividendsOf", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "_ethereumToSpend", "type": "uint256" }], + "name": "calculateTokensReceived", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "_tokensToSell", "type": "uint256" }], + "name": "calculateEthereumReceived", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "onlyAmbassadors", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "", "type": "bytes32" }], + "name": "administrators", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "sellPrice", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakingRequirement", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "_includeReferralBonus", "type": "bool" }], + "name": "myDividends", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalEthereumBalance", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "_customerAddress", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_amountOfTokens", "type": "uint256" }], + "name": "setStakingRequirement", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "buyPrice", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "_identifier", "type": "bytes32" }, + { "name": "_status", "type": "bool" } + ], + "name": "setAdministrator", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "myTokens", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "disableInitialStage", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "_toAddress", "type": "address" }, + { "name": "_amountOfTokens", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_symbol", "type": "string" }], + "name": "setSymbol", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_name", "type": "string" }], + "name": "setName", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_amountOfTokens", "type": "uint256" }], + "name": "sell", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "exit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "_referredBy", "type": "address" }], + "name": "buy", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "reinvest", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { "payable": true, "stateMutability": "payable", "type": "fallback" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "customerAddress", "type": "address" }, + { "indexed": false, "name": "incomingEthereum", "type": "uint256" }, + { "indexed": false, "name": "tokensMinted", "type": "uint256" }, + { "indexed": true, "name": "referredBy", "type": "address" } + ], + "name": "onTokenPurchase", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "customerAddress", "type": "address" }, + { "indexed": false, "name": "tokensBurned", "type": "uint256" }, + { "indexed": false, "name": "ethereumEarned", "type": "uint256" } + ], + "name": "onTokenSell", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "customerAddress", "type": "address" }, + { "indexed": false, "name": "ethereumReinvested", "type": "uint256" }, + { "indexed": false, "name": "tokensMinted", "type": "uint256" } + ], + "name": "onReinvestment", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "customerAddress", "type": "address" }, + { "indexed": false, "name": "ethereumWithdrawn", "type": "uint256" } + ], + "name": "onWithdraw", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "from", "type": "address" }, + { "indexed": true, "name": "to", "type": "address" }, + { "indexed": false, "name": "tokens", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + } +] diff --git a/subgraphs/powh3d/abis/Tokens/ChainlinkDataFeed.json b/subgraphs/powh3d/abis/Tokens/ChainlinkDataFeed.json new file mode 100644 index 0000000000..bca8a84144 --- /dev/null +++ b/subgraphs/powh3d/abis/Tokens/ChainlinkDataFeed.json @@ -0,0 +1,509 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "int256", + "name": "current", + "type": "int256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + } + ], + "name": "AnswerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "startedBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + } + ], + "name": "NewRound", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessController", + "outputs": [ + { + "internalType": "contract AccessControllerInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aggregator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "confirmAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "description", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "phaseAggregators", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "phaseId", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "proposeAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "proposedAggregator", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "proposedGetRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proposedLatestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "name": "setController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/powh3d/abis/Tokens/ERC20.json b/subgraphs/powh3d/abis/Tokens/ERC20.json new file mode 100644 index 0000000000..405d6b3648 --- /dev/null +++ b/subgraphs/powh3d/abis/Tokens/ERC20.json @@ -0,0 +1,222 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } +] diff --git a/subgraphs/powh3d/abis/Tokens/ERC20NameBytes.json b/subgraphs/powh3d/abis/Tokens/ERC20NameBytes.json new file mode 100644 index 0000000000..2d3c877a8c --- /dev/null +++ b/subgraphs/powh3d/abis/Tokens/ERC20NameBytes.json @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/powh3d/abis/Tokens/ERC20SymbolBytes.json b/subgraphs/powh3d/abis/Tokens/ERC20SymbolBytes.json new file mode 100644 index 0000000000..a76d616366 --- /dev/null +++ b/subgraphs/powh3d/abis/Tokens/ERC20SymbolBytes.json @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/powh3d/abis/Tokens/_ERC20.json b/subgraphs/powh3d/abis/Tokens/_ERC20.json new file mode 100644 index 0000000000..5c47f76a53 --- /dev/null +++ b/subgraphs/powh3d/abis/Tokens/_ERC20.json @@ -0,0 +1,828 @@ +[ + { + "name": "Transfer", + "inputs": [ + { "type": "address", "name": "sender", "indexed": true }, + { "type": "address", "name": "receiver", "indexed": true }, + { "type": "uint256", "name": "value", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "Approval", + "inputs": [ + { "type": "address", "name": "owner", "indexed": true }, + { "type": "address", "name": "spender", "indexed": true }, + { "type": "uint256", "name": "value", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyAdded", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "debtRatio", "indexed": false }, + { "type": "uint256", "name": "rateLimit", "indexed": false }, + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyReported", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "gain", "indexed": false }, + { "type": "uint256", "name": "loss", "indexed": false }, + { "type": "uint256", "name": "totalGain", "indexed": false }, + { "type": "uint256", "name": "totalLoss", "indexed": false }, + { "type": "uint256", "name": "totalDebt", "indexed": false }, + { "type": "uint256", "name": "debtAdded", "indexed": false }, + { "type": "uint256", "name": "debtRatio", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGovernance", + "inputs": [{ "type": "address", "name": "governance", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateManagement", + "inputs": [{ "type": "address", "name": "management", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGuestList", + "inputs": [{ "type": "address", "name": "guestList", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateRewards", + "inputs": [{ "type": "address", "name": "rewards", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateDepositLimit", + "inputs": [{ "type": "uint256", "name": "depositLimit", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdatePerformanceFee", + "inputs": [ + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateManagementFee", + "inputs": [ + { "type": "uint256", "name": "managementFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateGuardian", + "inputs": [{ "type": "address", "name": "guardian", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "EmergencyShutdown", + "inputs": [{ "type": "bool", "name": "active", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "UpdateWithdrawalQueue", + "inputs": [{ "type": "address[20]", "name": "queue", "indexed": false }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdateDebtRatio", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "debtRatio", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdateRateLimit", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "rateLimit", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyUpdatePerformanceFee", + "inputs": [ + { "type": "address", "name": "strategy", "indexed": true }, + { "type": "uint256", "name": "performanceFee", "indexed": false } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyMigrated", + "inputs": [ + { "type": "address", "name": "oldVersion", "indexed": true }, + { "type": "address", "name": "newVersion", "indexed": true } + ], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyRevoked", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyRemovedFromQueue", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "StrategyAddedToQueue", + "inputs": [{ "type": "address", "name": "strategy", "indexed": true }], + "anonymous": false, + "type": "event" + }, + { + "name": "initialize", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "address", "name": "governance" }, + { "type": "address", "name": "rewards" }, + { "type": "string", "name": "nameOverride" }, + { "type": "string", "name": "symbolOverride" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "initialize", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "address", "name": "governance" }, + { "type": "address", "name": "rewards" }, + { "type": "string", "name": "nameOverride" }, + { "type": "string", "name": "symbolOverride" }, + { "type": "address", "name": "guardian" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "apiVersion", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "pure", + "type": "function", + "gas": 4519 + }, + { + "name": "setName", + "outputs": [], + "inputs": [{ "type": "string", "name": "name" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 107017 + }, + { + "name": "setSymbol", + "outputs": [], + "inputs": [{ "type": "string", "name": "symbol" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 71867 + }, + { + "name": "setGovernance", + "outputs": [], + "inputs": [{ "type": "address", "name": "governance" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 36338 + }, + { + "name": "acceptGovernance", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37610 + }, + { + "name": "setManagement", + "outputs": [], + "inputs": [{ "type": "address", "name": "management" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37748 + }, + { + "name": "setGuestList", + "outputs": [], + "inputs": [{ "type": "address", "name": "guestList" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37778 + }, + { + "name": "setRewards", + "outputs": [], + "inputs": [{ "type": "address", "name": "rewards" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37808 + }, + { + "name": "setDepositLimit", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "limit" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37738 + }, + { + "name": "setPerformanceFee", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "fee" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37872 + }, + { + "name": "setManagementFee", + "outputs": [], + "inputs": [{ "type": "uint256", "name": "fee" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 37902 + }, + { + "name": "setGuardian", + "outputs": [], + "inputs": [{ "type": "address", "name": "guardian" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 39146 + }, + { + "name": "setEmergencyShutdown", + "outputs": [], + "inputs": [{ "type": "bool", "name": "active" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 39217 + }, + { + "name": "setWithdrawalQueue", + "outputs": [], + "inputs": [{ "type": "address[20]", "name": "queue" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 763893 + }, + { + "name": "transfer", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "receiver" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 76733 + }, + { + "name": "transferFrom", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "sender" }, + { "type": "address", "name": "receiver" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 116496 + }, + { + "name": "approve", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 38244 + }, + { + "name": "increaseAllowance", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 40285 + }, + { + "name": "decreaseAllowance", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 40309 + }, + { + "name": "permit", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [ + { "type": "address", "name": "owner" }, + { "type": "address", "name": "spender" }, + { "type": "uint256", "name": "amount" }, + { "type": "uint256", "name": "expiry" }, + { "type": "bytes", "name": "signature" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 81237 + }, + { + "name": "totalAssets", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 4123 + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "uint256", "name": "_amount" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "deposit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "_amount" }, + { "type": "address", "name": "recipient" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "maxAvailableShares", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 364171 + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "uint256", "name": "maxShares" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "maxShares" }, + { "type": "address", "name": "recipient" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "withdraw", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "maxShares" }, + { "type": "address", "name": "recipient" }, + { "type": "uint256", "name": "maxLoss" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "pricePerShare", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 12412 + }, + { + "name": "addStrategy", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "debtRatio" }, + { "type": "uint256", "name": "rateLimit" }, + { "type": "uint256", "name": "performanceFee" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1450351 + }, + { + "name": "updateStrategyDebtRatio", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "debtRatio" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 115316 + }, + { + "name": "updateStrategyRateLimit", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "rateLimit" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 41467 + }, + { + "name": "updateStrategyPerformanceFee", + "outputs": [], + "inputs": [ + { "type": "address", "name": "strategy" }, + { "type": "uint256", "name": "performanceFee" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 41344 + }, + { + "name": "migrateStrategy", + "outputs": [], + "inputs": [ + { "type": "address", "name": "oldVersion" }, + { "type": "address", "name": "newVersion" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1105801 + }, + { + "name": "revokeStrategy", + "outputs": [], + "inputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "revokeStrategy", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "addStrategyToQueue", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 1196920 + }, + { + "name": "removeStrategyFromQueue", + "outputs": [], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "nonpayable", + "type": "function", + "gas": 23091666 + }, + { + "name": "debtOutstanding", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "debtOutstanding", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "creditAvailable", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "creditAvailable", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "availableDepositLimit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 9808 + }, + { + "name": "expectedReturn", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "name": "expectedReturn", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "strategy" }], + "stateMutability": "view", + "type": "function" + }, + { + "name": "report", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "uint256", "name": "gain" }, + { "type": "uint256", "name": "loss" }, + { "type": "uint256", "name": "_debtPayment" } + ], + "stateMutability": "nonpayable", + "type": "function", + "gas": 937520 + }, + { + "name": "sweep", + "outputs": [], + "inputs": [{ "type": "address", "name": "token" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "sweep", + "outputs": [], + "inputs": [ + { "type": "address", "name": "token" }, + { "type": "uint256", "name": "amount" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "name": "name", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 9053 + }, + { + "name": "symbol", + "outputs": [{ "type": "string", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 8106 + }, + { + "name": "decimals", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2711 + }, + { + "name": "balanceOf", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 2956 + }, + { + "name": "allowance", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [ + { "type": "address", "name": "arg0" }, + { "type": "address", "name": "arg1" } + ], + "stateMutability": "view", + "type": "function", + "gas": 3201 + }, + { + "name": "totalSupply", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2801 + }, + { + "name": "token", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2831 + }, + { + "name": "governance", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2861 + }, + { + "name": "management", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2891 + }, + { + "name": "guardian", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2921 + }, + { + "name": "guestList", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 2951 + }, + { + "name": "strategies", + "outputs": [ + { "type": "uint256", "name": "performanceFee" }, + { "type": "uint256", "name": "activation" }, + { "type": "uint256", "name": "debtRatio" }, + { "type": "uint256", "name": "rateLimit" }, + { "type": "uint256", "name": "lastReport" }, + { "type": "uint256", "name": "totalDebt" }, + { "type": "uint256", "name": "totalGain" }, + { "type": "uint256", "name": "totalLoss" } + ], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 10322 + }, + { + "name": "withdrawalQueue", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [{ "type": "uint256", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 3120 + }, + { + "name": "emergencyShutdown", + "outputs": [{ "type": "bool", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3041 + }, + { + "name": "depositLimit", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3071 + }, + { + "name": "debtRatio", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3101 + }, + { + "name": "totalDebt", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3131 + }, + { + "name": "lastReport", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3161 + }, + { + "name": "activation", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3191 + }, + { + "name": "rewards", + "outputs": [{ "type": "address", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3221 + }, + { + "name": "managementFee", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3251 + }, + { + "name": "performanceFee", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3281 + }, + { + "name": "nonces", + "outputs": [{ "type": "uint256", "name": "" }], + "inputs": [{ "type": "address", "name": "arg0" }], + "stateMutability": "view", + "type": "function", + "gas": 3526 + }, + { + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "type": "bytes32", "name": "" }], + "inputs": [], + "stateMutability": "view", + "type": "function", + "gas": 3341 + } +] diff --git a/subgraphs/powh3d/configurations/configurations/configurations.ts b/subgraphs/powh3d/configurations/configurations/configurations.ts new file mode 100644 index 0000000000..7d9af610be --- /dev/null +++ b/subgraphs/powh3d/configurations/configurations/configurations.ts @@ -0,0 +1,20 @@ +import { log } from "@graphprotocol/graph-ts"; + +import { Configurations } from "./interface"; +import { Deploy } from "./deploy"; +import { Powh3dMainnetConfigurations } from "../../protocols/powh3d/config/deployments/powh3d-ethereum/configurations"; + +export function getNetworkConfigurations(deploy: i32): Configurations { + switch (deploy) { + case Deploy.POWH3D_ETHEREUM: { + return new Powh3dMainnetConfigurations(); + } + default: { + log.critical( + "No configurations found for deployment protocol/network", + [] + ); + return new Powh3dMainnetConfigurations(); + } + } +} diff --git a/subgraphs/powh3d/configurations/configurations/deploy.ts b/subgraphs/powh3d/configurations/configurations/deploy.ts new file mode 100644 index 0000000000..b016ac83dd --- /dev/null +++ b/subgraphs/powh3d/configurations/configurations/deploy.ts @@ -0,0 +1,3 @@ +export namespace Deploy { + export const POWH3D_ETHEREUM = 0; +} diff --git a/subgraphs/powh3d/configurations/configurations/interface.ts b/subgraphs/powh3d/configurations/configurations/interface.ts new file mode 100644 index 0000000000..42853be02d --- /dev/null +++ b/subgraphs/powh3d/configurations/configurations/interface.ts @@ -0,0 +1,6 @@ +export interface Configurations { + getNetwork(): string; + getProtocolId(): string; + getProtocolName(): string; + getProtocolSlug(): string; +} diff --git a/subgraphs/powh3d/configurations/configure.mustache b/subgraphs/powh3d/configurations/configure.mustache new file mode 100644 index 0000000000..971ba89573 --- /dev/null +++ b/subgraphs/powh3d/configurations/configure.mustache @@ -0,0 +1,6 @@ +import { getNetworkConfigurations } from "./configurations/configurations"; +import { Deploy } from "./configurations/deploy"; + +let deployment = Deploy.{{ deployment }}; + +export const NetworkConfigs = getNetworkConfigurations(deployment); diff --git a/subgraphs/powh3d/package.json b/subgraphs/powh3d/package.json new file mode 100644 index 0000000000..2ebfd92972 --- /dev/null +++ b/subgraphs/powh3d/package.json @@ -0,0 +1,15 @@ +{ + "name": "powh3d", + "license": "MIT", + "scripts": { + "format": "npx prettier --write .", + "prepare:constants": "mustache protocols/${npm_config_protocol}/config/deployments/${npm_config_id}/configurations.json configurations/configure.mustache > configurations/configure.ts" + }, + "dependencies": { + "@graphprotocol/graph-cli": "^0.80.1", + "@graphprotocol/graph-ts": "^0.35.1" + }, + "devDependencies": { + "prettier": "^3.2.5" + } +} diff --git a/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.json b/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.json new file mode 100644 index 0000000000..36c247e110 --- /dev/null +++ b/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.json @@ -0,0 +1,12 @@ +{ + "deployment": "POWH3D_ETHEREUM", + "network": "mainnet", + "file": "./src/mappings/handlers.ts", + "hourglass": { + "address": "0xb3775fb83f7d12a36e0475abdd1fca35c091efbe", + "startBlock": "10606501" + }, + "graftEnabled": false, + "subgraphId": "", + "graftStartBlock": 0 +} diff --git a/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.ts b/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.ts new file mode 100644 index 0000000000..d4958f049b --- /dev/null +++ b/subgraphs/powh3d/protocols/powh3d/config/deployments/powh3d-ethereum/configurations.ts @@ -0,0 +1,21 @@ +import { Configurations } from "../../../../../configurations/configurations/interface"; +import { + PROTOCOL_NAME, + PROTOCOL_SLUG, +} from "../../../../../src/common/constants"; +import { Network } from "../../../../../src/sdk/util/constants"; + +export class Powh3dMainnetConfigurations implements Configurations { + getNetwork(): string { + return Network.MAINNET; + } + getProtocolId(): string { + return "0xb3775fb83f7d12a36e0475abdd1fca35c091efbe"; + } + getProtocolName(): string { + return PROTOCOL_NAME; + } + getProtocolSlug(): string { + return PROTOCOL_SLUG; + } +} diff --git a/subgraphs/powh3d/protocols/powh3d/config/templates/powh3d.template.yaml b/subgraphs/powh3d/protocols/powh3d/config/templates/powh3d.template.yaml new file mode 100644 index 0000000000..20a4326f98 --- /dev/null +++ b/subgraphs/powh3d/protocols/powh3d/config/templates/powh3d.template.yaml @@ -0,0 +1,57 @@ +specVersion: 0.0.8 +schema: + file: ./schema.graphql +{{#graftEnabled}} +features: + - grafting +graft: + base: {{ subgraphId }} # Subgraph ID of base subgraph + block: {{ graftStartBlock }} # Block number +{{/graftEnabled}} +dataSources: + - kind: ethereum + name: Hourglass + network: {{ network }} + source: + address: "{{ hourglass.address }}" + abi: Hourglass + startBlock: {{ hourglass.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Token + - Pool + - PoolDailySnapshot + - PoolHourlySnapshot + - Protocol + - FinancialsDailySnapshot + - UsageMetricsDailySnapshot + - UsageMetricsHourlySnapshot + abis: + - name: Hourglass + file: ./abis/Powh3d/Hourglass.json + + - name: ERC20 + file: ./abis/Tokens/ERC20.json + - name: _ERC20 + file: ./abis/Tokens/_ERC20.json + - name: ERC20SymbolBytes + file: ./abis/Tokens/ERC20SymbolBytes.json + - name: ERC20NameBytes + file: ./abis/Tokens/ERC20NameBytes.json + - name: ChainlinkDataFeed + file: ./abis/Tokens/ChainlinkDataFeed.json + eventHandlers: + - event: onTokenPurchase(indexed address,uint256,uint256,indexed address) + handler: handleOnTokenPurchase + - event: onTokenSell(indexed address,uint256,uint256) + handler: handleOnTokenSell + - event: onReinvestment(indexed address,uint256,uint256) + handler: handleOnReinvestment + - event: onWithdraw(indexed address,uint256) + handler: handleOnWithdraw + # - event: Transfer(indexed address,indexed address,uint256) + # handler: handleTransfer + file: {{{ file }}} diff --git a/subgraphs/powh3d/schema.graphql b/subgraphs/powh3d/schema.graphql new file mode 100644 index 0000000000..9e73664985 --- /dev/null +++ b/subgraphs/powh3d/schema.graphql @@ -0,0 +1,352 @@ +# Subgraph Schema: Generic +# Version: 3.0.0 +# See https://github.com/messari/subgraphs/blob/master/docs/SCHEMA.md for details + +enum Network { + ARBITRUM_ONE + ARWEAVE_MAINNET + AURORA + AVALANCHE + BOBA + BSC # aka BNB Chain + CELO + COSMOS + CRONOS + MAINNET # Ethereum Mainnet + FANTOM + FUSE + HARMONY + JUNO + MOONBEAM + MOONRIVER + NEAR_MAINNET + OPTIMISM + OSMOSIS + MATIC # aka Polygon + GNOSIS +} + +enum ProtocolType { + EXCHANGE + LENDING + YIELD + BRIDGE + GENERIC + # Will add more +} + +enum TokenType { + MULTIPLE + UNKNOWN + ERC20 + ERC721 + ERC1155 + BEP20 + BEP721 + BEP1155 + # Will add more +} + +type Token @entity @regularPolling { + " Smart contract address of the token " + id: Bytes! + + " Name of the token, mirrored from the smart contract " + name: String! + + " Symbol of the token, mirrored from the smart contract " + symbol: String! + + " The number of decimal places this token uses, default to 18 " + decimals: Int! + + " Optional field to track the price of a token, mostly for caching purposes " + lastPriceUSD: BigDecimal + + " Optional field to track the block number of the last token price " + lastPriceBlockNumber: BigInt +} + +############################# +##### Protocol Metadata ##### +############################# + +type Protocol @entity @regularPolling { + " Smart contract address of the protocol's main contract (Factory, Registry, etc) " + id: Bytes! + + " Name of the protocol, including version. e.g. Uniswap v3 " + name: String! + + " Slug of protocol, including version. e.g. uniswap-v3 " + slug: String! + + " Version of the subgraph schema, in SemVer format (e.g. 1.0.0) " + schemaVersion: String! + + " Version of the subgraph implementation, in SemVer format (e.g. 1.0.0) " + subgraphVersion: String! + + " Version of the methodology used to compute metrics, loosely based on SemVer format (e.g. 1.0.0) " + methodologyVersion: String! + + " The blockchain network this subgraph is indexing on " + network: Network! + + " The type of protocol (e.g. DEX, Lending, Yield, etc) " + type: ProtocolType! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of the entire protocol " + totalValueLockedUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Total number of transactions. Transactions include events triggered by outside users (ie, deposit, withdraw, etc.)" + cumulativeTransactionCount: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Total number of pools " + totalPoolCount: Int! + + " Day ID of the most recent daily snapshot " + lastSnapshotDayID: Int! + + " Timestamp of the last time this entity was updated " + lastUpdateTimestamp: BigInt! + + ##### Snapshots ##### + + " Daily usage metrics for this protocol " + dailyUsageMetrics: [UsageMetricsDailySnapshot!]! + @derivedFrom(field: "protocol") + + " Daily financial metrics for this protocol " + financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol") + + ##### Pools ##### + + " All pools that belong to this protocol " + pools: [Pool!]! @derivedFrom(field: "protocol") +} + +############################### +##### Protocol Timeseries ##### +############################### + +type UsageMetricsDailySnapshot @entity @dailySnapshot { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " Protocol this snapshot is associated with " + protocol: Protocol! + + " Number of unique daily active users " + dailyActiveUsers: Int! + + " Number of cumulative unique users " + cumulativeUniqueUsers: Int! + + " Total number of transactions occurred in a day. Transactions include all entities that implement the Event interface. " + dailyTransactionCount: Int! + + " Total number of transactions. Transactions include events triggered by outside users (ie, deposit, withdraw, etc.)" + cumulativeTransactionCount: Int! + + " Total number of pools " + totalPoolCount: Int! + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +type FinancialsDailySnapshot @entity @dailySnapshot { + " ID is # of days since Unix epoch time " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " Protocol this snapshot is associated with " + protocol: Protocol! + + " Current TVL (Total Value Locked) of the entire protocol " + totalValueLockedUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + dailySupplySideRevenueUSD: BigDecimal! + + " Revenue claimed by suppliers to the protocol. LPs on DEXs (e.g. 0.25% of the swap fee in Sushiswap). Depositors on Lending Protocols. NFT sellers on OpenSea. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + dailyProtocolSideRevenueUSD: BigDecimal! + + " Gross revenue for the protocol (revenue claimed by protocol). Examples: AMM protocol fee (Sushi’s 0.05%). OpenSea 10% sell fee. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + dailyTotalRevenueUSD: BigDecimal! + + " All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +########################### +##### Pool-Level Data ##### +########################### + +type Pool @entity @regularPolling { + " Smart contract address of the pool " + id: Bytes! + + " The protocol this pool belongs to " + protocol: Protocol! + + " Name of the pool (e.g. Curve.fi DAI/USDC/USDT) " + name: String + + " Symbol of liquidity pool (e.g. 3CRV) " + symbol: String + + # Generally protocols accept one or multiple tokens and mint tokens to the depositor to track ownership + # Some protocols don't mint any tokens to track ownership, in that case outputToken is null. + + " Token that is minted to track ownership of position in protocol " + outputToken: Token + + " Tokens that need to be deposited to take a position in protocol. e.g. WETH and USDC to deposit into the WETH-USDC pool. Array to account for multi-asset pools like Curve and Balancer " + inputTokens: [Token!]! + + " Creation timestamp " + createdTimestamp: BigInt! + + " Creation block number " + createdBlockNumber: BigInt! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool in USD " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + _inputTokenDeposited: [BigInt!] + _inputTokenBorrowed: [BigInt!] + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " The USD value of input tokens in this pool. Should be the same order as the pool's `inputTokens` field. " + inputTokenBalancesUSD: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Day ID of the most recent daily snapshot " + lastSnapshotDayID: Int! + + " Timestamp of the last time this entity was updated " + lastUpdateTimestamp: BigInt! +} + +type PoolDailySnapshot @entity @dailySnapshot { + " { Smart contract address of the pool }-{ # of days since Unix epoch time } " + id: Bytes! + + " Number of days since Unix epoch time " + day: Int! + + " The protocol this snapshot belongs to " + protocol: Protocol! + + " The pool this snapshot belongs to " + pool: Pool! + + ##### Quantitative Data ##### + + " Current TVL (Total Value Locked) of this pool " + totalValueLockedUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the supply side. " + cumulativeSupplySideRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool, accrued to the supply side. " + dailySupplySideRevenueUSD: BigDecimal! + + " All revenue generated by the pool, accrued to the protocol. " + cumulativeProtocolSideRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool, accrued to the protocol. " + dailyProtocolSideRevenueUSD: BigDecimal! + + " All revenue generated by the pool. " + cumulativeTotalRevenueUSD: BigDecimal! + + " Daily revenue generated by the pool. " + dailyTotalRevenueUSD: BigDecimal! + + " Amount of input tokens in the pool. The ordering should be the same as the pool's `inputTokens` field. " + inputTokenBalances: [BigInt!]! + + " The USD value of input tokens in this pool. Should be the same order as the pool's `inputTokens` field. " + inputTokenBalancesUSD: [BigDecimal!]! + + " Total supply of output token. Note that certain DEXes don't have an output token (e.g. Bancor) " + outputTokenSupply: BigInt + + " Timestamp of when this snapshot was taken/last modified (May be taken after interval has passed) " + timestamp: BigInt! + + " Block number of when this snapshot was taken/last modified (May be taken after interval has passed) " + blockNumber: BigInt! +} + +# An account is a unique Ethereum address +# Helps to accumulate total unique users +type Account @entity @regularPolling { + " Address of the account " + id: ID! +} + +# Helper entity for calculating daily active users +type ActiveAccount @entity { + " { daily }-{ Address of the account }-{ Days since Unix epoch } " + id: ID! +} + +type _ActivityHelper @entity { + " { daily }-{ Days since Unix epoch} " + id: Bytes! + + dailyActiveUsers: Int! +} diff --git a/subgraphs/powh3d/src/common/constants.ts b/subgraphs/powh3d/src/common/constants.ts new file mode 100644 index 0000000000..53ea101e46 --- /dev/null +++ b/subgraphs/powh3d/src/common/constants.ts @@ -0,0 +1,6 @@ +////////////////////////////// +///// Protocol Constants ///// +////////////////////////////// + +export const PROTOCOL_NAME = "Powh 3D"; +export const PROTOCOL_SLUG = "powh3d"; diff --git a/subgraphs/powh3d/src/mappings/handlers.ts b/subgraphs/powh3d/src/mappings/handlers.ts new file mode 100644 index 0000000000..cf3f0c249c --- /dev/null +++ b/subgraphs/powh3d/src/mappings/handlers.ts @@ -0,0 +1,164 @@ +import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +import { Versions } from "../versions"; +import { NetworkConfigs } from "../../configurations/configure"; + +import { SDK } from "../sdk/protocols/generic"; +import { ProtocolConfig, TokenPricer } from "../sdk/protocols/config"; +import { TokenInitializer, TokenParams } from "../sdk/protocols/generic/tokens"; +import { bigIntToBigDecimal } from "../sdk/util/numbers"; +import { BIGDECIMAL_ZERO, ETH_ADDRESS, INT_ZERO } from "../sdk/util/constants"; + +import { + onTokenPurchase, + onTokenSell, + onReinvestment, + onWithdraw, + Hourglass, +} from "../../generated/Hourglass/Hourglass"; +import { _ERC20 } from "../../generated/Hourglass/_ERC20"; +import { ChainlinkDataFeed } from "../../generated/Hourglass/ChainlinkDataFeed"; +import { Token } from "../../generated/schema"; + +const conf = new ProtocolConfig( + NetworkConfigs.getProtocolId(), + NetworkConfigs.getProtocolName(), + NetworkConfigs.getProtocolSlug(), + Versions +); + +class Pricer implements TokenPricer { + getTokenPrice(token: Token, block: BigInt): BigDecimal { + if ( + Address.fromBytes(token.id) == Address.fromString(ETH_ADDRESS) && + block > BigInt.fromString("10606501") + ) { + const chainlinkDataFeedContract = ChainlinkDataFeed.bind( + Address.fromString("0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419") // ETH / USD feed + ); + const resultCall = chainlinkDataFeedContract.try_latestAnswer(); + const decimalsCall = chainlinkDataFeedContract.try_decimals(); + + if (!resultCall.reverted && !decimalsCall.reverted) { + return bigIntToBigDecimal(resultCall.value, decimalsCall.value); + } + } + + return BIGDECIMAL_ZERO; + } + + getAmountValueUSD(token: Token, amount: BigInt, block: BigInt): BigDecimal { + const usdPrice = this.getTokenPrice(token, block); + const _amount = bigIntToBigDecimal(amount, token.decimals); + + return usdPrice.times(_amount); + } +} + +class TokenInit implements TokenInitializer { + getTokenParams(address: Address): TokenParams { + let name = "unknown"; + let symbol = "UNKNOWN"; + let decimals = INT_ZERO as i32; + + if (address == Address.fromString(ETH_ADDRESS)) { + name = "eth"; + symbol = "ETH"; + decimals = 18 as i32; + } else { + const erc20 = _ERC20.bind(address); + name = erc20.name(); + symbol = erc20.symbol(); + decimals = erc20.decimals().toI32(); + } + return new TokenParams(name, symbol, decimals); + } +} + +export function handleOnTokenPurchase(event: onTokenPurchase): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(Address.fromString(ETH_ADDRESS)); + const pool = sdk.Pools.loadPool(event.address); + if (!pool.isInitialized) { + pool.initialize(token.name, token.symbol, [token.id], null); + } + + const contract = Hourglass.bind(event.address); + const balance = contract.totalEthereumBalance(); + pool.setInputTokenBalances([balance], true); + + const user = event.params.customerAddress; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleOnTokenSell(event: onTokenSell): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(Address.fromString(ETH_ADDRESS)); + const pool = sdk.Pools.loadPool(event.address); + if (!pool.isInitialized) { + pool.initialize(token.name, token.symbol, [token.id], null); + } + + const contract = Hourglass.bind(event.address); + const balance = contract.totalEthereumBalance(); + pool.setInputTokenBalances([balance], true); + + const user = event.params.customerAddress; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleOnReinvestment(event: onReinvestment): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(Address.fromString(ETH_ADDRESS)); + const pool = sdk.Pools.loadPool(event.address); + if (!pool.isInitialized) { + pool.initialize(token.name, token.symbol, [token.id], null); + } + + const contract = Hourglass.bind(event.address); + const balance = contract.totalEthereumBalance(); + pool.setInputTokenBalances([balance], true); + + const user = event.params.customerAddress; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} + +export function handleOnWithdraw(event: onWithdraw): void { + const sdk = SDK.initializeFromEvent( + conf, + new Pricer(), + new TokenInit(), + event + ); + const token = sdk.Tokens.getOrCreateToken(Address.fromString(ETH_ADDRESS)); + const pool = sdk.Pools.loadPool(event.address); + if (!pool.isInitialized) { + pool.initialize(token.name, token.symbol, [token.id], null); + } + + const contract = Hourglass.bind(event.address); + const balance = contract.totalEthereumBalance(); + pool.setInputTokenBalances([balance], true); + + const user = event.params.customerAddress; + const account = sdk.Accounts.loadAccount(user); + account.trackActivity(); +} diff --git a/subgraphs/powh3d/src/sdk/README.md b/subgraphs/powh3d/src/sdk/README.md new file mode 100644 index 0000000000..c8e3bddd41 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/README.md @@ -0,0 +1,25 @@ +## Wat dis? + +This folder contains a library which abstracts the developer from most of the _schema related_ functionality. Ideally, building a subgraph should only consist on understading a protocol and translating certain events into actions and metrics. But the particularities of how this metrics are stored and how they relate to each other inside the schema can and should be abstracted away. Things like taking snapshots of entities every X amount of time, updating TVL every time there is a deposit/withdrawal, updating fees at _swap & pool & protocol & snapshot levels_, etc ... This library aims to do that. + +When using this library, entities should not be updated directly, but always through the library unless absolutely needed. An exception to this is if you create your own auxiliary entity to aid on the handling of some events. + +## How It's Organized + +Pretty straightforward, `/protocols` and `/util`. + +Because we are currently experimenting different approaches, each protocol type has a different schema, and AssemblyScript has some limitations when dealing with interfaces, so far, each protocol type has its own implementation. They all live in their respective folders under `/protocols`, and have very little shared code. + +`/util` contains all these common functions and constants we use over and over. + +## Setting it up + +It would be ideal to have the library to get setup automatically with the messari-cli, in a similar way as we do to generate versions. We might eventually get there, but so far it consists on a manual copy process. + +Refer to each protocol type readme, since requirements might vary: + +- [Bridges](./protocols/bridge/README.md) +- [Lending](./protocols/lending/README.md) +- [Perpetual Futures](./protocols/perpfutures/README.md) +- DEX +- Yield diff --git a/subgraphs/powh3d/src/sdk/protocols/config.ts b/subgraphs/powh3d/src/sdk/protocols/config.ts new file mode 100644 index 0000000000..943f83919d --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/config.ts @@ -0,0 +1,45 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { Token } from "../../../generated/schema"; +import { Versions } from "../../../../../deployment/context/interface"; + +export interface ProtocolConfigurer { + getID(): string; + getName(): string; + getSlug(): string; + getVersions(): Versions; +} + +export class ProtocolConfig implements ProtocolConfigurer { + id: string; + name: string; + slug: string; + versions: Versions; + + constructor(id: string, name: string, slug: string, versions: Versions) { + this.id = id; + this.name = name; + this.slug = slug; + this.versions = versions; + } + + getID(): string { + return this.id; + } + + getName(): string { + return this.name; + } + + getSlug(): string { + return this.slug; + } + + getVersions(): Versions { + return this.versions; + } +} + +export interface TokenPricer { + getTokenPrice(token: Token, block: BigInt): BigDecimal; + getAmountValueUSD(token: Token, amount: BigInt, block: BigInt): BigDecimal; +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/account.ts b/subgraphs/powh3d/src/sdk/protocols/generic/account.ts new file mode 100644 index 0000000000..b962ef2360 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/account.ts @@ -0,0 +1,93 @@ +import { + ActiveAccount, + Account as AccountSchema, +} from "../../../../generated/schema"; +import { TokenManager } from "./tokens"; +import { ProtocolManager } from "./protocol"; +import { Address } from "@graphprotocol/graph-ts"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +/** + * This file contains the AccountClass, which does + * the operations on the Account entity. This includes: + * - Creating a new Account + * - Updating an existing Account + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class AccountManager { + protocol: ProtocolManager; + tokens: TokenManager; + + constructor(protocol: ProtocolManager, tokens: TokenManager) { + this.protocol = protocol; + this.tokens = tokens; + } + + loadAccount(address: Address): Account { + let acc = AccountSchema.load(address.toHexString()); + if (acc) { + return new Account(this.protocol, acc, this.tokens); + } + + acc = new AccountSchema(address.toHexString()); + acc.save(); + + this.protocol.addUser(); + + return new Account(this.protocol, acc, this.tokens); + } +} + +export class AccountWasActive { + hourly: boolean; + daily: boolean; +} + +export class Account { + account: AccountSchema; + event: CustomEventType; + protocol: ProtocolManager; + tokens: TokenManager; + + constructor( + protocol: ProtocolManager, + account: AccountSchema, + tokens: TokenManager + ) { + this.account = account; + this.protocol = protocol; + this.event = protocol.getCurrentEvent(); + this.tokens = tokens; + } + + trackActivity(): void { + const days = getUnixDays(this.event.block); + const hours = getUnixHours(this.event.block); + + const generalHourlyID = `${this.account.id}-hourly-${hours}`; + const generalDailyID = `${this.account.id}-daily-${days}`; + + const generalActivity: AccountWasActive = { + daily: this.isActiveByActivityID(generalDailyID), + hourly: this.isActiveByActivityID(generalHourlyID), + }; + + this.protocol.addActiveUser(generalActivity); + this.protocol.addTransaction(); + } + + private isActiveByActivityID(id: string): boolean { + const dAct = ActiveAccount.load(id); + if (!dAct) { + new ActiveAccount(id).save(); + return true; + } + return false; + } +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/index.ts b/subgraphs/powh3d/src/sdk/protocols/generic/index.ts new file mode 100644 index 0000000000..59f201e67f --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/index.ts @@ -0,0 +1,72 @@ +import { PoolManager } from "./pool"; +import { AccountManager } from "./account"; +import { ProtocolManager } from "./protocol"; +import { BIGINT_ZERO } from "../../util/constants"; +import { ethereum } from "@graphprotocol/graph-ts"; +import { CustomEventType } from "../../util/events"; +import { TokenManager, TokenInitializer } from "./tokens"; +import { ProtocolConfigurer, TokenPricer } from "../config"; + +/** + * This file contains the SDK class, which initializes + * all managers from event or call. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + + */ + +export class SDK { + Protocol: ProtocolManager; + Accounts: AccountManager; + Pools: PoolManager; + Tokens: TokenManager; + Pricer: TokenPricer; + + constructor( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: CustomEventType + ) { + this.Protocol = ProtocolManager.load(config, pricer, event); + this.Tokens = new TokenManager(this.Protocol, tokenInitializer); + this.Accounts = new AccountManager(this.Protocol, this.Tokens); + this.Pools = new PoolManager(this.Protocol, this.Tokens); + this.Pricer = pricer; + + this.Protocol.sdk = this; + } + + static initializeFromEvent( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: ethereum.Event + ): SDK { + const customEvent = CustomEventType.initialize( + event.block, + event.transaction, + event.logIndex, + event + ); + return new SDK(config, pricer, tokenInitializer, customEvent); + } + + static initializeFromCall( + config: ProtocolConfigurer, + pricer: TokenPricer, + tokenInitializer: TokenInitializer, + event: ethereum.Call + ): SDK { + const customEvent = CustomEventType.initialize( + event.block, + event.transaction, + BIGINT_ZERO + ); + return new SDK(config, pricer, tokenInitializer, customEvent); + } +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/pool.ts b/subgraphs/powh3d/src/sdk/protocols/generic/pool.ts new file mode 100644 index 0000000000..15c87c07aa --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/pool.ts @@ -0,0 +1,329 @@ +import { TokenManager } from "./tokens"; +import { ProtocolManager } from "./protocol"; +import { PoolSnapshot } from "./poolSnapshot"; +import { BIGDECIMAL_ZERO, BIGINT_ZERO } from "../../util/constants"; +import { Pool as PoolSchema, Token } from "../../../../generated/schema"; +import { Bytes, BigDecimal, BigInt, Address } from "@graphprotocol/graph-ts"; + +/** + * This file contains the PoolManager, which is used to + * initialize new pools in the protocol. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class PoolManager { + protocol: ProtocolManager; + tokens: TokenManager; + + constructor(protocol: ProtocolManager, tokens: TokenManager) { + this.protocol = protocol; + this.tokens = tokens; + } + + loadPool(id: Bytes): Pool { + let entity = PoolSchema.load(id); + if (entity) { + return new Pool(this.protocol, entity, this.tokens, true); + } + + entity = new PoolSchema(id); + entity.protocol = this.protocol.getBytesID(); + + const pool = new Pool(this.protocol, entity, this.tokens, false); + pool.isInitialized = false; + return pool; + } +} + +export class Pool { + pool: PoolSchema; + protocol: ProtocolManager; + tokens: TokenManager; + snapshoter: PoolSnapshot | null = null; + + public isInitialized: boolean = true; + + constructor( + protocol: ProtocolManager, + pool: PoolSchema, + tokens: TokenManager, + isInitialized: bool + ) { + this.pool = pool; + this.protocol = protocol; + this.tokens = tokens; + + if (isInitialized) { + this.snapshoter = new PoolSnapshot(pool, protocol.event); + this.pool.lastUpdateTimestamp = protocol.event.block.timestamp; + this.save(); + } + } + + private save(): void { + this.pool.save(); + } + + initialize( + name: string, + symbol: string, + inputTokens: Bytes[], + outputToken: Token | null + ): void { + if (this.isInitialized) { + return; + } + + const event = this.protocol.getCurrentEvent(); + this.pool.protocol = this.protocol.getBytesID(); + this.pool.name = name; + this.pool.symbol = symbol; + this.pool.inputTokens = inputTokens; + this.pool.outputToken = outputToken ? outputToken.id : null; + this.pool.createdTimestamp = event.block.timestamp; + this.pool.createdBlockNumber = event.block.number; + + const inputTokenBalances: BigInt[] = []; + const inputTokenBalancesUSD: BigDecimal[] = []; + for (let i = 0; i < inputTokens.length; i++) { + inputTokenBalances.push(BIGINT_ZERO); + inputTokenBalancesUSD.push(BIGDECIMAL_ZERO); + } + this.pool.inputTokenBalances = inputTokenBalances; + this.pool.inputTokenBalancesUSD = inputTokenBalancesUSD; + this.pool.totalValueLockedUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeSupplySideRevenueUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeProtocolSideRevenueUSD = BIGDECIMAL_ZERO; + this.pool.cumulativeTotalRevenueUSD = BIGDECIMAL_ZERO; + + this.pool.lastSnapshotDayID = 0; + this.pool.lastUpdateTimestamp = BIGINT_ZERO; + this.save(); + + this.protocol.addPool(); + } + + /** + * Recalculates the total value locked for this pool based on its current input token balance. + * This function will also update the protocol's total value locked based on the change in this pool's. + */ + private refreshTotalValueLocked(): void { + let totalValueLockedUSD = BIGDECIMAL_ZERO; + + for (let idx = 0; idx < this.pool.inputTokens.length; idx++) { + const inputTokenBalanceUSD = this.pool.inputTokenBalancesUSD[idx]; + totalValueLockedUSD = totalValueLockedUSD.plus(inputTokenBalanceUSD); + } + + this.setTotalValueLocked(totalValueLockedUSD); + } + + /** + * Updates the total value locked for this pool to the given value. + * Will also update the protocol's total value locked based on the change in this pool's. + */ + setTotalValueLocked(newTVL: BigDecimal): void { + const delta = newTVL.minus(this.pool.totalValueLockedUSD); + this.addTotalValueLocked(delta); + this.save(); + } + + /** + * Adds the given delta to the total value locked for this pool. + * Will also update the protocol's total value locked based on the change in this pool's. + * + * @param delta The change in total value locked for this pool. + */ + addTotalValueLocked(delta: BigDecimal): void { + this.pool.totalValueLockedUSD = this.pool.totalValueLockedUSD.plus(delta); + this.protocol.addTotalValueLocked(delta); + this.save(); + } + + /** + * Utility function to update token price. + * + * @param token + * @returns + */ + setTokenPrice(token: Token): void { + if ( + !token.lastPriceBlockNumber || + (token.lastPriceBlockNumber && + token.lastPriceBlockNumber! < this.protocol.event.block.number) + ) { + const pricePerToken = this.protocol + .getTokenPricer() + .getTokenPrice(token, this.protocol.event.block.number); + token.lastPriceUSD = pricePerToken; + token.lastPriceBlockNumber = this.protocol.event.block.number; + token.save(); + } + } + + /** + * Utility function to convert some amount of input token to USD. + * + * @param token + * @param amount the amount of inputToken to convert to USD + * @returns The converted amount. + */ + getInputTokenAmountPrice(token: Token, amount: BigInt): BigDecimal { + this.setTokenPrice(token); + + return this.protocol + .getTokenPricer() + .getAmountValueUSD(token, amount, this.protocol.event.block.number); + } + + addInputTokenBalances( + amounts: BigInt[], + updateMetrics: boolean = true + ): void { + if (amounts.length != this.pool.inputTokenBalances.length) return; + + const newBalances: BigInt[] = []; + for (let idx = 0; idx < this.pool.inputTokenBalances.length; idx++) { + newBalances[idx] = this.pool.inputTokenBalances[idx].plus(amounts[idx]); + } + this.setInputTokenBalances(newBalances, updateMetrics); + } + + /** + * Sets the pool's input token balance to the given amount. It will optionally + * update the pool's and protocol's total value locked. If not stated, will default to true. + * + * @param amount amount to be set as the pool's input token balance. + * @param updateMetrics optional parameter to indicate whether to update the pool's and protocol's total value locked. + */ + setInputTokenBalances( + newBalances: BigInt[], + updateMetrics: boolean = true + ): void { + this.pool.inputTokenBalances = newBalances; + this.setInputTokenBalancesUSD(); + if (updateMetrics) { + this.refreshTotalValueLocked(); + } + } + + /** + * Sets the pool's input token balance USD by calculating it for each token. + */ + private setInputTokenBalancesUSD(): void { + const inputTokenBalancesUSD: BigDecimal[] = []; + for (let idx = 0; idx < this.pool.inputTokens.length; idx++) { + const inputTokenBalance = this.pool.inputTokenBalances[idx]; + const inputToken = this.tokens.getOrCreateToken( + Address.fromBytes(this.pool.inputTokens[idx]) + ); + + const amountUSD = this.getInputTokenAmountPrice( + inputToken, + inputTokenBalance + ); + inputTokenBalancesUSD.push(amountUSD); + } + this.pool.inputTokenBalancesUSD = inputTokenBalancesUSD; + } + + getBytesID(): Bytes { + return this.pool.id; + } + + /** + * Adds a given USD value to the pool and protocol supplySideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addSupplySideRevenueUSD(rev: BigDecimal): void { + this.pool.cumulativeTotalRevenueUSD = + this.pool.cumulativeTotalRevenueUSD.plus(rev); + this.pool.cumulativeSupplySideRevenueUSD = + this.pool.cumulativeSupplySideRevenueUSD.plus(rev); + this.save(); + + this.protocol.addSupplySideRevenueUSD(rev); + } + + /** + * Adds a given USD value to the pool and protocol protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's protocolSideRevenue. + */ + addProtocolSideRevenueUSD(rev: BigDecimal): void { + this.pool.cumulativeTotalRevenueUSD = + this.pool.cumulativeTotalRevenueUSD.plus(rev); + this.pool.cumulativeProtocolSideRevenueUSD = + this.pool.cumulativeProtocolSideRevenueUSD.plus(rev); + this.save(); + + this.protocol.addProtocolSideRevenueUSD(rev); + } + + /** + * Adds a given USD value to the pool and protocol's supplySideRevenue and protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param protocolSide {BigDecimal} The value to add to the protocol's protocolSideRevenue. + * @param supplySide {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addRevenueUSD(protocolSide: BigDecimal, supplySide: BigDecimal): void { + this.addSupplySideRevenueUSD(supplySide); + this.addProtocolSideRevenueUSD(protocolSide); + } + + /** + * Convenience method to add revenue denominated in the pool's input token. It converts it to USD + * under the hood and calls addRevenueUSD. + */ + addRevenueNative( + inputToken: Token, + supplySide: BigInt, + protocolSide: BigInt + ): void { + const pricer = this.protocol.pricer; + + const pAmountUSD = pricer.getAmountValueUSD( + inputToken, + protocolSide, + this.protocol.event.block.number + ); + const sAmountUSD = pricer.getAmountValueUSD( + inputToken, + supplySide, + this.protocol.event.block.number + ); + this.addRevenueUSD(pAmountUSD, sAmountUSD); + } + + /** + * Adds a given amount to the pool's outputTokenSupply. It should only be used for pools + * of type LIQUIDITY. Or pools that emit some kind of LP token on deposit. + * @param amount + */ + addOutputTokenSupply(amount: BigInt): void { + if (!this.pool.outputTokenSupply) { + this.pool.outputTokenSupply = BIGINT_ZERO; + } + this.pool.outputTokenSupply = this.pool.outputTokenSupply!.plus(amount); + this.save(); + } + + /** + * Sets the pool's outputTokenSupply value. It should only be used for pools + * of type LIQUIDITY. Or pools that emit some kind of LP token on deposit. + * @param amount + */ + setOutputTokenSupply(amount: BigInt): void { + this.pool.outputTokenSupply = amount; + this.save(); + } +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/poolSnapshot.ts b/subgraphs/powh3d/src/sdk/protocols/generic/poolSnapshot.ts new file mode 100644 index 0000000000..c7945dbb64 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/poolSnapshot.ts @@ -0,0 +1,93 @@ +import { + Pool as PoolSchema, + PoolDailySnapshot, +} from "../../../../generated/schema"; +import { SECONDS_PER_DAY } from "../../util/constants"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +/** + * This file contains the PoolSnapshot, which is used to + * make all of the storage changes that occur in the pool daily and hourly snapshots. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export class PoolSnapshot { + pool: PoolSchema; + event: CustomEventType; + dayID: i32; + hourID: i32; + + constructor(pool: PoolSchema, event: CustomEventType) { + this.pool = pool; + this.event = event; + this.dayID = getUnixDays(event.block); + this.hourID = getUnixHours(event.block); + this.takeSnapshots(); + } + + private takeSnapshots(): void { + if (!this.pool.lastUpdateTimestamp) return; + + const snapshotDayID = + this.pool.lastUpdateTimestamp.toI32() / SECONDS_PER_DAY; + + if (snapshotDayID != this.dayID) { + this.takeDailySnapshot(snapshotDayID); + this.pool.lastSnapshotDayID = snapshotDayID; + this.pool.save(); + } + } + + private takeDailySnapshot(day: i32): void { + const snapshot = new PoolDailySnapshot(this.pool.id.concatI32(day)); + const previousSnapshot = PoolDailySnapshot.load( + this.pool.id.concatI32(this.pool.lastSnapshotDayID) + ); + + snapshot.day = day; + snapshot.protocol = this.pool.protocol; + snapshot.pool = this.pool.id; + snapshot.timestamp = this.event.block.timestamp; + snapshot.blockNumber = this.event.block.number; + + // tvl and balances + snapshot.totalValueLockedUSD = this.pool.totalValueLockedUSD; + snapshot.inputTokenBalances = this.pool.inputTokenBalances; + snapshot.inputTokenBalancesUSD = this.pool.inputTokenBalancesUSD; + + // revenues + snapshot.cumulativeSupplySideRevenueUSD = + this.pool.cumulativeSupplySideRevenueUSD; + snapshot.cumulativeProtocolSideRevenueUSD = + this.pool.cumulativeProtocolSideRevenueUSD; + snapshot.cumulativeTotalRevenueUSD = this.pool.cumulativeTotalRevenueUSD; + + // deltas + let supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD; + let protocolSideRevenueDelta = snapshot.cumulativeProtocolSideRevenueUSD; + let totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD; + + if (previousSnapshot) { + supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD.minus( + previousSnapshot.cumulativeSupplySideRevenueUSD + ); + protocolSideRevenueDelta = + snapshot.cumulativeProtocolSideRevenueUSD.minus( + previousSnapshot.cumulativeProtocolSideRevenueUSD + ); + totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD.minus( + previousSnapshot.cumulativeTotalRevenueUSD + ); + } + snapshot.dailySupplySideRevenueUSD = supplySideRevenueDelta; + snapshot.dailyProtocolSideRevenueUSD = protocolSideRevenueDelta; + snapshot.dailyTotalRevenueUSD = totalRevenueDelta; + + snapshot.save(); + } +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/protocol.ts b/subgraphs/powh3d/src/sdk/protocols/generic/protocol.ts new file mode 100644 index 0000000000..c09aac2905 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/protocol.ts @@ -0,0 +1,257 @@ +import { SDK } from "."; +import { + dataSource, + Address, + Bytes, + BigDecimal, +} from "@graphprotocol/graph-ts"; +import { AccountWasActive } from "./account"; +import * as constants from "../../util/constants"; +import { BIGINT_ZERO } from "../../util/constants"; +import { CustomEventType } from "../../util/events"; +import { ProtocolSnapshot } from "./protocolSnapshot"; +import { ProtocolConfigurer, TokenPricer } from "../config"; +import { Protocol as ProtocolSchema } from "../../../../generated/schema"; +import { Versions } from "../../../../../../deployment/context/interface"; + +/** + * This file contains the ProtocolManager class, which is used to + * make all of the storage changes that occur in a protocol. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +/** + * ProtocolManager is a wrapper around the ProtocolSchema entity that takes care of + * safely and conveniently updating the entity. Updating the Protocol entity using this + * wrapper also takes care of the Financials and Usage snapshots. + */ +export class ProtocolManager { + protocol: ProtocolSchema; + event: CustomEventType; + pricer: TokenPricer; + snapshoter: ProtocolSnapshot; + sdk: SDK | null = null; + /** + * Creates a new Protocol instance. This should only be called by the Protocol.load + * @private + */ + private constructor( + protocol: ProtocolSchema, + pricer: TokenPricer, + event: CustomEventType + ) { + this.protocol = protocol; + this.event = event; + this.pricer = pricer; + this.snapshoter = new ProtocolSnapshot(protocol, event); + this.protocol.lastUpdateTimestamp = event.block.timestamp; + } + + /** + * This is the main function to instantiate a Protocol entity. Most times it is not called directly, but from the SDK initializer. + * + * @param conf {ProtocolConfigurer} An object that implements the ProtocolConfigurer interface, to set some of the protocol's properties + * @param pricer {TokenPricer} An object that implements the TokenPricer interface, to allow the wrapper to access pricing data + * @param event {CustomEventType} The event being handled at a time. + * @returns Protocol + */ + static load( + conf: ProtocolConfigurer, + pricer: TokenPricer, + event: CustomEventType + ): ProtocolManager { + const id = Address.fromString(conf.getID()); + let protocol = ProtocolSchema.load(id); + if (protocol) { + const proto = new ProtocolManager(protocol, pricer, event); + proto.setVersions(conf.getVersions()); + return proto; + } + + protocol = new ProtocolSchema(id); + protocol.name = conf.getName(); + protocol.slug = conf.getSlug(); + protocol.network = dataSource.network().toUpperCase().replace("-", "_"); + protocol.type = constants.ProtocolType.GENERIC; + protocol.totalValueLockedUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeSupplySideRevenueUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeProtocolSideRevenueUSD = constants.BIGDECIMAL_ZERO; + protocol.cumulativeTotalRevenueUSD = constants.BIGDECIMAL_ZERO; + + protocol.cumulativeTransactionCount = 0; + protocol.cumulativeUniqueUsers = 0; + protocol.totalPoolCount = 0; + + protocol.lastSnapshotDayID = 0; + protocol.lastUpdateTimestamp = BIGINT_ZERO; + + protocol.schemaVersion = conf.getVersions().getSchemaVersion(); + protocol.subgraphVersion = conf.getVersions().getSubgraphVersion(); + protocol.methodologyVersion = conf.getVersions().getMethodologyVersion(); + + const proto = new ProtocolManager(protocol, pricer, event); + proto.save(); + return proto; + } + + /** + * Updates the protocol entity versions. This is called on load to make sure we update the version + * if we've grafted the subgraph. + * + * @param versions {Versions} An object that implements the Versions interface, to get the protocol's versions + */ + private setVersions(versions: Versions): void { + this.protocol.schemaVersion = versions.getSchemaVersion(); + this.protocol.subgraphVersion = versions.getSubgraphVersion(); + this.protocol.methodologyVersion = versions.getMethodologyVersion(); + this.save(); + } + + /** + * This will save the entity to storage. If any other action needs to be performed on + * save, it should be added here. + * It is meant to be used internally. If you need to save the entity from outside the wrapper + * you should probably be using some of the setters instead. + * @private + */ + private save(): void { + this.protocol.save(); + } + + /** + * + * @returns {string} The ID of the protocol entity. + */ + getID(): string { + return this.protocol.id.toHexString(); + } + + /** + * + * @returns {Bytes} The ID of the protocol entity, as Bytes. + */ + getBytesID(): Bytes { + return this.protocol.id; + } + + /** + * + * @returns {CustomEventType} the event currently being handled. + */ + getCurrentEvent(): CustomEventType { + return this.event; + } + + /** + * + * @returns {TokenPricer} The pricer object used by the wrapper. + * @see TokenPricer + */ + getTokenPricer(): TokenPricer { + return this.pricer; + } + + /** + * Sets the TVL in USD for the protocol. Most times this will be called internally by + * other members of the library when TVL changes are made to them. But if the library + * is not well fitted to a given protocol and you need to set the TVL manually, you can + * use this method. + * It will also update the protocol's snapshots. + * @param tvl {BigDecimal} The new total value locked for the protocol. + */ + setTotalValueLocked(tvl: BigDecimal): void { + this.protocol.totalValueLockedUSD = tvl; + this.save(); + } + + /** + * Adds a given USD value to the protocol's TVL. It can be a positive or negative amount. + * Same as for setTotalValueLocked, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param tvl {BigDecimal} The value to add to the protocol's TVL. + */ + addTotalValueLocked(tvl: BigDecimal): void { + this.protocol.totalValueLockedUSD = + this.protocol.totalValueLockedUSD.plus(tvl); + this.save(); + } + + /** + * Adds a given USD value to the protocol supplySideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addSupplySideRevenueUSD(rev: BigDecimal): void { + this.protocol.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD.plus(rev); + this.protocol.cumulativeSupplySideRevenueUSD = + this.protocol.cumulativeSupplySideRevenueUSD.plus(rev); + this.save(); + } + + /** + * Adds a given USD value to the protocol protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param rev {BigDecimal} The value to add to the protocol's protocolSideRevenue. + */ + addProtocolSideRevenueUSD(rev: BigDecimal): void { + this.protocol.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD.plus(rev); + this.protocol.cumulativeProtocolSideRevenueUSD = + this.protocol.cumulativeProtocolSideRevenueUSD.plus(rev); + this.save(); + } + + /** + * Adds a given USD value to the protocol's supplySideRevenue and protocolSideRevenue. It can be a positive or negative amount. + * Same as for the rest of setters, this is mostly to be called internally by the library. + * But you can use it if you need to. It will also update the protocol's snapshots. + * @param protocolSide {BigDecimal} The value to add to the protocol's protocolSideRevenue. + * @param supplySide {BigDecimal} The value to add to the protocol's supplySideRevenue. + */ + addRevenueUSD(protocolSide: BigDecimal, supplySide: BigDecimal): void { + this.addSupplySideRevenueUSD(supplySide); + this.addProtocolSideRevenueUSD(protocolSide); + } + + /** + * Adds some value to the cumulativeUniqueUsers counter. If the value is omitted it will default to 1. + * If you are loading accounts with the AccountManager you won't need to use this method. + * @param count {u8} The value to add to the counter. + */ + addUser(count: u8 = 1): void { + this.protocol.cumulativeUniqueUsers += count; + this.save(); + } + + /** + * Will increase the hourly and daily active users counters. These will be reflected + * on the next Usage snapshot whenever it comes up. + */ + addActiveUser(activity: AccountWasActive): void { + this.snapshoter.addActiveUser(activity); + } + + /** + * Increases the totalPoolCount counter by the given value. + * If you are using the PoolManager class you won't need to use this method. + * @param count {u8} The value to add to the counter. + * @see PoolManager + */ + addPool(count: u8 = 1): void { + this.protocol.totalPoolCount += count; + this.save(); + } + + addTransaction(): void { + this.protocol.cumulativeTransactionCount += 1; + this.save(); + } +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/protocolSnapshot.ts b/subgraphs/powh3d/src/sdk/protocols/generic/protocolSnapshot.ts new file mode 100644 index 0000000000..85d80bbc36 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/protocolSnapshot.ts @@ -0,0 +1,165 @@ +import { + _ActivityHelper, + FinancialsDailySnapshot, + UsageMetricsDailySnapshot, + Protocol as ProtocolSchema, +} from "../../../../generated/schema"; +import { AccountWasActive } from "./account"; +import { Bytes } from "@graphprotocol/graph-ts"; +import { SECONDS_PER_DAY } from "../../util/constants"; +import { CustomEventType, getUnixDays, getUnixHours } from "../../util/events"; + +const ActivityHelperID = Bytes.fromUTF8("_ActivityHelper"); + +/** + * This file contains the ProtocolSnapshot, which is used to + * make all of the storage changes that occur in the protocol's + * daily and hourly snapshots. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +/** + * Helper class to manage Financials and Usage snapshots. + * It is not meant to be used directly, but rather by the Protocol and Account lib classes. + * Whenever it is instantiated it will check if it is time to take any of the + * dailyFinancials, dailyUsage or hourlyUsage snapshots. + * + * Snapshots are taken in a way that allows the snapshot entity to be immutable. + */ +export class ProtocolSnapshot { + protocol: ProtocolSchema; + event: CustomEventType; + dayID: i32; + hourID: i32; + activityHelper: _ActivityHelper; + + constructor(protocol: ProtocolSchema, event: CustomEventType) { + this.protocol = protocol; + this.event = event; + this.dayID = getUnixDays(event.block); + this.hourID = getUnixHours(event.block); + this.activityHelper = initActivityHelper(); + this.takeSnapshots(); + } + + addActiveUser(activity: AccountWasActive): void { + this.activityHelper.dailyActiveUsers += activity.daily ? 1 : 0; + this.activityHelper.save(); + } + + private takeSnapshots(): void { + const snapshotDayID = + this.protocol.lastUpdateTimestamp.toI32() / SECONDS_PER_DAY; + + if (snapshotDayID != this.dayID) { + this.takeFinancialsDailySnapshot(snapshotDayID); + this.takeUsageDailySnapshot(snapshotDayID); + this.protocol.lastSnapshotDayID = snapshotDayID; + this.protocol.save(); + } + } + + private takeFinancialsDailySnapshot(day: i32): void { + const snapshot = new FinancialsDailySnapshot(Bytes.fromI32(day)); + const previousSnapshot = FinancialsDailySnapshot.load( + Bytes.fromI32(this.protocol.lastSnapshotDayID) + ); + + snapshot.day = day; + snapshot.protocol = this.protocol.id; + snapshot.blockNumber = this.event.block.number; + snapshot.timestamp = this.event.block.timestamp; + + // tvl + snapshot.totalValueLockedUSD = this.protocol.totalValueLockedUSD; + + // revenues + snapshot.cumulativeSupplySideRevenueUSD = + this.protocol.cumulativeSupplySideRevenueUSD; + snapshot.cumulativeProtocolSideRevenueUSD = + this.protocol.cumulativeProtocolSideRevenueUSD; + snapshot.cumulativeTotalRevenueUSD = + this.protocol.cumulativeTotalRevenueUSD; + + // deltas + let supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD; + let protocolSideRevenueDelta = snapshot.cumulativeProtocolSideRevenueUSD; + let totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD; + + if (previousSnapshot) { + supplySideRevenueDelta = snapshot.cumulativeSupplySideRevenueUSD.minus( + previousSnapshot.cumulativeSupplySideRevenueUSD + ); + protocolSideRevenueDelta = + snapshot.cumulativeProtocolSideRevenueUSD.minus( + previousSnapshot.cumulativeProtocolSideRevenueUSD + ); + totalRevenueDelta = snapshot.cumulativeTotalRevenueUSD.minus( + previousSnapshot.cumulativeTotalRevenueUSD + ); + } + snapshot.dailySupplySideRevenueUSD = supplySideRevenueDelta; + snapshot.dailyProtocolSideRevenueUSD = protocolSideRevenueDelta; + snapshot.dailyTotalRevenueUSD = totalRevenueDelta; + + snapshot.save(); + } + + private takeUsageDailySnapshot(day: i32): void { + const activity = this.activityHelper; + + const snapshot = new UsageMetricsDailySnapshot(Bytes.fromI32(day)); + const previousSnapshot = UsageMetricsDailySnapshot.load( + Bytes.fromI32(this.protocol.lastSnapshotDayID) + ); + + snapshot.protocol = this.protocol.id; + snapshot.day = day; + snapshot.blockNumber = this.event.block.number; + snapshot.timestamp = this.event.block.timestamp; + + // unique users + snapshot.cumulativeUniqueUsers = this.protocol.cumulativeUniqueUsers; + + // daily activity + snapshot.dailyActiveUsers = activity.dailyActiveUsers; + + // transaction counts + snapshot.cumulativeTransactionCount = + this.protocol.cumulativeTransactionCount; + + // misc + snapshot.totalPoolCount = this.protocol.totalPoolCount; + + // deltas + let transactionDelta = snapshot.cumulativeTransactionCount; + + if (previousSnapshot) { + transactionDelta = + snapshot.cumulativeTransactionCount - + previousSnapshot.cumulativeTransactionCount; + } + snapshot.dailyTransactionCount = transactionDelta; + snapshot.save(); + + activity.dailyActiveUsers = 0; + activity.save(); + } +} + +function initActivityHelper(): _ActivityHelper { + let helper = _ActivityHelper.load(ActivityHelperID); + if (helper) { + return helper; + } + helper = new _ActivityHelper(ActivityHelperID); + helper.dailyActiveUsers = 0; + + helper.save(); + return helper; +} diff --git a/subgraphs/powh3d/src/sdk/protocols/generic/tokens.ts b/subgraphs/powh3d/src/sdk/protocols/generic/tokens.ts new file mode 100644 index 0000000000..7095cf896c --- /dev/null +++ b/subgraphs/powh3d/src/sdk/protocols/generic/tokens.ts @@ -0,0 +1,58 @@ +import { ProtocolManager } from "./protocol"; +import { Address } from "@graphprotocol/graph-ts"; +import { Token } from "../../../../generated/schema"; +import { BIGDECIMAL_ZERO } from "../../util/constants"; + +/** + * This file contains the TokenManagerClass, which initializes + * token entities. + * + * Schema Version: 3.0.0 + * SDK Version: 1.1.0 + * Author(s): + * - @steegecs + * - @shashwatS22 + */ + +export interface TokenInitializer { + getTokenParams(address: Address): TokenParams; +} + +export class TokenParams { + name: string; + symbol: string; + decimals: i32; + + constructor(name: string, symbol: string, decimals: i32) { + this.name = name; + this.symbol = symbol; + this.decimals = decimals; + } +} + +export class TokenManager { + protocol: ProtocolManager; + initializer: TokenInitializer; + + constructor(protocol: ProtocolManager, init: TokenInitializer) { + this.protocol = protocol; + this.initializer = init; + } + + getOrCreateToken(address: Address): Token { + let token = Token.load(address); + if (token) { + return token; + } + + const params = this.initializer.getTokenParams(address); + token = new Token(address); + token.name = params.name; + token.symbol = params.symbol; + token.decimals = params.decimals; + token.lastPriceUSD = BIGDECIMAL_ZERO; + token.save(); + + return token; + } +} diff --git a/subgraphs/powh3d/src/sdk/util/arrays.ts b/subgraphs/powh3d/src/sdk/util/arrays.ts new file mode 100644 index 0000000000..d610008f16 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/util/arrays.ts @@ -0,0 +1,103 @@ +import { Bytes } from "@graphprotocol/graph-ts"; + +// A function which given 3 arrays of arbitrary types of the same length, +// where the first one holds the reference order, the second one holds the same elements +// as the first but in different order, and the third any arbitrary elements. It will return +// the third array after sorting it according to the order of the first one. +// For example: +// sortArrayByReference(['a', 'c', 'b'], ['a', 'b', 'c'], [1, 2, 3]) => [1, 3, 2] +export function sortArrayByReference( + reference: T[], + array: T[], + toSort: K[] +): K[] { + const sorted: K[] = new Array(); + for (let i = 0; i < reference.length; i++) { + const index = array.indexOf(reference[i]); + sorted.push(toSort[index]); + } + return sorted; +} + +// sortBytesArray will sort an array of Bytes in ascending order +// by comparing their hex string representation. +export function sortBytesArray(array: Bytes[]): Bytes[] { + const toSort = array.map((item) => item.toHexString()); + toSort.sort(); + return toSort.map((item) => Bytes.fromHexString(item)); +} + +export function updateArrayAtIndex(x: T[], item: T, index: i32): T[] { + if (x.length == 0) { + return [item]; + } + if (index == -1 || index > x.length) { + index = x.length; + } + const retval = new Array(); + let i = 0; + while (i < index) { + retval.push(x[i]); + i += 1; + } + retval.push(item); + i += 1; + while (i < x.length) { + retval.push(x[i]); + i += 1; + } + return retval; +} + +export function addToArrayAtIndex(x: T[], item: T, index: i32 = -1): T[] { + if (x.length == 0) { + return [item]; + } + if (index == -1 || index > x.length) { + index = x.length; + } + const retval = new Array(); + let i = 0; + while (i < index) { + retval.push(x[i]); + i += 1; + } + retval.push(item); + while (i < x.length) { + retval.push(x[i]); + i += 1; + } + return retval; +} + +export function addArrays(a: T[], b: T[]): T[] { + const retval = new Array(); + const arraysByLength = a.length <= b.length ? [a, b] : [b, a]; + + let i = 0; + while (i < arraysByLength[0].length) { + retval.push(a[i].plus(b[i])); + i += 1; + } + while (i < arraysByLength[1].length) { + retval.push(arraysByLength[1][i]); + i += 1; + } + return retval; +} + +export function subtractArrays(a: T[], b: T[]): T[] { + const retval = new Array(); + const arraysByLength = a.length <= b.length ? [a, b] : [b, a]; + + let i = 0; + while (i < arraysByLength[0].length) { + retval.push(a[i].minus(b[i])); + i += 1; + } + while (i < arraysByLength[1].length) { + retval.push(arraysByLength[1][i]); + i += 1; + } + return retval; +} diff --git a/subgraphs/powh3d/src/sdk/util/constants.ts b/subgraphs/powh3d/src/sdk/util/constants.ts new file mode 100644 index 0000000000..1cdf19dd52 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/util/constants.ts @@ -0,0 +1,235 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +//////////////////////// +///// Schema Enums ///// +//////////////////////// + +// The network names corresponding to the Network enum in the schema. +// They also correspond to the ones in `dataSource.network()` after converting to lower case. +// See below for a complete list: +// https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/#supported-networks-on-the-hosted-service +export namespace Network { + export const ARBITRUM_ONE = "ARBITRUM_ONE"; + export const AVALANCHE = "AVALANCHE"; + export const AURORA = "AURORA"; + export const BASE = "BASE"; + export const BSC = "BSC"; // aka BNB Chain + export const CELO = "CELO"; + export const MAINNET = "MAINNET"; // Ethereum mainnet + export const FANTOM = "FANTOM"; + export const FUSE = "FUSE"; + export const MOONBEAM = "MOONBEAM"; + export const MOONRIVER = "MOONRIVER"; + export const NEAR_MAINNET = "NEAR_MAINNET"; + export const OPTIMISM = "OPTIMISM"; + export const MATIC = "MATIC"; // aka Polygon + export const XDAI = "XDAI"; // aka Gnosis Chain + + // other networks + export const UBIQ = "UBIQ"; + export const SONGBIRD = "SONGBIRD"; + export const ELASTOS = "ELASTOS"; + export const KARDIACHAIN = "KARDIACHAIN"; + export const CRONOS = "CRONOS"; + export const RSK = "RSK"; + export const TELOS = "TELOS"; + export const XDC = "XDC"; + export const ZYX = "ZYX"; + export const CSC = "CSC"; + export const SYSCOIN = "SYSCOIN"; + export const GOCHAIN = "GOCHAIN"; + export const ETHEREUMCLASSIC = "ETHEREUMCLASSIC"; + export const OKEXCHAIN = "OKEXCHAIN"; + export const HOO = "HOO"; + export const METER = "METER"; + export const NOVA_NETWORK = "NOVA_NETWORK"; + export const TOMOCHAIN = "TOMOCHAIN"; + export const VELAS = "VELAS"; + export const THUNDERCORE = "THUNDERCORE"; + export const HECO = "HECO"; + export const XDAIARB = "XDAIARB"; + export const ENERGYWEB = "ENERGYWEB"; + export const HPB = "HPB"; + export const BOBA = "BOBA"; + export const KUCOIN = "KUCOIN"; + export const SHIDEN = "SHIDEN"; + export const THETA = "THETA"; + export const SX = "SX"; + export const CANDLE = "CANDLE"; + export const ASTAR = "ASTAR"; + export const CALLISTO = "CALLISTO"; + export const WANCHAIN = "WANCHAIN"; + export const METIS = "METIS"; + export const ULTRON = "ULTRON"; + export const STEP = "STEP"; + export const DOGECHAIN = "DOGECHAIN"; + export const RONIN = "RONIN"; + export const KAVA = "KAVA"; + export const IOTEX = "IOTEX"; + export const XLC = "XLC"; + export const NAHMII = "NAHMII"; + export const TOMBCHAIN = "TOMBCHAIN"; + export const CANTO = "CANTO"; + export const KLAYTN = "KLAYTN"; + export const EVMOS = "EVMOS"; + export const SMARTBCH = "SMARTBCH"; + export const BITGERT = "BITGERT"; + export const FUSION = "FUSION"; + export const OHO = "OHO"; + export const ARB_NOVA = "ARB_NOVA"; + export const OASIS = "OASIS"; + export const REI = "REI"; + export const REICHAIN = "REICHAIN"; + export const GODWOKEN = "GODWOKEN"; + export const POLIS = "POLIS"; + export const KEKCHAIN = "KEKCHAIN"; + export const VISION = "VISION"; + export const HARMONY = "HARMONY"; + export const PALM = "PALM"; + export const CURIO = "CURIO"; + + export const UNKNOWN_NETWORK = "UNKNOWN_NETWORK"; +} +export type Network = string; + +export namespace ProtocolType { + export const EXCHANGE = "EXCHANGE"; + export const LENDING = "LENDING"; + export const YIELD = "YIELD"; + export const BRIDGE = "BRIDGE"; + export const OPTION = "OPTION"; + export const PERPETUAL = "PERPETUAL"; + export const GENERIC = "GENERIC"; +} + +export namespace VaultFeeType { + export const MANAGEMENT_FEE = "MANAGEMENT_FEE"; + export const PERFORMANCE_FEE = "PERFORMANCE_FEE"; + export const DEPOSIT_FEE = "DEPOSIT_FEE"; + export const WITHDRAWAL_FEE = "WITHDRAWAL_FEE"; +} + +export namespace LiquidityPoolFeeType { + export const FIXED_TRADING_FEE = "FIXED_TRADING_FEE"; + export const TIERED_TRADING_FEE = "TIERED_TRADING_FEE"; + export const DYNAMIC_TRADING_FEE = "DYNAMIC_TRADING_FEE"; + export const FIXED_LP_FEE = "FIXED_LP_FEE"; + export const DYNAMIC_LP_FEE = "DYNAMIC_LP_FEE"; + export const FIXED_PROTOCOL_FEE = "FIXED_PROTOCOL_FEE"; + export const DYNAMIC_PROTOCOL_FEE = "DYNAMIC_PROTOCOL_FEE"; +} +export type LiquidityPoolFeeType = string; + +export namespace RewardTokenType { + export const DEPOSIT = "DEPOSIT"; + export const BORROW = "BORROW"; + export const STAKE = "STAKE"; +} +export type RewardTokenType = string; + +export namespace ActivityInterval { + export const HOURLY = "HOURLY"; + export const DAILY = "DAILY"; +} + +export namespace LendingType { + export const CDP = "CDP"; + export const POOLED = "POOLED"; +} + +export namespace RiskType { + export const GLOBAL = "GLOBAL"; + export const ISOLATED = "ISOLATED"; +} + +export namespace InterestRateType { + export const STABLE = "STABLE"; + export const VARIABLE = "VARIABLE"; + export const FIXED_TERM = "FIXED_TERM"; +} + +export namespace InterestRateSide { + export const LENDER = "LENDER"; + export const BORROWER = "BORROWER"; +} + +export namespace UsageType { + export const DEPOSIT = "DEPOSIT"; + export const WITHDRAW = "WITHDRAW"; + export const SWAP = "SWAP"; +} + +export namespace PositionSide { + export const LONG = "LONG"; + export const SHORT = "SHORT"; +} +export type PositionSide = string; + +////////////////////////////// +///// Ethereum Addresses ///// +////////////////////////////// + +export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + +//////////////////////// +///// Type Helpers ///// +//////////////////////// + +export const DEFAULT_DECIMALS = 18; + +export const USDC_DECIMALS = 6; +export const USDC_DENOMINATOR = BigDecimal.fromString("1000000"); + +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const BIGINT_TWO = BigInt.fromI32(2); +export const BIGINT_NINE = BigInt.fromI32(9); +export const BIGINT_TEN = BigInt.fromI32(10); +export const BIGINT_HUNDRED = BigInt.fromI32(100); +export const BIGINT_THOUSAND = BigInt.fromI32(1000); +export const BIGINT_TEN_TO_EIGHTEENTH = BigInt.fromString("10").pow(18); +export const BIGINT_MINUS_ONE = BigInt.fromI32(-1); +export const BIGINT_MAX = BigInt.fromString( + "115792089237316195423570985008687907853269984665640564039457584007913129639935" +); + +export const INT_NEGATIVE_ONE = -1 as i32; +export const INT_ZERO = 0 as i32; +export const INT_ONE = 1 as i32; +export const INT_TWO = 2 as i32; +export const INT_FOUR = 4 as i32; + +export const BIGDECIMAL_ZERO = new BigDecimal(BIGINT_ZERO); +export const BIGDECIMAL_ONE = new BigDecimal(BIGINT_ONE); +export const BIGDECIMAL_TWO = new BigDecimal(BIGINT_TWO); +export const BIGDECIMAL_TEN = new BigDecimal(BIGINT_TEN); +export const BIGDECIMAL_HUNDRED = new BigDecimal(BIGINT_HUNDRED); +export const BIGDECIMAL_THOUSAND = new BigDecimal(BIGINT_THOUSAND); +export const BIGDECIMAL_MINUS_ONE = new BigDecimal(BIGINT_MINUS_ONE); + +export const MAX_UINT = BigInt.fromI32(2).times(BigInt.fromI32(255)); +export const QI92 = BigDecimal.fromString( + "6277101735386680763835789423207666416102355444464034512896" +); // 2 ** 192 + +///////////////////// +///// Date/Time ///// +///////////////////// + +export const SECONDS_PER_DAY = 60 * 60 * 24; // 86400 +export const SECONDS_PER_HOUR = 60 * 60; // 3600 +export const SECONDS_PER_DAY_BI = BigInt.fromI32(SECONDS_PER_DAY); +export const SECONDS_PER_HOUR_BI = BigInt.fromI32(SECONDS_PER_HOUR); +export const MS_PER_DAY = new BigDecimal(BigInt.fromI32(24 * 60 * 60 * 1000)); +export const DAYS_PER_YEAR = new BigDecimal(BigInt.fromI32(365)); +export const MS_PER_YEAR = DAYS_PER_YEAR.times( + new BigDecimal(BigInt.fromI32(24 * 60 * 60 * 1000)) +); + +//////////////// +///// Misc ///// +//////////////// + +export const ETH_SYMBOL = "ETH"; +export const ETH_NAME = "Ether"; diff --git a/subgraphs/powh3d/src/sdk/util/events.ts b/subgraphs/powh3d/src/sdk/util/events.ts new file mode 100644 index 0000000000..5c6ee1e4d1 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/util/events.ts @@ -0,0 +1,70 @@ +import { BigInt, Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { + BIGINT_ZERO, + SECONDS_PER_DAY, + SECONDS_PER_HOUR, + ZERO_ADDRESS, +} from "./constants"; + +export class CustomEventType { + block: ethereum.Block; + transaction: ethereum.Transaction; + logIndex: BigInt; + event: ethereum.Event | null; + + constructor() { + this.block = new ethereum.Block( + Bytes.empty(), + Bytes.empty(), + Bytes.empty(), + Address.fromString(ZERO_ADDRESS), + Bytes.empty(), + Bytes.empty(), + Bytes.empty(), + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + null, + null + ); + this.transaction = new ethereum.Transaction( + Bytes.empty(), + BIGINT_ZERO, + Address.fromString(ZERO_ADDRESS), + null, + BIGINT_ZERO, + BIGINT_ZERO, + BIGINT_ZERO, + Bytes.empty(), + BIGINT_ZERO + ); + this.logIndex = BIGINT_ZERO; + this.event = null; + } + + static initialize( + block: ethereum.Block, + transaction: ethereum.Transaction, + logIndex: BigInt, + event: ethereum.Event | null = null + ): CustomEventType { + const customEvent = new CustomEventType(); + customEvent.block = block; + customEvent.transaction = transaction; + customEvent.logIndex = logIndex; + customEvent.event = event; + + return customEvent; + } +} + +export function getUnixDays(block: ethereum.Block): i32 { + return block.timestamp.toI32() / SECONDS_PER_DAY; +} + +export function getUnixHours(block: ethereum.Block): i32 { + return block.timestamp.toI32() / SECONDS_PER_HOUR; +} diff --git a/subgraphs/powh3d/src/sdk/util/numbers.ts b/subgraphs/powh3d/src/sdk/util/numbers.ts new file mode 100644 index 0000000000..725140a922 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/util/numbers.ts @@ -0,0 +1,61 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { + BIGDECIMAL_ZERO, + BIGINT_TEN, + DEFAULT_DECIMALS, + INT_TWO, +} from "./constants"; + +export function bigIntToBigDecimal( + quantity: BigInt, + decimals: i32 = DEFAULT_DECIMALS +): BigDecimal { + return quantity.divDecimal(BIGINT_TEN.pow(decimals as u8).toBigDecimal()); +} + +export function bigDecimalToBigInt(input: BigDecimal): BigInt { + const str = input.truncate(0).toString(); + return BigInt.fromString(str); +} + +// returns 10^exp +export function exponentToBigDecimal(exp: i32 = DEFAULT_DECIMALS): BigDecimal { + let bd = BigDecimal.fromString("1"); + const ten = BigDecimal.fromString("10"); + for (let i = 0; i < exp; i++) { + bd = bd.times(ten); + } + return bd; +} + +export function calculateAverage(prices: BigDecimal[]): BigDecimal { + let sum = BigDecimal.fromString("0"); + for (let i = 0; i < prices.length; i++) { + sum = sum.plus(prices[i]); + } + + return sum.div( + BigDecimal.fromString(BigInt.fromI32(prices.length).toString()) + ); +} + +export function calculateMedian(prices: BigDecimal[]): BigDecimal { + const sorted = prices.sort((a, b) => { + return a.equals(b) ? 0 : a.gt(b) ? 1 : -1; + }); + + const mid = Math.ceil(sorted.length / 2) as i32; + if (sorted.length % 2 == 0) { + return sorted[mid] + .plus(sorted[mid - 1]) + .div(BigDecimal.fromString(INT_TWO.toString())); + } + + return sorted[mid - 1]; +} + +export function safeDivide(a: BigDecimal, b: BigDecimal): BigDecimal { + if (b == BIGDECIMAL_ZERO) return BIGDECIMAL_ZERO; + + return a.div(b); +} diff --git a/subgraphs/powh3d/src/sdk/util/rewards.ts b/subgraphs/powh3d/src/sdk/util/rewards.ts new file mode 100644 index 0000000000..ad68987205 --- /dev/null +++ b/subgraphs/powh3d/src/sdk/util/rewards.ts @@ -0,0 +1,295 @@ +///////////////////// +// VERSION 1.0.3 //// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// The purpose of this program is to dynamically estimate the blocks generated for the 24 HR period following the most recent update. // +// It does so by calculating the moving average block rate for an arbitrary length of time preceding the current block. // +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +import { log, BigDecimal, BigInt, dataSource } from "@graphprotocol/graph-ts"; +import { _CircularBuffer } from "../../../generated/schema"; +import { + Network, + BIGDECIMAL_ZERO, + INT_FOUR, + INT_NEGATIVE_ONE, + INT_ONE, + INT_TWO, + INT_ZERO, +} from "./constants"; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WINDOW_SIZE_SECONDS, TIMESTAMP_STORAGE_INTERVALS, and BUFFER_SIZE can be modified. These are just recommended values - 'somewhat' arbitrary. // +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// The storage interval tells you to only store blocks where the timestamps are separated by at least this amount. +// Increasing this value will mean less blocks stored and less frequently computes blocksSpeed. +export const TIMESTAMP_STORAGE_INTERVAL = 600; + +// The window size determines the range of blocks that you track from the current block minus the window size. +// Window of block time used to calculate the moving average. +// Increasing means less deviation but also less sensitivity to changing block speeds. +export const WINDOW_SIZE_SECONDS = 86400; + +// BUFFER_SIZE determined the size of the array +// Makes the buffer the maximum amount of blocks that can be stored given the block rate and storage interval +// Recommended value is (RATE_IN_SECODNDS / TIMESTAMP_STORAGE_INTERVAL) * 2 - > Round up to nearest even integer +export const BUFFER_SIZE = 288; + +// Add this entity to the schema. +// type _CircularBuffer @entity { +// " 'CIRCULAR_BUFFER' " +// id: ID! + +// " Array of sorted block numbers sorted continuously " +// blocks: [Int!]! + +// " The index in the blocks array which will be used with the newest block to calculate block speed (Usally set to about a day before newest block) " +// windowStartIndex: Int! + +// " The next index in the blocks array that will be replaced with the newest block " +// nextIndex: Int! + +// " This determines the size of the blocks array. Should be set to contain at least a days worth of blocks according to a 1 day window for measuring speed" +// bufferSize: Int! + +// " The current calculated number of blocks per day based on calculated block speed " +// blocksPerDay: BigDecimal! + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const CIRCULAR_BUFFER = "CIRCULAR_BUFFER"; + +// Describes whether the interval for which rewards are emitted is done by block or timestamp +export namespace RewardIntervalType { + export const BLOCK = "BLOCK"; + export const TIMESTAMP = "TIMESTAMP"; +} + +// Forecast period. This gives you the time period that you want to estimate count of blocks per interval, based on moving average block speed. +// 86400 = 1 Day +export const RATE_IN_SECONDS = 86400; +export const RATE_IN_SECONDS_BD = BigDecimal.fromString( + RATE_IN_SECONDS.toString() +); + +// Estimated seconds per block of the protocol +export const STARTING_BLOCKS_PER_DAY = RATE_IN_SECONDS_BD.div( + getStartingBlockRate() +); + +export const WINDOW_SIZE_SECONDS_BD = BigDecimal.fromString( + WINDOW_SIZE_SECONDS.toString() +); + +// Call this function in event handlers frequently enough so that it calls on blocks frequently enough +/** + * @param {BigInt} currentTimestamp - Timestamp for current event + * @param {BigInt} currentBlockNumber - Block nunmber of current event + * @param {BigInt} rewardRate - Rate of reward emissions per reward interval + * @param {BigInt} rewardType - Describes whether rewards are given per block or timestamp + * @returns {BigDecimal} - Returns estimated blocks for specified rate + */ +export function getRewardsPerDay( + currentTimestamp: BigInt, + currentBlockNumber: BigInt, + rewardRate: BigDecimal, + rewardType: string +): BigDecimal { + const circularBuffer = getOrCreateCircularBuffer(); + + // Create entity for the current block + const currentTimestampI32 = currentTimestamp.toI32(); + const currentBlockNumberI32 = currentBlockNumber.toI32(); + + const blocks = circularBuffer.blocks; + + // Interval between index and the index of the start of the window block + const windowWidth = abs( + circularBuffer.windowStartIndex - circularBuffer.nextIndex + ); + if (windowWidth == INT_ZERO) { + if (circularBuffer.nextIndex >= circularBuffer.bufferSize) { + blocks[INT_ZERO] = currentTimestampI32; + blocks[INT_ONE] = currentBlockNumberI32; + circularBuffer.nextIndex = INT_TWO; + } else { + blocks[circularBuffer.nextIndex] = currentTimestampI32; + blocks[circularBuffer.nextIndex + INT_ONE] = currentBlockNumberI32; + circularBuffer.nextIndex += INT_TWO; + } + + circularBuffer.save(); + + // return because there is only 1 reference point. + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return circularBuffer.blocksPerDay.times(rewardRate); + } + } + + // Add current timestamp and block numnber to array if new block is at least X blocks later than previously stored. + // Used to save memory and efficiency on array resizing. + let recentSavedTimestamp: i32; + if (circularBuffer.nextIndex == INT_ZERO) { + recentSavedTimestamp = blocks[circularBuffer.bufferSize - INT_TWO]; + } else { + recentSavedTimestamp = blocks[circularBuffer.nextIndex - INT_TWO]; + } + + if ( + currentTimestampI32 - recentSavedTimestamp <= + TIMESTAMP_STORAGE_INTERVAL + ) { + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return circularBuffer.blocksPerDay.times(rewardRate); + } + } + + blocks[circularBuffer.nextIndex] = currentTimestampI32; + blocks[circularBuffer.nextIndex + INT_ONE] = currentBlockNumberI32; + if (circularBuffer.nextIndex >= BUFFER_SIZE - INT_TWO) { + circularBuffer.nextIndex = INT_ZERO; + } else { + circularBuffer.nextIndex += INT_TWO; + } + // The timestamp at the start of the window (default 24 hours in seconds). + const startTimestamp = currentTimestampI32 - WINDOW_SIZE_SECONDS; + + // Make sure to still have 2 blocks to calculate rate (This shouldn't happen past the beginning). + while (true) { + if (circularBuffer.nextIndex > circularBuffer.windowStartIndex) { + if ( + circularBuffer.nextIndex - circularBuffer.windowStartIndex <= + INT_FOUR + ) { + break; + } + } else { + if ( + BUFFER_SIZE - + circularBuffer.windowStartIndex + + circularBuffer.nextIndex <= + INT_FOUR + ) { + break; + } + } + const windowIndexBlockTimestamp = blocks[circularBuffer.windowStartIndex]; + + // Shift the start of the window if the current timestamp moves out of desired rate window + if (windowIndexBlockTimestamp < startTimestamp) { + circularBuffer.windowStartIndex = + circularBuffer.windowStartIndex + INT_TWO; + if (circularBuffer.windowStartIndex >= circularBuffer.bufferSize) { + circularBuffer.windowStartIndex = INT_ZERO; + } + } else { + break; + } + } + + // Wideness of the window in seconds. + const windowSecondsCount = BigDecimal.fromString( + (currentTimestampI32 - blocks[circularBuffer.windowStartIndex]).toString() + ); + + // Wideness of the window in blocks. + const windowBlocksCount = BigDecimal.fromString( + ( + currentBlockNumberI32 - blocks[circularBuffer.windowStartIndex + INT_ONE] + ).toString() + ); + + // Estimate block speed for the window in seconds. + const unnormalizedBlockSpeed = + WINDOW_SIZE_SECONDS_BD.div(windowSecondsCount).times(windowBlocksCount); + + // block speed converted to specified rate. + const normalizedBlockSpeed = RATE_IN_SECONDS_BD.div( + WINDOW_SIZE_SECONDS_BD + ).times(unnormalizedBlockSpeed); + + // Update BlockTracker with new values. + circularBuffer.blocksPerDay = normalizedBlockSpeed; + circularBuffer.blocks = blocks; + + circularBuffer.save(); + + if (rewardType == RewardIntervalType.TIMESTAMP) { + return rewardRate.times(RATE_IN_SECONDS_BD); + } else { + return rewardRate.times(circularBuffer.blocksPerDay); + } +} + +function getOrCreateCircularBuffer(): _CircularBuffer { + let circularBuffer = _CircularBuffer.load(CIRCULAR_BUFFER); + + if (!circularBuffer) { + circularBuffer = new _CircularBuffer(CIRCULAR_BUFFER); + + const blocks = new Array(BUFFER_SIZE); + for (let i = INT_ZERO; i < BUFFER_SIZE; i += INT_TWO) { + blocks[i] = INT_NEGATIVE_ONE; + blocks[i + INT_ONE] = INT_NEGATIVE_ONE; + } + + circularBuffer.blocks = blocks; + circularBuffer.windowStartIndex = INT_ZERO; + circularBuffer.nextIndex = INT_ZERO; + circularBuffer.bufferSize = BUFFER_SIZE; + circularBuffer.blocksPerDay = STARTING_BLOCKS_PER_DAY; + + circularBuffer.save(); + } + + return circularBuffer; +} + +function getStartingBlockRate(): BigDecimal { + // Block rates pulled from google searches - rough estimates + + const network = dataSource.network().toUpperCase().replace("-", "_"); + if (network == Network.MAINNET) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.ARBITRUM_ONE) { + return BigDecimal.fromString("15"); + } else if (network == Network.AURORA) { + return BigDecimal.fromString("1.03"); + } else if (network == Network.BSC) { + return BigDecimal.fromString("5"); + } else if (network == Network.CELO) { + return BigDecimal.fromString("5"); + } else if (network == Network.FANTOM) { + return BigDecimal.fromString("1"); + } else if (network == Network.FUSE) { + return BigDecimal.fromString("1"); + } else if (network == Network.OPTIMISM) { + return BigDecimal.fromString("12.5"); + } else if (network == Network.MATIC) { + return BigDecimal.fromString("2"); + } else if (network == Network.XDAI) { + return BigDecimal.fromString("5"); + } else if (network == Network.MOONBEAM) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.MOONRIVER) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.AVALANCHE) { + return BigDecimal.fromString("13.39"); + } else if (network == Network.CRONOS) { + return BigDecimal.fromString("5.5"); + } else if (network == Network.BASE) { + // assuming same block rate as OPTIMISM + return BigDecimal.fromString("12.5"); + } + + // else if (network == SubgraphNetwork.AVALANCHE) return BigDecimal.fromString("2.5") + // else if (dataSource.network() == "harmony") return BigDecimal.fromString("13.39") + else { + log.warning("getStartingBlockRate(): Network not found", []); + return BIGDECIMAL_ZERO; + } +} diff --git a/subgraphs/powh3d/tsconfig.json b/subgraphs/powh3d/tsconfig.json new file mode 100644 index 0000000000..5c5d17c928 --- /dev/null +++ b/subgraphs/powh3d/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src"] +}