### Example of Generalized CosmWasm Pool Implementation (Go) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md An example of implementing a generalized CosmWasm pool type that interacts with the chain for quotes and spot prices. This involves making network API queries. ```go package pools import ( "context" "fmt" "math/big" "github.com/osmosis-labs/sqs/router/types" "github.com/osmosis-labs/sqs/sqsrouter" // Assume necessary imports for chain interaction (e.g., Tendermint RPC client) ) // RoutableCosmWasmPool implements sqsrouter.RoutablePool for generalized CosmWasm pools. type RoutableCosmWasmPool struct { // ... pool specific fields, including chain client chainClient sqsrouter.ChainClient codeID uint64 poolID uint64 } func NewRoutableCosmWasmPool(chainClient sqsrouter.ChainClient, codeID, poolID uint64 /*...*/) *RoutableCosmWasmPool { // ... initialization logic return &RoutableCosmWasmPool{chainClient: chainClient, codeID: codeID, poolID: poolID} } func (p *RoutableCosmWasmPool) PoolID() uint64 { return p.poolID } func (p *RoutableCosmWasmPool) AssetDenoms() []string { // ... fetch denoms from chain via chainClient return nil } func (p *RoutableCosmWasmPool) QuoteAsset() string { // ... determine quote asset from chain return "" } func (p *RoutableCosmWasmPool) GetSpotPrice(ctx context.Context, tokenIn, tokenOut string) (*big.Int, error) { // Make an API query to the chain for spot price spotPrice, err := p.chainClient.QueryWasmSmart(ctx, p.codeID, p.poolID, []byte(fmt.Sprintf(`{\"spot_price\": {\"token_in\": \"%s\", \"token_out\": \"%s\"}}`, tokenIn, tokenOut))) if err != nil { return nil, fmt.Errorf("failed to get spot price from chain: %w", err) } // Parse the response from the chain // ... parse spotPrice return nil, nil } func (p *RoutableCosmWasmPool) GetTotalPoolLiquidity(ctx context.Context) ([]types.PoolBalance, error) { // Make an API query to the chain for total liquidity // ... query chainClient return nil, fmt.Errorf("not implemented for generalized CosmWasm pool") } func (p *RoutableCosmWasmPool) GetUserLiquidity(ctx context.Context, address string) ([]types.PoolBalance, error) { // Make an API query to the chain for user liquidity // ... query chainClient return nil, fmt.Errorf("not implemented for generalized CosmWasm pool") } func (p *RoutableCosmWasmPool) GetQuoteAmount(ctx context.Context, tokenIn, tokenOut string, amountIn *big.Int) (*big.Int, error) { // Make an API query to the chain for quote amount quoteAmount, err := p.chainClient.QueryWasmSmart(ctx, p.codeID, p.poolID, []byte(fmt.Sprintf(`{\"swap\": {\"token_in\": \"%s\", \"token_out\": \"%s\"}}`, tokenIn, tokenOut))) if err != nil { return nil, fmt.Errorf("failed to get quote amount from chain: %w", err) } // Parse the response from the chain // ... parse quoteAmount return nil, nil } func (p *RoutableCosmWasmPool) IsActive() bool { // ... check pool status, potentially via chain query return true } var _ sqsrouter.RoutablePool = (*RoutableCosmWasmPool)(nil) ``` -------------------------------- ### Start Osmosis SQS Service Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Commands to start the Osmosis SQS service for development against mainnet. Requires node configuration in `app.toml` and uses the `config.json` from the repository root. ```bash # Starts the Osmosis node from the default $HOME directory # Starts sqs from the config.json in the root of this repository make all-start ``` -------------------------------- ### Setup Testing Environment (Bash) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/tests/README.md Commands to set up a Python virtual environment and install necessary requirements for E2E testing. ```bash make e2e-setup-venv make e2e-source-venv make e2e-install-requirements ``` -------------------------------- ### Start Order Book Filler Bot via Docker Compose Source: https://github.com/osmosis-labs/sqs/blob/v28.x/ingest/usecase/plugins/orderbook/fillbot/README.md Instructions to navigate to the fillbot directory and start the order book filler service using Docker Compose, after ensuring all configurations are complete. ```bash # Ensure "Configuration" section is complete. # From project root, cd into ingest/usecase/plugins/orderbook/fillbot # Update .env with your environment variables. make orderbook-fillbot-start ``` -------------------------------- ### Example Token Liquidity Capitalizations Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/routing.md Illustrates the total liquidity capitalizations across all pools for different tokens used in routing examples. This data is used to determine applicable liquidity filters. ```text - ATOM -> $2M - JUNO -> $300K - BONK -> $1K ``` -------------------------------- ### Example Liquidity Thresholds Configuration Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/routing.md Demonstrates the configuration of thresholds for mapping token liquidity capitalization to specific filters. This example shows a descending order of liquidity values and their corresponding filter values. ```text 1_000_000 -> 100_000 50_000 -> 10_000 ``` -------------------------------- ### Example of Routable Transmuter Pool Implementation (Go) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md An example of implementing a pool type similar to transmuter for custom CosmWasm pools. This involves writing Go code to handle quote and spot price logic directly within SQS. ```go package pools import ( "context" "fmt" "math/big" "github.com/osmosis-labs/sqs/router/types" "github.com/osmosis-labs/sqs/sqsrouter" ) // RoutableTransmuterPool implements sqsrouter.RoutablePool for transmuter-like pools. type RoutableTransmuterPool struct { // ... pool specific fields } func NewRoutableTransmuterPool(/*...*/) *RoutableTransmuterPool { // ... initialization logic return &RoutableTransmuterPool{} } func (p *RoutableTransmuterPool) PoolID() uint64 { // ... return pool ID return 0 } func (p *RoutableTransmuterPool) AssetDenoms() []string { // ... return asset denoms return nil } func (p *RoutableTransmuterPool) QuoteAsset() string { // ... return quote asset denom return "" } func (p *RoutableTransmuterPool) GetSpotPrice(ctx context.Context, tokenIn, tokenOut string) (*big.Int, error) { // ... implement spot price logic for transmuter pool fmt.Printf("Getting spot price for %s -> %s\n", tokenIn, tokenOut) return nil, fmt.Errorf("not implemented for transmuter pool") } func (p *RoutableTransmuterPool) GetTotalPoolLiquidity(ctx context.Context) ([]types.PoolBalance, error) { // ... implement liquidity logic return nil, fmt.Errorf("not implemented for transmuter pool") } func (p *RoutableTransmuterPool) GetUserLiquidity(ctx context.Context, address string) ([]types.PoolBalance, error) { // ... implement user liquidity logic return nil, fmt.Errorf("not implemented for transmuter pool") } func (p *RoutableTransmuterPool) GetQuoteAmount(ctx context.Context, tokenIn, tokenOut string, amountIn *big.Int) (*big.Int, error) { // ... implement quote amount logic for transmuter pool fmt.Printf("Getting quote amount for %s (%s) -> %s\n", amountIn.String(), tokenIn, tokenOut) return nil, fmt.Errorf("not implemented for transmuter pool") } func (p *RoutableTransmuterPool) IsActive() bool { // ... return pool active status return true } var _ sqsrouter.RoutablePool = (*RoutableTransmuterPool)(nil) ``` -------------------------------- ### Get All Token Swap Routes (Bash) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Lists all available routing paths for swapping between specified input and output tokens. Useful for understanding liquidity and potential swap options. Requires tokenIn and tokenOutDenom. ```bash curl "https://sqs.osmosis.zone/router/routes?tokenIn=uosmo&tokenOutDenom=uion" | jq . ``` -------------------------------- ### Get All Pools Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves a list of all available liquidity pools. This endpoint is available in the production environment. ```APIDOC ## GET /pools ### Description Retrieves a list of all available liquidity pools. ### Method GET ### Endpoint /pools ### Parameters #### Query Parameters - **include_all_pairs** (boolean) - Optional - If true, includes all pairs, even those with zero liquidity. ### Request Example ``` (No request body for GET requests) ``` ### Response #### Success Response (200) - **data** (array) - An array of pool objects. - **id** (string) - The unique identifier for the pool. - **type** (string) - The type of the pool (e.g., "Balancer", "ConcentratedLiquidity"). - **token0Denom** (string) - The denomination of the first token in the pool. - **token1Denom** (string) - The denomination of the second token in the pool. - **token0Weight** (string) - The weight of the first token in the pool. - **token1Weight** (string) - The weight of the second token in the pool. #### Response Example ```json [ { "id": "1", "type": "Balancer", "token0Denom": "uosmo", "token1Denom": "uakt", "token0Weight": "500000000000000000", "token1Weight": "500000000000000000" }, { "id": "2", "type": "Balancer", "token0Denom": "uosmo", "token1Denom": "ibc/273F9532D301883B0B57214D83234E30A3480E3A8517BB274E78E7256A628539", "token0Weight": "500000000000000000", "token1Weight": "500000000000000000" } ] ``` ``` -------------------------------- ### GET /tokens/prices Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Fetches spot prices for token pairs. Allows specifying base denominations in human-readable format. ```APIDOC ## GET /tokens/prices ### Description Retrieves spot prices for token pairs. Allows specifying base denominations in human-readable format. ### Method GET ### Endpoint /tokens/prices ### Parameters #### Query Parameters - **base** (string) - Comma-separated list of base denominations (human-readable or chain format based on humanDenoms parameter). - **humanDenoms** (boolean) - Specify true if input denominations are in human-readable format; defaults to false. ### Response #### Success Response (200) A map where each key is a base denomination (on-chain format), containing another map with a key as the quote denomination (on-chain format) and the value as the spot price. #### Response Example ```json { "ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C": { "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858": "3.104120355715761583051226000000000000" }, "ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F": { "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858": "51334.702258726899383983572895277207392200" } } ``` ``` -------------------------------- ### Get Token Prices Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves the current prices for all supported tokens. This endpoint is available in the production environment. ```APIDOC ## GET /tokens/prices ### Description Retrieves the current prices for all supported tokens. ### Method GET ### Endpoint /tokens/prices ### Parameters #### Query Parameters - None ### Request Example ``` (No request body for GET requests) ``` ### Response #### Success Response (200) - **data** (object) - An object containing token prices, where keys are token symbols and values are their prices. - **symbol** (string) - The symbol of the token. - **price** (string) - The current price of the token as a string representing a decimal number. #### Response Example ```json { "data": { "ATOM": "3.52145", "OSMO": "0.87654" } } ``` ``` -------------------------------- ### Run SQS with Combined Configuration Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/config.md This Docker command illustrates running SQS with both a configuration file and environment variables. Environment variables will take precedence, overriding any conflicting settings in the configuration file. ```bash docker run -d --name sqs \ -v /path/to/your/config.json:/osmosis/config.json:ro \ -e SQS_SERVER_ADDRESS=":9093" \ -p 9093:9093 \ osmolabs/sqs:local \ -config /osmosis/config.json ``` -------------------------------- ### Run SQS with a Configuration File Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/config.md This Docker command demonstrates how to run the SQS service using a custom configuration file mounted into the container. The configuration file's settings will be applied, subject to environment variable overrides. ```bash docker run -d --name sqs \ -v /path/to/your/config.json:/osmosis/config.json:ro \ -p 9092:9092 \ osmolabs/sqs:local \ -config /osmosis/config.json ``` -------------------------------- ### Query All Pools Source: https://github.com/osmosis-labs/sqs/blob/v28.x/router/README.md Fetches all available pools from the router. This is a simple GET request to the pools endpoint. ```bash curl "localhost:9092/pools/all" | jq . ``` -------------------------------- ### GET /router/routes Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves all available trading routes between a specified input token and output token denomination. ```APIDOC ## GET /router/routes ### Description Returns all routes that can be used for routing from tokenIn to tokenOutDenom. ### Method GET ### Endpoint /router/routes ### Parameters #### Query Parameters - **tokenIn** (string) - Required - The string representation of the denom of the token in. - **tokenOutDenom** (string) - Required - The string representing the denom of the token out. - **humanReadable** (boolean) - Optional - Boolean flag indicating whether a human readable denom is given as opposed to chain. ### Response #### Success Response (200) - **Routes** (array) - A list of possible trading routes. - **Pools** (array) - The pools constituting a route. - **ID** (integer) - The ID of the pool. - **TokenOutDenom** (string) - The denomination of the token swapped out of the pool. - **UniquePoolIDs** (object) - An object containing unique pool IDs involved in the routes. #### Response Example ```json { "Routes": [ { "Pools": [ { "ID": 1100, "TokenOutDenom": "uion" } ] }, { "Pools": [ { "ID": 2, "TokenOutDenom": "uion" } ] }, { "Pools": [ { "ID": 1013, "TokenOutDenom": "uion" } ] }, { "Pools": [ { "ID": 1092, "TokenOutDenom": "ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1" }, { "ID": 476, "TokenOutDenom": "uion" } ] }, { "Pools": [ { "ID": 1108, "TokenOutDenom": "ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84" }, { "ID": 26, "TokenOutDenom": "uion" } ] } ], "UniquePoolIDs": { "1013": {}, "1092": {}, "1100": {}, "1108": {}, "2": {}, "26": {}, "476": {} } } ``` ``` -------------------------------- ### Run SQS with Environment Variable Overrides Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/config.md This Docker command shows how to configure the SQS service by setting specific environment variables. These variables override default configurations and any settings in a configuration file. ```bash docker run -d --name sqs \ -e SQS_SERVER_ADDRESS=":9093" \ -e SQS_LOGGER_LEVEL="debug" \ -e SQS_ROUTER_MAX_POOLS_PER_ROUTE="5" \ -p 9093:9093 \ osmolabs/sqs:local ``` -------------------------------- ### Get Token Metadata Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves metadata for all supported tokens. This endpoint is available in the production environment. ```APIDOC ## GET /tokens/metadata ### Description Retrieves metadata for all supported tokens. ### Method GET ### Endpoint /tokens/metadata ### Parameters #### Query Parameters - None ### Request Example ``` (No request body for GET requests) ``` ### Response #### Success Response (200) - **data** (object) - An object containing token metadata, where keys are token symbols and values are token details. - **symbol** (string) - The symbol of the token. - **name** (string) - The name of the token. - **channelId** (string) - The IBC channel ID for the token. - **decimals** (integer) - The number of decimal places for the token. - **iconUrl** (string) - The URL of the token's icon. #### Response Example ```json { "data": { "ATOM": { "symbol": "ATOM", "name": "Cosmos Hub", "channelId": "channel-0", "decimals": 6, "iconUrl": "https://raw.githubusercontent.com/cosmology-tech/chain-registry/master/cosmos/images/atom.png" }, "OSMO": { "symbol": "OSMO", "name": "Osmosis", "channelId": "channel-0", "decimals": 6, "iconUrl": "https://raw.githubusercontent.com/cosmology-tech/chain-registry/master/osmosis/images/osmosis.png" } } } ``` ``` -------------------------------- ### GET /pools Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves a list of all liquidity pools. If the 'IDs' query parameter is provided, it fetches specific pools by their IDs. ```APIDOC ## GET /pools ### Description Retrieves a list of all liquidity pools. If the 'IDs' query parameter is provided, it fetches specific pools by their IDs. ### Method GET ### Endpoint /pools ### Parameters #### Query Parameters - **IDs** (string) - Optional - The comma-separated list of pool IDs to batch fetch. If not provided, all pools are returned. ### Request Example ``` curl "http://localhost:9092/pools?IDs=1,2" ``` ### Response #### Success Response (200) - **chain_model** (object) - Details about the pool's configuration and assets. - **address** (string) - The contract address of the pool. - **id** (integer) - The unique identifier of the pool. - **pool_params** (object) - Parameters related to swapping and fees. - **swap_fee** (string) - The fee charged for swaps. - **exit_fee** (string) - The fee charged for exiting the pool. - **future_pool_governor** (string) - The governance period for future pool parameters. - **total_weight** (string) - The total weight of assets in the pool. - **total_shares** (object) - Information about the total shares in the pool. - **denom** (string) - The denomination of the pool shares. - **amount** (string) - The total amount of pool shares. - **pool_assets** (array) - An array of assets within the pool. - **token** (object) - Details of a specific token asset. - **denom** (string) - The denomination of the token. - **amount** (string) - The amount of the token in the pool. - **weight** (string) - The weight of the token in the pool. - **balances** (array) - An array of the current balances for each asset in the pool. - **denom** (string) - The denomination of the asset. - **amount** (string) - The amount of the asset. - **type** (integer) - The type of the pool. - **spread_factor** (string) - The spread factor applied to trades. #### Response Example ```json [ { "chain_model": { "address": "osmo1mw0ac6rwlp5r8wapwk3zs6g29h8fcscxqakdzw9emkne6c8wjp9q0t3v8t", "id": 1, "pool_params": { "swap_fee": "0.002000000000000000", "exit_fee": "0.000000000000000000" }, "future_pool_governor": "24h", "total_weight": "1073741824000000.000000000000000000", "total_shares": { "denom": "gamm/pool/1", "amount": "68705408290810473783205087" }, "pool_assets": [ { "token": { "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", "amount": "1099147835604" }, "weight": "536870912000000" }, { "token": { "denom": "uosmo", "amount": "6560821009725" }, "weight": "536870912000000" } ] }, "balances": [ { "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", "amount": "1099147835604" }, { "denom": "ibc/9989AD6CCA39D1131523DB0617B50F6442081162294B4795E26746292467B525", "amount": "1000000000" }, { "denom": "ibc/B9E0A1A524E98BB407D3CED8720EFEFD186002F90C1B1B7964811DD0CCC12228", "amount": "999800" }, { "denom": "uosmo", "amount": "6560821009725" } ], "type": 0, "spread_factor": "0.002000000000000000" } ] ``` -------------------------------- ### Enable Custom CosmWasm Pool (Option 2) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Guides on how to enable support for custom CosmWasm pools by utilizing a generalized CosmWasm pool type. This requires adding the code ID to 'general-cosmwasm-code-ids' in the config.json. ```json { "general-cosmwasm-code-ids": [ // ... other code IDs "YOUR_CODE_ID_HERE" ] } ``` -------------------------------- ### Get Best Token Swap Quote (Bash) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves the most efficient swap quote between two tokens. Allows specifying single route preference to exclude token splits. Requires tokenIn and tokenOutDenom. ```bash curl "https://sqs.osmosis.zone/router/quote?tokenIn=1000000uosmo&tokenOutDenom=uion?singleRoute=false" | jq . ``` -------------------------------- ### Get Quote for Token Swap Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Calculates the best quote for swapping a specified amount of one token for another. This endpoint is available in the production environment. ```APIDOC ## GET /router/quote ### Description Calculates the best quote for swapping a specified amount of one token for another, considering all available pools and routing strategies. ### Method GET ### Endpoint /router/quote ### Parameters #### Query Parameters - **from_symbol** (string) - Required - The symbol of the token to swap from. - **to_symbol** (string) - Required - The symbol of the token to swap to. - **amount** (string) - Required - The amount of the token to swap from, as a string representing a decimal number. - **max_split** (integer) - Optional - The maximum number of pools to split the swap across. Defaults to 5. - **optimistic** (boolean) - Optional - If true, the quote may be slightly off due to real-time price fluctuations. Defaults to false. ### Request Example ``` (No request body for GET requests) ``` ### Response #### Success Response (200) - **result** (string) - The amount of the `to_symbol` token that can be received for the given swap, as a string representing a decimal number. #### Response Example ```json { "result": "10.56789" } ``` ``` -------------------------------- ### Enable Custom CosmWasm Pool (Option 1) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Guides on how to enable support for custom CosmWasm pools by implementing a pool type directly in SQS. This involves updating the config.json with a new field under 'pools'. ```json { "pools": [ // ... other pool configurations { "custom_pool_type": "new_transmuter_like" } ] } ``` -------------------------------- ### GET /router/quote Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves the best possible swap quote for a given input token and output token denomination. Supports an option to exclude routes involving token splits. ```APIDOC ## GET /router/quote ### Description Returns the best quote it can compute for the given tokenIn and tokenOutDenom. If `singleRoute` parameter is set to true, it gives the best single quote while excluding splits. ### Method GET ### Endpoint /router/quote ### Parameters #### Query Parameters - **tokenIn** (string) - Required - The string representation of the sdk.Coin for the token in. - **tokenOutDenom** (string) - Required - The string representing the denom of the token out. - **singleRoute** (boolean) - Optional - Boolean flag indicating whether to return single routes (no splits). False (splits enabled) by default. - **humanReadable** (boolean) - Optional - Boolean flag indicating whether a human readable denom is given as opposed to chain. ### Response #### Success Response (200) - **amount_in** (object) - The amount of input token. - **denom** (string) - The denomination of the input token. - **amount** (string) - The amount of the input token. - **amount_out** (string) - The calculated output amount. - **route** (array) - The recommended swap route. - **pools** (array) - The list of pools in the route. - **id** (integer) - The ID of the pool. - **type** (integer) - The type of the pool. - **balances** (array) - Balances of tokens in the pool. - **spread_factor** (string) - The spread factor of the pool. - **token_out_denom** (string) - The denomination of the token out of the pool. - **taker_fee** (string) - The taker fee for the pool. - **out_amount** (string) - The output amount for this route. - **in_amount** (string) - The input amount for this route. - **effective_fee** (string) - The effective fee for the entire route. #### Response Example ```json { "amount_in": { "denom": "uosmo", "amount": "1000000" }, "amount_out": "1803", "route": [ { "pools": [ { "id": 2, "type": 0, "balances": [], "spread_factor": "0.005000000000000000", "token_out_denom": "uion", "taker_fee": "0.001000000000000000" } ], "out_amount": "1803", "in_amount": "1000000" } ], "effective_fee": "0.006000000000000000" } ``` ``` -------------------------------- ### GET /tokens/metadata Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves token metadata, including chain denomination, human denomination, and precision. It uses testnet or mainnet asset lists based on the environment. ```APIDOC ## GET /tokens/metadata ### Description Returns token metadata including chain denom, human denom, and precision. Uses osmo-test-5 asset list for testnet and osmosis-1 for mainnet. ### Method GET ### Endpoint /tokens/metadata ### Parameters #### Query Parameters - **denoms** (list of strings) - Optional - A list of denoms (either human or chain denoms). If none are provided, metadata for all denoms is returned. ### Response #### Success Response (200) - **chain_denom** (string) - The on-chain denomination of the token. - **human_denom** (string) - The human-readable denomination of the token. - **precision** (integer) - The precision of the token. #### Response Example ```json { "chain_denom": "ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "human_denom": "statom", "precision": 6 } ``` ``` -------------------------------- ### Get Token Prices Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Fetches spot prices for specified token pairs. It accepts a comma-separated list of base denominations and an option to specify if denominations are human-readable. The response is a map of base denominations to quote denominations with their prices. ```bash curl https://sqs.osmosis.zone//tokens/prices?base=wbtc,dydx&humanDenoms=true { "ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C": { "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858": "3.104120355715761583051226000000000000" }, "ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F": { "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858": "51334.702258726899383983572895277207392200" } } ``` -------------------------------- ### GET /router/quote Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/routing.md Retrieves a quote for a swap, considering dynamic minimum liquidity capitalization. The `disableMinLiquidityFallback` parameter can be used to disable the fallback mechanism. ```APIDOC ## GET /router/quote ### Description Retrieves a quote for a swap, considering dynamic minimum liquidity capitalization. This endpoint allows clients to get routing information for token swaps. ### Method GET ### Endpoint /router/quote ### Parameters #### Query Parameters - **disableMinLiquidityFallback** (boolean) - Optional - Disables the dynamic minimum liquidity fallback, causing an error instead of using the default minimum liquidity capitalization. ### Request Example ``` GET /router/quote?tokenIn=ATOM&tokenOut=JUNO&disableMinLiquidityFallback=true ``` ### Response #### Success Response (200) - **quote** (object) - Contains details of the swap quote. - **minTokenLiquidity** (string) - The calculated minimum token liquidity. - **dynamicMinLiquidityCap** (string) - The dynamically determined minimum liquidity capitalization. #### Response Example ```json { "quote": { "amountIn": "1000000", "amountOut": "950000" }, "minTokenLiquidity": "300000", "dynamicMinLiquidityCap": "10000" } ``` ``` -------------------------------- ### GET /router/custom-direct-quote Source: https://github.com/osmosis-labs/sqs/blob/v28.x/docs/architecture/routing.md Retrieves a custom direct quote for a swap, influenced by dynamic minimum liquidity capitalization. Clients can opt out of the fallback behavior using `disableMinLiquidityFallback`. ```APIDOC ## GET /router/custom-direct-quote ### Description Retrieves a custom direct quote for a swap, taking into account dynamic minimum liquidity capitalization. This endpoint allows for more specific routing queries. ### Method GET ### Endpoint /router/custom-direct-quote ### Parameters #### Query Parameters - **disableMinLiquidityFallback** (boolean) - Optional - Disables the dynamic minimum liquidity fallback, causing an error instead of using the default minimum liquidity capitalization. ### Request Example ``` GET /router/custom-direct-quote?tokenIn=ATOM&tokenOut=BONK&disableMinLiquidityFallback=true ``` ### Response #### Success Response (200) - **quote** (object) - Contains details of the custom swap quote. - **minTokenLiquidity** (string) - The calculated minimum token liquidity. - **dynamicMinLiquidityCap** (string) - The dynamically determined minimum liquidity capitalization. #### Response Example ```json { "quote": { "amountIn": "2000000", "amountOut": "500" }, "minTokenLiquidity": "1000", "dynamicMinLiquidityCap": "1000" } ``` ``` -------------------------------- ### Get Token Metadata Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Retrieves metadata for tokens, including chain denom, human denom, and precision. It uses different asset lists for testnet and mainnet. Optionally accepts a list of denoms to filter results. ```bash curl "https://sqs.osmosis.zone/tokens/metadata/statom" | jq . { "chain_denom": "ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "human_denom": "statom", "precision": 6 } ``` -------------------------------- ### Get Custom Direct Token Swap Quote (Bash) Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Fetches a swap quote for a direct route defined by a comma-separated list of pool IDs. This bypasses the router's search and is not affected by minimum liquidity parameters, ensuring a quote if the pools exist. Requires tokenIn, tokenOutDenom, and poolIDs. ```bash curl "https://sqs.osmosis.zone/router/custom-direct-quote?tokenIn=1000000uosmo&tokenOutDenom=uion&poolID=2" | jq . ``` -------------------------------- ### Get Custom Direct Quote for Token Swap Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Calculates a quote for swapping a specified amount of one token for another using a specific CosmWasm pool. This endpoint is available in the production environment. ```APIDOC ## GET /router/custom-direct-quote ### Description Calculates a quote for swapping a specified amount of one token for another using a specific CosmWasm pool. This is used for custom pools that require direct interaction. ### Method GET ### Endpoint /router/custom-direct-quote ### Parameters #### Query Parameters - **from_symbol** (string) - Required - The symbol of the token to swap from. - **to_symbol** (string) - Required - The symbol of the token to swap to. - **pool_id** (string) - Required - The ID of the custom CosmWasm pool to use. - **amount** (string) - Required - The amount of the token to swap from, as a string representing a decimal number. ### Request Example ``` (No request body for GET requests) ``` ### Response #### Success Response (200) - **result** (string) - The amount of the `to_symbol` token that can be received for the given swap from the specified pool, as a string representing a decimal number. #### Response Example ```json { "result": "5.12345" } ``` ``` -------------------------------- ### GET /router/custom-direct-quote Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Fetches a swap quote for a specific route defined by a comma-separated list of pool IDs. This endpoint bypasses the router's search mechanism and directly quotes the specified path. ```APIDOC ## GET /router/custom-direct-quote ### Description Returns the quote over route with the given poolIDs. If such route does not exist, returns error. This endpoint does not use the router route search. As a result, it is not affected by the minimum liquidity parameter. As long as the pool exists on-chain, it will return a quote. ### Method GET ### Endpoint /router/custom-direct-quote ### Parameters #### Query Parameters - **tokenIn** (string) - Required - The string representation of the sdk.Coin for the token in. - **tokenOutDenom** (string) - Required - The string representing the denom of the token out. - **poolIDs** (string) - Required - Comma-separated list of pool IDs. ### Response #### Success Response (200) - **amount_in** (object) - The amount of input token. - **denom** (string) - The denomination of the input token. - **amount** (string) - The amount of the input token. - **amount_out** (string) - The calculated output amount. - **route** (array) - The recommended swap route. - **pools** (array) - The list of pools in the route. - **id** (integer) - The ID of the pool. - **type** (integer) - The type of the pool. - **balances** (array) - Balances of tokens in the pool. - **spread_factor** (string) - The spread factor of the pool. - **token_out_denom** (string) - The denomination of the token out of the pool. - **taker_fee** (string) - The taker fee for the pool. - **out_amount** (string) - The output amount for this route. - **in_amount** (string) - The input amount for this route. - **effective_fee** (string) - The effective fee for the entire route. #### Response Example ```json { "amount_in": { "denom": "uosmo", "amount": "1000000" }, "amount_out": "1803", "route": [ { "pools": [ { "id": 2, "type": 0, "balances": [], "spread_factor": "0.005000000000000000", "token_out_denom": "uion", "taker_fee": "0.001000000000000000" } ], "out_amount": "1803", "in_amount": "1000000" } ], "effective_fee": "0.006000000000000000" } ``` ``` -------------------------------- ### Initialize Osmosis Node Source: https://github.com/osmosis-labs/sqs/blob/v28.x/ingest/usecase/plugins/orderbook/fillbot/README.md Initializes a new Osmosis node with a specified chain ID. This is the first step in setting up the environment for the order book filler plugin. ```bash osmosisd init fill-bot --chain-id osmosis-1 ``` -------------------------------- ### Run End-to-End Tests with API Key Source: https://github.com/osmosis-labs/sqs/blob/v28.x/RELEASE.md This command executes end-to-end tests for SQS. The API key required for the test must be provided as an environment variable named SQS_API_KEY. ```bash make e2e-run-dev # API key must be specified thru environment variable SQS_API_KEY before running the test. ``` -------------------------------- ### Create and List Osmosis Keys Source: https://github.com/osmosis-labs/sqs/blob/v28.x/ingest/usecase/plugins/orderbook/fillbot/README.md Commands to add a new key named 'local' using the test keyring backend and then list all keys in the test keyring to confirm its creation. This is crucial for securing transactions. ```bash osmosisd keys add local --keyring-backend test --recover # Enter your mnemonic # Confirm the key is created Osmosisd keys list --keyring-backend test ``` -------------------------------- ### System Resource Endpoints Source: https://github.com/osmosis-labs/sqs/blob/v28.x/README.md Provides endpoints for checking system health, retrieving metrics, version information, and server configuration. ```APIDOC ## System Resource Endpoints ### GET /healthcheck #### Description Returns 200 if the server is healthy. Validates node reachability, sync status, cache height, and update timestamps. ### GET /metrics #### Description Returns the prometheus metrics for the server. ### GET /version #### Description Returns the version of the server. ### GET /config #### Description Returns the configuration of the server, including the router. ``` -------------------------------- ### Manually Create Transmuter Commands Source: https://github.com/osmosis-labs/sqs/blob/v28.x/router/README.md A series of bash commands to interact with the transmuter contract on the Osmosis blockchain. This includes code upload, governance actions, pool creation, and LPing. ```bash # Gov prop for code upload osmosisd tx gov submit-proposal upload-code-id-and-whitelist x/cosmwasmpool/bytecode/transmuter_migrate.wasm --title "T" --description "T" --from lo-test1 --keyring-backend test --chain-id localosmosis --gas=50000000 --fees 625000uosmo -b=block # Deposit gov prop osmosisd tx gov deposit 1 10000000uosmo --from val --keyring-backend test --chain-id localosmosis -b=block --fees=125000uosmo --gas=50000000 # Vote yes on gov prop osmosisd tx gov vote 1 yes --from val --keyring-backend test --chain-id localosmosis -b=block --fees=6250uosmo --gas=2500000 # Create transmuter osmosisd tx cosmwasmpool create-pool 1 "{\"pool_asset_denoms\":[\"uion\",\"uosmo\"]}" --from lo-test1 --keyring-backend test --chain-id localosmosis --fees 8750uosmo -b=block --gas=3500000 # Lp into transmuter osmosisd tx wasm execute osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 "{\"join_pool\":{} }" --amount 1000000uosmo,2000000uion --from lo-test1 --keyring-backend test --chain-id localosmosis --fees 8750uosmo -b=block --gas=3500000 ```