Skip to content

Commit

Permalink
update interface
Browse files Browse the repository at this point in the history
  • Loading branch information
deadit committed Oct 22, 2023
1 parent 292c630 commit 9880c75
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 234 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"axios-hooks": "^4.0.0",
"craco-less": "^1.20.0",
"dexy-sdk-ts": "0.2.0",
"ergo-lib-wasm-browser": "^0.21.0",
"ergo-lib-wasm-browser": "^0.23.0",
"eslint-plugin-react-hooks": "^4.2.0",
"lodash": "^4.17.21",
"luxon": "^2.1.1",
Expand Down
122 changes: 0 additions & 122 deletions src/api/submitContributionTx/buildTx.ts

This file was deleted.

59 changes: 0 additions & 59 deletions src/api/submitContributionTx/submitContributionTx.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions src/api/whitelistSignup/whitelistSignup.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/common/models/PoolChartData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { DateTime } from 'luxon';

import { AssetInfo } from './AssetInfo';
import { Ratio } from './Ratio';

interface PoolChartDataRaw {
reservesCount: number;
timestamp: number;
Expand All @@ -18,14 +15,9 @@ export class PoolChartData {
constructor(private raw: PoolChartDataRaw) {
this.ts = this.raw.timestamp;
this.reservesCount = this.raw.reservesCount;
// this.invertedPrice = this.price.invertRatio();
this.date = DateTime.fromMillis(this.raw.timestamp);
}

// getRatio(isInverted = false): Ratio {
// return isInverted ? this.invertedPrice : this.price;
// }

clone(raw?: Partial<PoolChartDataRaw>): PoolChartData {
return new PoolChartData({ ...this.raw, ...raw });
}
Expand Down
10 changes: 2 additions & 8 deletions src/components/BankInfo/BankInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ const BankInfo = () => {
<Typography.Body
style={{ fontSize: valBySize('12px', '14px', '16px') }}
>
1 DexyGOLD ={' '}
{new Currency(
mint.getMintObject().oracleRate(),
ergAsset,
).toString()}{' '}
1 DexyGOLD = {new Currency(mint.oracleRate(), ergAsset).toString()}{' '}
ERG
</Typography.Body>
</div>
Expand All @@ -66,9 +62,7 @@ const BankInfo = () => {
<Typography.Body
style={{ fontSize: valBySize('12px', '14px', '16px') }}
>
1 DexyGOLD ={' '}
{new Currency(mint.getMintObject().lpRate(), ergAsset).toString()}{' '}
ERG
1 DexyGOLD = {new Currency(mint.lpRate(), ergAsset).toString()} ERG
</Typography.Body>
</div>
</Flex.Item>
Expand Down
15 changes: 12 additions & 3 deletions src/components/BankReservesGraph/BankReservesGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ import styled from 'styled-components';
import { ergAsset } from '../../common/assets/ergAsset';
import { DateTimeView } from '../../common/components/DateTimeView/DateTimeView';
import { Truncate } from '../../common/components/Truncate/Truncate';
import { useObservable } from '../../common/hooks/useObservable';
import { Currency } from '../../common/models/Currency';
import { PoolChartData } from '../../common/models/PoolChartData';
import { bankReservesGraph } from '../../mockData/chart';
import { useAggregatedByDateData } from './useAggregatedByDateData';
import { useChartData } from './useChartData';
import { Period, usePeriodSettings } from './usePeriodSettings';
import { useTicks } from './useTicks';

Expand Down Expand Up @@ -80,7 +79,17 @@ export const BankReservesGraph: React.FC = () => {
usePeriodSettings(defaultActivePeriod);

const ticks = useTicks(tick, durationOffset, [defaultActivePeriod]);
const rawData = bankReservesGraph.map((value) => new PoolChartData(value));

const params = useMemo(
() => ({
start: DateTime.now().minus(durationOffset).valueOf(),
end: DateTime.now().valueOf(),
}),
[durationOffset],
);
const [getChartData] = useChartData(params);
const rawData = getChartData?.map((value) => new PoolChartData(value)) ?? [];

const data = useAggregatedByDateData(rawData, ticks);

// recharts couldn't animate when dataKey is changed
Expand Down
35 changes: 35 additions & 0 deletions src/components/BankReservesGraph/useChartData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useCallback } from 'react';

import { applicationConfig } from '../../applicationConfig';
import { useAxios } from '../../utils/axios';

export const useChartData = ({
start,
end,
}: {
start: number;
end: number;
}) => {
const [requestState, runRequest] = useAxios<any>(
{
url: `${applicationConfig.dexybankUrl}/gold/bankReserve`,
method: 'GET',
params: {
start,
end,
},
},
{ useCache: false },
);

const refresh = useCallback(() => {
runRequest();
}, [runRequest]);

return [
requestState.data,
requestState.loading,
requestState.error,
refresh,
] as const;
};
12 changes: 11 additions & 1 deletion src/components/CirculationSupply/CirculationSupply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Currency } from '../../common/models/Currency';
import { PoolChartData } from '../../common/models/PoolChartData';
import { bankReservesGraph } from '../../mockData/chart';
import { useAggregatedByDateData } from './useAggregatedByDateData';
import { useChartData } from './useChartData';
import { Period, usePeriodSettings } from './usePeriodSettings';
import { useTicks } from './useTicks';

Expand Down Expand Up @@ -79,7 +80,16 @@ export const CirculationSupply: React.FC = () => {
usePeriodSettings(defaultActivePeriod);

const ticks = useTicks(tick, durationOffset, [defaultActivePeriod]);
const rawData = bankReservesGraph.map((value) => new PoolChartData(value));
const params = useMemo(
() => ({
start: DateTime.now().minus(durationOffset).valueOf(),
end: DateTime.now().valueOf(),
}),
[durationOffset],
);
const [getChartData] = useChartData(params);
const rawData = getChartData?.map((value) => new PoolChartData(value)) ?? [];

const data = useAggregatedByDateData(rawData, ticks);

// recharts couldn't animate when dataKey is changed
Expand Down
35 changes: 35 additions & 0 deletions src/components/CirculationSupply/useChartData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useCallback } from 'react';

import { applicationConfig } from '../../applicationConfig';
import { useAxios } from '../../utils/axios';

export const useChartData = ({
start,
end,
}: {
start: number;
end: number;
}) => {
const [requestState, runRequest] = useAxios<any>(
{
url: `${applicationConfig.dexybankUrl}/gold/circulationSupply`,
method: 'GET',
params: {
start,
end,
},
},
{ useCache: false },
);

const refresh = useCallback(() => {
runRequest();
}, [runRequest]);

return [
requestState.data,
requestState.loading,
requestState.error,
refresh,
] as const;
};
Loading

0 comments on commit 9880c75

Please sign in to comment.