Skip to content
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
115 changes: 65 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 68 additions & 11 deletions src/commands/governance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {
IDataWarehouse_ABI,
IVotingMachineWithProofs_ABI,
IVotingPortal_ABI,
} from '@bgd-labs/aave-address-book/abis';
import type {Command} from '@commander-js/extra-typings';
import {confirm, input, select} from '@inquirer/prompts';
import {type Hex, encodeAbiParameters, encodeFunctionData, getContract} from 'viem';
Expand All @@ -20,6 +15,68 @@ const localCacheAdapter = customStorageProvider(fileSystemStorageAdapter);
import {refreshCache} from '@bgd-labs/aave-v3-governance-cache/refreshCache';
import {ChainList} from '@bgd-labs/toolbox';

const VOTING_PORTAL_ABI = [
{
type: 'function',
name: 'VOTING_MACHINE',
stateMutability: 'view',
inputs: [],
outputs: [{name: '', type: 'address', internalType: 'address'}],
},
{
type: 'function',
name: 'VOTING_MACHINE_CHAIN_ID',
stateMutability: 'view',
inputs: [],
outputs: [{name: '', type: 'uint256', internalType: 'uint256'}],
},
] as const;

const VOTING_MACHINE_WITH_PROOFS_ABI = [
{
type: 'function',
name: 'DATA_WAREHOUSE',
stateMutability: 'view',
inputs: [],
outputs: [{name: '', type: 'address', internalType: 'address'}],
},
{
type: 'function',
name: 'submitVote',
stateMutability: 'nonpayable',
inputs: [
{name: 'proposalId', type: 'uint256', internalType: 'uint256'},
{name: 'support', type: 'bool', internalType: 'bool'},
{
name: 'votingBalanceProofs',
type: 'tuple[]',
internalType: 'struct VotingBalanceProof[]',
components: [
{name: 'underlyingAsset', type: 'address', internalType: 'address'},
{name: 'slot', type: 'uint128', internalType: 'uint128'},
{name: 'proof', type: 'bytes', internalType: 'bytes'},
],
},
],
outputs: [],
},
] as const;

const DATA_WAREHOUSE_ABI = [
{
type: 'function',
name: 'processStorageRoot',
stateMutability: 'nonpayable',
inputs: [
{name: 'account', type: 'address', internalType: 'address'},
{name: 'blockHash', type: 'bytes32', internalType: 'bytes32'},
{name: 'blockHeaderRLP', type: 'bytes', internalType: 'bytes'},
{name: 'accountStateProofRLP', type: 'bytes', internalType: 'bytes'},
],
outputs: [],
},
] as const;

enum DialogOptions {
DETAILS = 0,
IPFS_TEXT = 1,
Expand Down Expand Up @@ -161,7 +218,7 @@ export function addCommand(program: Command) {
});
const portal = getContract({
address: cache.proposal.votingPortal,
abi: IVotingPortal_ABI,
abi: VOTING_PORTAL_ABI,
client: DEFAULT_GOVERNANCE_CLIENT,
});
const [machine, chainId] = await Promise.all([
Expand All @@ -184,7 +241,7 @@ export function addCommand(program: Command) {
logSuccess(
'encoded calldata',
encodeFunctionData({
abi: IVotingMachineWithProofs_ABI,
abi: VOTING_MACHINE_WITH_PROOFS_ABI,
functionName: 'submitVote',
args: [selectedProposalId, support, proofs],
}),
Expand All @@ -196,7 +253,7 @@ export function addCommand(program: Command) {
if (moreInfo === DialogOptions.HOW_TO_REGISTER_STORAGE_ROOTS) {
const portalContract = getContract({
address: cache.proposal.votingPortal,
abi: IVotingPortal_ABI,
abi: VOTING_PORTAL_ABI,
client: DEFAULT_GOVERNANCE_CLIENT,
});
const [machine, chainId] = await Promise.all([
Expand All @@ -205,7 +262,7 @@ export function addCommand(program: Command) {
]);
const machineContract = getContract({
address: machine,
abi: IVotingMachineWithProofs_ABI,
abi: VOTING_MACHINE_WITH_PROOFS_ABI,
client: getClient(Number(chainId)),
});
const dataWarehouse = await machineContract.read.DATA_WAREHOUSE();
Expand Down Expand Up @@ -234,7 +291,7 @@ export function addCommand(program: Command) {
logSuccess(
'Encoded callData',
encodeFunctionData({
abi: IDataWarehouse_ABI,
abi: DATA_WAREHOUSE_ABI,
functionName: 'processStorageRoot',
args: [root.address, cache.proposal.snapshotBlockHash, blockRPL, accountRPL],
}),
Expand Down Expand Up @@ -314,7 +371,7 @@ export function addCommand(program: Command) {

const portal = getContract({
address: proposal.votingPortal,
abi: IVotingPortal_ABI,
abi: VOTING_PORTAL_ABI,
client: DEFAULT_GOVERNANCE_CLIENT,
});
const chainId = await portal.read.VOTING_MACHINE_CHAIN_ID();
Expand Down
8 changes: 4 additions & 4 deletions src/govv3/governance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AaveSafetyModule, AaveV3Ethereum, GovernanceV3Ethereum} from '@bgd-labs/aave-address-book';
import {IGovernanceCore_ABI} from '@bgd-labs/aave-address-book/abis';
import {IGovernance_ABI} from '@bgd-labs/toolbox';
import merge from 'deepmerge';
import {
type Client,
Expand Down Expand Up @@ -29,7 +29,7 @@ import {VOTING_SLOTS, WAREHOUSE_SLOTS, getAccountRPL, getProof} from './proofs';
import {ProposalState, type ProposalExecutedEvent} from '@bgd-labs/aave-v3-governance-cache';

export interface Governance {
governanceContract: GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
governanceContract: GetContractReturnType<typeof IGovernance_ABI, Client>;
/**
* Thin caching wrapper on top of getProposal.
* If the proposal state is final, the proposal will be stored in json and fetched from there.
Expand Down Expand Up @@ -78,7 +78,7 @@ interface GetGovernanceParams {

export const getGovernance = ({address, client}: GetGovernanceParams): Governance => {
const governanceContract = getContract({
abi: IGovernanceCore_ABI,
abi: IGovernance_ABI,
address,
client,
});
Expand Down Expand Up @@ -110,7 +110,7 @@ export const getGovernance = ({address, client}: GetGovernanceParams): Governanc
from: EOA,
to: governanceContract.address,
input: encodeFunctionData({
abi: IGovernanceCore_ABI,
abi: IGovernance_ABI,
functionName: 'executeProposal',
args: [proposalId],
}),
Expand Down
8 changes: 4 additions & 4 deletions src/govv3/payloadsController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IPayloadsControllerCore_ABI} from '@bgd-labs/aave-address-book/abis';
import {IPayloadsController_ABI} from '@bgd-labs/toolbox';
import {
type Client,
type GetContractReturnType,
Expand Down Expand Up @@ -27,7 +27,7 @@ export const HUMAN_READABLE_PAYLOAD_STATE = {
};

export interface PayloadsController {
controllerContract: GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
controllerContract: GetContractReturnType<typeof IPayloadsController_ABI, Client>;
getSimulationPayloadForExecution: (id: number) => Promise<TenderlyRequest>;
simulatePayloadExecutionOnTenderly: (
id: number,
Expand All @@ -41,7 +41,7 @@ const SLOTS = {

export const getPayloadsController = (address: Hex, client: Client): PayloadsController => {
const controllerContract = getContract({
abi: IPayloadsControllerCore_ABI,
abi: IPayloadsController_ABI,
address,
client,
});
Expand All @@ -54,7 +54,7 @@ export const getPayloadsController = (address: Hex, client: Client): PayloadsCon
from: EOA,
to: controllerContract.address,
input: encodeFunctionData({
abi: IPayloadsControllerCore_ABI,
abi: IPayloadsController_ABI,
functionName: 'executePayload',
args: [id],
}),
Expand Down
4 changes: 2 additions & 2 deletions src/govv3/utils/checkAddress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as addresses from '@bgd-labs/aave-address-book';
import {IPool_ABI, IERC20Detailed_ABI} from '@bgd-labs/aave-address-book/abis';
import {IPool_ABI, IERC20Metadata_ABI} from '@bgd-labs/toolbox';
import {findObjectPaths} from 'find-object-paths';
import {type Address, type Client, HDKey, type Hex, getAddress, getContract} from 'viem';

Expand Down Expand Up @@ -59,7 +59,7 @@ export async function findAsset(client: Client, address: Hex) {
if (!assetsCache[chainId]) assetsCache[chainId] = {};
const asset = assetsCache[chainId][address];
if (asset) return asset;
const erc20Contract = getContract({client, address: address, abi: IERC20Detailed_ABI});
const erc20Contract = getContract({client, address: address, abi: IERC20Metadata_ABI});
let symbol = 'unknown';
let decimals = 0;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/reports/raw-storage-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {bytes32ToAddress} from '../utils/storageSlots';
import {RawStorage, SlotDiff} from './snapshot-types';
import {isKnownAddress} from '../govv3/utils/checkAddress';
import {Address, getContract, isAddress, zeroHash} from 'viem';
import {IPool_ABI} from '@bgd-labs/aave-address-book/abis';
import {
getClient,
BlockscoutStyleSourceCode,
diffCode,
getSourceCode,
IPool_ABI,
parseBlockscoutStyleSourceCode,
parseEtherscanStyleSourceCode,
StandardJsonInput,
Expand Down
Loading