Skip to content
Merged
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
19 changes: 0 additions & 19 deletions configs/local/orderbook.toml

This file was deleted.

11 changes: 11 additions & 0 deletions playground/configs/autopilot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ filter = "warn,autopilot=debug,shared=info,price_estimation=info"
[current-block]
poll-interval = "1s"

[run-loop]
solve-deadline = "20s"

[[gas-estimators]]
type = "Web3"

Expand All @@ -20,6 +23,14 @@ address = "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"

[fee-policies]

[database]
write-url = "%DB_WRITE_URL"
read-url = "%DB_READ_URL"

[ethflow]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change should be necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing here that it's a required value and it gave me errors without it. Perhaps I'm wrong but it seemed like it just didn't have that value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't hurt being here, but it shouldnt be required, it just wont index ethflow trades

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_playground actually creates an EthFlow order, so this should be here because of it.

contracts = ["0x04501b9b1d52e67f6862d157e00d13419d2d6e95"]
skip-event-sync = true

[order-quoting]
price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }]

Expand Down
16 changes: 12 additions & 4 deletions playground/configs/orderbook.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
eip1271-skip-creation-validation = true
bind-address = "0.0.0.0:80"

[order-quoting]
price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }]
[shared]
node-url = "http://chain:8545"
simulation-node-url = "http://chain:8545"

[native-price-estimation]
estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]]
[shared.tracing]
collector-endpoint = "http://tempo:4317"

[database]
write-url = "%DB_WRITE_URL"
read-url = "%DB_READ_URL"

[native-price-estimation]
estimators = [[{ type = "Driver", name = "baseline", url = "http://driver/baseline" }]]

[order-quoting]
price-estimation-drivers = [{ name = "baseline", url = "http://driver/baseline" }]
19 changes: 0 additions & 19 deletions playground/orderbook.toml

This file was deleted.

12 changes: 3 additions & 9 deletions playground/tempo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ distributor:
grpc:
endpoint: 0.0.0.0:4317

ingester:
trace_idle_period: 10s
max_block_bytes: 1_000_000

compactor:
compaction:
compacted_block_retention: 1h

storage:
trace:
backend: local
wal:
path: /tmp/tempo/wal
local:
path: /tmp/tempo
path: /tmp/tempo/blocks
55 changes: 46 additions & 9 deletions playground/test_playground.sh
Comment thread
jmg-duarte marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -u

# Setup parameters
HOST=localhost:8080
OTTERSCAN_URL=http://localhost:8003
WETH_ADDRESS="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" # WETH token
SELL_TOKEN=$WETH_ADDRESS
BUY_TOKEN="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" # USDC token
Expand All @@ -21,19 +22,19 @@ APPDATA='{"version":"1.3.0","metadata":{}}'
PRIVATE_KEY="0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"

# Wait for 2 minutes for all services are read
echo "Waiting until all services are ready"
echo -e "\n Waiting until all services are ready..."
curl --retry 24 --retry-delay 5 --retry-all-errors --fail-with-body -s --show-error \
-H 'accept:application/json' \
http://$HOST/api/v1/token/$BUY_TOKEN/native_price > /dev/null

# Run test flow
echo "Using private key:" $PRIVATE_KEY
echo -e "\n Private key: $PRIVATE_KEY"
receiver=$(cast wallet address $PRIVATE_KEY)

# Calculate AppData hash
app_data_hash=$(cast keccak $APPDATA)

echo "Request price quote for buying USDC for WETH"
echo -e "\n>>> Requesting price quote for buying USDC for WETH..."
quote_response=$( curl --retry 5 --fail-with-body -s --show-error -X 'POST' \
"http://$HOST/api/v1/quote" \
-H 'accept: application/json' \
Expand Down Expand Up @@ -78,8 +79,10 @@ orderUid=$(docker exec playground-chain-1 cast abi-encode \
"$COW_ETHFLOW_CONTRACT" \
"0xffffffff"
)
echo "Order UID: $orderUid"
echo " Order UID: $orderUid"
echo

echo -e ">>> Creating order on-chain...\n"
docker exec playground-chain-1 cast send \
--json \
--private-key "$PRIVATE_KEY" \
Expand All @@ -88,14 +91,48 @@ docker exec playground-chain-1 cast send \
"createOrder((address, address, uint256, uint256, bytes32, uint256, uint32, bool, int64))" \
"($BUY_TOKEN,$receiver,$sellAmount,$buyAmount,$app_data_hash,$feeAmount,$validTo,false,$quoteId)" > /dev/null

print_settlement_tx() {
trade_response=$(curl --retry 5 --fail-with-body -s --show-error -X 'GET' \
"http://$HOST/api/v1/trades?orderUid=$orderUid" \
-H 'accept: application/json')
tx_hash=$(jq -r '.[0].txHash // empty' <<< "${trade_response}")

if [ -n "$tx_hash" ]; then
echo -e "\n--------------------------------------------------------------- SUCCESS ----------------------------------------------------------------"
echo " Settlement tx hash: $tx_hash"
echo " Inspect with: cast receipt $tx_hash --rpc-url http://localhost:8545"
echo " Open in Otterscan: $OTTERSCAN_URL/tx/$tx_hash"
echo "----------------------------------------------------------------------------------------------------------------------------------------"
else
echo "Settlement tx hash not available yet"
fi
}

echo ">>> Polling order status..."
for i in $(seq 1 24);
do
orderStatus=$( curl --retry 5 --fail-with-body -s --show-error -X 'GET' \
"http://$HOST/api/v1/orders/$orderUid/status" \
-H 'accept: application/json' | jq -r '.type')
echo -e -n "Order status: $orderStatus \r"
status_response=$(curl --retry 5 --retry-delay 2 --retry-all-errors -s --show-error --max-time 10 --connect-timeout 3 \
-H 'accept: application/json' \
Comment thread
igorroncevic marked this conversation as resolved.
-w '\n%{http_code}' \
"http://$HOST/api/v1/orders/$orderUid/status") || {
echo "Polling failed while checking order status"
exit 1
}
status_http_code=$(tail -n 1 <<< "${status_response}")
status_body=$(sed '$d' <<< "${status_response}")

if [ "$status_http_code" = "404" ]; then
orderStatus="indexing"
elif [ "$status_http_code" = "200" ]; then
orderStatus=$(jq -r '.type' <<< "${status_body}")
else
echo "Unexpected order status response ($status_http_code): ${status_body}"
exit 1
fi

echo " Order status: $orderStatus"
if [ "$orderStatus" = "traded" ]; then
echo -e "\nSuccess"
print_settlement_tx
exit 0
fi
sleep 5
Expand Down
Loading