Skip to content

Commit

Permalink
Merge pull request #293 from jediswaplabs/iamoskvin/new_rewards_pairs
Browse files Browse the repository at this point in the history
Iamoskvin/new rewards pairs
  • Loading branch information
iamoskvin authored Mar 22, 2024
2 parents 510ef0d + 1615992 commit 8935537
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
36 changes: 36 additions & 0 deletions src/pages/Rewards/RewardPairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,42 @@ const pairs = [
tokenAddress: '0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8',
symbol: 'USDC'
}
},
{
rewardName: 'USDC/DAI',
poolAddress: '0x7582a77c9128e063c6f7d5a57acae969417f925904540edfac388bacaeb1fa6',
token0: {
tokenAddress: '0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8',
symbol: 'USDC'
},
token1: {
tokenAddress: '0x5574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad',
symbol: 'DAI'
}
},
{
rewardName: 'WSTETH/ETH',
poolAddress: '0x70cda8400d7b1ee9e21f7194d320b9ad9c7a2b27e0d15a5a9967b9fefe10c76',
token0: {
tokenAddress: '0x42b8f0484674ca266ac5d08e4ac6a3fe65bd3129795def2dca5c34ecc5f96d2',
symbol: 'wstETH'
},
token1: {
tokenAddress: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
symbol: 'ETH'
}
},
{
rewardName: 'WBTC/ETH',
poolAddress: '0x260e98362e0949fefff8b4de85367c035e44f734c9f8069b6ce2075ae86b45c',
token0: {
tokenAddress: '0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac',
symbol: 'WBTC'
},
token1: {
tokenAddress: '0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7',
symbol: 'ETH'
}
}
]

Expand Down
19 changes: 9 additions & 10 deletions src/pages/Rewards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,24 +459,23 @@ export default function Rewards() {
fetchPolicy: 'cache-first'
})
const rewardsResp = await fetch(STARKNET_REWARDS_API_URL)
.then(res => res.text()) // Get the response as text
.then(text => {
const validJson = text.replace(/NaN/g, 'null') // Replace NaN with null
return JSON.parse(validJson) // Parse the corrected string as JSON
})
const priceResp = await fetch(STRK_PRICE_API_URL).then(res => res.json())
const rewardsRespStr = await rewardsResp.text()
const rewardsRespStrClean = rewardsRespStr.replace(/\bNaN\b/g, "null")
const rewardsRespJson = JSON.parse(rewardsRespStrClean)

const strkPrice = parseFloat(priceResp.price)
const jediRewards = rewardsResp.Jediswap_v1
const jediRewards = rewardsRespJson.Jediswap_v1
const rewardsPositions: any = []
for (const pair of pairs) {
const rewardsData = jediRewards[pair.rewardName].pop()
if (!rewardsData) {
continue
}
const recentDate = rewardsData.date
const pairDayData = pairsResp.data.pairDayDatas.find(
dayData => dayData.pairId === pair.poolAddress && dayData.date === recentDate + 'T00:00:00'
)
const aprFee = ((pairDayData.dailyVolumeUSD * 0.003) / pairDayData.reserveUSD) * 365 * 100
const aprStarknet = (rewardsData.allocation / pairDayData.reserveUSD) * 365 * 100 * strkPrice
const aprStarknet = rewardsData.apr * 100
rewardsPositions.push({
...pair,
reserveUSD: pairDayData.reserveUSD,
Expand Down Expand Up @@ -633,7 +632,7 @@ export default function Rewards() {
pair.token1.symbol === 'ETH' ? pair.token1 : allTokens[validateAndParseAddress(pair.token1.tokenAddress)]

return (
<Column style={{ padding: 10 }}>
<Column style={{ padding: 10, flexBasis: '32%', flexGrow: 0 }}>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<DoubleCurrencyLogo size={24} currency0={token0} currency1={token1} />
</div>
Expand Down

0 comments on commit 8935537

Please sign in to comment.