feat: introducing maverick

This commit is contained in:
0xMochan
2024-03-07 16:57:17 -05:00
parent 3f87d151df
commit 249fe6eb4c
25 changed files with 9636 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# ABIs
`get_abis.py` is a simple python script using the etherscan API (free plan) to gather ABIs for all of the contracts we are tracking!
We then can define all of the abis via `substreams_ethereum::Abigen::new` in our `build.rs`.
## Recommendation
It would be apt to convert (maybe through copilot) the python code into the `build.rs` file and then automate the `Abigen` functionality.
## Usage
Requires `python 3.8+`,
```bash
cd abi
python get_abis.py
```
This will populate the files in the `abi` folder.
When the `build.rs` file runs (when `rust-analyzer` activates or `cargo build` is manually ran), Abigen will generate new rust src files from the abis in the `src/abi` folder.

View File

@@ -0,0 +1,224 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "poolAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tickSpacing",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int32",
"name": "activeTick",
"type": "int32"
},
{
"indexed": false,
"internalType": "int256",
"name": "lookback",
"type": "int256"
},
{
"indexed": false,
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
},
{
"indexed": false,
"internalType": "contract IERC20",
"name": "tokenA",
"type": "address"
},
{
"indexed": false,
"internalType": "contract IERC20",
"name": "tokenB",
"type": "address"
}
],
"name": "PoolCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "SetFactoryOwner",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
}
],
"name": "SetFactoryProtocolFeeRatio",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_fee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_tickSpacing",
"type": "uint256"
},
{
"internalType": "int256",
"name": "_lookback",
"type": "int256"
},
{
"internalType": "int32",
"name": "_activeTick",
"type": "int32"
},
{
"internalType": "contract IERC20",
"name": "_tokenA",
"type": "address"
},
{
"internalType": "contract IERC20",
"name": "_tokenB",
"type": "address"
}
],
"name": "create",
"outputs": [
{
"internalType": "contract IPool",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IPool",
"name": "pool",
"type": "address"
}
],
"name": "isFactoryPool",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tickSpacing",
"type": "uint256"
},
{
"internalType": "int256",
"name": "lookback",
"type": "int256"
},
{
"internalType": "contract IERC20",
"name": "tokenA",
"type": "address"
},
{
"internalType": "contract IERC20",
"name": "tokenB",
"type": "address"
}
],
"name": "lookup",
"outputs": [
{
"internalType": "contract IPool",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "position",
"outputs": [
{
"internalType": "contract IPosition",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "protocolFeeRatio",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
}
]

View File

@@ -0,0 +1,48 @@
#!/usr/bin/python
import json
import os
import re
import time
import urllib.request
# Exports contract ABI in JSON
abis = {
# Factories
"CryptoSwapRegistry": "0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0",
"MainRegistry": "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5",
"MetaPoolFactory": "0xB9fC157394Af804a3578134A6585C0dc9cc990d4",
"CryptoPoolFactory": "0xF18056Bbd320E96A48e3Fbf8bC061322531aac99",
# pool
"Pool": "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
}
ABI_ENDPOINT = (
"https://api.etherscan.io/api?module=contract&action=getabi&address={address}"
)
if etherscan_key := os.environ.get("ETHERSCAN_API_TOKEN"):
print("API KEY Loaded!")
ABI_ENDPOINT += f"&apikey={etherscan_key}"
def __main__():
for name, addr in abis.items():
normalized_name = "_".join(re.findall(r"[A-Z]+[a-z]*", name)).lower()
print(f"Getting ABI for {name} at {addr} ({normalized_name})")
try:
with urllib.request.urlopen(ABI_ENDPOINT.format(address=addr)) as response:
response_json = json.loads(response.read().decode())
abi_json = json.loads(response_json["result"])
result = json.dumps(abi_json, indent=4, sort_keys=True)
with open(f"{normalized_name}.json", "w") as f:
f.write(result)
except Exception as err:
print(response.content)
raise err
time.sleep(0.25)
if __name__ == "__main__":
__main__()

View File

@@ -0,0 +1,955 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"indexed": false,
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"name": "AddLiquidity",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "reserveA",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "reserveB",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "mergeId",
"type": "uint128"
}
],
"name": "BinMerged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "int128",
"name": "previousTick",
"type": "int128"
},
{
"indexed": false,
"internalType": "int128",
"name": "newTick",
"type": "int128"
}
],
"name": "BinMoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint32",
"name": "maxRecursion",
"type": "uint32"
}
],
"name": "MigrateBinsUpStack",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "protocolFee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "isTokenA",
"type": "bool"
}
],
"name": "ProtocolFeeCollected",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"indexed": false,
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"name": "RemoveLiquidity",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "protocolFee",
"type": "uint256"
}
],
"name": "SetProtocolFeeRatio",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "tokenAIn",
"type": "bool"
},
{
"indexed": false,
"internalType": "bool",
"name": "exactOutput",
"type": "bool"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int32",
"name": "activeTick",
"type": "int32"
}
],
"name": "Swap",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "fromTokenId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "toTokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"indexed": false,
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "TransferLiquidity",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "pos",
"type": "int32"
},
{
"internalType": "bool",
"name": "isDelta",
"type": "bool"
},
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
}
],
"internalType": "struct IPool.AddLiquidityParams[]",
"name": "params",
"type": "tuple[]"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "addLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "tokenAAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenBAmount",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "lpToken",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "binBalanceA",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "binBalanceB",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "int32",
"name": "tick",
"type": "int32"
}
],
"name": "binMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "int32",
"name": "tick",
"type": "int32"
},
{
"internalType": "uint256",
"name": "kind",
"type": "uint256"
}
],
"name": "binPositions",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "factory",
"outputs": [
{
"internalType": "contract IFactory",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "fee",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lookback",
"outputs": [
{
"internalType": "int256",
"name": "",
"type": "int256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
}
],
"name": "getBin",
"outputs": [
{
"components": [
{
"internalType": "uint128",
"name": "reserveA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "reserveB",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "mergeBinBalance",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "mergeId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "totalSupply",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
}
],
"internalType": "struct IPool.BinState",
"name": "bin",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentTwa",
"outputs": [
{
"internalType": "int256",
"name": "",
"type": "int256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getState",
"outputs": [
{
"components": [
{
"internalType": "int32",
"name": "activeTick",
"type": "int32"
},
{
"internalType": "uint8",
"name": "status",
"type": "uint8"
},
{
"internalType": "uint128",
"name": "binCounter",
"type": "uint128"
},
{
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
}
],
"internalType": "struct IPool.State",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getTwa",
"outputs": [
{
"components": [
{
"internalType": "int96",
"name": "twa",
"type": "int96"
},
{
"internalType": "int96",
"name": "value",
"type": "int96"
},
{
"internalType": "uint64",
"name": "lastTimestamp",
"type": "uint64"
}
],
"internalType": "struct IPool.TwaState",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint32",
"name": "maxRecursion",
"type": "uint32"
}
],
"name": "migrateBinUpStack",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "removeLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "tokenAOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenBOut",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "tokenAIn",
"type": "bool"
},
{
"internalType": "bool",
"name": "exactOutput",
"type": "bool"
},
{
"internalType": "uint256",
"name": "sqrtPriceLimit",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "swap",
"outputs": [
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "tickSpacing",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenA",
"outputs": [
{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenAScale",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenB",
"outputs": [
{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenBScale",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "fromTokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "toTokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "transferLiquidity",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]