Skip to content

Commit

Permalink
fix: apys
Browse files Browse the repository at this point in the history
  • Loading branch information
linkielink committed Nov 8, 2024
1 parent 6c70830 commit 611e62b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
24 changes: 13 additions & 11 deletions src/api/campaign/getCampaignApys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,31 @@ export default async function getCampaignApys(
try {
await fetchWithTimeout(url.toString(), FETCH_TIMEOUT).then(async (res) => {
const data = (await res.json()) as any
if (Array.isArray(data[apyStructure[0]])) {
if (apyStructure[0] === denomStructure[0])
data[apyStructure[0]].forEach((apyData: any) => {
const dataObject = data[apyStructure[0]]
if (Array.isArray(dataObject[apyStructure[1]])) {
if (apyStructure[1] === denomStructure[0])
dataObject[apyStructure[1]].forEach((apyData: any) => {
apys.push({
apy: processApyData(apyData[apyStructure[1]], isApr, isPercent),
apy: processApyData(apyData[apyStructure[2]], isApr, isPercent),
denom: apyData[denomStructure[1]],
})
})
} else if (Array.isArray(data)) {
data.forEach((campaign: any) => {
} else if (Array.isArray(dataObject)) {
dataObject.forEach((campaign: any) => {
apys.push({
apy: processApyData(campaign[apyStructure[0]], isApr, isPercent),
apy: processApyData(campaign[apyStructure[1]], isApr, isPercent),
denom: campaign[denomStructure[0]],
})
})
} else {
const apyData =
apyStructure.length === 1 ? data[apyStructure[0]] : data[apyStructure[0]][apyStructure[1]]
apyStructure.length === 2
? dataObject[apyStructure[1]]
: dataObject[apyStructure[1]][apyStructure[2]]
const denomData =
denomStructure.length === 1
? data[denomStructure[0]]
: data[denomStructure[0]][denomStructure[1]]

? dataObject[denomStructure[0]]
: dataObject[denomStructure[0]][denomStructure[1]]
apys.push({
apy: processApyData(apyData, isApr, isPercent),
denom: denomData,
Expand Down
1 change: 0 additions & 1 deletion src/chains/neutron/neutron-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const Neutron1: ChainConfig = {
gasPrices: '/feemarket/v1/gas_price/untrn',
aprs: {
vaults: '',
stride: 'https://edge.stride.zone/api/stake-stats',
},
},
network: NETWORK.MAINNET,
Expand Down
1 change: 0 additions & 1 deletion src/chains/neutron/pion-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const Pion1: ChainConfig = {
gasPrices: '/feemarket/v1/gas_price/untrn',
aprs: {
vaults: '',
stride: 'https://edge.stride.zone/api/stake-stats',
perpsVault: 'https://testnet-api.marsprotocol.io/v2/perps_vault?chain=neutron',
},
},
Expand Down
1 change: 0 additions & 1 deletion src/chains/osmosis/osmosis-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const Osmosis1: ChainConfig = {
gasPrices: 'https://osmosis-api.polkachu.com/osmosis/txfees/v1beta1/cur_eip_base_fee',
aprs: {
vaults: 'https://api.marsprotocol.io/v1/vaults/osmosis',
stride: 'https://edge.stride.zone/api/stake-stats',
},
},
dexName: 'Osmosis Dex',
Expand Down
8 changes: 4 additions & 4 deletions src/constants/campaigns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const CAMPAIGNS: AssetCampaign[] = [
url: 'https://neutron-cache-api.onrender.com/stride',
isApr: true,
isPercent: false,
apyStructure: ['stats', 'strideYield'],
apyStructure: ['strideData', 'stats', 'strideYield'],
denomStructure: ['stats', 'denom'],
},
incentiveCopy: '+##APY##% APY',
Expand Down Expand Up @@ -49,7 +49,7 @@ export const CAMPAIGNS: AssetCampaign[] = [
url: 'https://neutron-cache-api.onrender.com/drop',
isApr: false,
isPercent: false,
apyStructure: ['apy'],
apyStructure: ['dropData', 'apy'],
denomStructure: ['denom'],
},
incentiveCopy: '+##APY##% APY',
Expand All @@ -67,7 +67,7 @@ export const CAMPAIGNS: AssetCampaign[] = [
url: 'https://neutron-cache-api.onrender.com/lido',
isApr: true,
isPercent: true,
apyStructure: ['data', 'smaApr'],
apyStructure: ['lidoData', 'data', 'smaApr'],
denomStructure: ['meta', 'symbol'],
},
incentiveCopy: '+##APY##% APY',
Expand All @@ -86,7 +86,7 @@ export const CAMPAIGNS: AssetCampaign[] = [
url: 'https://neutron-cache-api.onrender.com/milkyway',
isApr: true,
isPercent: true,
apyStructure: ['apr'],
apyStructure: ['milkywayData', 'apr'],
denomStructure: ['symbol'],
},
incentiveCopy: '+##APY##% APY',
Expand Down
1 change: 0 additions & 1 deletion src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ interface ChainConfig {
gasPrices?: string
aprs: {
vaults: string
stride: string
perpsVault?: string
}
}
Expand Down

0 comments on commit 611e62b

Please sign in to comment.