Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Balancer L2 BAL rewards #1012

Merged
merged 2 commits into from
Sep 23, 2023
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
243 changes: 243 additions & 0 deletions src/adaptors/balancer-v2/abis/balancer_token_admin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
[
{
"inputs": [
{ "internalType": "contract IVault", "name": "vault", "type": "address" },
{
"internalType": "contract IBalancerToken",
"name": "balancerToken",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "rate",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "supply",
"type": "uint256"
}
],
"name": "MiningParametersUpdated",
"type": "event"
},
{
"inputs": [],
"name": "INITIAL_RATE",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "RATE_DENOMINATOR",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "RATE_REDUCTION_COEFFICIENT",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "RATE_REDUCTION_TIME",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "activate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "available_supply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "futureEpochTimeWrite",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "future_epoch_time_write",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "bytes4", "name": "selector", "type": "bytes4" }
],
"name": "getActionId",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAuthorizer",
"outputs": [
{ "internalType": "contract IAuthorizer", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAvailableSupply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getBalancerToken",
"outputs": [
{
"internalType": "contract IBalancerToken",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getFutureEpochTime",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getInflationRate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getMiningEpoch",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getStartEpochSupply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getStartEpochTime",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getVault",
"outputs": [
{ "internalType": "contract IVault", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "start", "type": "uint256" },
{ "internalType": "uint256", "name": "end", "type": "uint256" }
],
"name": "mintableInTimeframe",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "start", "type": "uint256" },
{ "internalType": "uint256", "name": "end", "type": "uint256" }
],
"name": "mintable_in_timeframe",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "rate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "snapshot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "startEpochTimeWrite",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "start_epoch_time_write",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "updateMiningParameters",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "update_mining_parameters",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
48 changes: 48 additions & 0 deletions src/adaptors/balancer-v2/childChainGauges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { request, gql } = require('graphql-request');
const { capitalizeFirstLetter } = require('../utils');

const urlBase = 'https://api.thegraph.com/subgraphs/name/balancer-labs';
const urlGaugesEthereum = `${urlBase}/balancer-gauges`;

// For reference - this is how chains are stored in the gauges subgraph
// const chainToEnum = {
// arbitrum: 0,
// xdai: 1,
// polygon: 2,
// optimism: 3,
// avalanche: 4,
// polygonZkEvm: 5,
// base: 6,
// };

const queryChildGauge = gql`
query ($chain: String!) {
rootGauges(where: { chain: $chain }) {
chain
id
recipient
relativeWeightCap
}
}
`;

/**
* @param chain chainString
* @returns array of: {chain, id (root gauge address on ethereum), recipient (gauge on child chain), relativeWeightCap}
*/
const getChildChainRootGauge = async (chain) => {
chain = capitalizeFirstLetter(chain);

const variables = { chain };
const { rootGauges } = await request(
urlGaugesEthereum,
queryChildGauge,
variables
);

return rootGauges;
};

module.exports = {
getChildChainRootGauge,
};
Loading