Skip to content
Open
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
2 changes: 0 additions & 2 deletions oracle/provider/gate_get_external_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package provider

import (
"encoding/json"
"fmt"
"net/http"
"strconv"

Expand Down Expand Up @@ -35,7 +34,6 @@ func (p *GateProvider) GetExternalLiquidity(
}
//https://api.gateio.ws/api/v4/spot/order_book?currency_pair=BTC_USDT&limit=5000
route := p.endpoints.Rest + gateRestOrderBook + "?currency_pair=" + pair.Base + "_" + pair.Quote + "&limit=5000"
fmt.Println("external_liquidity_route", route)
resp, err := http.Get(route)
if err != nil {
p.logger.Err(err).
Expand Down
4 changes: 0 additions & 4 deletions usecase/calculate_external_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
var highestBid math.LegacyDec
var lowestAsk math.LegacyDec

if len(depthData.Bids) > 0 && len(depthData.Asks) > 0 && len(depthData.Bids[0]) > 0 && len(depthData.Asks[0]) > 0 {
var err error
highestBid, err = math.LegacyNewDecFromStr(fmt.Sprintf("%f", depthData.Bids[0][0]))
if err != nil {
return nil, err
}
lowestAsk, err = math.LegacyNewDecFromStr(fmt.Sprintf("%f", depthData.Asks[0][0]))
if err != nil {
return nil, err
}
} else {
return nil, errors.New("no bids or asks in depthData")
}

Check failure on line 42 in usecase/calculate_external_liquidity.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

if c { ... } else { ... return } can be simplified to if !c { ... return } ...

// Allow to take 50% on both sides, in case of equal
highestBidAllowed := highestBid.QuoInt64(2)
Expand Down Expand Up @@ -94,7 +94,6 @@
lowestPrice = price
}

fmt.Println("highestPrice, lowestPrice, baseAmount, quoteAmount", highestPrice, lowestPrice, baseAmount, quoteAmount)
for _, ask := range depthData.Asks {
price, err := math.LegacyNewDecFromStr(fmt.Sprintf("%f", ask[0]))
if err != nil {
Expand All @@ -111,11 +110,8 @@
baseAmount = baseAmount.Add(amount)
highestPrice = price
}
fmt.Println("highestPrice, lowestPrice, baseAmount, quoteAmount", highestPrice, lowestPrice, baseAmount, quoteAmount)
baseDepth := (highestPrice.Quo(price)).Sub(math.LegacyOneDec())
quoteDepth := math.LegacyOneDec().Sub(lowestPrice.Quo(price))
fmt.Println("baseDepth", baseDepth)
fmt.Println("quoteDepth", quoteDepth)

// Use decimals
externalLiquidityEntity := entity.ExternalLiquidity{
Expand Down
Loading