Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compensate for API error by assuming all fees are network fees #750

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const config = {
externalUrls: {
networkFeesSnapshotUrl:
'https://vote.bancor.network/#/proposal/0x61cd3ec4295bf0819fb7fd80a9dcc0922036510f40b02c76213b29c48a1a5137',
'https://vote.bancor.network/#/proposal/0x74917631a57cfbd39b06f25473941a993cdf1e57f2873bfe46a9f62bfee5e8f4',
rewardsProgramsArticle:
'https://support.bancor.network/hc/en-us/articles/5415540047506-Auto-Compounding-Rewards-Standard-Rewards-programs',
governance: 'https://gov.bancor.network',
Expand Down
12 changes: 2 additions & 10 deletions src/elements/earn/pools/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,11 @@ const toolTip = (stats: Statistic) => {
<div className="w-[220px] text-black-medium dark:text-white-medium">
<div className="flex items-center justify-between">
<div className="flex items-center justify-start">
<span>Fees</span>
<span className="ml-4 text-secondary">24h</span>
</div>
<div>{`$${numbro(stats.totalFees).format(averageFormat)}`}</div>
</div>
<div className="flex items-center justify-between">
<div className="flex items-center justify-start">
{/* we show the text as Network Fees instead of fees - see this commit to better understand */}
<span>Network Fees</span>
<span className="ml-4 text-secondary">24h</span>
</div>
<div>
{`$${numbro(stats.totalNetworkFees).format(averageFormat)}`}
</div>
<div>{`$${numbro(stats.totalFees).format(averageFormat)}`}</div>
</div>
<div className="flex items-center justify-between">
<div className="flex items-center justify-start">
Expand Down
27 changes: 4 additions & 23 deletions src/elements/earn/pools/poolsTable/PoolsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,41 +61,22 @@ export const PoolsTable = ({
<div className="w-[150px] text-black-medium dark:text-white-medium">
<div className="flex items-center justify-between">
Liquidity
<div>
{toBigNumber(row.stakedBalance.usd).isZero()
? 'New'
: prettifyNumber(row.stakedBalance.usd, true)}
</div>
<div>{prettifyNumber(row.stakedBalance.usd, true)}</div>
</div>
<div className="flex items-center justify-between">
Volume 7d
<div>
{toBigNumber(row.volume7d.usd).isZero()
? 'New'
: prettifyNumber(row.volume7d.usd, true)}
</div>
<div>{prettifyNumber(row.volume7d.usd, true)}</div>
</div>
<div className="flex items-center justify-between">
Fees 7d
<div>
{toBigNumber(row.fees7d.usd).isZero()
? 'New'
: prettifyNumber(row.fees7d.usd, true)}
</div>
<div>{prettifyNumber(row.fees7d.usd, true)}</div>
</div>
<div className="flex items-center justify-between">
<div className="flex items-center justify-start">
LP Fees 7d
<SnapshotLink />
</div>
<div>
{toBigNumber(row.fees7d.usd).minus(row.networkFees7d.usd).isZero()
? 'New'
: prettifyNumber(
toBigNumber(row.fees7d.usd).minus(row.networkFees7d.usd),
true
)}
</div>
<div>0</div>
</div>
</div>
),
Expand Down
4 changes: 1 addition & 3 deletions src/elements/earn/portfolio/v3/V3AvailableToStake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const AvailableItem = ({ token, pool }: { token: Token; pool: PoolV3 }) => {
<div className="mb-5 text-secondary">Earn</div>
<div className="flex">
<span className="text-[22px]">
{pool.apr7d.total === 0 && !pool.depositingEnabled
? 'New'
: `${pool.apr7d.total.toFixed(2)}%`}
{`${pool.apr7d.total.toFixed(2)}%`}
</span>
<IconArrow className="w-10 rotate-[90deg] ml-10" />
</div>
Expand Down
19 changes: 9 additions & 10 deletions src/services/observables/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Token,
tokensV3$,
} from 'services/observables/tokens';
import BigNumber from 'bignumber.js';
import { combineLatest } from 'rxjs';
import { switchMapIgnoreThrow } from 'services/observables/customOperators';
import { distinctUntilChanged, shareReplay } from 'rxjs/operators';
Expand Down Expand Up @@ -201,15 +200,15 @@ const buildPoolV3Object = (
programs
);

const tradingFeesApr24h = calcApr(
new BigNumber(apiPool.fees24h.usd).minus(apiPool.networkFees24h.usd),
stakedBalance.usd
);
const tradingFeesApr7d = calcApr(
new BigNumber(apiPool.fees7d.usd).minus(apiPool.networkFees7d.usd),
stakedBalance.usd,
true
);
const tradingFeesApr24h = 0; // calcApr(
zavelevsky marked this conversation as resolved.
Show resolved Hide resolved
// new BigNumber(apiPool.fees24h.usd).minus(apiPool.networkFees24h.usd),
// stakedBalance.usd
// );
const tradingFeesApr7d = 0; // calcApr(
// new BigNumber(apiPool.fees7d.usd).minus(apiPool.networkFees7d.usd),
// stakedBalance.usd,
// true
// );

// Auto Comp APR
const autoCompoundingApr24H = calcApr(
Expand Down
2 changes: 1 addition & 1 deletion src/services/observables/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const statisticsV3$ = combineLatest([apiData$, oneMinute$]).pipe(
bntRate: stats.bntRate,
totalBNTStaked: totalBNTStaked.toString(),
totalNetworkFees: totalNetworkFees.toString(),
totalLpFees: totalFees.minus(totalNetworkFees).toString(),
totalLpFees: '0',
};
return statistics;
}),
Expand Down
Loading