Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ BOLTZ_CLIENT_IMAGE=boltz/boltz-client:latest
FOUNDRY_IMAGE=boltz/foundry:latest
GAS_SPONSOR_EMULATOR_IMAGE=boltz/gas-sponsor-emulator:latest
ARBITRUM_E2E_BLOCK_NUMBER=465600501
ETHEREUM_E2E_BLOCK_NUMBER=25155533
STABLES_E2E_ACCOUNT_INDEX=1
STABLES_E2E_USDT0_ETH_AMOUNT=500000000
BITCOIN_CORE_IMAGE=boltz/bitcoin-core:latest
ELEMENTS_IMAGE=boltz/elements:latest
ELECTRS_IMAGE=boltz/electrs:latest
Expand Down
4 changes: 2 additions & 2 deletions data/backend/boltz.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ maxSwapAmount = 4_294_967
minSwapAmount = 50_000

[pairs.timeoutDelta]
chain= 1440
chain = 1440
reverse = 1440
swapMinimal = 1440
swapMaximal = 2880
Expand All @@ -104,7 +104,7 @@ swapTypes = ["chain"]
minSwapAmount = 25_000

[pairs.timeoutDelta]
chain= 1440
chain = 1440
reverse = 1440
swapMinimal = 1440
swapMaximal = 2880
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ services:
anvil-eth:
condition: service_healthy
required: false
stables-e2e-wallet:
condition: service_completed_successfully
required: false
regtest-start:
condition: service_completed_successfully
postgres:
Expand Down Expand Up @@ -293,6 +296,33 @@ services:
start_period: 0s
profiles: ['default', 'ci', 'backend-dev', 'webapp-ci']

anvil-eth:
<<: *base-anvil
hostname: anvil-eth
container_name: anvil-eth
environment:
FORK_RPC_URL: ${ETHEREUM_E2E_RPC_URL:-}
FORK_BLOCK_NUMBER: ${ETHEREUM_E2E_BLOCK_NUMBER}
CHAIN_ID: 1
ports:
- ${ETHEREUM_E2E_PORT:-18546}:8545

stables-e2e-wallet:
hostname: stables-e2e-wallet
container_name: stables-e2e-wallet
image: ${SCRIPTS_IMAGE}
depends_on:
anvil-eth:
condition: service_healthy
environment:
STABLES_E2E_ACCOUNT_INDEX: ${STABLES_E2E_ACCOUNT_INDEX:-1}
STABLES_E2E_USDT0_ETH_AMOUNT: ${STABLES_E2E_USDT0_ETH_AMOUNT:-500000000}
STABLES_E2E_USDT0_ETH_TOKEN: ${STABLES_E2E_USDT0_ETH_TOKEN:-0xdAC17F958D2ee523a2206206994597C13D831ec7}
STABLES_E2E_USDT0_ETH_FUNDING_SOURCE: ${STABLES_E2E_USDT0_ETH_FUNDING_SOURCE:-0xF977814e90dA44bFA03b6295A0616a897441aceC}
command:
['/bin/bash', '-c', 'source /etc/profile.d/utils.sh && fund-stables-e2e-wallet']
profiles: ['stables-e2e']

anvil-arb:
<<: *base-anvil
hostname: anvil-arb
Expand Down
53 changes: 53 additions & 0 deletions images/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,59 @@ wait-for-cln-sync(){
done
}

# Funds an Anvil account with USDT0-ETH on the Ethereum e2e fork by
# impersonating a whale funding source and transferring tokens from it.
fund-stables-e2e-wallet() {
set -euo pipefail

local rpc_url="http://anvil-eth:8545"
local account_index="${STABLES_E2E_ACCOUNT_INDEX:-1}"
local amount="${STABLES_E2E_USDT0_ETH_AMOUNT:-500000000}"
local token="${STABLES_E2E_USDT0_ETH_TOKEN:-0xdAC17F958D2ee523a2206206994597C13D831ec7}"
local funding_source="${STABLES_E2E_USDT0_ETH_FUNDING_SOURCE:-0xF977814e90dA44bFA03b6295A0616a897441aceC}"

rpc() { cast rpc --rpc-url "$rpc_url" "$@"; }

if ! [[ "$account_index" =~ ^[0-9]+$ ]]; then
echo "STABLES_E2E_ACCOUNT_INDEX must be a non-negative integer" >&2
return 1
fi

local wallet_address
wallet_address="$(rpc eth_accounts | jq -r --argjson index "$account_index" '.[$index] // empty')"
if [ -z "$wallet_address" ]; then
echo "missing Anvil account at STABLES_E2E_ACCOUNT_INDEX=$account_index" >&2
return 1
fi

if [ "$(cast code --rpc-url "$rpc_url" "$token")" = "0x" ]; then
echo "missing USDT0-ETH token contract on Ethereum e2e fork" >&2
return 1
fi

rpc anvil_setBalance "$wallet_address" 0x8ac7230489e80000 # 10 ETH for gas
rpc anvil_setBalance "$funding_source" 0xde0b6b3a7640000 # 1 ETH for gas
rpc anvil_impersonateAccount "$funding_source"
trap 'rpc anvil_stopImpersonatingAccount "$funding_source" >/dev/null || true' RETURN

cast send \
--rpc-url "$rpc_url" \
--unlocked \
--from "$funding_source" \
"$token" \
"transfer(address,uint256)" \
"$wallet_address" \
"$amount"

# cast call annotates the result as "<value> (uint256)"; keep only the value.
local wallet_balance
wallet_balance="$(cast call --rpc-url "$rpc_url" "$token" "balanceOf(address)(uint256)" "$wallet_address" | awk '{print $1}')"
if [ "$wallet_balance" -lt "$amount" ]; then
echo "failed to fund stables e2e wallet" >&2
return 1
fi
}

# Deploy contracts
deploy_contract() {
cast send --rpc-url http://anvil:8545 --private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --create $1
Expand Down