Skip to content

Latest commit

 

History

History
189 lines (137 loc) · 5.44 KB

test-globiance.md

File metadata and controls

189 lines (137 loc) · 5.44 KB

Test globiance exchange

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.

Preparations

1. Setup enviroment

Setup enviroment according to instructions before test.

Test cases

1. Approve allowance

Set allowances to maximum for each test token.

1.1 If use curl

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

1.2 If use httpie

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

1666779725755

2. Query allowances

2.1 If use curl

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

2.2 If use httpie

xinfin

https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} spender=globiance tokenSymbols:='["GBEX", "SRX"]'

1666779804001

3. fetch token price

3.1 If use curl

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

3.2 If use httpie

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

1666779895385

4. Trade

We will check balances of base and quote tokens before and after trade. Notice: wait 3-4 seconds to send next request.

4.1 If use curl

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

4.2 If use httpie

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"]'

1666780493107

# 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"]'

1666780585280