From 66dd011e241cd916142a64d7ab75154bba916b79 Mon Sep 17 00:00:00 2001 From: Felix Egbert <47861849+fegbert@users.noreply.github.com> Date: Wed, 25 May 2022 17:53:21 +0200 Subject: [PATCH] fix: Updated displayed fees on bidding transaction page (#262) --- core/src/fees.ts | 34 ++++++++++++------- core/src/types.ts | 12 ++++--- frontend/components/GasTable.vue | 4 +-- frontend/components/transaction/BidBlock.vue | 2 +- .../transaction/BidTransactionTable.vue | 8 ++--- .../transaction/SwapTransaction.vue | 2 +- .../transaction/SwapTransactionTable.vue | 8 ++--- frontend/helpers/generateFakeAuction.ts | 18 +++++----- frontend/helpers/generateFakeGas.ts | 12 ++++--- 9 files changed, 59 insertions(+), 41 deletions(-) diff --git a/core/src/fees.ts b/core/src/fees.ts index b38ddc5fc..ac2c2a045 100644 --- a/core/src/fees.ts +++ b/core/src/fees.ts @@ -15,13 +15,16 @@ export const getApproximateTransactionFees = async function (network: string): P // TODO: figure out a way to properly estimate gas // for each transaction when no wallet is connected - const biddingTransactionFeeETH = gasPrice.multipliedBy(722651); + const bidTransactionFeeETH = gasPrice.multipliedBy(145438); + const swapTransactionFeeETH = gasPrice.multipliedBy(722651); const authTransactionFeeETH = gasPrice.multipliedBy(48356); const restartTransactionFeeETH = gasPrice.multipliedBy(209182); return { - biddingTransactionFeeETH, - biddingTransactionFeeDAI: await convertETHtoDAI(network, biddingTransactionFeeETH), + bidTransactionFeeETH, + bidTransactionFeeDAI: await convertETHtoDAI(network, bidTransactionFeeETH), + swapTransactionFeeETH, + swapTransactionFeeDAI: await convertETHtoDAI(network, swapTransactionFeeETH), authTransactionFeeETH, authTransactionFeeDAI: await convertETHtoDAI(network, authTransactionFeeETH), restartTransactionFeeETH, @@ -34,7 +37,8 @@ export const enrichAuctionWithTransactionFees = async function ( fees: TransactionFees, network: string ): Promise { - let totalFeeETH = fees.biddingTransactionFeeETH; + let combinedSwapFeesETH = fees.swapTransactionFeeETH; + let combinedBidFeesETH = fees.bidTransactionFeeETH; try { const signer = await getSigner(network); @@ -47,24 +51,30 @@ export const enrichAuctionWithTransactionFees = async function ( ); if (!isWalletAuthed) { - totalFeeETH = totalFeeETH.plus(fees.authTransactionFeeETH); + combinedSwapFeesETH = combinedSwapFeesETH.plus(fees.authTransactionFeeETH); + combinedBidFeesETH = combinedBidFeesETH.plus(fees.authTransactionFeeETH); } if (!isCollateralAuthed) { - totalFeeETH = totalFeeETH.plus(fees.authTransactionFeeETH); + combinedSwapFeesETH = combinedSwapFeesETH.plus(fees.authTransactionFeeETH); + combinedBidFeesETH = combinedSwapFeesETH.plus(fees.authTransactionFeeETH); } } catch (e) { - totalFeeETH = totalFeeETH.plus(fees.authTransactionFeeETH).plus(fees.authTransactionFeeETH); + combinedSwapFeesETH = combinedSwapFeesETH.plus(fees.authTransactionFeeETH).plus(fees.authTransactionFeeETH); + combinedBidFeesETH = combinedBidFeesETH.plus(fees.authTransactionFeeETH).plus(fees.authTransactionFeeETH); } - const totalFeeDAI = await convertETHtoDAI(network, totalFeeETH); + const combinedSwapFeesDAI = await convertETHtoDAI(network, combinedSwapFeesETH); + const combinedBidFeesDAI = await convertETHtoDAI(network, combinedBidFeesETH); const auctionTransaction = { ...auction, ...fees, - totalFeeETH: totalFeeETH, - totalFeeDAI: totalFeeDAI, + combinedBidFeesETH: combinedBidFeesETH, + combinedBidFeesDAI: combinedBidFeesDAI, + combinedSwapFeesETH: combinedSwapFeesETH, + combinedSwapFeesDAI: combinedSwapFeesDAI, } as AuctionTransaction; - if (auction.transactionGrossProfit && fees.biddingTransactionFeeDAI) { - auctionTransaction.transactionNetProfit = auction.transactionGrossProfit.minus(totalFeeDAI); + if (auction.transactionGrossProfit && fees.swapTransactionFeeDAI) { + auctionTransaction.transactionNetProfit = auction.transactionGrossProfit.minus(combinedSwapFeesDAI); } return auctionTransaction; }; diff --git a/core/src/types.ts b/core/src/types.ts index c000fff61..ce7ab77a7 100644 --- a/core/src/types.ts +++ b/core/src/types.ts @@ -48,8 +48,10 @@ export declare interface Auction extends AuctionInitialInfo { } export declare interface TransactionFees { - biddingTransactionFeeETH: BigNumber; - biddingTransactionFeeDAI: BigNumber; + bidTransactionFeeETH: BigNumber; + bidTransactionFeeDAI: BigNumber; + swapTransactionFeeETH: BigNumber; + swapTransactionFeeDAI: BigNumber; authTransactionFeeETH: BigNumber; authTransactionFeeDAI: BigNumber; restartTransactionFeeETH: BigNumber; @@ -64,8 +66,10 @@ export declare interface CollateralRow extends CollateralConfig, Partial Unknown @@ -82,7 +82,7 @@ Unknown diff --git a/frontend/components/transaction/BidBlock.vue b/frontend/components/transaction/BidBlock.vue index 266a8b707..ea90d575b 100644 --- a/frontend/components/transaction/BidBlock.vue +++ b/frontend/components/transaction/BidBlock.vue @@ -3,7 +3,7 @@
(~ Unknown @@ -42,8 +42,8 @@
Unknown diff --git a/frontend/components/transaction/SwapTransaction.vue b/frontend/components/transaction/SwapTransaction.vue index 8429aecf1..15a40cd0f 100644 --- a/frontend/components/transaction/SwapTransaction.vue +++ b/frontend/components/transaction/SwapTransaction.vue @@ -79,7 +79,7 @@ :wallet-address="walletAddress" :is-explanations-shown="isExplanationsShown" :collateral-type="auctionTransaction.collateralType" - :transaction-fee="auctionTransaction.biddingTransactionFeeETH" + :transaction-fee="auctionTransaction.swapTransactionFeeETH" :transaction-gross-profit="auctionTransaction.transactionGrossProfit" @execute="$emit('execute', { id: auctionTransaction.id, alternativeDestinationAddress: $event })" /> diff --git a/frontend/components/transaction/SwapTransactionTable.vue b/frontend/components/transaction/SwapTransactionTable.vue index 38c973de7..ab6e59966 100644 --- a/frontend/components/transaction/SwapTransactionTable.vue +++ b/frontend/components/transaction/SwapTransactionTable.vue @@ -63,8 +63,8 @@ Combined Transactions Fees (~ Unknown @@ -73,8 +73,8 @@
Unknown diff --git a/frontend/helpers/generateFakeAuction.ts b/frontend/helpers/generateFakeAuction.ts index b8e6e4430..967883dba 100644 --- a/frontend/helpers/generateFakeAuction.ts +++ b/frontend/helpers/generateFakeAuction.ts @@ -56,24 +56,24 @@ export const generateFakeAuction = function () { export const generateFakeAuctionTransaction = function () { const auction = generateFakeAuction(); - const biddingTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); - const biddingTransactionFeeDAI = biddingTransactionFeeETH.multipliedBy(1000); + const swapTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); + const swapTransactionFeeDAI = swapTransactionFeeETH.multipliedBy(1000); const authTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); const authTransactionFeeDAI = authTransactionFeeETH.multipliedBy(1000); const restartTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); - const transactionNetProfit = auction.transactionGrossProfit.minus(biddingTransactionFeeDAI); - const totalFeeETH = biddingTransactionFeeETH.plus(authTransactionFeeETH); - const totalFeeDAI = totalFeeETH.multipliedBy(1000); + const transactionNetProfit = auction.transactionGrossProfit.minus(swapTransactionFeeDAI); + const combinedSwapFeesETH = swapTransactionFeeETH.plus(authTransactionFeeETH); + const combinedSwapFeesDAI = combinedSwapFeesETH.multipliedBy(1000); return { ...auction, - biddingTransactionFeeETH, - biddingTransactionFeeDAI, + swapTransactionFeeETH, + swapTransactionFeeDAI, authTransactionFeeETH, authTransactionFeeDAI, restartTransactionFeeETH, transactionNetProfit, - totalFeeETH, - totalFeeDAI, + combinedSwapFeesETH, + combinedSwapFeesDAI, }; }; diff --git a/frontend/helpers/generateFakeGas.ts b/frontend/helpers/generateFakeGas.ts index 12d398754..d5ec75ac5 100644 --- a/frontend/helpers/generateFakeGas.ts +++ b/frontend/helpers/generateFakeGas.ts @@ -11,16 +11,20 @@ export function generateFakeGasParameters(): GasParameters { } export function generateFakeTransactionFees(): TransactionFees { - const biddingTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); - const biddingTransactionFeeDAI = biddingTransactionFeeETH.multipliedBy(1000); + const bidTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); + const bidTransactionFeeDAI = bidTransactionFeeETH.multipliedBy(1000); + const swapTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); + const swapTransactionFeeDAI = swapTransactionFeeETH.multipliedBy(1000); const authTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); const authTransactionFeeDAI = authTransactionFeeETH.multipliedBy(1000); const restartTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); const restartTransactionFeeDAI = restartTransactionFeeETH.multipliedBy(1000); return { - biddingTransactionFeeETH, - biddingTransactionFeeDAI, + bidTransactionFeeETH, + bidTransactionFeeDAI, + swapTransactionFeeETH, + swapTransactionFeeDAI, authTransactionFeeETH, authTransactionFeeDAI, restartTransactionFeeETH,