Skip to content

Commit

Permalink
Update sodaki interface (#621)
Browse files Browse the repository at this point in the history
* update sodaki interface

* fix: bridge balance display issue

* Fix pool dateils error

* Fix pool details tvl

* Fix pool details bugs

---------

Co-authored-by: lq0-github <[email protected]>
Co-authored-by: naturexie <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent 7fefbf4 commit 5cf5480
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/pages/Bridge/hooks/useBridgeForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default function useBridgeForm() {
if (!getWallet(bridgeFromValue.chain)?.accountId) return '0';
return tokenServices.getBalance(
bridgeFromValue.chain,
getTokenMeta(bridgeToValue.tokenMeta.symbol),
getTokenMeta(bridgeFromValue.tokenMeta.symbol),
true
);
},
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Orderly/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function getConfig(
helperUrl: 'https://api.kitwallet.app',
explorerUrl: 'https://nearblocks.io',
indexerUrl: 'https://api.ref.finance',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
blackList: process.env.FARM_BLACK_LIST || ['1371#3', '2769#2'],
REF_FI_CONTRACT_ID:
Expand Down Expand Up @@ -96,7 +96,7 @@ export default function getConfig(
helperUrl: 'https://testnet-api.kitwallet.app',
explorerUrl: 'https://testnet.nearblocks.io',
indexerUrl: 'https://testnet-indexer.ref-finance.com',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
blackList: process.env.FARM_BLACK_LIST || ['1371#3'],
REF_FI_CONTRACT_ID:
Expand Down Expand Up @@ -167,7 +167,7 @@ export default function getConfig(
helperUrl: 'https://testnet-api.kitwallet.app',
explorerUrl: 'https://testnet.nearblocks.io',
indexerUrl: 'https://dev-indexer.ref-finance.com',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
blackList: process.env.FARM_BLACK_LIST || ['1371#3'],
REF_FI_CONTRACT_ID:
Expand Down Expand Up @@ -235,7 +235,7 @@ export default function getConfig(
helperUrl: 'https://api.kitwallet.app',
explorerUrl: 'https://nearblocks.io',
indexerUrl: 'https://api.ref.finance',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
blackList: process.env.FARM_BLACK_LIST || ['1371#3', '2769#2'],
REF_FI_CONTRACT_ID:
Expand Down
4 changes: 2 additions & 2 deletions src/pages/pools/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2290,7 +2290,7 @@ export function TVLChart({
cursor={{ opacity: '0.3' }}
/>
<Area
dataKey="scaled_tvl"
dataKey="total_tvl"
dot={false}
stroke="#00c6a2"
strokeWidth={3}
Expand Down Expand Up @@ -3399,4 +3399,4 @@ export const formatNumber = (v: string | number, decimal?: number) => {

function setIsLoading(arg0: boolean) {
throw new Error('Function not implemented.');
}
}
8 changes: 4 additions & 4 deletions src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default function getConfig(
pikespeakUrl: 'https://pikespeak.ai',
nearExplorerUrl: 'https://explorer.near.org/',
indexerUrl: 'https://mainnet-indexer.ref-finance.com',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
txIdApiUrl: 'https://api3.nearblocks.io',
memeRankApiUrl: 'https://api.ref.finance',
Expand Down Expand Up @@ -289,7 +289,7 @@ export default function getConfig(
pikespeakUrl: 'https://pikespeak.ai',
nearExplorerUrl: 'https://explorer.testnet.near.org/',
indexerUrl: 'https://testnet-indexer.ref-finance.com',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
txIdApiUrl: 'https://api-testnet.nearblocks.io',
memeRankApiUrl: 'https://testnet-indexer.ref-finance.com',
Expand Down Expand Up @@ -395,7 +395,7 @@ export default function getConfig(
pikespeakUrl: 'https://pikespeak.ai',
nearExplorerUrl: 'https://explorer.testnet.near.org/',
indexerUrl: 'https://dev-indexer.ref-finance.com',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://dev.data-service.ref-finance.com/api',
txIdApiUrl: 'https://api-testnet.nearblocks.io',
memeRankApiUrl: 'https://dev-indexer.ref-finance.com',
Expand Down Expand Up @@ -498,7 +498,7 @@ export default function getConfig(
pikespeakUrl: 'https://pikespeak.ai',
nearExplorerUrl: 'https://explorer.near.org/',
indexerUrl: 'https://api.ref.finance',
sodakiApiUrl: 'https://api.stats.ref.finance/api',
sodakiApiUrl: ' https://api.data-service.ref.finance/api',
dataServiceApiUrl: 'https://api.data-service.ref.finance/api',
txIdApiUrl: 'https://api3.nearblocks.io',
memeRankApiUrl: 'https://api.ref.finance',
Expand Down
4 changes: 2 additions & 2 deletions src/services/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ export const getAllV3Pool24Volume = async (): Promise<any[]> => {
};

export const getAllTvl = async () => {
return await fetch(config.sodakiApiUrl + '/historical-tvl?period=1', {
return await fetch(config.sodakiApiUrl + '/historical_tvl?period=1', {
method: 'GET',
})
.then((res) => res.json())
Expand All @@ -1004,7 +1004,7 @@ export const getAllTvl = async () => {
};

export const getAllVolume24h = async () => {
return await fetch(config.sodakiApiUrl + '/24h-volume-variation', {
return await fetch(config.sodakiApiUrl + '/24h_volume_variation', {
method: 'GET',
})
.then((res) => res.json())
Expand Down
60 changes: 35 additions & 25 deletions src/state/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ export const useRemoveLiquidity = ({

export interface volumeType {
pool_id: string;
dateString: string;
date_string: string;
fiat_volume: string;
asset_volume: string;
volume_dollar: string;
Expand All @@ -937,6 +937,7 @@ export const useMonthVolume = (pool_id: string) => {
return {
...v,
volume_dollar: Number(v.volume_dollar),
dateString: v.date_string,
};
})
.reverse();
Expand All @@ -948,46 +949,55 @@ export const useMonthVolume = (pool_id: string) => {
};

export interface TVLType {
// pool_id: string;
// asset_amount: string;
// fiat_amount: string;
// asset_price: string;
// fiat_price: string;
// asset_tvl: string;
// fiat_tvl: string;
// date: string;
date_string: string;
pool_id: string;
asset_amount: string;
fiat_amount: string;
asset_price: string;
fiat_price: string;
asset_tvl: string;
fiat_tvl: string;
date: string;
time: number;
tvl: number;
}
export interface TVLDataType {
pool_id: string;
asset_amount: string;
fiat_amount: string;
asset_price: string;
fiat_price: string;
asset_tvl: number;
fiat_tvl: number;
// pool_id: string;
// asset_amount: string;
// fiat_amount: string;
// asset_price: string;
// fiat_price: string;
// asset_tvl: number;
// fiat_tvl: number;
date: string;
total_tvl: number;
scaled_tvl: number;
// scaled_tvl: number;
pool_id: string;
time: number;
tvl: number;
}

export const useMonthTVL = (pool_id: string) => {
const [monthTVLById, setMonthTVLById] = useState<TVLDataType[]>();
useEffect(() => {
getPoolMonthTVL(pool_id).then((res) => {
const minDay = _.minBy(res, (o) => {
return Number(o.asset_tvl) + Number(o.fiat_tvl);
});
const minValue = Number(minDay?.asset_tvl) + Number(minDay?.fiat_tvl);
// const minDay = _.minBy(res, (o) => {
// return Number(o.asset_tvl) + Number(o.fiat_tvl);
// });
// const minValue = Number(minDay?.asset_tvl) + Number(minDay?.fiat_tvl);

const monthTVL = res
.map((v, i) => {
return {
...v,
asset_tvl: Number(v?.asset_tvl),
fiat_tvl: Number(v?.fiat_tvl),
total_tvl: Number(v?.fiat_tvl) + Number(v?.asset_tvl),
scaled_tvl:
Number(v?.fiat_tvl) + Number(v?.asset_tvl) - minValue * 0.99,
total_tvl: Number(v.tvl),
date: v.date_string,
// asset_tvl: Number(v?.asset_tvl),
// fiat_tvl: Number(v?.fiat_tvl),
// total_tvl: Number(v?.fiat_tvl) + Number(v?.asset_tvl),
// scaled_tvl:
// Number(v?.fiat_tvl) + Number(v?.asset_tvl) - minValue * 0.99,
};
})
.reverse();
Expand Down

0 comments on commit 5cf5480

Please sign in to comment.