Files
proxmox/scripts/deployment/compute-mainnet-truu-pmm-seed-amounts.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- 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
2026-04-12 06:12:20 -07:00

75 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Compute raw token amounts for a cWUSD* / TRUU PMM seed where legs are 1:1 in USD NOTIONAL
# (same dollar value on each side at deposit). This is NOT 1:1 raw token count unless TRUU/USD = $1.
#
# Args (env or flags):
# USD_NOTIONAL_PER_LEG — USD value to place on EACH side (default: 1000)
# TRUU_USD_PRICE — USD price of one full TRUU token (10 decimals), e.g. 0.00004
#
# Output: base_amount (6-dec cW), quote_amount (10-dec TRUU) for deploy-mainnet-pmm-cw-truu-pool.sh
#
# Example:
# USD_NOTIONAL_PER_LEG=5000 TRUU_USD_PRICE=0.00004 bash scripts/deployment/compute-mainnet-truu-pmm-seed-amounts.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
USD_NOTIONAL_PER_LEG="${USD_NOTIONAL_PER_LEG:-1000}"
TRUU_USD_PRICE="${TRUU_USD_PRICE:-}"
for arg in "$@"; do
case "$arg" in
--usd-per-leg=*) USD_NOTIONAL_PER_LEG="${arg#*=}" ;;
--truu-usd-price=*) TRUU_USD_PRICE="${arg#*=}" ;;
*)
echo "[fail] unknown arg: $arg (use --usd-per-leg= N --truu-usd-price= P)" >&2
exit 2
;;
esac
done
if [[ -z "$TRUU_USD_PRICE" ]]; then
echo "[fail] TRUU_USD_PRICE required (USD per 1 full TRUU token), e.g. export TRUU_USD_PRICE=0.00004" >&2
exit 1
fi
command -v python3 >/dev/null 2>&1 || {
echo "[fail] python3 required" >&2
exit 1
}
read -r BASE_RAW QUOTE_RAW TRUU_FULL <<EOF
$(python3 - <<PY
from decimal import Decimal, getcontext
getcontext().prec = 40
usd = Decimal("$USD_NOTIONAL_PER_LEG")
p = Decimal("$TRUU_USD_PRICE")
if p <= 0:
raise SystemExit("price must be positive")
# cW leg: 6 decimals, 1 unit = 1 USD notionally
base_raw = int((usd * Decimal(10) ** 6).quantize(Decimal("1")))
# TRUU leg: 10 decimals; token count = usd / price
truu_tokens = usd / p
quote_raw = int((truu_tokens * Decimal(10) ** 10).quantize(Decimal("1")))
print(base_raw, quote_raw, format(truu_tokens.normalize(), "f"))
PY
)
EOF
echo "=== cW / TRUU seed (1:1 USD notional per leg) ==="
echo "usd_per_leg=$USD_NOTIONAL_PER_LEG"
echo "truu_usd_price=$TRUU_USD_PRICE"
echo "cW_base_amount_raw (6 dec)=$BASE_RAW (~${USD_NOTIONAL_PER_LEG} USD of cW)"
echo "truu_quote_amount_raw (10 dec)=$QUOTE_RAW (~${USD_NOTIONAL_PER_LEG} USD of TRUU ≈ $TRUU_FULL full tokens)"
echo
echo "deploy-mainnet-pmm-cw-truu-pool.sh \\"
echo " --pair=cwusdt-truu # or --pair=cwusdc-truu \\"
echo " --initial-price=<set from DODO fork> \\"
echo " --base-amount=$BASE_RAW \\"
echo " --quote-amount=$QUOTE_RAW \\"
echo " --dry-run"
echo
echo "# After pools exist, ratio-matched top-up from wallet balances:"
echo "# bash scripts/deployment/add-mainnet-truu-pmm-topup.sh --pair=cwusdt-truu"