Skip to content

Commit

Permalink
Merge branch 'james/acx-1627-add-acx-rebate-fee-preview-to-bridge-pag…
Browse files Browse the repository at this point in the history
…e' into james/acx-1624-update-rewards-page
  • Loading branch information
james-a-morris committed Nov 20, 2023
2 parents d6a11eb + ed66187 commit 0deddd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/utils/ethers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { Contract, ethers } from "ethers";
import { Contract, ethers, providers } from "ethers";
import type { Event } from "ethers";
import { Provider } from "@ethersproject/providers";
import { Signer } from "@ethersproject/abstract-signer";

import type { TypedEvent, TypedEventFilter } from "utils/typechain";

export { Provider, Signer, Contract, TypedEventFilter, TypedEvent, Event };
export {
Provider,
Signer,
Contract,
TypedEventFilter,
TypedEvent,
Event,
providers,
};

export type Result = ethers.utils.Result;

export type ContractTransaction = ethers.ContractTransaction;

export interface Callable {
(...args: any[]): any;
}
2 changes: 1 addition & 1 deletion src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,5 @@ export function humanReadableNumber(num: number, decimals = 0): string {
*/
export function formatUSD(value: BigNumberish): string {
const formattedString = formatUnits(value, 18);
return numeral(formattedString).format("0.00");
return numeral(formattedString).format("0,0.00");
}
14 changes: 7 additions & 7 deletions src/utils/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Contract, ContractTransaction, ethers } from "ethers";
import { parseEther } from "ethers/lib/utils";
import {
fixedPointAdjustment,
gasMultiplierPerChain,
hubPoolChainId,
} from "./constants";
import { Contract, ContractTransaction, Signer, providers } from "./ethers";
import { parseUnits } from "./format";

/**
* This function takes a raw transaction and a signer and returns the result of signing the transaction.
Expand All @@ -13,17 +13,17 @@ import {
* @returns The raw transaction signed by the given `signer`.
*/
export function signTransaction(
rawTx: ethers.providers.TransactionRequest,
signer: ethers.Signer
rawTx: providers.TransactionRequest,
signer: Signer
): Promise<string> {
//TODO: here is where we might do safety checks on the transaction
return signer.signTransaction(rawTx);
}

export async function sendSignedTransaction(
signedTx: string,
provider: ethers.providers.Provider
): Promise<ethers.providers.TransactionResponse> {
provider: providers.Provider
): Promise<providers.TransactionResponse> {
const tx = await provider.sendTransaction(signedTx);
return tx;
}
Expand All @@ -45,7 +45,7 @@ export async function getPaddedGasEstimation(
const gasEstimation = await contract.estimateGas[method](...args);
// Factor in the padding
const gasToRecommend = gasEstimation
.mul(parseEther(String(gasMultiplier)))
.mul(parseUnits(String(gasMultiplier), 18))
.div(fixedPointAdjustment);
return gasToRecommend;
}
Expand Down

0 comments on commit 0deddd3

Please sign in to comment.