diff --git a/examples/morpho_blue.ipynb b/examples/morpho_blue.ipynb index 29bdf15d..50e4235f 100644 --- a/examples/morpho_blue.ipynb +++ b/examples/morpho_blue.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -20,19 +20,19 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ - "CREATION_MARKET_TOPIC = \"0xac4b2400f169220b0c0afdde7a0b32e775ba727ea1cb30b35f935cdaab8683ac\"\n", - "INTEREST_TOPIC = \"0x9d9bd501d0657d7dfe415f779a620a62b78bc508ddc0891fbbd8b7ac0f8fce87\"\n", - "BORROW_TOPIC = \"0x570954540bed6b1304a87dfe815a5eda4a648f7097a16240dcd85c9b5fd42a43\"\n", - "REPAY_TOPIC = \"0x52acb05cebbd3cd39715469f22afbf5a17496295ef3bc9bb5944056c63ccaa09\"\n", - "SUPPLY_COLLATERAL_TOPIC = \"0xa3b9472a1399e17e123f3c2e6586c23e504184d504de59cdaa2b375e880c6184\"\n", - "WITHDRAW_COLLATERAL_TOPIC = \"0xe80ebd7cc9223d7382aab2e0d1d6155c65651f83d53c8b9b06901d167e321142\"\n", - "SUPPLY_TOPIC = \"0xedf8870433c83823eb071d3df1caa8d008f12f6440918c20d75a3602cda30fe0\"\n", - "WITHDRAW_TOPIC = \"0xa56fc0ad5702ec05ce63666221f796fb62437c32db1aa1aa075fc6484cf58fbf\"\n", - "LIQUIDATION_TOPIC = \"0xa4946ede45d0c6f06a0f5ce92c9ad3b4751452d2fe0e25010783bcab57a67e41\"\n", + "CREATION_MARKET_SIG_HASH = \"0xac4b2400f169220b0c0afdde7a0b32e775ba727ea1cb30b35f935cdaab8683ac\"\n", + "ACCRUE_INTEREST_SIG_HASH = \"0x9d9bd501d0657d7dfe415f779a620a62b78bc508ddc0891fbbd8b7ac0f8fce87\"\n", + "BORROW_SIG_HASH = \"0x570954540bed6b1304a87dfe815a5eda4a648f7097a16240dcd85c9b5fd42a43\"\n", + "REPAY_SIG_HASH = \"0x52acb05cebbd3cd39715469f22afbf5a17496295ef3bc9bb5944056c63ccaa09\"\n", + "SUPPLY_COLLATERAL_SIG_HASH = \"0xa3b9472a1399e17e123f3c2e6586c23e504184d504de59cdaa2b375e880c6184\"\n", + "WITHDRAW_COLLATERAL_SIG_HASH = \"0xe80ebd7cc9223d7382aab2e0d1d6155c65651f83d53c8b9b06901d167e321142\"\n", + "SUPPLY_SIG_HASH = \"0xedf8870433c83823eb071d3df1caa8d008f12f6440918c20d75a3602cda30fe0\"\n", + "WITHDRAW_SIG_HASH = \"0xa56fc0ad5702ec05ce63666221f796fb62437c32db1aa1aa075fc6484cf58fbf\"\n", + "LIQUIDATE_SIG_HASH = \"0xa4946ede45d0c6f06a0f5ce92c9ad3b4751452d2fe0e25010783bcab57a67e41\"\n", "\n", "# Id is an alias for bytes32\n", "# MarketParams is a struct with the following fields:\n", @@ -48,8 +48,8 @@ "REPAY_SIG = \"event Repay(Id indexed id, address indexed caller, address indexed onBehalf, uint256 assets, uint256 shares)\".replace('Id', \"bytes32\")\n", "SUPPLY_COLLATERAL_SIG = \"event SupplyCollateral(Id indexed id, address indexed caller, address indexed onBehalf, uint256 assets)\".replace('Id', \"bytes32\")\n", "WITHDRAW_COLLATERAL_SIG = \"event WithdrawCollateral(Id indexed id, address caller, address indexed onBehalf, address indexed receiver, uint256 assets)\".replace('Id', \"bytes32\")\n", - "LIQUIDATION_SIG = \"event Liquidate(Id indexed id,address indexed caller,address indexed borrower,uint256 repaidAssets,uint256 repaidShares,uint256 seizedAssets,uint256 badDebtAssets,uint256 badDebtShares);\".replace('Id', \"bytes32\")\n", - "INTEREST_SIG = \"event AccrueInterest(Id indexed id, uint256 prevBorrowRate, uint256 interest, uint256 feeShares);\".replace('Id', \"bytes32\")\n", + "LIQUIDATE_SIG = \"event Liquidate(Id indexed id,address indexed caller,address indexed borrower,uint256 repaidAssets,uint256 repaidShares,uint256 seizedAssets,uint256 badDebtAssets,uint256 badDebtShares);\".replace('Id', \"bytes32\")\n", + "ACCRUE_INTEREST_SIG = \"event AccrueInterest(Id indexed id, uint256 prevBorrowRate, uint256 interest, uint256 feeShares);\".replace('Id', \"bytes32\")\n", "\n", "BLUE_CONTRACT_ADDRESS = \"0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb\"\n" ] @@ -63,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -205,7 +205,7 @@ "└─────────────┴─────────────┴───────────┴────────────┴───┴────────┴────────┴────────────┴──────────┘" ] }, - "execution_count": 7, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -218,7 +218,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [CREATION_MARKET_TOPIC],\n", + " \"topic0\": [CREATION_MARKET_SIG_HASH],\n", "}\n", "\n", "# Collect the raw events with cryo\n", @@ -231,7 +231,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -286,7 +286,7 @@ "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘" ] }, - "execution_count": 8, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -316,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -371,7 +371,7 @@ "└────────────┴────────────┴────────────┴───────────┴───────────┴───────────┴───────────┴───────────┘" ] }, - "execution_count": 6, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -383,7 +383,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [SUPPLY_TOPIC],\n", + " \"topic0\": [SUPPLY_SIG_HASH],\n", "}\n", "blue_supply_raw = cryo.collect(\n", " **params\n", @@ -403,7 +403,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -458,7 +458,7 @@ "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘" ] }, - "execution_count": 7, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -469,7 +469,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [WITHDRAW_TOPIC],\n", + " \"topic0\": [WITHDRAW_SIG_HASH],\n", "}\n", "\n", "blue_withdraw_raw = cryo.collect(\n", @@ -490,7 +490,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -540,7 +540,7 @@ "└──────────────┴──────────────┴──────────────┴──────────────┴──────────────┴───────────┴───────────┘" ] }, - "execution_count": 8, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -552,7 +552,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [SUPPLY_COLLATERAL_TOPIC]\n", + " \"topic0\": [SUPPLY_COLLATERAL_SIG_HASH]\n", "}\n", "\n", "blue_supply_collateral_raw = cryo.collect(\n", @@ -573,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -628,7 +628,7 @@ "└────────────┴────────────┴────────────┴───────────┴───────────┴───────────┴───────────┴───────────┘" ] }, - "execution_count": 9, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -640,7 +640,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [WITHDRAW_COLLATERAL_TOPIC]\n", + " \"topic0\": [WITHDRAW_COLLATERAL_SIG_HASH]\n", "}\n", "\n", "blue_withdraw_collateral_raw = cryo.collect(\n", @@ -661,7 +661,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -716,7 +716,7 @@ "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘" ] }, - "execution_count": 10, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -728,7 +728,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [BORROW_TOPIC]\n", + " \"topic0\": [BORROW_SIG_HASH]\n", "}\n", "\n", "blue_borrow_raw = cryo.collect(\n", @@ -749,66 +749,9 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Parsing Event name: event Repay\n", - "Indexed types: [('bytes32', 'id'), ('address', 'caller'), ('address', 'onBehalf')]\n", - "Data types: [('uint256', 'assets'), ('uint256', 'shares')]\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "shape: (5, 8)
idcalleronBehalfblock_numbertransaction_indexlog_indexassetsshares
strstrstru32u32u32f64f64
"0x4a8221eef163…"0xa7995f71aa11…"0x4563364bd619…18942670701854e73.9997e13
"0x4a8221eef163…"0xa7995f71aa11…"0x2b5469940fa5…1894997481160100000.09.9991e10
"0x4a8221eef163…"0xa7995f71aa11…"0x2b5469940fa5…18965474311093.726e63.7254e12
"0xd7a576506870…"0xa7995f71aa11…"0x6e632701fd42…189751911171791.0775e141.0774e20
"0x4a8221eef163…"0x9106cbf2c882…"0x9106cbf2c882…1898255954779.5115e99.5088e15
" - ], - "text/plain": [ - "shape: (5, 8)\n", - "┌────────────┬────────────┬────────────┬───────────┬───────────┬───────────┬───────────┬───────────┐\n", - "│ id ┆ caller ┆ onBehalf ┆ block_num ┆ transacti ┆ log_index ┆ assets ┆ shares │\n", - "│ --- ┆ --- ┆ --- ┆ ber ┆ on_index ┆ --- ┆ --- ┆ --- │\n", - "│ str ┆ str ┆ str ┆ --- ┆ --- ┆ u32 ┆ f64 ┆ f64 │\n", - "│ ┆ ┆ ┆ u32 ┆ u32 ┆ ┆ ┆ │\n", - "╞════════════╪════════════╪════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡\n", - "│ 0x4a8221ee ┆ 0xa7995f71 ┆ 0x4563364b ┆ 18942670 ┆ 70 ┆ 185 ┆ 4e7 ┆ 3.9997e13 │\n", - "│ f163e4bccf ┆ aa11525db0 ┆ d61976ba6f ┆ ┆ ┆ ┆ ┆ │\n", - "│ dedc2a6f46 ┆ 2fc2473c37 ┆ 1297c253be ┆ ┆ ┆ ┆ ┆ │\n", - "│ 96… ┆ de… ┆ ae… ┆ ┆ ┆ ┆ ┆ │\n", - "│ 0x4a8221ee ┆ 0xa7995f71 ┆ 0x2b546994 ┆ 18949974 ┆ 81 ┆ 160 ┆ 100000.0 ┆ 9.9991e10 │\n", - "│ f163e4bccf ┆ aa11525db0 ┆ 0fa577bc40 ┆ ┆ ┆ ┆ ┆ │\n", - "│ dedc2a6f46 ┆ 2fc2473c37 ┆ 82c6940ee4 ┆ ┆ ┆ ┆ ┆ │\n", - "│ 96… ┆ de… ┆ d8… ┆ ┆ ┆ ┆ ┆ │\n", - "│ 0x4a8221ee ┆ 0xa7995f71 ┆ 0x2b546994 ┆ 18965474 ┆ 31 ┆ 109 ┆ 3.726e6 ┆ 3.7254e12 │\n", - "│ f163e4bccf ┆ aa11525db0 ┆ 0fa577bc40 ┆ ┆ ┆ ┆ ┆ │\n", - "│ dedc2a6f46 ┆ 2fc2473c37 ┆ 82c6940ee4 ┆ ┆ ┆ ┆ ┆ │\n", - "│ 96… ┆ de… ┆ d8… ┆ ┆ ┆ ┆ ┆ │\n", - "│ 0xd7a57650 ┆ 0xa7995f71 ┆ 0x6e632701 ┆ 18975191 ┆ 117 ┆ 179 ┆ 1.0775e14 ┆ 1.0774e20 │\n", - "│ 6870346a78 ┆ aa11525db0 ┆ fd42a9b856 ┆ ┆ ┆ ┆ ┆ │\n", - "│ a11a6762e2 ┆ 2fc2473c37 ┆ 294a2172dd ┆ ┆ ┆ ┆ ┆ │\n", - "│ cc… ┆ de… ┆ 63… ┆ ┆ ┆ ┆ ┆ │\n", - "│ 0x4a8221ee ┆ 0x9106cbf2 ┆ 0x9106cbf2 ┆ 18982559 ┆ 54 ┆ 77 ┆ 9.5115e9 ┆ 9.5088e15 │\n", - "│ f163e4bccf ┆ c882340b23 ┆ c882340b23 ┆ ┆ ┆ ┆ ┆ │\n", - "│ dedc2a6f46 ┆ cc40985c05 ┆ cc40985c05 ┆ ┆ ┆ ┆ ┆ │\n", - "│ 96… ┆ 64… ┆ 64… ┆ ┆ ┆ ┆ ┆ │\n", - "└────────────┴────────────┴────────────┴───────────┴───────────┴───────────┴───────────┴───────────┘" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "\n", "params = {\n", @@ -816,7 +759,7 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [REPAY_TOPIC]\n", + " \"topic0\": [REPAY_SIG_HASH]\n", "}\n", "\n", "blue_repay_raw = cryo.collect(\n", @@ -837,7 +780,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -892,7 +835,7 @@ "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘" ] }, - "execution_count": 12, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -903,14 +846,14 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [LIQUIDATION_TOPIC]\n", + " \"topic0\": [LIQUIDATE_SIG_HASH]\n", "}\n", "\n", "blue_liquidation_raw = cryo.collect(\n", " **params\n", ")\n", "\n", - "blue_liquidation = parse_raw_events(blue_liquidation_raw, LIQUIDATION_SIG)\n", + "blue_liquidation = parse_raw_events(blue_liquidation_raw, LIQUIDATE_SIG)\n", "\n", "blue_liquidation.head(5)" ] @@ -924,7 +867,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -974,7 +917,7 @@ "└────────────────┴──────────────┴───────────────┴───────────┴───────────────┴──────────┴───────────┘" ] }, - "execution_count": 13, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -986,14 +929,14 @@ " \"blocks\": [\"18.9M:\"],\n", " \"inner_request_size\": 10000,\n", " \"contract\": [BLUE_CONTRACT_ADDRESS],\n", - " \"topic0\": [INTEREST_TOPIC]\n", + " \"topic0\": [ACCRUE_INTEREST_SIG_HASH]\n", "}\n", "\n", "blue_interest_raw = cryo.collect(\n", " **params\n", ")\n", "\n", - "blue_interest = parse_raw_events(blue_interest_raw, INTEREST_SIG)\n", + "blue_interest = parse_raw_events(blue_interest_raw, ACCRUE_INTEREST_SIG)\n", "\n", "blue_interest.head(5)" ]