Test hummingbot API with globiance exchange
Notice: The globiance exchange is not ready on testnet(apothem) now.
According to https://raw.githubusercontent.com/pro100skm/xdc-token-list/master/mainnet.tokenlist.json, 0x951857744785E80e2De051c32EE7b25f9c458C42 is WXDC, 0x8A3cc832Bb6B255622E92dc9d4611F2A94d200DA is GBEX-WXDC.
Setup enviroment according to instructions before test.
Set allowances to maximum for each test token.
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"$XDC_ADDRESS"'",
"spender": "globiance",
"token": "GBEX"
}' | jq
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"$XDC_ADDRESS"'",
"spender": "globiance",
"token": "SRX"
}' | jq
xinfin
# set GBEX allowance for globiance
https --print=h POST ${SERVER}/evm/approve chain=xdc network=xinfin address=${XDC_ADDRESS} spender=globiance token=GBEX
# set SRX allowance for globiance
https --print=h POST ${SERVER}/evm/approve chain=xdc network=xinfin address=${XDC_ADDRESS} spender=globiance token=SRX
xinfin
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/allowances" -d '{
"chain": "xdc",
"network": "xinfin",
"address": "'"$XDC_ADDRESS"'",
"spender": "globiance",
"tokenSymbols": ["GBEX", "SRX"]
}' | jq
xinfin
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} spender=globiance tokenSymbols:='["GBEX", "SRX"]'
xinfin
# buy SRX, quote with GBEX
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/amm/price" -d '{
"connector": "globiance",
"chain": "xdc",
"network": "xinfin",
"base": "SRX",
"quote": "GBEX",
"amount": "1",
"side": "BUY"
}' | jq
# sell SRX, quote with GBEX
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/amm/price" -d '{
"connector": "globiance",
"chain": "xdc",
"network": "xinfin",
"base": "SRX",
"quote": "GBEX",
"amount": "1",
"side": "SELL"
}' | jq
xinfin
# buy SRX, quote with GBEX
https --print=b POST ${SERVER}/amm/price connector=globiance chain=xdc network=xinfin quote=GBEX amount=1 base=SRX side=BUY
# sell SRX, quote with GBEX
https --print=b POST ${SERVER}/amm/price connector=globiance chain=xdc network=xinfin quote=GBEX amount=1 base=SRX side=SELL
We will check balances of base and quote tokens before and after trade. Notice: wait 3-4 seconds to send next request.
xinfin
# buy SRX, quote with GBEX
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/amm/trade" -d '{
"address": "'"$XDC_ADDRESS"'",
"base": "SRX",
"quote": "GBEX",
"amount": "1",
"side": "BUY",
"chain": "xdc",
"network": "xinfin",
"connector": "globiance"
}' | jq
# sell SRX, quote with GBEX
curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/amm/trade" -d '{
"address": "'"$XDC_ADDRESS"'",
"base": "SRX",
"quote": "GBEX",
"amount": "1",
"side": "SELL",
"chain": "xdc",
"network": "xinfin",
"connector": "globiance"
}' | jq
xinfin
# query GBEX and SRX balances before buy
https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin address=${XDC_ADDRESS} tokenSymbols:='["GBEX", "SRX"]'
# buy SRX, quote with GBEX
https --print=h POST ${SERVER}/amm/trade connector=globiance chain=xdc network=xinfin address=${XDC_ADDRESS} quote=GBEX amount=1 base=SRX side=BUY
# query GBEX and SRX balances after buy
https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin address=${XDC_ADDRESS} tokenSymbols:='["GBEX", "SRX"]'
# query GBEX and SRX balances before sell
https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin address=${XDC_ADDRESS} tokenSymbols:='["GBEX", "SRX"]'
# sell SRX, quote with GBEX
https --print=h POST ${SERVER}/amm/trade connector=globiance chain=xdc network=xinfin address=${XDC_ADDRESS} quote=GBEX amount=1 base=SRX side=SELL
# query GBEX and SRX balances after sell
https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin address=${XDC_ADDRESS} tokenSymbols:='["GBEX", "SRX"]'