-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Kay <kehiiiiya@gmail.com>
- Loading branch information
1 parent
85f8e26
commit 32d3095
Showing
10 changed files
with
82 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ jobs: | |
run: npm install | ||
|
||
- name: Run Hardhat tests | ||
run: npx hardhat test | ||
run: npm run test |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ethers, upgrades } from "hardhat" | ||
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers" | ||
import { expect } from "chai" | ||
|
||
export const shouldBehaveLikeFee = async () => { | ||
let wpac: any | ||
let owner: SignerWithAddress | ||
|
||
before(async () => { | ||
const signers = await ethers.getSigners() | ||
owner = signers[0] | ||
const Factory = await ethers.getContractFactory("WrappedPAC") | ||
const WPAC = await upgrades.deployProxy(Factory, undefined, { initializer: "initialize" }) | ||
wpac = await WPAC.waitForDeployment() | ||
}) | ||
|
||
it("should calculate correct fee", async () => { | ||
expect(await wpac.getFee(1_903_076_060_983)).to.be.equal(5_000_000_000) | ||
expect(await wpac.getFee(2_874_345_000)).to.be.equal(1_000_000_000) | ||
expect(await wpac.getFee(200e9)).to.be.equal(1e9) | ||
}) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { decimal } from "../../utils/decimal" | ||
|
||
export function getFee(amount: number): bigint { | ||
const f = amount / 200 | ||
|
||
if (f <= decimal(1)) { | ||
return decimal(1) | ||
} | ||
|
||
if (f >= decimal(5)) { | ||
return decimal(5) | ||
} | ||
|
||
return decimal(f) | ||
} |