Skip to content

Commit

Permalink
add the PowerPool token (CVP) in the payout tokens (#2424)
Browse files Browse the repository at this point in the history
* add the PowerPool token (CVP) in the payout tokens

* make direct grant question "payout token" editable

* add power pool logo

* feat: enable single option in a dropdown

* fix: don't show matching funds in dg pre round

* feat: enable custom payout in dg

* fix: remove gas limit

---------

Co-authored-by: eagle <[email protected]>
Co-authored-by: Atris <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent 4572749 commit 90b5242
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 54 deletions.
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export const RedstoneTokenIds = {
GTC: "GTC",
MATIC: "MATIC",
AVAX: "AVAX",
CVP: "CVP",
} as const;

export const useTokenPrice = (tokenId: string | undefined) => {
Expand Down
68 changes: 38 additions & 30 deletions packages/grant-explorer/src/features/round/ViewRoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -654,36 +654,44 @@ function PreRoundPage(props: {
)}
</span>
</p>
<p
className="text-lg my-2 text-grey-400 font-normal"
data-testid="matching-funds"
>
Matching Funds Available:
<span>
{" "}
&nbsp;
{round.roundMetadata?.quadraticFundingConfig?.matchingFundsAvailable.toLocaleString()}
&nbsp;
{tokenData?.symbol ?? "..."}
</span>
</p>
<p
className="text-lg my-2 text-grey-400 font-normal"
data-testid="matching-cap"
>
Matching Cap:
{round.roundMetadata?.quadraticFundingConfig?.matchingCapAmount ? (
<span>
{" "}
&nbsp;
{round.roundMetadata?.quadraticFundingConfig?.matchingCapAmount}
&nbsp;
{"%"}
</span>
) : (
<span>None</span>
)}
</p>
{!isDirectRound(round) && (
<div>
<p
className="text-lg my-2 text-grey-400 font-normal"
data-testid="matching-funds"
>
Matching Funds Available:
<span>
{" "}
&nbsp;
{round.roundMetadata?.quadraticFundingConfig?.matchingFundsAvailable.toLocaleString()}
&nbsp;
{tokenData?.symbol ?? "..."}
</span>
</p>
<p
className="text-lg my-2 text-grey-400 font-normal"
data-testid="matching-cap"
>
Matching Cap:
{round.roundMetadata?.quadraticFundingConfig
?.matchingCapAmount ? (
<span>
{" "}
&nbsp;
{
round.roundMetadata?.quadraticFundingConfig
?.matchingCapAmount
}
&nbsp;
{"%"}
</span>
) : (
<span>None</span>
)}
</p>
</div>
)}
<p className="text-lg my-5 text-grey-400 font-normal border-t py-5 border-b">
<span>{round.roundMetadata?.eligibility.description}</span>
</p>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 10 additions & 13 deletions packages/round-manager/src/context/application/usePayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,16 @@ export function usePayout() {
let txBlockNumber: number;
try {
setContractUpdatingStatus(ProgressStatus.IN_PROGRESS);
const payoutReceipt = await directPayout.payout(
{
vault: payoutVault,
token: token.address,
amount: payoutAmount,
grantAddress: payoutWallet,
projectId: projectId,
applicationIndex: applicationIndex,
allowanceModule: ethers.constants.AddressZero,
allowanceSignature: ethers.constants.HashZero,
},
{ gasLimit: "5000000" }
);
const payoutReceipt = await directPayout.payout({
vault: payoutVault,
token: token.address,
amount: payoutAmount,
grantAddress: payoutWallet,
projectId: projectId,
applicationIndex: applicationIndex,
allowanceModule: ethers.constants.AddressZero,
allowanceSignature: ethers.constants.HashZero,
});
const res = await payoutReceipt.wait();
txBlockNumber = res.blockNumber;
setContractUpdatingStatus(ProgressStatus.IS_SUCCESS);
Expand Down
17 changes: 17 additions & 0 deletions packages/round-manager/src/features/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const TokenNamesAndLogos = {
GTC: "/logos/gtc.svg",
AVAX: "/logos/avax-logo.svg",
MATIC: "/logos/pol-logo.svg",
CVP: "/logos/power-pool.png", // PowerPool
} as const;

const MAINNET_TOKENS: PayoutToken[] = [
Expand All @@ -125,6 +126,14 @@ const MAINNET_TOKENS: PayoutToken[] = [
logo: TokenNamesAndLogos["ETH"],
redstoneTokenId: RedstoneTokenIds["ETH"],
},
{
name: "CVP",
chainId: ChainId.MAINNET,
address: "0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1",
decimal: 18,
logo: TokenNamesAndLogos["CVP"],
redstoneTokenId: RedstoneTokenIds["CVP"],
},
];

const OPTIMISM_MAINNET_TOKENS: PayoutToken[] = [
Expand Down Expand Up @@ -404,6 +413,14 @@ export const getPayoutTokenOptions = (chainId: ChainId): PayoutToken[] => {
logo: TokenNamesAndLogos["ETH"],
decimal: 18,
},
{
name: "CVP",
chainId: ChainId.MAINNET,
address: "0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1",
decimal: 18,
logo: TokenNamesAndLogos["CVP"],
redstoneTokenId: RedstoneTokenIds["CVP"],
},
];
}
case ChainId.OPTIMISM_MAINNET_CHAIN_ID: {
Expand Down
15 changes: 10 additions & 5 deletions packages/round-manager/src/features/common/AddQuestionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ function AddQuestionModal({

if (
renderOptions.length === 0 ||
((selectedQuestion === "multiple-choice" ||
selectedQuestion === "dropdown") &&
renderOptions.length === 1)
(selectedQuestion === "multiple-choice" && renderOptions.length === 1)
) {
renderOptions.push("");
setQuestionOptions({
Expand Down Expand Up @@ -308,14 +306,21 @@ function AddQuestionModal({
errors.push("Please provide at least 1 option.");
}
if (
(questionOptions.type === "multiple-choice" ||
questionOptions.type === "dropdown") &&
questionOptions.type === "multiple-choice" &&
(!questionOptions.choices ||
questionOptions.choices?.length < 2 ||
questionOptions.choices?.[1] === "")
) {
errors.push("Please provide at least 2 options.");
}
if (
questionOptions.type === "dropdown" &&
(!questionOptions.choices ||
questionOptions.choices?.length < 1 ||
questionOptions.choices?.[0] === "")
) {
errors.push("Please provide at least 1 option.");
}
if (questionOptions.encrypted && !questionOptions.hidden) {
errors.push(
"Questions cannot be marked as encrypted and shown in explorer. Please select one."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function ApplicationDirectPayout({
const tokenInfo = tokensByChainInfo.find(
(t) => t.name.toLowerCase() == payoutTokenAnswer.answer?.toLowerCase()
);

if (!tokenInfo) {
throw Error(
`Token info not found for chain id: ${chain.id} and token ${payoutTokenAnswer}!`
Expand Down Expand Up @@ -297,7 +298,9 @@ export default function ApplicationDirectPayout({
</label>
<div className="relative mt-2 rounded-md shadow-sm">
<div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<span className="text-gray-400 sm:text-sm">DAI</span>
<span className="text-gray-400 sm:text-sm">
{tokenInfo.name}
</span>
</div>
<Input
{...register("amount")}
Expand All @@ -306,7 +309,7 @@ export default function ApplicationDirectPayout({
}
type="number"
placeholder="Enter payout amount"
aria-describedby="DAI-symbol"
aria-describedby="token-symbol"
$hasError={errors.amount !== undefined}
step="any"
data-testid="payout-amount-input"
Expand Down Expand Up @@ -424,15 +427,14 @@ export default function ApplicationDirectPayout({
<strong>Important:</strong>
<p>
Make sure the vault address has a balance of at least{" "}
{getAmountWithFee()}
DAI.
{getAmountWithFee()} {tokenInfo.name}.
</p>
{allInputs.address &&
address.toLowerCase() !== allInputs.address.toLowerCase() && (
<p>
Make sure the vault address has allowed the payout
contract with address {round.payoutStrategy.id} to spend{" "}
{getAmountWithFee()} DAI.
{getAmountWithFee()} {tokenInfo.name}.
</p>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const initialQuestionsDirect: SchemaQuestion[] = [
hidden: true,
type: "dropdown",
choices: ["DAI"], // ETH is not supported.
fixed: true,
fixed: false,
},
{
id: 5,
Expand Down

5 comments on commit 90b5242

@vercel
Copy link

@vercel vercel bot commented on 90b5242 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder – ./packages/builder

builder-kappa-one.vercel.app
builder-grants-stack.vercel.app
builder-git-main-grants-stack.vercel.app
builder.gitcoin.co

@vercel
Copy link

@vercel vercel bot commented on 90b5242 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

manager – ./packages/round-manager

manager-grants-stack.vercel.app
grants-stack-round-manager.vercel.app
manager-git-main-grants-stack.vercel.app
manager.gitcoin.co

@vercel
Copy link

@vercel vercel bot commented on 90b5242 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer-staging – ./packages/grant-explorer

grants-stack-grant-explorer-ten.vercel.app
explorer-staging-git-main-grants-stack.vercel.app
explorer-staging-grants-stack.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 90b5242 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

manager-staging – ./packages/round-manager

manager-staging-grants-stack.vercel.app
manager-staging.vercel.app
manager-staging-git-main-grants-stack.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 90b5242 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-staging – ./packages/builder

builder-staging-git-main-grants-stack.vercel.app
builder-staging-grants-stack.vercel.app
builder-staging-xi.vercel.app

Please sign in to comment.