diff --git a/src/routes/index.ts b/src/routes/index.ts index 0771044..6501b9e 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -115,15 +115,22 @@ router.get('/blinks/deposit', async (req: Request, res: Response) => { }); await driftClient.subscribe(); - let title = `Deposit ${depositToken} into Drift`; + let title = `Deposit ${depositToken} into Drift`; + + const spotMarket = driftClient.getSpotMarketAccount( + spotMarketConfig.marketIndex + ); - const spotMarket = driftClient.getSpotMarketAccount(spotMarketConfig.marketIndex); - if (spotMarket) { - const apr = convertToNumber(calculateDepositRate(spotMarket), new BN(10000)); + const apr = convertToNumber( + calculateDepositRate(spotMarket), + new BN(10000) + ); if (apr >= 0.1) { - title = `Deposit ${depositToken} into Drift and earn ${apr}% APR`; + title = `Deposit ${depositToken} into Drift and earn ${apr.toFixed( + 2 + )}% APR`; } } @@ -157,7 +164,7 @@ router.get('/blinks/deposit', async (req: Request, res: Response) => { }, ], }; - + const response: ActionsSpecGetResponse = { icon, label, @@ -166,7 +173,7 @@ router.get('/blinks/deposit', async (req: Request, res: Response) => { disabled, links, }; - + driftClient.unsubscribe(); return res.json(response);