-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Balancer L2 BAL rewards (#1012)
* feat: add support for Balancer L2 BAL rewards * fix: balancer-v2 - remove unused code from childChainGauges.js
- Loading branch information
Showing
4 changed files
with
363 additions
and
47 deletions.
There are no files selected for viewing
243 changes: 243 additions & 0 deletions
243
src/adaptors/balancer-v2/abis/balancer_token_admin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
Oops, something went wrong.