-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Crescent and Osmosis LPs tokens prices #152
base: main
Are you sure you want to change the base?
Changes from all commits
df7223f
7bf53b5
102c9f2
0685939
11550e5
5b8caee
4d8aba1
ae81aea
25a1211
1e0f236
02103a9
09a1f44
43df220
5299a16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package prices | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/emerishq/demeris-api-server/usecase" | ||
) | ||
|
||
type App interface { | ||
PoolPrices(ctx context.Context) usecase.PoolPricesResult | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package prices | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/emerishq/demeris-api-server/lib/ginutils" | ||
"github.com/emerishq/demeris-api-server/usecase" | ||
"github.com/emerishq/emeris-utils/logging" | ||
"github.com/gin-gonic/gin" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type PricesAPI struct { | ||
app App | ||
} | ||
|
||
func New(app App) *PricesAPI { | ||
return &PricesAPI{ | ||
app: app, | ||
} | ||
} | ||
|
||
func Register(router *gin.Engine, app App) { | ||
api := New(app) | ||
|
||
router.Group("/prices"). | ||
GET("/pools", api.GetPoolsPrices) | ||
} | ||
|
||
type GetPoolsPricesResponse struct { | ||
PoolResults usecase.PoolPricesResult `json:"pool_results"` | ||
} | ||
|
||
// GetPoolsPrices returns the list of available pools and their associated token's price. | ||
// @Summary Get pools' tokens prices | ||
// @Tags Price | ||
// @ID get-pools-prices | ||
// @Produce json | ||
// @Success 200 {object} GetPoolsPricesResponse | ||
// @Failure 500 {object} apierrors.UserFacingError | ||
// @Router /prices/pools [get] | ||
func (api *PricesAPI) GetPoolsPrices(c *gin.Context) { | ||
prices := api.app.PoolPrices(c.Request.Context()) | ||
|
||
logger := ginutils.GetValue[*zap.SugaredLogger](c, logging.LoggerKey) | ||
for _, opt := range prices { | ||
if opt.Err != nil { | ||
logger.Errorw("fetching pool price", "err", opt.Err) | ||
} | ||
} | ||
|
||
c.JSON(http.StatusOK, GetPoolsPricesResponse{ | ||
PoolResults: prices, | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"github.com/emerishq/demeris-api-server/api/database" | ||
"github.com/emerishq/demeris-api-server/api/router" | ||
"github.com/emerishq/demeris-api-server/lib/fflag" | ||
"github.com/emerishq/demeris-api-server/lib/poclient" | ||
"github.com/emerishq/demeris-api-server/sdkservice" | ||
"github.com/emerishq/demeris-api-server/usecase" | ||
"github.com/emerishq/emeris-utils/k8s" | ||
|
@@ -108,7 +109,17 @@ func main() { | |
l.Panicw("cannot initialize sdk-service clients", "error", err) | ||
} | ||
|
||
app := usecase.NewApp(sdkServiceClients) | ||
osmosisClient := usecase.NewOsmosisGrpcClient("osmosis:9090") | ||
|
||
crescentClient := usecase.NewCrescentGrpcClient("crescent:9090") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO these GRPC clients shouldn't be located in the In addition, it's weird to have both |
||
|
||
priceOracle := poclient.NewPOClient("http://price-oracle:8000") | ||
|
||
denomer := usecase.NewDatabaseDenomer(dbi) | ||
|
||
denomPricer := usecase.NewPriceOracleDenomPricer(denomer, dbi, priceOracle) | ||
|
||
app := usecase.NewApp(sdkServiceClients, osmosisClient, crescentClient, denomPricer) | ||
|
||
r := router.New( | ||
dbi, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this setup, you can expect one denom :