Rewards Fee Calculator

This guide covers steps to deploy Fee Calculator hook.

Prerequisites

  • AVS contracts

  • Access to AVS governance multisig

1

Set Up the Contract

Create a contract called FeeCalculator , use IFeeCalculator interface to override calculateBaseRewardFees, calculateFeesPerId and isBaseRewardFee hook functions for custom logic.

contract FeeCalculator is IFeeCalculator {

}
2

Deploy the contract

After implementation, deploy the contract on the same L2 network as the AttestationCenter.

3

Register AVSLogic with AttestationCenter

After deployment, you must call the setFeeCalculator function on the AttestationCenter and provide the address of the FeeCalculator contract as the parameter, as shown in the script below.

Script to execute setFeeCalculator function
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

/*______     __      __                              __      __ 
 /      \   /  |    /  |                            /  |    /  |
/$$$$$$  | _$$ |_   $$ |____    ______   _______   _$$ |_   $$/   _______ 
$$ |  $$ |/ $$   |  $$      \  /      \ /       \ / $$   |  /  | /       |
$$ |  $$ |$$$$$$/   $$$$$$$  |/$$$$$$  |$$$$$$$  |$$$$$$/   $$ |/$$$$$$$/ 
$$ |  $$ |  $$ | __ $$ |  $$ |$$    $$ |$$ |  $$ |  $$ | __ $$ |$$ |
$$ \__$$ |  $$ |/  |$$ |  $$ |$$$$$$$$/ $$ |  $$ |  $$ |/  |$$ |$$ \_____ 
$$    $$/   $$  $$/ $$ |  $$ |$$       |$$ |  $$ |  $$  $$/ $$ |$$       |
 $$$$$$/     $$$$/  $$/   $$/  $$$$$$$/ $$/   $$/    $$$$/  $$/  $$$$$$$/
*/
/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 */

import {Script, console} from "forge-std/Script.sol";
import "../src/IAttestationCenter.sol";
import "../src/FeeCalculator.sol";

// forge script FeeCalculatorScript --rpc-url $L2_RPC --private-key $PRIVATE_KEY
// --broadcast -vvvv --verify --etherscan-api-key $L2_ETHERSCAN_API_KEY --chain
// $L2_CHAIN --verifier-url $L2_VERIFIER_URL --sig="run(address)" $ATTESTATION_CENTER_ADDRESS
contract FeeCalculatorScript is Script {
    function setUp() public {}

    function run(address attestationCenter) public {
        vm.broadcast();
        FeeCalculator feeCalculator = new FeeCalculator(attestationCenter);
        IAttestationCenter(attestationCenter).setFeeCalculator(address(feeCalculator));
    }
}

Note that only the AVS Governance Multisig is authorized to call this function.

4

Verify the Hook contract

Last updated