-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
import type {HardhatRuntimeEnvironment} from "hardhat/types"; | ||
import assert from "node:assert"; | ||
|
||
import type { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
export async function deployNilContract( | ||
hre: HardhatRuntimeEnvironment, | ||
name: string, | ||
args: string[] = [], | ||
hre: HardhatRuntimeEnvironment, | ||
name: string, | ||
args: string[] = [], | ||
) { | ||
const factory = await hre.ethers.getContractFactory(name); | ||
assert.ok(factory.runner); | ||
assert.ok(factory.runner.sendTransaction); | ||
const factory = await hre.ethers.getContractFactory(name); | ||
assert.ok(factory.runner); | ||
assert.ok(factory.runner.sendTransaction); | ||
|
||
const deployTx = await factory.getDeployTransaction(...args); | ||
const sentTx = await factory.runner.sendTransaction(deployTx); | ||
const txReceipt = await sentTx.wait(); | ||
const deployTx = await factory.getDeployTransaction(...args); | ||
const sentTx = await factory.runner.sendTransaction(deployTx); | ||
const txReceipt = await sentTx.wait(); | ||
|
||
if (!txReceipt || !txReceipt.contractAddress) { | ||
throw new Error("Contract deployment failed"); | ||
} | ||
if (!txReceipt || !txReceipt.contractAddress) { | ||
throw new Error("Contract deployment failed"); | ||
} | ||
|
||
const deployedContract = factory.attach(txReceipt.contractAddress); | ||
return { deployedContract, contractAddress: txReceipt.contractAddress }; | ||
} | ||
const deployedContract = factory.attach(txReceipt.contractAddress); | ||
return { deployedContract, contractAddress: txReceipt.contractAddress }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
|
||
export function calculateOutputAmount( | ||
amountIn: bigint, | ||
reserveIn: bigint, | ||
reserveOut: bigint, | ||
amountIn: bigint, | ||
reserveIn: bigint, | ||
reserveOut: bigint, | ||
): bigint { | ||
const amountInWithFee = amountIn * BigInt(997); | ||
const numerator = amountInWithFee * reserveOut; | ||
const denominator = reserveIn * BigInt(1000) + amountInWithFee; | ||
return numerator / denominator; | ||
} | ||
const amountInWithFee = amountIn * BigInt(997); | ||
const numerator = amountInWithFee * reserveOut; | ||
const denominator = reserveIn * BigInt(1000) + amountInWithFee; | ||
return numerator / denominator; | ||
} |