- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
136 lines
4.1 KiB
Bash
Executable File
136 lines
4.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Suggest matched 1:1 seed raw amounts (6 decimals) for a new Mainnet cWUSDT/cWUSDC PMM pool
|
|
# by scaling the smaller of the two reference rails' matched depth:
|
|
# - cWUSDT/USDT
|
|
# - cWUSDC/USDC
|
|
#
|
|
# This is a planning helper only. Review wallet balances before executing deploy/add-liquidity.
|
|
#
|
|
# Usage:
|
|
# source scripts/lib/load-project-env.sh
|
|
# bash scripts/deployment/compute-mainnet-cwusdt-cwusdc-seed-amounts.sh --multiplier=50
|
|
# bash scripts/deployment/compute-mainnet-cwusdt-cwusdc-seed-amounts.sh --multiplier=50 --cap-raw=500000000000
|
|
#
|
|
# Env overrides:
|
|
# POOL_CWUSDT_USDT_MAINNET, POOL_CWUSDC_USDC_MAINNET
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" 2>/dev/null || true
|
|
|
|
require_cmd() {
|
|
command -v "$1" >/dev/null 2>&1 || {
|
|
echo "[fail] missing required command: $1" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
require_cmd cast
|
|
require_cmd python3
|
|
|
|
MULTIPLIER="50"
|
|
CAP_RAW=""
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--multiplier=*) MULTIPLIER="${arg#*=}" ;;
|
|
--cap-raw=*) CAP_RAW="${arg#*=}" ;;
|
|
-h | --help)
|
|
sed -n '1,22p' "$0"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "[fail] unknown arg: $arg" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
RPC_URL="${ETHEREUM_MAINNET_RPC:-}"
|
|
if [[ -z "$RPC_URL" ]]; then
|
|
echo "[fail] ETHEREUM_MAINNET_RPC is required" >&2
|
|
exit 1
|
|
fi
|
|
|
|
POOL_UT="${POOL_CWUSDT_USDT_MAINNET:-0x79156F6B7bf71a1B72D78189B540A89A6C13F6FC}"
|
|
POOL_UC="${POOL_CWUSDC_USDC_MAINNET:-0x69776fc607e9edA8042e320e7e43f54d06c68f0E}"
|
|
|
|
read_reserves() {
|
|
local pool="$1"
|
|
cast call "$pool" 'getVaultReserve()(uint256,uint256)' --rpc-url "$RPC_URL"
|
|
}
|
|
|
|
min_side() {
|
|
python3 - "$1" "$2" <<'PY'
|
|
import sys
|
|
b, q = int(sys.argv[1]), int(sys.argv[2])
|
|
print(min(b, q))
|
|
PY
|
|
}
|
|
|
|
line1_ut="$(read_reserves "$POOL_UT" | sed -n '1p' | awk '{print $1}')"
|
|
line2_ut="$(read_reserves "$POOL_UT" | sed -n '2p' | awk '{print $1}')"
|
|
line1_uc="$(read_reserves "$POOL_UC" | sed -n '1p' | awk '{print $1}')"
|
|
line2_uc="$(read_reserves "$POOL_UC" | sed -n '2p' | awk '{print $1}')"
|
|
|
|
min_ut="$(min_side "$line1_ut" "$line2_ut")"
|
|
min_uc="$(min_side "$line1_uc" "$line2_uc")"
|
|
|
|
ref="$(python3 - "$min_ut" "$min_uc" <<'PY'
|
|
import sys
|
|
print(min(int(sys.argv[1]), int(sys.argv[2])))
|
|
PY
|
|
)"
|
|
|
|
seed="$(python3 - "$ref" "$MULTIPLIER" <<'PY'
|
|
import sys
|
|
r, m = int(sys.argv[1]), int(sys.argv[2])
|
|
print(r * m)
|
|
PY
|
|
)"
|
|
|
|
if [[ -n "$CAP_RAW" ]]; then
|
|
seed="$(python3 - "$seed" "$CAP_RAW" <<'PY'
|
|
import sys
|
|
s, c = int(sys.argv[1]), int(sys.argv[2])
|
|
print(min(s, c))
|
|
PY
|
|
)"
|
|
fi
|
|
|
|
echo "=== cWUSDT/cWUSDC matched seed suggestion (1:1 raw on both legs) ==="
|
|
echo "referencePools: cWUSDT/USDT=$POOL_UT cWUSDC/USDC=$POOL_UC"
|
|
echo "minSide_cWUSDT_USDT_raw=$min_ut"
|
|
echo "minSide_cWUSDC_USDC_raw=$min_uc"
|
|
echo "referenceMin_raw=$ref"
|
|
echo "multiplier=$MULTIPLIER"
|
|
echo "suggested_base_raw(cWUSDT)=$seed"
|
|
echo "suggested_quote_raw(cWUSDC)=$seed"
|
|
echo
|
|
echo "Dry-run deploy + seed:"
|
|
echo " bash scripts/deployment/deploy-mainnet-cwusdt-cwusdc-pool.sh \\"
|
|
echo " --initial-price=1000000000000000000 \\"
|
|
echo " --base-amount=$seed --quote-amount=$seed --dry-run"
|
|
echo
|
|
echo "Optional: deepen the two reference rails toward ~${MULTIPLIER}x their current min-side depth"
|
|
echo "(only if you intend matched adds and pool state supports equal base/quote adds; verify live reserves first):"
|
|
delta_ut="$(python3 - "$min_ut" "$MULTIPLIER" <<'PY'
|
|
import sys
|
|
m, k = int(sys.argv[1]), int(sys.argv[2])
|
|
print(max(0, m * (k - 1)))
|
|
PY
|
|
)"
|
|
delta_uc="$(python3 - "$min_uc" "$MULTIPLIER" <<'PY'
|
|
import sys
|
|
m, k = int(sys.argv[1]), int(sys.argv[2])
|
|
print(max(0, m * (k - 1)))
|
|
PY
|
|
)"
|
|
echo " suggested extra raw per side cWUSDT/USDT: base=$delta_ut quote=$delta_ut"
|
|
echo " bash scripts/deployment/add-mainnet-public-dodo-cw-liquidity.sh --pair=cwusdt-usdt --base-amount=$delta_ut --quote-amount=$delta_ut --dry-run"
|
|
echo " suggested extra raw per side cWUSDC/USDC: base=$delta_uc quote=$delta_uc"
|
|
echo " bash scripts/deployment/add-mainnet-public-dodo-cw-liquidity.sh --pair=cwusdc-usdc --base-amount=$delta_uc --quote-amount=$delta_uc --dry-run"
|