Files
dexorder/bin/liquidity
2023-11-13 20:56:18 -04:00

22 lines
502 B
Bash
Executable File

#!/bin/bash
if [ -z "$1" ]; then
source ./bin/shmockenv.sh
# ^^ sets the POOL variable
else
POOL=$1
fi
T0=$(cast call "$POOL" "token0()" | cast parse-bytes32-address)
T1=$(cast call "$POOL" "token1()" | cast parse-bytes32-address)
liquidity() {
T=$(cast call "$1" "symbol() returns(string)" "$POOL")
L=$(cast call "$1" "balanceOf(address)" "$POOL" | cast to-dec)
D=$(cast call "$1" "decimals()" | cast to-dec)
echo $T $(echo "scale=18; $L / 10^$D" | bc)
}
liquidity $T0
liquidity $T1