Skip to content

Commit

Permalink
update apr for orai staking (#32)
Browse files Browse the repository at this point in the history
* update apr for orai staking

* update: handle error fetchValidator
  • Loading branch information
ninhxuanhuan authored Dec 5, 2024
1 parent 137bd15 commit 399b1f6
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/pages/UniversalSwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from 'axios';
import cn from 'classnames/bind';
import BuyOraiModal from 'layouts/BuyOraiModal';
import Content from 'layouts/Content';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { AssetsTab, HeaderTab } from './Component';
import ConnectBanner from './Component/ConnectBanner';
import Feature from './Component/Feature';
Expand Down Expand Up @@ -84,7 +84,23 @@ const Swap: React.FC = () => {
const [isLoadedIframe, setIsLoadedIframe] = useState(false); // check iframe data loaded
const [openBuy, setOpenBuy] = useState(false);
const data = useGetInfoOraichain();
const dataStake = useGetInfoStakeOraichain();
// const dataStake = useGetInfoStakeOraichain();
const [aprOrai, setAprOrai] = useState<number>();

useEffect(() => {
async function fetchValidator() {
try {
const res = await fetch(`https://api.scan.orai.io/v1/validators?page_id=1&moniker=megaorai2`).then((data) =>
data.json()
);
const appOrai = res?.data[0]?.apr * 1.05;
setAprOrai(appOrai);
} catch (error) {
console.log({ error });
}
}
fetchValidator();
}, []);

return (
<Content nonBackground>
Expand All @@ -111,7 +127,7 @@ const Swap: React.FC = () => {
</div>
</div>
<div className={styles.looking}>You are looking for...</div>
<StakeSummary data={data?.controlCenter} aprOrai={dataStake?.inflationRate || 0} />
<StakeSummary data={data?.controlCenter} aprOrai={aprOrai || 0} />
<Feature />
</div>

Expand Down

0 comments on commit 399b1f6

Please sign in to comment.