Off chain votes to on chain data

Off chain vote results to on chain submission

Alluo carries out a votes on snapshot on a fortnightly basis. These include (as of writing) three different governance proposals. 1. Tokenomics rewards 2. Liquidity Direction (distributing treasury funds between yield opportunities) 3. Setting APY on IbAlluo farms.

This is triggered automatically by Github Actions.

Here is an example below:

There are a few key things to note:

  1. Parameters for contract: This json object is decoded and then parsed (see below how this works)

  2. Vote results : Since 5% APY has the most votes, that is what should be set on chain.

Using Github Actions to automate parsing results and submitting on chain:

Once the votes are complete, the results are parsed as the script below.

Most importantly, The commands from the paramters set inside each vote is encoded appropriately so that we can "encodeAllMessages()" and then "submitData()" correctly on chain. This is executed with a private key stored inside the automation.

if (winningParams.length > 0) {
 const commandIndexes = => Number.parseInt(;
 const commands = =>;

 const mainnetProvider = new ethers.providers.JsonRpcProvider(process.env.NODE_URL as string);
 let signer = Wallet.fromMnemonic(process.env.MNEMONIC as string);
 signer = new Wallet(signer.privateKey, mainnetProvider);

 const veMasterInterface = await ethers.getContractAt("IVoteExecutorMaster", voteExecutorMasterAddressMainnet);
 const veMaster = new Contract(voteExecutorMasterAddressMainnet, veMasterInterface.interface, signer);

 console.log("Tx sender address:", signer.address)
 const cmdEncoded = await veMaster.callStatic.encodeAllMessages(commandIndexes, commands);

 console.log("Message hash:", cmdEncoded.messagesHash);
 console.log("Trying to broadcast tx...");
 const tx = await veMaster.submitData(cmdEncoded.inputData);

 console.log("Tx is broadcasted on chainId", (await ethers.provider.getNetwork()).chainId, "txHash:", tx.hash);
 console.log("Waiting for tx confirmation...");

 await tx.wait();
 console.log("Tx is confirmed");

Last updated