Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- MASTER_INDEX: Last Updated 2026-03-06; status 59/59 contracts; add NEXT_STEPS_LIST, CONTRACT_NEXT_STEPS_LIST - docs/README, NEXT_STEPS_INDEX, 06-besu/MASTER_INDEX: Last Updated 2026-03-06 - Contract check script: 59 addresses (PMM, vault/reserve, CompliantFiatTokens); canonical CCIP/router - New docs: EXECUTION_CHECKLIST, NEXT_STEPS_LIST, DOTENV_AUDIT, ADDITIONAL_PATHS, deployer gas runbook, WEMIX_ACQUISITION_TABLED, etc. - Config: deployer-gas-routes, cro-wemix-swap-routes, routing-registry, token-mapping - Scripts: check-contracts-on-chain-138, check-pmm-pool-balances-chain138, deployer-gas-auto-route, acquire-cro-and-wemix-gas - Operator rule: operator-lan-access-check.mdc Made-with: Cursor
90 lines
4.2 KiB
Bash
Executable File
90 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Chain 138 path for deployer gas auto-route: try token-aggregation quote for cUSDT/cUSDC → WETH.
|
|
# If no c*→WETH pool exists (current state), output "use genesis/validator only".
|
|
# Uses config/deployer-gas-routes.json for 138 entry (tokenAggregationBaseUrl, token addresses).
|
|
#
|
|
# Usage:
|
|
# ./scripts/deployment/chain138-tokens-to-gas.sh [--dry-run] [--amount-raw WEI]
|
|
# TOKEN_AGGREGATION_URL=https://dbis-api.d-bis.org/api/v1 ./scripts/deployment/chain138-tokens-to-gas.sh
|
|
#
|
|
# Requires: curl, jq. Optional: RPC_URL_138, PRIVATE_KEY for execute path (not implemented in v1).
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
CONFIG="${PROJECT_ROOT}/config/deployer-gas-routes.json"
|
|
|
|
DRY_RUN=false
|
|
AMOUNT_RAW="${AMOUNT_RAW:-1000000000}"
|
|
# Default: 1000 USDT (6 decimals) in raw units
|
|
|
|
if [[ -f "$CONFIG" ]]; then
|
|
BASE_URL="${TOKEN_AGGREGATION_URL:-$(jq -r '.chains[] | select(.chainId==138) | .tokenAggregationBaseUrl // empty' "$CONFIG")}"
|
|
FALLBACK_URL="$(jq -r '.chains[] | select(.chainId==138) | .tokenAggregationFallbackUrl // empty' "$CONFIG")"
|
|
CUSDT="$(jq -r '.chains[] | select(.chainId==138) | .cusdt // empty' "$CONFIG")"
|
|
CUSDC="$(jq -r '.chains[] | select(.chainId==138) | .cusdc // empty' "$CONFIG")"
|
|
WETH9="$(jq -r '.chains[] | select(.chainId==138) | .weth9 // empty' "$CONFIG")"
|
|
fi
|
|
BASE_URL="${BASE_URL:-https://dbis-api.d-bis.org/api/v1}"
|
|
CUSDT="${CUSDT:-0x93E66202A11B1772E55407B32B44e5Cd8eda7f22}"
|
|
CUSDC="${CUSDC:-0xf22258f57794CC8E06237084b353Ab30fFfa640b}"
|
|
WETH9="${WETH9:-0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2}"
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--dry-run) DRY_RUN=true ;;
|
|
--amount-raw=*) AMOUNT_RAW="${arg#*=}" ;;
|
|
esac
|
|
done
|
|
|
|
# Try quote cUSDT -> WETH
|
|
quote_cusdt_weth() {
|
|
local url="${1:-$BASE_URL}"
|
|
curl -sS --connect-timeout 5 "${url}/quote?chainId=138&tokenIn=${CUSDT}&tokenOut=${WETH9}&amountIn=${AMOUNT_RAW}" 2>/dev/null || echo '{"amountOut":null,"error":"request failed"}'
|
|
}
|
|
|
|
# Try quote cUSDC -> WETH
|
|
quote_cusdc_weth() {
|
|
local url="${1:-$BASE_URL}"
|
|
curl -sS --connect-timeout 5 "${url}/quote?chainId=138&tokenIn=${CUSDC}&tokenOut=${WETH9}&amountIn=${AMOUNT_RAW}" 2>/dev/null || echo '{"amountOut":null,"error":"request failed"}'
|
|
}
|
|
|
|
echo "Chain 138 path: tokens → gas (WETH)"
|
|
echo " Token-aggregation: $BASE_URL"
|
|
echo " Amount (raw): $AMOUNT_RAW"
|
|
echo ""
|
|
|
|
res_cusdt="$(quote_cusdt_weth)"
|
|
res_cusdc="$(quote_cusdc_weth)"
|
|
amount_out_cusdt="$(echo "$res_cusdt" | jq -r '.amountOut // empty' 2>/dev/null)"
|
|
amount_out_cusdc="$(echo "$res_cusdc" | jq -r '.amountOut // empty' 2>/dev/null)"
|
|
err_cusdt="$(echo "$res_cusdt" | jq -r '.error // empty' 2>/dev/null)"
|
|
err_cusdc="$(echo "$res_cusdc" | jq -r '.error // empty' 2>/dev/null)"
|
|
|
|
if [[ -n "$amount_out_cusdt" && "$amount_out_cusdt" != "null" && "$amount_out_cusdt" -gt 0 ]] 2>/dev/null; then
|
|
echo " cUSDT → WETH: quote available (amountOut=$amount_out_cusdt). Pool exists; use DODO PMM swap then optional unwrap."
|
|
echo " Action: build DODO swap tx (swapCUSDTFor* to WETH pool) and optional WETH9.withdraw; see DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER.md."
|
|
exit 0
|
|
fi
|
|
if [[ -n "$amount_out_cusdc" && "$amount_out_cusdc" != "null" && "$amount_out_cusdc" -gt 0 ]] 2>/dev/null; then
|
|
echo " cUSDC → WETH: quote available (amountOut=$amount_out_cusdc). Pool exists; use DODO PMM swap then optional unwrap."
|
|
echo " Action: build DODO swap tx (swapCUSDCFor* to WETH pool) and optional WETH9.withdraw; see DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER.md."
|
|
exit 0
|
|
fi
|
|
|
|
# Fallback URL if primary failed with network error
|
|
if [[ -z "$amount_out_cusdt" && -z "$amount_out_cusdc" && -n "$FALLBACK_URL" ]]; then
|
|
res_cusdt="$(quote_cusdt_weth "$FALLBACK_URL")"
|
|
amount_out_cusdt="$(echo "$res_cusdt" | jq -r '.amountOut // empty' 2>/dev/null)"
|
|
if [[ -n "$amount_out_cusdt" && "$amount_out_cusdt" != "null" && "$amount_out_cusdt" -gt 0 ]] 2>/dev/null; then
|
|
echo " cUSDT → WETH: quote available (fallback URL). Pool exists."
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
echo " No cUSDT/cUSDC → WETH pool found on Chain 138 (token-aggregation returned no quote)."
|
|
echo " Chain 138 gas: use genesis alloc or validator transfer. See FUNDING_AND_DEPLOYMENT_CHECKLIST.md."
|
|
echo " Output: method=genesis_or_validator"
|
|
exit 0
|