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-658 | Decouple Node releases from SQS #599

Draft
wants to merge 2 commits into
base: v28.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/app",
"env": {
"OSMOSIS_KEYRING_PATH":"/root/.osmosisd/keyring-test",
Expand Down
2 changes: 1 addition & 1 deletion app/sidecar_query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/osmosis-labs/sqs/tokens/usecase/pricing"
pricingWorker "github.com/osmosis-labs/sqs/tokens/usecase/pricing/worker"

sqspassthroughdomain "github.com/osmosis-labs/osmosis/v28/ingest/types/passthroughdomain"
"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/domain/cache"
"github.com/osmosis-labs/sqs/domain/cosmos/tx"
Expand All @@ -56,7 +57,6 @@ import (
passthroughdomain "github.com/osmosis-labs/sqs/domain/passthrough"
"github.com/osmosis-labs/sqs/log"
"github.com/osmosis-labs/sqs/middleware"
sqspassthroughdomain "github.com/osmosis-labs/sqs/sqsdomain/passthroughdomain"

routerHttpDelivery "github.com/osmosis-labs/sqs/router/delivery/http"
routerUseCase "github.com/osmosis-labs/sqs/router/usecase"
Expand Down
16 changes: 8 additions & 8 deletions domain/candidate_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package domain

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/sqs/sqsdomain"
ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
)

// CandidateRoutePoolFiltrerCb defines a candidate route pool filter
// that takes in a pool and returns true if the pool should be skipped.
type CandidateRoutePoolFiltrerCb func(*sqsdomain.PoolWrapper) bool
type CandidateRoutePoolFiltrerCb func(*ingesttypes.PoolWrapper) bool

// CandidateRouteSearchOptions represents the options for finding candidate routes.
type CandidateRouteSearchOptions struct {
Expand All @@ -30,7 +30,7 @@ type CandidateRouteSearchOptions struct {

// ShouldSkipPool returns true if the candidate route algorithm should skip
// a given pool by matching at least one of the pool filters
func (c CandidateRouteSearchOptions) ShouldSkipPool(pool *sqsdomain.PoolWrapper) bool {
func (c CandidateRouteSearchOptions) ShouldSkipPool(pool *ingesttypes.PoolWrapper) bool {
for _, filter := range c.PoolFiltersAnyOf {
if filter(pool) {
return true
Expand All @@ -47,7 +47,7 @@ type CandidateRoutePoolIDFilterOptionCb struct {
}

// ShouldSkipPool returns true of the given pool has ID that is present in c.PoolIDsToSkip
func (c CandidateRoutePoolIDFilterOptionCb) ShouldSkipPool(pool *sqsdomain.PoolWrapper) bool {
func (c CandidateRoutePoolIDFilterOptionCb) ShouldSkipPool(pool *ingesttypes.PoolWrapper) bool {
poolID := pool.GetId()
_, ok := c.PoolIDsToSkip[poolID]
return ok
Expand All @@ -57,7 +57,7 @@ var (
// ShouldSkipOrderbookPool skips orderbook pools
// by returning true if pool.SQSModel.CosmWasmPoolModel is not nil
// and pool.SQSModel.CosmWasmPoolModel.IsOrderbook() returns true.
ShouldSkipOrderbookPool CandidateRoutePoolFiltrerCb = func(pool *sqsdomain.PoolWrapper) bool {
ShouldSkipOrderbookPool CandidateRoutePoolFiltrerCb = func(pool *ingesttypes.PoolWrapper) bool {
cosmWasmPoolModel := pool.SQSModel.CosmWasmPoolModel
return cosmWasmPoolModel != nil && cosmWasmPoolModel.IsOrderbook()
}
Expand All @@ -68,15 +68,15 @@ type CandidateRouteSearcher interface {
// FindCandidateRoutes finds candidate routes for a given tokenIn and tokenOutDenom
// using the given options.
// Returns the candidate routes and an error if any.
FindCandidateRoutes(tokenIn sdk.Coin, tokenOutDenom string, options CandidateRouteSearchOptions) (sqsdomain.CandidateRoutes, error)
FindCandidateRoutes(tokenIn sdk.Coin, tokenOutDenom string, options CandidateRouteSearchOptions) (ingesttypes.CandidateRoutes, error)
}

// CandidateRouteDenomData represents the data for a candidate route for a given denom.
type CandidateRouteDenomData struct {
// SortedPools is the sorted list of pools for the denom.
SortedPools []sqsdomain.PoolI
SortedPools []ingesttypes.PoolI
// CanonicalOrderbooks is the map of canonical orderbooks keyed by the pair token.
// For example if this is candidate route denom data for OSMO and there is a canonical orderbook with ID 23
// for ATOM/OSMO, we would have an entry from ATOM to 23 in this map.
CanonicalOrderbooks map[string]sqsdomain.PoolI
CanonicalOrderbooks map[string]ingesttypes.PoolI
}
14 changes: 7 additions & 7 deletions domain/candidate_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package domain_test
import (
"testing"

ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
"github.com/osmosis-labs/osmosis/v28/ingest/types/cosmwasmpool"
"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/domain/mocks"
"github.com/osmosis-labs/sqs/sqsdomain"
"github.com/osmosis-labs/sqs/sqsdomain/cosmwasmpool"
"github.com/stretchr/testify/require"
)

Expand All @@ -24,15 +24,15 @@ func TestCandidateRouteSearchOptions_ShouldSkipPool(t *testing.T) {
)

var (
defaultNonOrderBookPool = sqsdomain.PoolWrapper{
defaultNonOrderBookPool = ingesttypes.PoolWrapper{
ChainModel: &mocks.ChainPoolMock{
ID: defaultPoolID,
},
}

// instruments the given pool with orderbook data, returning new copy.
withOrderBookPool = func(pool sqsdomain.PoolWrapper) sqsdomain.PoolWrapper {
pool.SQSModel = sqsdomain.SQSPool{
withOrderBookPool = func(pool ingesttypes.PoolWrapper) ingesttypes.PoolWrapper {
pool.SQSModel = ingesttypes.SQSPool{
CosmWasmPoolModel: &cosmwasmpool.CosmWasmPoolModel{
ContractInfo: cosmwasmpool.ContractInfo{
Contract: cosmwasmpool.ORDERBOOK_CONTRACT_NAME,
Expand All @@ -48,7 +48,7 @@ func TestCandidateRouteSearchOptions_ShouldSkipPool(t *testing.T) {
}

// instruments the given pool with a new id returning new copy
withPoolID = func(pool sqsdomain.PoolWrapper, newPoolID uint64) sqsdomain.PoolWrapper {
withPoolID = func(pool ingesttypes.PoolWrapper, newPoolID uint64) ingesttypes.PoolWrapper {
pool.ChainModel = &mocks.ChainPoolMock{
ID: newPoolID,
}
Expand All @@ -63,7 +63,7 @@ func TestCandidateRouteSearchOptions_ShouldSkipPool(t *testing.T) {

poolIDsToFilter map[uint64]struct{}

poolToTest sqsdomain.PoolWrapper
poolToTest ingesttypes.PoolWrapper

expectedShouldSkip bool
}{
Expand Down
2 changes: 1 addition & 1 deletion domain/cosmwasm/cosmwasm_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cosmwasmdomain
import (
"context"

"github.com/osmosis-labs/sqs/sqsdomain/json"
"github.com/osmosis-labs/osmosis/v28/ingest/types/json"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/osmosis-labs/sqs/domain"
Expand Down
6 changes: 3 additions & 3 deletions domain/mocks/candidate_route_finder_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package mocks

import (
"github.com/cosmos/cosmos-sdk/types"
ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/sqsdomain"
)

type CandidateRouteFinderMock struct {
Routes sqsdomain.CandidateRoutes
Routes ingesttypes.CandidateRoutes
Error error
}

var _ domain.CandidateRouteSearcher = CandidateRouteFinderMock{}

// FindCandidateRoutes implements domain.CandidateRouteSearcher.
func (c CandidateRouteFinderMock) FindCandidateRoutes(tokenIn types.Coin, tokenOutDenom string, options domain.CandidateRouteSearchOptions) (sqsdomain.CandidateRoutes, error) {
func (c CandidateRouteFinderMock) FindCandidateRoutes(tokenIn types.Coin, tokenOutDenom string, options domain.CandidateRouteSearchOptions) (ingesttypes.CandidateRoutes, error) {
return c.Routes, c.Error
}
6 changes: 3 additions & 3 deletions domain/mocks/orderbook_usecase_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package mocks
import (
"context"

ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/domain/mvc"
orderbookdomain "github.com/osmosis-labs/sqs/domain/orderbook"
"github.com/osmosis-labs/sqs/sqsdomain"

"github.com/osmosis-labs/osmosis/osmomath"
)
Expand All @@ -15,15 +15,15 @@ var _ mvc.OrderBookUsecase = &OrderbookUsecaseMock{}

// OrderbookUsecaseMock is a mock implementation of the RouterUsecase interface
type OrderbookUsecaseMock struct {
ProcessPoolFunc func(ctx context.Context, pool sqsdomain.PoolI) error
ProcessPoolFunc func(ctx context.Context, pool ingesttypes.PoolI) error
GetAllTicksFunc func(poolID uint64) (map[int64]orderbookdomain.OrderbookTick, bool)
GetActiveOrdersFunc func(ctx context.Context, address string) ([]orderbookdomain.LimitOrder, bool, error)
GetActiveOrdersStreamFunc func(ctx context.Context, address string) <-chan orderbookdomain.OrderbookResult
CreateFormattedLimitOrderFunc func(orderbook domain.CanonicalOrderBooksResult, order orderbookdomain.Order) (orderbookdomain.LimitOrder, error)
GetClaimableOrdersForOrderbookFunc func(ctx context.Context, fillThreshold osmomath.Dec, orderbook domain.CanonicalOrderBooksResult) ([]orderbookdomain.ClaimableOrderbook, error)
}

func (m *OrderbookUsecaseMock) ProcessPool(ctx context.Context, pool sqsdomain.PoolI) error {
func (m *OrderbookUsecaseMock) ProcessPool(ctx context.Context, pool ingesttypes.PoolI) error {
if m.ProcessPoolFunc != nil {
return m.ProcessPoolFunc(ctx, pool)
}
Expand Down
10 changes: 5 additions & 5 deletions domain/mocks/pool_handler_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package mocks
import (
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/types"
ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
"github.com/osmosis-labs/sqs/domain"
"github.com/osmosis-labs/sqs/domain/mvc"
"github.com/osmosis-labs/sqs/sqsdomain"
)

type PoolHandlerMock struct {
Pools []sqsdomain.PoolI
Pools []ingesttypes.PoolI
ForceGetPoolsError error
ForceStorePoolsError error
}

var _ mvc.PoolHandler = &PoolHandlerMock{}

// GetPools implements mvc.PoolHandler.
func (p *PoolHandlerMock) GetPools(opts ...domain.PoolsOption) ([]sqsdomain.PoolI, uint64, error) {
func (p *PoolHandlerMock) GetPools(opts ...domain.PoolsOption) ([]ingesttypes.PoolI, uint64, error) {
if p.ForceGetPoolsError != nil {
return nil, 0, p.ForceGetPoolsError
}
Expand All @@ -27,7 +27,7 @@ func (p *PoolHandlerMock) GetPools(opts ...domain.PoolsOption) ([]sqsdomain.Pool
opt(&options)
}

result := make([]sqsdomain.PoolI, 0)
result := make([]ingesttypes.PoolI, 0)
if f := options.Filter; f != nil && len(f.PoolId) > 0 {
for _, id := range f.PoolId {
for _, pool := range p.Pools {
Expand All @@ -50,7 +50,7 @@ func (p *PoolHandlerMock) GetPools(opts ...domain.PoolsOption) ([]sqsdomain.Pool
}

// StorePools implements mvc.PoolHandler.
func (p *PoolHandlerMock) StorePools(pools []sqsdomain.PoolI) error {
func (p *PoolHandlerMock) StorePools(pools []ingesttypes.PoolI) error {
if p.ForceStorePoolsError != nil {
return p.ForceStorePoolsError
}
Expand Down
50 changes: 25 additions & 25 deletions domain/mocks/pool_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmomath"
ingesttypes "github.com/osmosis-labs/osmosis/v28/ingest/types"
"github.com/osmosis-labs/osmosis/v28/ingest/types/cosmwasmpool"
sqspassthroughdomain "github.com/osmosis-labs/osmosis/v28/ingest/types/passthroughdomain"
"github.com/osmosis-labs/sqs/domain"
api "github.com/osmosis-labs/sqs/pkg/api/v1beta1/pools"
"github.com/osmosis-labs/sqs/sqsdomain"
"github.com/osmosis-labs/sqs/sqsdomain/cosmwasmpool"
sqspassthroughdomain "github.com/osmosis-labs/sqs/sqsdomain/passthroughdomain"

"github.com/osmosis-labs/osmosis/v28/x/gamm/pool-models/balancer"
poolmanagertypes "github.com/osmosis-labs/osmosis/v28/x/poolmanager/types"
Expand All @@ -21,7 +21,7 @@ type MockRoutablePool struct {
CalculateTokenOutByTokenInFunc func(ctx context.Context, tokenIn sdk.Coin) (sdk.Coin, error)

ChainPoolModel poolmanagertypes.PoolI
TickModel *sqsdomain.TickModel
TickModel *ingesttypes.TickModel
CosmWasmPoolModel *cosmwasmpool.CosmWasmPoolModel
ID uint64
Balances sdk.Coins
Expand All @@ -42,22 +42,22 @@ type MockRoutablePool struct {
PoolLiquidityCapError string
}

// GetAPRData implements sqsdomain.PoolI.
// GetAPRData implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetAPRData() sqspassthroughdomain.PoolAPRDataStatusWrap {
return mp.APRData
}

// GetFeesData implements sqsdomain.PoolI.
// GetFeesData implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetFeesData() sqspassthroughdomain.PoolFeesDataStatusWrap {
return mp.FeesData
}

// SetAPRData implements sqsdomain.PoolI.
// SetAPRData implements ingesttypes.PoolI.
func (mp *MockRoutablePool) SetAPRData(aprData sqspassthroughdomain.PoolAPRDataStatusWrap) {
mp.APRData = aprData
}

// SetFeesData implements sqsdomain.PoolI.
// SetFeesData implements ingesttypes.PoolI.
func (mp *MockRoutablePool) SetFeesData(feesData sqspassthroughdomain.PoolFeesDataStatusWrap) {
mp.FeesData = feesData
}
Expand Down Expand Up @@ -97,9 +97,9 @@ func (mp *MockRoutablePool) GetUnderlyingPool() poolmanagertypes.PoolI {
return mp.ChainPoolModel
}

// GetSQSPoolModel implements sqsdomain.PoolI.
func (mp *MockRoutablePool) GetSQSPoolModel() sqsdomain.SQSPool {
return sqsdomain.SQSPool{
// GetSQSPoolModel implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetSQSPoolModel() ingesttypes.SQSPool {
return ingesttypes.SQSPool{
Balances: mp.Balances,
PoolLiquidityCap: mp.PoolLiquidityCap,
SpreadFactor: mp.SpreadFactor,
Expand Down Expand Up @@ -138,17 +138,17 @@ func (*MockRoutablePool) String() string {
}

// GetTickModel implements domain.RoutablePool.
func (mp *MockRoutablePool) GetTickModel() (*sqsdomain.TickModel, error) {
func (mp *MockRoutablePool) GetTickModel() (*ingesttypes.TickModel, error) {
return mp.TickModel, nil
}

// SetTickModel implements sqsdomain.PoolI.
func (mp *MockRoutablePool) SetTickModel(tickModel *sqsdomain.TickModel) error {
// SetTickModel implements ingesttypes.PoolI.
func (mp *MockRoutablePool) SetTickModel(tickModel *ingesttypes.TickModel) error {
mp.TickModel = tickModel
return nil
}

// Validate implements sqsdomain.PoolI.
// Validate implements ingesttypes.PoolI.
func (*MockRoutablePool) Validate(minUOSMOTVL math.Int) error {
// Note: always valid for tests.
return nil
Expand All @@ -174,7 +174,7 @@ func (mp *MockRoutablePool) ChargeTakerFeeExactIn(tokenIn sdk.Coin) (tokenInAfte
return tokenIn.Sub(sdk.NewCoin(tokenIn.Denom, mp.TakerFee.Mul(tokenIn.Amount.ToLegacyDec()).TruncateInt()))
}

// GetTakerFee implements sqsdomain.PoolI.
// GetTakerFee implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetTakerFee() math.LegacyDec {
return mp.TakerFee
}
Expand All @@ -183,25 +183,25 @@ func (mp *MockRoutablePool) Incentive() api.IncentiveType {
return mp.IncentiveType
}

var _ sqsdomain.PoolI = &MockRoutablePool{}
var _ ingesttypes.PoolI = &MockRoutablePool{}
var _ domain.RoutablePool = &MockRoutablePool{}

// GetId implements sqsdomain.PoolI.
// GetId implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetId() uint64 {
return mp.ID
}

// GetPoolDenoms implements sqsdomain.PoolI.
// GetPoolDenoms implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetPoolDenoms() []string {
return mp.Denoms
}

// GetPoolLiquidityCap implements sqsdomain.PoolI.
// GetPoolLiquidityCap implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetPoolLiquidityCap() math.Int {
return mp.PoolLiquidityCap
}

// GetType implements sqsdomain.PoolI.
// GetType implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetType() poolmanagertypes.PoolType {
return mp.PoolType
}
Expand All @@ -216,22 +216,22 @@ func (mp *MockRoutablePool) GetCodeID() uint64 {
return 0
}

// GetLiquidityCap implements sqsdomain.PoolI.
// GetLiquidityCap implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetLiquidityCap() math.Int {
return mp.PoolLiquidityCap
}

// GetLiquidityCapError implements sqsdomain.PoolI.
// GetLiquidityCapError implements ingesttypes.PoolI.
func (mp *MockRoutablePool) GetLiquidityCapError() string {
return mp.PoolLiquidityCapError
}

// SetLiquidityCap implements sqsdomain.PoolI.
// SetLiquidityCap implements ingesttypes.PoolI.
func (mp *MockRoutablePool) SetLiquidityCap(liquidityCap math.Int) {
mp.PoolLiquidityCap = liquidityCap
}

// SetLiquidityCapError implements sqsdomain.PoolI.
// SetLiquidityCapError implements ingesttypes.PoolI.
func (mp *MockRoutablePool) SetLiquidityCapError(liquidityCapError string) {
mp.PoolLiquidityCapError = liquidityCapError
}
Expand Down
Loading
Loading