Skip to content

feat: Spell Proposal #682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/hooks/useIndexDTF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type DTFQueryResponse = {
executionDelay: number
}
}
legacyAdmins: Address[]
tradingGovernance?: {
id: Address
votingDelay: number
Expand All @@ -45,6 +46,7 @@ type DTFQueryResponse = {
executionDelay: number
}
}
legacyAuctionApprovers: Address[]
token: {
id: Address
name: string
Expand Down Expand Up @@ -78,6 +80,7 @@ type DTFQueryResponse = {
executionDelay: number
}
}
legacyGovernance: Address[]
rewards: {
rewardToken: {
address: Address
Expand Down Expand Up @@ -128,6 +131,7 @@ const dtfQuery = gql`
executionDelay
}
}
legacyAdmins
tradingGovernance {
id
votingDelay
Expand All @@ -140,6 +144,7 @@ const dtfQuery = gql`
executionDelay
}
}
legacyAuctionApprovers
token {
id
name
Expand Down Expand Up @@ -173,6 +178,7 @@ const dtfQuery = gql`
executionDelay
}
}
legacyGovernance
rewards(where: { active: true }) {
rewardToken {
address
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export type IndexDTF = {
executionDelay: number
}
}
legacyAdmins: Address[]
tradingGovernance?: {
id: Address
votingDelay: number
Expand All @@ -304,6 +305,7 @@ export type IndexDTF = {
executionDelay: number
}
}
legacyAuctionApprovers: Address[]
token: {
id: Address
name: string
Expand Down Expand Up @@ -337,6 +339,7 @@ export type IndexDTF = {
executionDelay: number
}
}
legacyGovernance: Address[]
rewardTokens: Token[]
}
totalRevenue: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ const txAtom = atom<
const ownerGovernanceConfig: GovernanceConfig = {
votingDelay: Math.floor((formData.governanceVotingDelay || 0) * 86400),
votingPeriod: Math.floor((formData.governanceVotingPeriod || 0) * 86400),
proposalThreshold: parseEther(
(formData.governanceVotingThreshold || 0).toString()
),
proposalThreshold:
parseEther((formData.governanceVotingThreshold || 0).toString()) / 100n,
quorumPercent: BigInt(Math.floor(formData.governanceVotingQuorum || 0)),
timelockDelay: BigInt(
Math.floor((formData.governanceExecutionDelay || 0) * 86400)
Expand All @@ -187,9 +186,8 @@ const txAtom = atom<
const tradingGovernanceConfig: GovernanceConfig = {
votingDelay: Math.floor((formData.basketVotingDelay || 0) * 3600),
votingPeriod: Math.floor((formData.basketVotingPeriod || 0) * 3600),
proposalThreshold: parseEther(
(formData.basketVotingThreshold || 0).toString()
),
proposalThreshold:
parseEther((formData.basketVotingThreshold || 0).toString()) / 100n,
quorumPercent: BigInt(Math.floor(formData.basketVotingQuorum || 0)),
timelockDelay: BigInt(
Math.floor((formData.basketExecutionDelay || 0) * 3600)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAtomValue } from 'jotai'
import { Address, decodeFunctionData, getAbiItem } from 'viem'

import dtfIndexAbi from '@/abis/dtf-index-abi'
import dtfAdminAbi from '@/abis/dtf-admin-abi'
import dtfIndexGovernance from '@/abis/dtf-index-governance'
import dtfIndexStakingVault from '@/abis/dtf-index-staking-vault'
import { Button } from '@/components/ui/button'
Expand All @@ -26,6 +27,10 @@ import { Abi, Hex } from 'viem'
import BasketProposalPreview from '../views/propose/basket/components/proposal-basket-preview'
import RawCallPreview from './proposal-preview/raw-call-preview'
import TokenRewardPreview from './proposal-preview/token-reward-preview'
import {
spellAbi as governanceSpell_31_03_2025Abi,
spellAddress as governanceSpell_31_03_2025Address,
} from '../views/propose/components/propose-governance-spell-31-03-2025'

const dtfAbiMapppingAtom = atom((get) => {
const dtf = get(indexDTFAtom)
Expand All @@ -34,6 +39,7 @@ const dtfAbiMapppingAtom = atom((get) => {

const abiMapping: Record<string, Abi> = {
[dtf.id.toLowerCase()]: dtfIndexAbi,
[dtf.proxyAdmin.toLowerCase()]: dtfAdminAbi,
}

if (dtf.ownerGovernance) {
Expand All @@ -52,6 +58,11 @@ const dtfAbiMapppingAtom = atom((get) => {
}
}

if (governanceSpell_31_03_2025Address[dtf.chainId]) {
abiMapping[governanceSpell_31_03_2025Address[dtf.chainId].toLowerCase()] =
governanceSpell_31_03_2025Abi
}

return abiMapping
})

Expand All @@ -62,6 +73,7 @@ const dtfContractAliasAtom = atom((get) => {

const aliasMapping: Record<string, string> = {
[dtf.id.toLowerCase()]: 'Folio',
[dtf.proxyAdmin.toLowerCase()]: 'ProxyAdmin',
}

if (dtf.ownerGovernance) {
Expand All @@ -80,6 +92,11 @@ const dtfContractAliasAtom = atom((get) => {
}
}

if (governanceSpell_31_03_2025Address[dtf.chainId]) {
aliasMapping[governanceSpell_31_03_2025Address[dtf.chainId].toLowerCase()] =
'GovernanceSpell_31_03_2025'
}

return aliasMapping
})

Expand Down
86 changes: 23 additions & 63 deletions src/views/index-dtf/governance/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { Address, formatEther } from 'viem'
import { indexGovernanceOverviewAtom, refetchTokenAtom } from './atoms'

type Response = {
governances: {
proposals: PartialProposal[]
proposalCount: number
}[]
ownerGovernance: {
proposals: PartialProposal[]
proposalCount: number
Expand Down Expand Up @@ -36,57 +40,9 @@ type Response = {
}

const query = gql`
query getGovernanceStats(
$ownerGovernance: String!
$tradingGovernance: String!
$vaultGovernance: String!
$stToken: String!
) {
ownerGovernance: governance(id: $ownerGovernance) {
proposals {
id
description
creationTime
state
forWeightedVotes
abstainWeightedVotes
againstWeightedVotes
executionETA
quorumVotes
voteStart
voteEnd
executionBlock
executionTime
creationBlock
proposer {
address
}
}
proposalCount
}
tradingGovernance: governance(id: $tradingGovernance) {
proposals {
id
description
creationTime
state
forWeightedVotes
abstainWeightedVotes
againstWeightedVotes
executionETA
executionTime
quorumVotes
voteStart
voteEnd
executionBlock
creationBlock
proposer {
address
}
}
proposalCount
}
vaultGovernance: governance(id: $vaultGovernance) {
query getGovernanceStats($governanceIds: [String!]!, $stToken: String!) {
governances(where: { id_in: $governanceIds }) {
id
proposals {
id
description
Expand All @@ -109,6 +65,7 @@ const query = gql`
proposalCount
}
stakingToken(id: $stToken) {
id
totalDelegates
token {
totalSupply
Expand Down Expand Up @@ -142,23 +99,26 @@ const Updater = () => {
INDEX_DTF_SUBGRAPH_URL[chainId],
query,
{
ownerGovernance: dtf?.ownerGovernance?.id ?? '',
tradingGovernance: dtf?.tradingGovernance?.id ?? '',
vaultGovernance: dtf?.stToken?.governance?.id ?? '',
governanceIds: [
dtf?.ownerGovernance?.id,
...(dtf?.legacyAdmins || []),
dtf?.tradingGovernance?.id,
...(dtf?.legacyAuctionApprovers || []),
dtf?.stToken?.governance?.id,
...(dtf?.stToken?.legacyGovernance || []),
],
stToken: dtf?.stToken?.id ?? '',
}
)

return {
proposals: [
...(data.ownerGovernance.proposals ?? []),
...(data.tradingGovernance?.proposals ?? []),
...(data.vaultGovernance?.proposals ?? []),
].sort((a, b) => b.creationTime - a.creationTime),
proposalCount:
+data.ownerGovernance.proposalCount +
+(data.tradingGovernance?.proposalCount ?? 0) +
+(data.vaultGovernance?.proposalCount ?? 0),
proposals: data.governances
.flatMap((g) => g.proposals)
.sort((a, b) => b.creationTime - a.creationTime),
proposalCount: data.governances.reduce(
(x, y) => x + Number(y.proposalCount),
0
),
delegates: data.stakingToken?.delegates ?? [],
delegatesCount: +(data.stakingToken?.totalDelegates ?? 0),
voteSupply: +formatEther(data.stakingToken?.token.totalSupply ?? 0n),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'lucide-react'
import { Link } from 'react-router-dom'
import ProposeIndexUpgrade from './propose-index-upgrade'
import ProposeGovernanceSpell31032025 from './propose-governance-spell-31-03-2025'

const proposalTypes = [
{
Expand Down Expand Up @@ -92,7 +93,7 @@ const ProposalTypeSelection = () => {
<div className="flex h-[calc(100vh-146px)] lg:h-[calc(100vh-72px)] w-full">
<div className="flex flex-col gap-4 items-center justify-center m-4 flex-grow border-none sm:border-dashed border-2 border-foreground/40 rounded-3xl">
<ProposeIndexUpgrade />

<ProposeGovernanceSpell31032025 />
<div className="bg-secondary rounded-3xl w-full sm:w-[408px]">
<Header />
<TypeList />
Expand Down
Loading