├── README.md ├── aave └── v3_supply_and_withdraw.py ├── beraswap └── bera_swap.py ├── flashbots ├── README.md ├── eth_send_bundle.py ├── eth_send_private.py ├── mev-sse │ ├── events.csv │ ├── simple_logger.py │ └── simple_streamer.py └── mev_send_bundle.py ├── general ├── bloom_filter.py ├── multi2.py ├── swap_topic.py └── transfer_override.py ├── misc ├── con │ └── net.py ├── makas_py_on_chain.png └── migrations.py ├── raw_calls ├── raw_approval.py ├── raw_deploy.py ├── raw_deposit.py └── raw_transfer.py ├── scrapbots ├── flash_bot.py ├── skym_bot │ ├── README.md │ ├── abi │ │ ├── erc20_abi.json │ │ ├── relay_abi.json │ │ └── slp_abi.json │ ├── caller.py │ └── relay.vy └── voly.py ├── signing ├── pysign.py ├── setMasterContractApproval.py ├── universal_permit2_abstract.py └── universal_permit2_extended.py ├── sushiswap ├── exact_input.py ├── get_kava_farms.py ├── get_rewards.py ├── graph_call.py ├── route_processor.md ├── route_processor.py ├── route_processor_multi.py ├── swap_volume_since_midnight.py ├── trident_help_sheet.md ├── trident_multicall.py └── xSwap.py ├── sync_swap ├── sync_swap.py └── sync_swap_with_permit.py ├── uni_router ├── universal_router_swap.md ├── universal_router_swap.py ├── universal_swap_from_token.py └── universal_v2_swap.py ├── uniswapv2 ├── mempool_filter.py ├── scale4whale.py └── v2path_encode.md ├── uniswapv3 ├── v3exactOutput.py ├── v3exactOutputSingle.py └── v3quoter_iterations.py └── zk ├── check_balance.py └── transfer.py /README.md: -------------------------------------------------------------------------------- 1 | The previous repository structure can be found here 2 | 3 | --- 4 | 5 | 6 | 7 | --- 8 | 9 | Hi! Originally this repo started as a bunch of _scripts and examples,_ written for users while handling support queries as a contributor at Sushiswap. However the repository had grown to encompass many more protocols and areas of defi, as well as outgrowing its initial lack of structure. 10 | 11 | To make it easier to find things that might be useful, as well to know which related scripts are worth skimming through. I have attempted to better organise into folders, adding an index with short descriptions. 12 | 13 | Always love to hear which examples can been useful, and am often happy to take requests if you might be struggling with something. 14 | Can find me in the ethereum python discord with any questions. 15 | All the best on your journey. - Maka 16 | 17 | - [Ethereum Python Community](https://discord.gg/J8XFujprRA) 18 | 19 | --- 20 | 21 | | folder | script | description | 22 | |---------------------------------|--------------------------------------------------------------------------------|--------------------------------------------------------------| 23 | | > [ aave ]( aave/ ) | | **Aave lending protocol** | 24 | | | [ v3_supply_and_withdraw.py ]( aave/v3_supply_and_withdraw.py ) | Approve, supply and withdraw from a v3 aave pool. | 25 | | > [ beraswap ]( beraswap/ ) | | **Berachain DEX** | 26 | | | [ bera_swap.py ]( beraswap/bera_swap.py ) | Swap using `batchSwap` with their `ERC20_DEX`. | 27 | | > [ flashbots ]( flashbots/ ) | | Call structures and direct calls to flashbots endpoints. | 28 | | | [ eth_send_bundle.py ]( flashbots/eth_send_bundle.py ) | Building and sending a classic bundle. | 29 | | | [ eth_send_private.py ]( flashbots/eth_send_private.py ) | Using Flashbots endpoint to send a private transaction. | 30 | | | [ mev_send_bundle.py ]( flashbots/mev_send_bundle.py ) | Building and sending a MevShare bundle. | 31 | | > [ general ]( general ) | | **Overrides, bloom filters, log topics and wider EVM** | 32 | | | [ bloom_filter.py ]( general/bloom_filter.py ) | Filtering the `logsBloom` for more efficient searches. | 33 | | | [ multi2.py ]( general/multi2.py ) | Using a popular mulicall contract, to batch static requests. | 34 | | | [ swap_topic.py ]( general/swap_topic.py ) | How to encode and pull an `Event` topic. | 35 | | | [ transfer_override.py ]( general/transfer_override.py ) | Overriding an accounts ERC20 balance, prior to an `eth_call`.| 36 | | > [ raw_calls ]( raw_calls/ ) | [ ]( ) | **Contract calls sending raw calldata** | 37 | | | [ raw_approval.py ]( raw_calls/raw_approval.py ) | Send a token approval using pre prepared calldata. | 38 | | | [ raw_deploy.py ]( raw_calls/raw_deploy.py ) | Deploy a contract using pre prepared calldata. | 39 | | | [ raw_deposit.py ]( raw_calls/raw_deposit.py ) | Deposit ETH to receive WETH using pre prepared calldata. | 40 | | | [ raw_transfer.py ]( raw_calls/raw_transfer.py ) | Make an ERC20 transfer using pre prepared calldata. | 41 | | > [ scrapbots ]( scrapbots/) | | **Basic bot flow** | 42 | | | [ skym_bot/ ]( scrapbots/skym_bot/ ) | Monitor a v2 pair for imbalance, skim with contract if so. | 43 | | | [ flash_bot.py ]( scrapbots/flash_bot.py ) | A basic flashbot script, using flashbots py library. | 44 | | | [ voly.py ]( scrapbots/voly.py ) | Polls a v2 pair for price, buys or sells, tracks if holding. | 45 | | > [ signing ]( signing/ ) | | **Offchain signing, permits, EIP712** | 46 | | | [ pysign.py ]( signing/pysign.py ) | Deprectated signing pattern. | 47 | | | [ setMasterContractApproval.py ]( signing/setMasterContractApproval.py ) | Building and signing an EIP712 digest. | 48 | | | [ universal_permit2_extended.py ]( signing/universal_permit2_extended.py ) | Offchain permit for Universal router (long way). | 49 | | | [ universal_permit2_abstract.py ]( signing/universal_permit2_abstract.py ) | Offchain permit for Universal router (short way). | 50 | | > [ sushiswap ]( sushiswap/ ) | | **Sushi specific** | 51 | | | [ exact_input.py ]( sushiswap/exact_input.py ) | Trident single hop swap. | 52 | | | [ get_kava_farms.py ]( sushiswap/get_kava_farms.py ) | Get a list of all farms from a chef. | 53 | | | [ get_rewards.py ]( sushiswap/get_rewards.py ) | Calculating rewards from a Minichef. | 54 | | | [ graph_call.py ]( sushiswap/graph_call.py ) | Outdated: Exchange subgraph call (Pre needing a key). | 55 | | | [ route_processor.md ]( sushiswap/route_processor.md ) | Notes Sushi's router processor. | 56 | | | [ route_processor.py ]( sushiswap/route_processor.py ) | Single hop swap using Sushi route processor. | 57 | | | [ route_processor_multi.py ]( sushiswap/route_processor_multi.py ) | Multi hop swap using Sushi route processor. | 58 | | | [ swap_volume_since_midnight.py ]( sushiswap/swap_volume_since_midnight.py ) | Outdated: Use a subgraph to get volume day data. | 59 | | | [ trident_help_sheet.md ]( sushiswap/trident_help_sheet.md ) | Notes on Sushi Trident. | 60 | | | [ trident_multicall.py ]( sushiswap/trident_multicall.py ) | Trident multi hop swap. | 61 | | | [ xSwap.py ]( sushiswap/xSwap.py ) | Extensive cross chain swap, encoding, off chain signing etc. | 62 | | > [ syncswap ]( syncswap/ ) | | **How to swap on Syncwap DEX.** | 63 | | | [ sync_swap.py ]( syncswap/sync_swap.py ) | Basic Syncswap router interaction. | 64 | | | [ sync_swap_with_permit.py ]( syncswap/sync_swap_with_permit.py ) | Basic Syncswap router interaction using a permit. | 65 | | > [ uniswapv2 ]( uniswapv2/ ) | | **Examples for Uniswap v2 and clones** | 66 | | | [ mempool_filter.py ]( uniswapv2/mempool_filter.py ) | IPC filter the tx pool for swaps and decode them. | 67 | | | [ scale4whale.py ]( uniswapv2/scale4whale.py ) | Get an amount required to buy a tokens total supply. | 68 | | | [ v2path_encode.md ]( uniswapv2/v2path_encode.md ) | Step through of the ABI encoding. | 69 | | > [ uniswapv3 ]( uniswapv3/ ) | | **Examples for Uniswap v3 and clones** | 70 | | | [ v3exactOutput.py ]( uniswapv3/v3exactOutput.py ) | Uniswap v3 swap, multihop. | 71 | | | [ v3exactOutputSingle.py ]( uniswapv3/v3exactOutputSingle.py ) | Uniswap v3 swap, single hop. | 72 | | | [ v3quoter_iterations.py ]( uniswapv3/v3quoter_iterations.py ) | Uniswap v3 quoter discrepancies, example calls to each. | 73 | | > [ uni_router ]( uni_router/) | | **Uniswaps Universal router** | 74 | | | [ universal_router_swap.md ]( uni_router/universal_router_swap.md ) | Notes on Uniswaps Universal Router. | 75 | | | [ universal_router_swap.py ]( uni_router/universal_router_swap.py ) | Wrap and swap from Eth using Universal router.. | 76 | | | [ universal_swap_from_token.py ]( uni_router/universal_swap_from_token.py ) | Swap from token using Universal router (uses dual tx permit).| 77 | | | [ universal_v2_swap.py ]( uni_router/universal_v2_swap.py ) | Swap on a v2 pool using Universal router (dual tx permit). | 78 | | > [ zk ]( zk/ ) | | **Anything ZK specific** | 79 | | | [ check_balance.py ]( zk/check_balance.py ) | Simple balance check, using the sdk. | 80 | | | [ transfer.py ]( zk/transfer.py ) | Simple eth transfer, using the sdk. | 81 | | | | | 82 | 83 |