-
Notifications
You must be signed in to change notification settings - Fork 52
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
1 parent
bc2f0fd
commit 9e10841
Showing
5 changed files
with
107 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { formatUnits } from "viem"; | ||
import { Address } from "~~/components/scaffold-eth"; | ||
import { usePoolContract } from "~~/hooks/balancer"; | ||
|
||
/** | ||
* Display all the contract details for a balancer pool | ||
*/ | ||
export const PoolDetails = () => { | ||
const pool = usePoolContract("ConstantPricePool"); | ||
return ( | ||
<div className="flex flex-col gap-5 text-xl"> | ||
<div className="flex gap-5"> | ||
<div>Name:</div> | ||
<div>{pool.name}</div> | ||
</div> | ||
|
||
<div className="flex gap-5"> | ||
<div>Symbol:</div> | ||
<div>({pool.symbol})</div> | ||
</div> | ||
|
||
<div className="flex gap-5"> | ||
<div>Pool Address:</div> | ||
<div> | ||
<Address address={pool.address} size="xl" /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex gap-5"> | ||
<div>Vault Address:</div> | ||
<div> | ||
<Address address={pool.vaultAddress} size="xl" /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex gap-5"> | ||
<div>Total Supply:</div> | ||
<div>{formatUnits(pool.totalSupply || 0n, pool.decimals || 18)}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export * from "./PoolDetails"; |
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 @@ | ||
export * from "./usePoolContract"; |
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,50 @@ | ||
import { useDeployedContractInfo, useScaffoldContractRead } from "~~/hooks/scaffold-eth"; | ||
|
||
export interface PoolDetails { | ||
name: string | undefined; | ||
address: string | undefined; | ||
symbol: string | undefined; | ||
decimals: number | undefined; | ||
totalSupply: bigint | undefined; | ||
vaultAddress: string | undefined; | ||
} | ||
|
||
type DeployedPoolNames = "ConstantPricePool"; | ||
|
||
export const usePoolContract = (contractName: DeployedPoolNames): PoolDetails => { | ||
const { data: deployedContractData } = useDeployedContractInfo(contractName); | ||
|
||
const { data: name } = useScaffoldContractRead({ | ||
contractName, | ||
functionName: "name", | ||
}); | ||
|
||
const { data: symbol } = useScaffoldContractRead({ | ||
contractName, | ||
functionName: "symbol", | ||
}); | ||
|
||
const { data: totalSupply } = useScaffoldContractRead({ | ||
contractName, | ||
functionName: "totalSupply", | ||
}); | ||
|
||
const { data: decimals } = useScaffoldContractRead({ | ||
contractName, | ||
functionName: "decimals", | ||
}); | ||
|
||
const { data: vaultAddress } = useScaffoldContractRead({ | ||
contractName, | ||
functionName: "getVault", | ||
}); | ||
|
||
return { | ||
name, | ||
address: deployedContractData?.address, | ||
symbol, | ||
totalSupply: totalSupply, | ||
decimals, | ||
vaultAddress, | ||
}; | ||
}; |