Alluo Explained
Search
K

Automated execution of votes

Now that the votes have been submitted either manually or automatically through Github Actions, the function executeSpecificData can be called, with the corresponding data index.
VoteExecutorMaster.sol
1
function executeSpecificData(uint256 index) external {
2
SubmittedData memory exactData = submittedData[index];
3
(bytes32 hashed, Message[] memory messages,) = abi.decode(exactData.data, (bytes32, Message[], uint256));
4
require(exactData.time + timeLock < block.timestamp, "Under timelock");
5
require(hashExecutionTime[hashed] == 0, "Duplicate Hash");
6
7
if(exactData.signs.length >= minSigns){
8
uint256 currentChain = generalBridgingInfo.currentChain;
9
for (uint256 j; j < messages.length; j++) {
10
if(messages[j].commandIndex == 1){
11
(uint256 mintAmount, uint256 period) = abi.decode(messages[j].commandData, (uint256, uint256));
12
IAlluoToken(ALLUO).mint(locker, mintAmount);
13
ILocker(locker).setReward(mintAmount / (period));
14
}
15
if(messages[j].commandIndex == 2) {
16
// Handle all withdrawals first and then add all deposit actions to an array to be executed afterwards
17
(address strategyAddress, uint256 delta, uint256 chainId, address strategyPrimaryToken,, bytes memory data) = abi.decode(messages[j].commandData, (address, uint256, uint256, address,address, bytes));
18
if (chainId == currentChain) {
19
IAlluoStrategy(strategyAddress).exitAll(data, delta, strategyPrimaryToken, address(this), false);
20
}
21
}
22
else if(messages[j].commandIndex == 3) {
23
// Add all deposits to the queue.
24
(address strategyAddress, uint256 delta, uint256 chainId, address strategyPrimaryToken, address entryToken, bytes memory data) = abi.decode(messages[j].commandData, (address, uint256, uint256, address,address, bytes));
25
if (chainId == currentChain) {
26
tokenToDepositQueue[strategyPrimaryToken].depositList.push(Deposit(strategyAddress, delta, strategyPrimaryToken, entryToken, data));
27
}
28
}
29
}
30
// Execute deposits. Only executes if we have sufficient balances.
31
hashExecutionTime[hashed] = block.timestamp;
32
bytes memory finalData = abi.encode(exactData.data, exactData.signs);
33
IAnyCall(messagingInfo.anyCallAddress).anyCall(messagingInfo.nextChainExecutor, finalData, address(0), messagingInfo.nextChain, 0);
34
}
35
}

What exactly happens when executeSpecificData is called?

  1. 1.
    The data is checked for legitimacy then decoded.
  2. 2.
    Any actions to be immediately taken on the current chain happens first.
3. Any actions that must occur on another chain is passed on through Multichain crosschain messaging.