Skip to content

Commit

Permalink
added STRK price
Browse files Browse the repository at this point in the history
  • Loading branch information
iamoskvin committed Mar 1, 2024
1 parent 1e9dd7c commit 5735d7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const getApiUrl = () => {
return 'https://api.jediswap.xyz/graphql'
}
export const STARKNET_REWARDS_API_URL = 'https://kx58j6x5me.execute-api.us-east-1.amazonaws.com//starknet/fetchFile?file=qa_strk_grant.json'
export const STRK_PRICE_API_URL = 'https://api.binance.com/api/v3/ticker/price?symbol=STRKUSDT'

export const apiTimeframeOptions = {
oneDay: 'one_day',
Expand Down
11 changes: 7 additions & 4 deletions src/pages/RewardsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import RewardPoolsList from '../components/RewardPoolsList'
import { PAIRS_DATA_FOR_REWARDS, POOLS_DATA } from '../apollo/queries.js'
import { jediSwapClient } from '../apollo/client.js'
import { isEmpty } from 'lodash'
import { STARKNET_REWARDS_API_URL } from '../constants/index.js'
import { STARKNET_REWARDS_API_URL, STRK_PRICE_API_URL } from '../constants/index.js'

const BaseStar = styled.img`
position: absolute;
Expand Down Expand Up @@ -133,10 +133,13 @@ function RewardsPage() {
}),
fetchPolicy: 'cache-first',
}),
fetch(STARKNET_REWARDS_API_URL)
fetch(STARKNET_REWARDS_API_URL),
fetch(STRK_PRICE_API_URL)
];
const [pairsResp, starknetResp] = await Promise.all(requests);
const [pairsResp, starknetResp, strkPriceResp] = await Promise.all(requests);
const rewardsResp = await starknetResp.json();
const priceResp = await strkPriceResp.json();
const strkPrice = parseFloat(priceResp.price)
const jediRewards = rewardsResp.Jediswap_v1;
const rewardsPositions = []
for (const pair of pairs) {
Expand All @@ -145,7 +148,7 @@ function RewardsPage() {
const pairDayData = pairsResp.data.pairDayDatas.find(dayData => dayData.pairId === pair.poolAddress && dayData.date === recentDate + 'T00:00:00')
// console.log('pairDayData', pairDayData)
const aprFee = pairDayData.dailyVolumeUSD * 0.003 / pairDayData.reserveUSD * 365 * 100
const aprStarknet = rewardsData.allocation / pairDayData.reserveUSD * 365 * 100
const aprStarknet = rewardsData.allocation / pairDayData.reserveUSD * 365 * 100 * strkPrice
rewardsPositions.push({
...pair,
reserveUSD: pairDayData.reserveUSD,
Expand Down

0 comments on commit 5735d7c

Please sign in to comment.