Get Pools Info
This page shows how to retrieve pool data from Aquarius AMM.
You can retrieve information about pools in two ways: by calling smart contract methods or by using the Aquarius backend API.
Pool details are also displayed on the Aquarius website, on pool info page - e.g. https://aqua.network/pools/CCY2PXGMKNQHO7WNYXEWX76L2C5BH3JUW3RCATGUYKY7QQTRILBZIFWV/
Using smart contracts: Step by Step Guide
Since calling contract methods does not alter the Stellar network and is executed through transaction simulation, a transaction signature is not required, and the call can be made using a public key. Scroll here to see the complete code.
Specify user public key and tokens
# AQUA issuer - we don't call user related information in our simulations, so any public key is fine
USER_PUBLIC_KEY = 'GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA'
# XLM
TOKEN_A = Asset.native()
# AQUA
TOKEN_B = Asset('AQUA', 'GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA')// AQUA issuer - we don't call user related information in our simulations, so any public key is fine
const userPublicKey = 'GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA'
// XLM
const tokenA = Asset.native();
// AQUA
const tokenB = new Asset('AQUA','GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA');Retrieve a list of pools with specified tokens.
def get_pools(server, address, router_contract_id, tokens: list[Asset]) -> dict:
tx_builder = TransactionBuilder(
source_account=server.load_account(address),
network_passphrase=NETWORK_PASSPHRASE,
base_fee=1000000 # Set base fee; adjust as necessary
).set_timeout(3600) # Set transaction timeout
tx = (
tx_builder
.append_invoke_contract_function_op(
contract_id=router_contract_id,
function_name="get_pools",
parameters=[
scval.to_vec(order_token_ids([
Address(token.contract_id(NETWORK_PASSPHRASE)).to_xdr_sc_val()
for token in tokens
])),
],
)
.build()
)
simulation = server.simulate_transaction(tx)
tx_result = [xdr.SCVal.from_xdr(r.xdr) for r in simulation.results][0]
if not tx_result:
raise RuntimeError
return {
entry.key.bytes.sc_bytes.hex(): StrKey.encode_contract(binascii.unhexlify(entry.val.address.contract_id.hash.hex()))
for entry in tx_result.map.sc_map
}Retrieve information about each pool obtained in the previous step.
Complete Code Examples
Using backend API
Last updated