code.vegaprotocol.io/vega@v0.79.0/datanode/service/amm_service.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package service
    17  
    18  import (
    19  	"context"
    20  
    21  	"code.vegaprotocol.io/vega/datanode/entities"
    22  	"code.vegaprotocol.io/vega/datanode/sqlstore"
    23  	"code.vegaprotocol.io/vega/libs/ptr"
    24  )
    25  
    26  type AMMPools struct {
    27  	*sqlstore.AMMPools
    28  }
    29  
    30  func (a *AMMPools) ListByMarket(ctx context.Context, marketID string, liveOnly bool, pagination entities.CursorPagination) ([]entities.AMMPool, entities.PageInfo, error) {
    31  	return a.AMMPools.ListByMarket(ctx, entities.MarketID(marketID), liveOnly, pagination)
    32  }
    33  
    34  func (a *AMMPools) ListByParty(ctx context.Context, partyID string, liveOnly bool, pagination entities.CursorPagination) ([]entities.AMMPool, entities.PageInfo, error) {
    35  	return a.AMMPools.ListByParty(ctx, entities.PartyID(partyID), liveOnly, pagination)
    36  }
    37  
    38  func (a *AMMPools) ListByPool(ctx context.Context, poolID string, liveOnly bool, pagination entities.CursorPagination) ([]entities.AMMPool, entities.PageInfo, error) {
    39  	return a.AMMPools.ListByPool(ctx, entities.AMMPoolID(poolID), liveOnly, pagination)
    40  }
    41  
    42  func (a *AMMPools) ListBySubAccount(ctx context.Context, ammPartyID string, liveOnly bool, pagination entities.CursorPagination) ([]entities.AMMPool, entities.PageInfo, error) {
    43  	return a.AMMPools.ListBySubAccount(ctx, entities.PartyID(ammPartyID), liveOnly, pagination)
    44  }
    45  
    46  func (a *AMMPools) ListByPartyMarketStatus(ctx context.Context, partyID, marketID *string, status *entities.AMMStatus, liveOnly bool, pagination entities.CursorPagination) ([]entities.AMMPool, entities.PageInfo, error) {
    47  	var (
    48  		party  *entities.PartyID
    49  		market *entities.MarketID
    50  	)
    51  	if partyID != nil {
    52  		party = ptr.From(entities.PartyID(*partyID))
    53  	}
    54  	if marketID != nil {
    55  		market = ptr.From(entities.MarketID(*marketID))
    56  	}
    57  	return a.AMMPools.ListByPartyMarketStatus(ctx, party, market, status, liveOnly, pagination)
    58  }