Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE-632 | Include limit order balances in passthrough/portfolio-assets #552

Open
wants to merge 13 commits into
base: v27.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
8 changes: 8 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ pull_request_rules:
backport:
branches:
- v25.x
- name: backport patches to v27.x branch
conditions:
- base=v26.x
- label=A:backport/v27.x
actions:
backport:
branches:
- v27.x
4 changes: 2 additions & 2 deletions .github/workflows/required-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches:
- "v25.x"
- "v26.x"

jobs:
backport_labels:
Expand All @@ -26,4 +26,4 @@ jobs:
with: #Require one of the following labels
mode: exactly
count: 1
labels: "A:backport/v26.x"
labels: "A:backport/v27.x"
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## Unreleased

- #547 - Add /quote simulation for "out given in" single routes.
- #526 - Refactor gas estimation APIs
- #524 - Claimbot

## v26.1.0

e42b32bc SQS-412 | Active Orders Query: SSE (#518)
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,25 @@ orderbook-fillbot-start:
./ingest/usecase/plugins/orderbook/fillbot/create_copy_config.sh
cd ./ingest/usecase/plugins/orderbook/fillbot && docker compose up -d
cd ../../../../
echo "Order Book Filler Bot Started"
echo "Orderbook Fill Bot Started"
sleep 10 && osmosisd status
sleep 10 && docker logs -f osmosis-sqs

orderbook-fillbot-stop:
cd ./ingest/usecase/plugins/orderbook/fillbot && docker compose down
cd ../../../../
echo "Order Book Filler Bot Stopped"
echo "Orderbook Fill Bot Stopped"


orderbook-claimbot-start:
./ingest/usecase/plugins/orderbook/fillbot/create_copy_config.sh
cd ./ingest/usecase/plugins/orderbook/claimbot && docker compose up -d
cd ../../../../
echo "Orderbook Claim Bot Started"
sleep 10 && osmosisd status
sleep 10 && docker logs -f osmosis-sqs

orderbook-claimbot-stop:
cd ./ingest/usecase/plugins/orderbook/claimbot && docker compose down
cd ../../../../
echo "Orderbook Claim Bot Stopped"
53 changes: 45 additions & 8 deletions app/sidecar_query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/osmosis-labs/osmosis/v26/app"
txfeestypes "github.com/osmosis-labs/osmosis/v26/x/txfees/types"
"github.com/osmosis-labs/sqs/domain/cosmos/auth/types"
ingestrpcdelivry "github.com/osmosis-labs/sqs/ingest/delivery/grpc"
ingestusecase "github.com/osmosis-labs/sqs/ingest/usecase"
orderbookclaimbot "github.com/osmosis-labs/sqs/ingest/usecase/plugins/orderbook/claimbot"
orderbookfillbot "github.com/osmosis-labs/sqs/ingest/usecase/plugins/orderbook/fillbot"
orderbookrepository "github.com/osmosis-labs/sqs/orderbook/repository"
orderbookusecase "github.com/osmosis-labs/sqs/orderbook/usecase"
"github.com/osmosis-labs/sqs/quotesimulator"
"github.com/osmosis-labs/sqs/sqsutil/datafetchers"

chaininforepo "github.com/osmosis-labs/sqs/chaininfo/repository"
Expand All @@ -42,6 +47,7 @@ import (

"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/domain/cache"
"github.com/osmosis-labs/sqs/domain/cosmos/tx"
"github.com/osmosis-labs/sqs/domain/keyring"
"github.com/osmosis-labs/sqs/domain/mvc"
orderbookgrpcclientdomain "github.com/osmosis-labs/sqs/domain/orderbook/grpcclient"
Expand Down Expand Up @@ -179,8 +185,13 @@ func NewSideCarQueryServer(appCodec codec.Codec, config domain.Config, logger lo
return nil, err
}

wasmQueryClient := wasmtypes.NewQueryClient(passthroughGRPCClient.GetChainGRPCClient())
orderBookAPIClient := orderbookgrpcclientdomain.New(wasmQueryClient)
orderBookRepository := orderbookrepository.New()
orderBookUseCase := orderbookusecase.New(orderBookRepository, orderBookAPIClient, poolsUseCase, tokensUseCase, logger)

// Initialize passthrough query use case
passthroughUseCase := passthroughUseCase.NewPassThroughUsecase(passthroughGRPCClient, poolsUseCase, tokensUseCase, liquidityPricer, defaultQuoteDenom, logger)
passthroughUseCase := passthroughUseCase.NewPassThroughUsecase(passthroughGRPCClient, poolsUseCase, tokensUseCase, orderBookUseCase, liquidityPricer, defaultQuoteDenom, logger)
deividaspetraitis marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
deividaspetraitis marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -197,19 +208,24 @@ func NewSideCarQueryServer(appCodec codec.Codec, config domain.Config, logger lo
tokensUseCase.RegisterPricingStrategy(domain.ChainPricingSourceType, chainPricingSource)
tokensUseCase.RegisterPricingStrategy(domain.CoinGeckoPricingSourceType, coingeckoPricingSource)

wasmQueryClient := wasmtypes.NewQueryClient(passthroughGRPCClient.GetChainGRPCClient())
orderBookAPIClient := orderbookgrpcclientdomain.New(wasmQueryClient)
orderBookRepository := orderbookrepository.New()
orderBookUseCase := orderbookusecase.New(orderBookRepository, orderBookAPIClient, poolsUseCase, tokensUseCase, logger)

// HTTP handlers
poolsHttpDelivery.NewPoolsHandler(e, poolsUseCase)
passthroughHttpDelivery.NewPassthroughHandler(e, passthroughUseCase, orderBookUseCase, logger)
systemhttpdelivery.NewSystemHandler(e, config, logger, chainInfoUseCase)
if err := tokenshttpdelivery.NewTokensHandler(e, *config.Pricing, tokensUseCase, pricingSimpleRouterUsecase, logger); err != nil {
return nil, err
}
routerHttpDelivery.NewRouterHandler(e, routerUsecase, tokensUseCase, logger)

grpcClient := passthroughGRPCClient.GetChainGRPCClient()
gasCalculator := tx.NewGasCalculator(grpcClient, tx.CalculateGas)
quoteSimulator := quotesimulator.NewQuoteSimulator(
gasCalculator,
app.GetEncodingConfig(),
txfeestypes.NewQueryClient(grpcClient),
types.NewQueryClient(grpcClient),
config.ChainID,
)
routerHttpDelivery.NewRouterHandler(e, routerUsecase, tokensUseCase, quoteSimulator, logger)

// Create a Numia HTTP client
passthroughConfig := config.Passthrough
Expand Down Expand Up @@ -271,7 +287,7 @@ func NewSideCarQueryServer(appCodec codec.Codec, config domain.Config, logger lo
if plugin.IsEnabled() {
var currentPlugin domain.EndBlockProcessPlugin

if plugin.GetName() == orderbookplugindomain.OrderBookPluginName {
if plugin.GetName() == orderbookplugindomain.OrderbookFillbotPlugin {
// Create keyring
keyring, err := keyring.New()
if err != nil {
Expand All @@ -282,6 +298,27 @@ func NewSideCarQueryServer(appCodec codec.Codec, config domain.Config, logger lo
currentPlugin = orderbookfillbot.New(poolsUseCase, routerUsecase, tokensUseCase, passthroughGRPCClient, orderBookAPIClient, keyring, defaultQuoteDenom, logger)
}

if plugin.GetName() == orderbookplugindomain.OrderbookClaimbotPlugin {
// Create keyring
keyring, err := keyring.New()
if err != nil {
return nil, err
}

logger.Info("Using keyring with address", zap.Stringer("address", keyring.GetAddress()))
currentPlugin, err = orderbookclaimbot.New(
keyring,
orderBookUseCase,
poolsUseCase,
logger,
config.ChainGRPCGatewayEndpoint,
config.ChainID,
)
if err != nil {
return nil, err
}
}

// Register the plugin with the ingest use case
ingestUseCase.RegisterEndBlockProcessPlugin(currentPlugin)
}
Expand Down
32 changes: 19 additions & 13 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"flight-record": {
"enabled": false
},
"otel": {
"enabled": false,
"environment": "sqs-dev"
},
"plugins": [
{
"name": "orderbook",
"enabled": false
}
]
"flight-record": {
"enabled": false
},
"otel": {
"enabled": false,
"environment": "sqs-dev"
},
"grpc-ingester": {
"plugins": [
{
"name": "orderbook-fillbot-plugin",
"enabled": false
},
{
"name": "orderbook-claimbot-plugin",
"enabled": false
}
]
}
}
20 changes: 16 additions & 4 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ const docTemplate = `{
"description": "Boolean flag indicating whether to apply exponents to the spot price. False by default.",
"name": "applyExponents",
"in": "query"
},
{
"type": "string",
"description": "Address of the simulator to simulate the quote. If provided, the quote will be simulated.",
"name": "simulatorAddress",
"in": "query"
},
{
"type": "string",
"description": "Slippage tolerance multiplier for the simulation. If simulatorAddress is provided, this must be provided.",
"name": "simulationSlippageTolerance",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -514,7 +526,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"amount": {
"$ref": "#/definitions/types.Int"
"$ref": "#/definitions/math.Int"
},
"denom": {
"type": "string"
Expand Down Expand Up @@ -663,6 +675,9 @@ const docTemplate = `{
}
}
},
"math.Int": {
"type": "object"
},
"sqsdomain.CandidatePool": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -707,9 +722,6 @@ const docTemplate = `{
}
}
}
},
"types.Int": {
"type": "object"
}
}
}`
Expand Down
20 changes: 16 additions & 4 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@
"description": "Boolean flag indicating whether to apply exponents to the spot price. False by default.",
"name": "applyExponents",
"in": "query"
},
{
"type": "string",
"description": "Address of the simulator to simulate the quote. If provided, the quote will be simulated.",
"name": "simulatorAddress",
"in": "query"
},
{
"type": "string",
"description": "Slippage tolerance multiplier for the simulation. If simulatorAddress is provided, this must be provided.",
"name": "simulationSlippageTolerance",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -505,7 +517,7 @@
"type": "object",
"properties": {
"amount": {
"$ref": "#/definitions/types.Int"
"$ref": "#/definitions/math.Int"
},
"denom": {
"type": "string"
Expand Down Expand Up @@ -654,6 +666,9 @@
}
}
},
"math.Int": {
"type": "object"
},
"sqsdomain.CandidatePool": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -698,9 +713,6 @@
}
}
}
},
"types.Int": {
"type": "object"
}
}
}
16 changes: 13 additions & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ definitions:
github_com_cosmos_cosmos-sdk_types.Coin:
properties:
amount:
$ref: '#/definitions/types.Int'
$ref: '#/definitions/math.Int'
denom:
type: string
type: object
Expand Down Expand Up @@ -142,6 +142,8 @@ definitions:
$ref: '#/definitions/github_com_osmosis-labs_sqs_domain_orderbook.LimitOrder'
type: array
type: object
math.Int:
type: object
sqsdomain.CandidatePool:
properties:
id:
Expand Down Expand Up @@ -171,8 +173,6 @@ definitions:
type: object
type: object
type: object
types.Int:
type: object
info:
contact: {}
title: Osmosis Sidecar Query Server Example API
Expand Down Expand Up @@ -407,6 +407,16 @@ paths:
in: query
name: applyExponents
type: boolean
- description: Address of the simulator to simulate the quote. If provided,
the quote will be simulated.
in: query
name: simulatorAddress
type: string
- description: Slippage tolerance multiplier for the simulation. If simulatorAddress
is provided, this must be provided.
in: query
name: simulationSlippageTolerance
type: string
produces:
- application/json
responses:
Expand Down
10 changes: 8 additions & 2 deletions domain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ var (
Plugins: []Plugin{
&OrderBookPluginConfig{
Enabled: false,
Name: orderbookplugindomain.OrderBookPluginName,
Name: orderbookplugindomain.OrderbookFillbotPlugin,
},
&OrderBookPluginConfig{
Enabled: false,
Name: orderbookplugindomain.OrderbookClaimbotPlugin,
},
},
},
Expand Down Expand Up @@ -377,7 +381,9 @@ func validateDynamicMinLiquidityCapDesc(values []DynamicMinLiquidityCapFilterEnt
// PluginFactory creates a Plugin instance based on the provided name.
func PluginFactory(name string) Plugin {
switch name {
case orderbookplugindomain.OrderBookPluginName:
case orderbookplugindomain.OrderbookFillbotPlugin:
return &OrderBookPluginConfig{}
case orderbookplugindomain.OrderbookClaimbotPlugin:
return &OrderBookPluginConfig{}
// Add cases for other plugins as needed
default:
Expand Down
Loading
Loading