Skip to content

Commit

Permalink
Merge pull request #225 from lidofinance/feat/holesky-contracts
Browse files Browse the repository at this point in the history
feat: Holesky top up motions
  • Loading branch information
AnnaSila authored Jan 9, 2024
2 parents b80a72d + a88ccb9 commit 4a9734c
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 43 deletions.
15 changes: 15 additions & 0 deletions modules/blockChain/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const STETH: ChainAddressMap = {
export const DAI: ChainAddressMap = {
[CHAINS.Mainnet]: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
[CHAINS.Goerli]: '0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844',
[CHAINS.Holesky]: '0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c',
}

export const Finance: ChainAddressMap = {
Expand All @@ -59,16 +60,19 @@ export const AllowedRecipientReferralDaiRegistry: ChainAddressMap = {
export const AllowedRecipientTrpLdoRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0x231Ac69A1A37649C6B06a71Ab32DdD92158C80b8',
[CHAINS.Goerli]: '0x8C96a6522aEc036C4a384f8B7e05D93d6f3Dae39',
[CHAINS.Holesky]: '0x5f4E9A917d6556dB91Cf351f49b0edCc5A255bAE',
}

export const LegoLDORegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0x97615f72c3428A393d65A84A3ea6BBD9ad6C0D74',
[CHAINS.Goerli]: '0x6342213719839c56fEe817539863aFB9821B03cb',
[CHAINS.Holesky]: '0x77CF728329920E4191a6Edd9b009cD055D3cD29A',
}

export const LegoDAIRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0xb0FE4D300334461523D9d61AaD90D0494e1Abb43',
[CHAINS.Goerli]: '0x5884f5849414D4317d175fEc144e2F87f699B082',
[CHAINS.Holesky]: '0x10Ff9c02C65775379D9E20BFF9AC92Cbaf15Ab8F',
}

export const RccStablesRegistry: ChainAddressMap = {
Expand All @@ -95,11 +99,13 @@ export const gasFunderETHRegistry: ChainAddressMap = {
export const StethRewardProgramRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0x48c4929630099b217136b64089E8543dB0E5163a',
[CHAINS.Goerli]: '0x78797efCca6C537BF92FA6b25cBb14A6f1c128A0',
[CHAINS.Holesky]: '0x55B304a585D540421F1fD3579Ef12Abab7304492',
}

export const StethGasSupplyRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0x49d1363016aA899bba09ae972a1BF200dDf8C55F',
[CHAINS.Goerli]: '0xF08a5f00824D4554a1FBebaE726609418dc819fb',
[CHAINS.Holesky]: '0x1B68a7BeE396e2eaAD9D2716E0A271A4BB568BCd',
}

export const AragonACL: ChainAddressMap = {
Expand All @@ -117,6 +123,7 @@ export const EVMScriptExecutor: ChainAddressMap = {
export const RewardsShareProgramRegistry: ChainAddressMap = {
[CHAINS.Mainnet]: '0xdc7300622948a7AdaF339783F6991F9cdDD79776',
[CHAINS.Goerli]: '0x8b59609f4bEa230E565Ae0C3C7b6913746Df1cF2',
[CHAINS.Holesky]: '0xAc2F596191c75B77c2835Afe83c3a9097f0AC071',
}

export const SDVTRegistry: ChainAddressMap = {
Expand All @@ -131,3 +138,11 @@ export const SandboxNodeOperatorsRegistry: ChainAddressMap = {
export const AllowedTokensRegistry: ChainAddressMap = {
[CHAINS.Goerli]: '0xeda5a9F02a580B4A879aEA65E2a7B7fEc0956b0E',
}

export const SandboxStablesAllowedTokensRegistry: ChainAddressMap = {
[CHAINS.Holesky]: '0x091c0ec8b4d54a9fcb36269b5d5e5af43309e666',
}

export const SandboxStablesAllowedRecipientRegistry: ChainAddressMap = {
[CHAINS.Holesky]: '0xF8a63a36B954D72de197097377aa00C238c653Cf',
}
27 changes: 27 additions & 0 deletions modules/blockChain/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,30 @@ export const ContractEvmAtcStablesTopUp = createContractHelpers({
factory: TypeChain.TopUpWithLimitsStablesAbi__factory,
address: EvmAddressesByType[MotionType.AtcStablesTopUp],
})

export const ContractSandboxStablesAllowedRecipientRegistry =
createContractHelpers({
factory: TypeChain.RegistryWithLimitsAbi__factory,
address: CONTRACT_ADDRESSES.SandboxStablesAllowedRecipientRegistry,
})

export const ContractSandboxStablesAllowedTokensRegistry =
createContractHelpers({
factory: TypeChain.AllowedTokensRegistryAbi__factory,
address: CONTRACT_ADDRESSES.SandboxStablesAllowedTokensRegistry,
})

export const ContractEvmSandboxStablesAdd = createContractHelpers({
factory: TypeChain.AddAllowedRecipientAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStablesAdd],
})

export const ContractEvmSandboxStablesRemove = createContractHelpers({
factory: TypeChain.RemoveAllowedRecipientAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStablesRemove],
})

export const ContractEvmSandboxStablesTopUp = createContractHelpers({
factory: TypeChain.TopUpWithLimitsStablesAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStablesTopUp],
})
40 changes: 28 additions & 12 deletions modules/motions/evmAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,28 @@ export const EvmAddressesByChain: EvmAddresses = {
[CHAINS.Holesky]: {
[MotionType.NodeOperatorIncreaseLimit]:
'0x18Ff3bD97739bf910cDCDb8d138976c6afDB4449',
[MotionType.AllowedRecipientTopUpTrpLdo]: '',
[MotionType.LegoLDOTopUp]: '',
[MotionType.LegoDAITopUp]: '',
[MotionType.StethRewardProgramAdd]: '',
[MotionType.StethRewardProgramRemove]: '',
[MotionType.StethRewardProgramTopUp]: '',
[MotionType.StethGasSupplyAdd]: '',
[MotionType.StethGasSupplyRemove]: '',
[MotionType.StethGasSupplyTopUp]: '',
[MotionType.RewardsShareProgramAdd]: '',
[MotionType.RewardsShareProgramRemove]: '',
[MotionType.RewardsShareProgramTopUp]: '',
[MotionType.AllowedRecipientTopUpTrpLdo]:
'0xD618F0CF48F057B5256e102dC18d8011e08c19D3',
[MotionType.LegoLDOTopUp]: '0xCfaFcD35ACcc4383e2CCDf7DD3F58114914F1955',
[MotionType.LegoDAITopUp]: '0xBCcfe42cc3EF530db9888dC8F82B1B4A4DfB9DB4',
[MotionType.StethRewardProgramAdd]:
'0xf0968B9bE18282dD23bbbC79a1c9C8996CE6984D',
[MotionType.StethRewardProgramRemove]:
'0xF0F34b82241cD49BB3952149BD30A08Eb9D8B54E',
[MotionType.StethRewardProgramTopUp]:
'0xBB06DD9a3C7eE8cE093860094e769a1E3D6F97F6',
[MotionType.StethGasSupplyAdd]:
'0x13dB9E1ddE54d2641f571EA288D9e79C0E8bce2e',
[MotionType.StethGasSupplyRemove]:
'0x64CE36D2DC7e7786BF56D2DF8A5F3c788977Fb19',
[MotionType.StethGasSupplyTopUp]:
'0xf97E048A952d170d5D5E817C8D9c8253f4D50F96',
[MotionType.RewardsShareProgramAdd]:
'0x49D3211203e8E18B4e60F74C1126934da2520987',
[MotionType.RewardsShareProgramRemove]:
'0x112c48c4659A9a1d42a3e45EBc8e37B6150F2B0C',
[MotionType.RewardsShareProgramTopUp]:
'0x089bc04630c056D76fF4Ec172e752A7d5B855e16',

[MotionType.SDVTNodeOperatorsAdd]:
'0xeF5233A5bbF243149E35B353A73FFa8931FDA02b',
Expand All @@ -191,6 +201,12 @@ export const EvmAddressesByChain: EvmAddresses = {

[MotionType.SandboxNodeOperatorIncreaseLimit]:
'0xbD37e55748c6f4Ece637AeD3e278e7575346B587',
[MotionType.SandboxStablesAdd]:
'0xB238fB1e7c8da5da022140dA956Fc3052808fC56',
[MotionType.SandboxStablesRemove]:
'0x51c730af05777c4D3CcC8c8B80558F4D155bb7BF',
[MotionType.SandboxStablesTopUp]:
'0x71bcEf1f4E4945005e1D22d68F02085D5167ab43',

// next motion factories are @deprecated
// we are keeping them here to display history data
Expand Down
47 changes: 17 additions & 30 deletions modules/motions/hooks/useAllowedTokensRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
import { ContractAllowedTokensRegistry } from 'modules/blockChain/contracts'
import {
ContractAllowedTokensRegistry,
ContractSandboxStablesAllowedTokensRegistry,
} from 'modules/blockChain/contracts'
import { useSWR } from 'modules/network/hooks/useSwr'
import { useWeb3 } from 'modules/blockChain/hooks/useWeb3'
import { AllowedTokensRegistryAbi } from 'generated'
import { DAI } from 'modules/blockChain/contractAddresses'
import { connectERC20Contract } from '../utils/connectTokenContract'
import { MotionType } from '../types'

export function useAllowedTokens() {
const TOKENS_REGISTRY_BY_MOTION_TYPE = {
[MotionType.AtcStablesTopUp]: ContractAllowedTokensRegistry,
[MotionType.PmlStablesTopUp]: ContractAllowedTokensRegistry,
[MotionType.RccStablesTopUp]: ContractAllowedTokensRegistry,
[MotionType.SandboxStablesTopUp]: ContractSandboxStablesAllowedTokensRegistry,
}

type RegistryType = keyof typeof TOKENS_REGISTRY_BY_MOTION_TYPE

export function useAllowedTokens(registryType: RegistryType) {
const { chainId, library } = useWeb3()
const registry = TOKENS_REGISTRY_BY_MOTION_TYPE[registryType].useRpc()

const { data, initialLoading } = useSWR(
`allowed-tokens-${chainId}`,
`allowed-tokens-${registryType}-${chainId}`,
async () => {
if (!library) {
return
}

let registry: AllowedTokensRegistryAbi | undefined
try {
registry = ContractAllowedTokensRegistry.connectRpc({ chainId })
} catch (error) {
// Fallback for motions without registry support

const address = DAI[chainId]
if (!address) {
return
}

const daiContract = connectERC20Contract(address, chainId)
const decimals = await daiContract.decimals()

return {
allowedTokens: [
{
address,
label: 'DAI',
decimals,
},
],
decimalsMap: { [address]: decimals },
}
}
const tokensAddresses = await registry.getAllowedTokens()

const allowedTokens = await Promise.all(
Expand Down
3 changes: 3 additions & 0 deletions modules/motions/hooks/useContractEvmScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export const EVM_CONTRACTS = {
[MotionType.RccStablesTopUp]: CONTRACTS.ContractEvmRccStablesTopUp,
[MotionType.PmlStablesTopUp]: CONTRACTS.ContractEvmPmlStablesTopUp,
[MotionType.AtcStablesTopUp]: CONTRACTS.ContractEvmAtcStablesTopUp,
[MotionType.SandboxStablesAdd]: CONTRACTS.ContractEvmSandboxStablesAdd,
[MotionType.SandboxStablesTopUp]: CONTRACTS.ContractEvmSandboxStablesTopUp,
[MotionType.SandboxStablesRemove]: CONTRACTS.ContractEvmSandboxStablesRemove,
} as const

export function useContractEvmScript<T extends MotionType | EvmUnrecognized>(
Expand Down
7 changes: 7 additions & 0 deletions modules/motions/hooks/useRegistryWithLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ContractStethGasSupplyRegistry,
ContractRewardsShareProgramRegistry,
ContractRccStablesRegistry,
ContractSandboxStablesAllowedRecipientRegistry,
} from 'modules/blockChain/contracts'
import { getEventsRecipientAdded } from 'modules/motions/utils'
import { MotionType } from 'modules/motions/types'
Expand Down Expand Up @@ -55,6 +56,12 @@ export const REGISTRY_WITH_LIMITS_BY_MOTION_TYPE = {
[MotionType.RccStablesTopUp]: ContractRccStablesRegistry,
[MotionType.PmlStablesTopUp]: ContractPmlStablesRegistry,
[MotionType.AtcStablesTopUp]: ContractAtcStablesRegistry,
[MotionType.SandboxStablesAdd]:
ContractSandboxStablesAllowedRecipientRegistry,
[MotionType.SandboxStablesRemove]:
ContractSandboxStablesAllowedRecipientRegistry,
[MotionType.SandboxStablesTopUp]:
ContractSandboxStablesAllowedRecipientRegistry,
} as const

type HookArgs = {
Expand Down
3 changes: 3 additions & 0 deletions modules/motions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const MotionTypeForms = {

SandboxNodeOperatorIncreaseLimit: 'SandboxNodeOperatorIncreaseLimit',

SandboxStablesTopUp: 'SandboxStablesTopUp',
SandboxStablesAdd: 'SandboxStablesAdd',
SandboxStablesRemove: 'SandboxStablesRemove',
RccDAITopUp: 'RccDAITopUp',
PmlDAITopUp: 'PmlDAITopUp',
AtcDAITopUp: 'AtcDAITopUp',
Expand Down
20 changes: 20 additions & 0 deletions modules/motions/ui/MotionDescription/MotionDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ const MOTION_DESCRIPTIONS = {
registryType={MotionType.AtcStablesTopUp}
/>
),
[MotionType.SandboxStablesAdd]: (props: DescAllowedRecipientAddProps) => (
<DescAllowedRecipientAdd
{...props}
registryType={MotionType.SandboxStablesAdd}
/>
),
[MotionType.SandboxStablesRemove]: (
props: DescAllowedRecipientRemoveProps,
) => (
<DescAllowedRecipientRemove
{...props}
registryType={MotionType.SandboxStablesRemove}
/>
),
[MotionType.SandboxStablesTopUp]: (props: GenericDescProps) => (
<DescTopUpWithLimitsAndCustomToken
{...props}
registryType={MotionType.SandboxStablesTopUp}
/>
),
} as const

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ContractStethGasSupplyAdd,
ContractStethRewardProgramAdd,
ContractRewardsShareProgramAdd,
ContractEvmSandboxStablesAdd,
} from 'modules/blockChain/contracts'
import { MotionTypeForms } from 'modules/motions/types'
import { createMotionFormPart } from './createMotionFormPart'
Expand All @@ -29,6 +30,10 @@ export const ALLOWED_RECIPIENT_ADD_MAP = {
evmContract: ContractRewardsShareProgramAdd,
motionType: MotionTypeForms.RewardsShareProgramAdd,
},
[MotionTypeForms.SandboxStablesAdd]: {
evmContract: ContractEvmSandboxStablesAdd,
motionType: MotionTypeForms.SandboxStablesAdd,
},
}

export const formParts = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ContractStethGasSupplyRemove,
ContractStethRewardProgramRemove,
ContractRewardsShareProgramRemove,
ContractEvmSandboxStablesRemove,
} from 'modules/blockChain/contracts'
import { MotionTypeForms } from 'modules/motions/types'
import { createMotionFormPart } from './createMotionFormPart'
Expand All @@ -28,6 +29,10 @@ export const ALLOWED_RECIPIENT_REMOVE_MAP = {
evmContract: ContractRewardsShareProgramRemove,
motionType: MotionTypeForms.RewardsShareProgramRemove,
},
[MotionTypeForms.SandboxStablesRemove]: {
evmContract: ContractEvmSandboxStablesRemove,
motionType: MotionTypeForms.SandboxStablesRemove,
},
}

export const formParts = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ContractEvmRccStablesTopUp,
ContractEvmPmlStablesTopUp,
ContractEvmAtcStablesTopUp,
ContractEvmSandboxStablesTopUp,
} from 'modules/blockChain/contracts'
import { MotionType } from 'modules/motions/types'
import { createMotionFormPart } from './createMotionFormPart'
Expand Down Expand Up @@ -56,6 +57,10 @@ export const TOPUP_WITH_LIMITS_MAP = {
evmContract: ContractEvmAtcStablesTopUp,
motionType: MotionType.AtcStablesTopUp,
},
[MotionType.SandboxStablesTopUp]: {
evmContract: ContractEvmSandboxStablesTopUp,
motionType: MotionType.SandboxStablesTopUp,
},
}

type Program = {
Expand Down Expand Up @@ -110,7 +115,7 @@ export const formParts = ({
allowedTokens,
tokensDecimalsMap,
initialLoading: isTokensDataLoading,
} = useAllowedTokens()
} = useAllowedTokens(registryType)
const {
data: periodLimitsData,
initialLoading: isPeriodLimitsDataLoading,
Expand Down
10 changes: 10 additions & 0 deletions modules/motions/ui/MotionFormStartNew/Parts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ export const formParts = {
StartNewNodeOperatorLimitIncrease.formParts({
motionType: MotionTypeForms.SandboxNodeOperatorIncreaseLimit,
}),
[MotionTypeForms.SandboxStablesAdd]: formAllowedRecipientAdd.formParts({
registryType: MotionTypeForms.SandboxStablesAdd,
}),
[MotionTypeForms.SandboxStablesRemove]: formAllowedRecipientRemove.formParts({
registryType: MotionTypeForms.SandboxStablesRemove,
}),
[MotionTypeForms.SandboxStablesTopUp]:
StartNewTopUpWithLimitsAndCustomToken.formParts({
registryType: MotionTypeForms.SandboxStablesTopUp,
}),
[MotionTypeForms.RccDAITopUp]: StartNewTopUpWithLimits.formParts({
registryType: MotionTypeForms.RccDAITopUp,
}),
Expand Down
3 changes: 3 additions & 0 deletions modules/motions/utils/getMotionTypeDisplayName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export const MotionTypeDisplayNames: Record<
[MotionType.RccDAITopUp]: 'Top up RCC DAI',
[MotionType.PmlDAITopUp]: 'Top up PML DAI',
[MotionType.AtcDAITopUp]: 'Top up ATC DAI',
[MotionType.SandboxStablesTopUp]: 'Top up sandbox stables',
[MotionType.SandboxStablesAdd]: 'Add sandbox stables recipient',
[MotionType.SandboxStablesRemove]: 'Remove sandbox stables recipient',
} as const

export function getMotionTypeDisplayName(
Expand Down

0 comments on commit 4a9734c

Please sign in to comment.