-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: integrate fee subsidy feature
- Loading branch information
1 parent
a11be8b
commit e60fe41
Showing
13 changed files
with
447 additions
and
72 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
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
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,30 @@ | ||
import { getJsonRpcProvider, getReadOnlyContract } from '@/services/transactions/utils'; | ||
import type { Chain, Token } from '@/types/data'; | ||
import type { FeeSub } from '@/types/ethers-contracts'; | ||
import { FeeSub__factory } from '@/types/ethers-contracts'; | ||
import type { TokenAmount } from '@/types/token-amount'; | ||
import { UInt256 } from '@/types/uint-256'; | ||
|
||
export async function amountCanBeSubsidized( | ||
chain: Chain, | ||
token: Token, | ||
tokenAmount: TokenAmount, | ||
): Promise<boolean> { | ||
if (!chain.feeSubAddress) { | ||
return false; | ||
} | ||
const provider = getJsonRpcProvider(chain.internalRpcUrl); | ||
|
||
const feeSubContract = getReadOnlyContract<FeeSub>( | ||
chain.feeSubAddress, | ||
FeeSub__factory.createInterface(), | ||
provider, | ||
); | ||
const threshold = await feeSubContract.minimumAmounts(token.address); | ||
|
||
if (threshold.isZero() || tokenAmount.uint256.lt(UInt256.parse(threshold.toString()))) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
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
Oops, something went wrong.