Skip to content

Commit

Permalink
Merge branch 'main' into feat/generate_ui_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Tritium-VLK authored Jul 26, 2024
2 parents 62c99ed + 771c37a commit f2e2fcd
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 26 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ref: https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
schedule:
interval: "daily"
6 changes: 3 additions & 3 deletions .github/workflows/run_payment_round.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -33,7 +33,7 @@ jobs:
python3 main.py --ts_bound $TIMESTAMP
- name: Create PR
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Generate incentives run for ${{ github.event.inputs.epoch_end_date }}"
title: "Generate incentives run for ${{ github.event.inputs.epoch_end_date }}"
Expand Down
28 changes: 21 additions & 7 deletions automation/arbitrum_stip_bridge_start_q2_2024.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from web3 import Web3
from automation.constants import (
FIXED_INCENTIVE_TOKENS_PER_EPOCH,
MAX_FIXED_INCENTIVE_TOKENS_PER_EPOCH,
DESIRED_DEFAULT_VOTE_CAP,
DEFAULT_PCT_TO_AURA,
)
Expand Down Expand Up @@ -35,16 +35,32 @@
## "meta": {"symbol": "ECLP-AUSDC-AUSDT"},
## },
## {
{
"pool_id": "0xdfa752ca3ff49d4b6dbe08e2d5a111f51773d3950000000000000000000004e8",
"meta": {"symbol": "sFRAX/FRAX"},
},
{
"pool_id": "0x59743f1812bb85db83e9e4ee061d124aaa64290000000000000000000000052b",
"meta": {"symbol": "sUSDe-sFRAX"},
"fixedBoost": 1.5,
"fixedEmissions": 8_000,
},
{
"pool_id": "0x2f0cdf8596be980ef24924ca7bf54e630ca526b2000000000000000000000529",
"meta": {"symbol": "sUSDe-USDC"},
},
{
"pool_id": "0x315dd595e82bdc0c194f3a38a08fde480d7e5d2100020000000000000000056a",
"meta": {"symbol": "GYD-wUSDM-ECLP"},
},
{
"pool_id": "0xe8a6026365254f779b6927f00f8724ea1b8ae5e0000000000000000000000580",
"meta": {"symbol": "gUSDC-USDC"},
"fixedBoost": 1.75,
"fixedEmissions": 2000,
},
{
"pool_id": "0x90e6cb5249f5e1572afbf8a96d8a1ca6acffd73900000000000000000000055c",
"meta": {"symbol": "rsETH-wETH"},
"fixedEmissions": 4000,
},
{
"pool_id": "0xcdcef9765d369954a4a936064535710f7235110a000200000000000000000558",
Expand All @@ -55,7 +71,6 @@
"pool_id": "0x7967fa58b9501600d96bd843173b9334983ee6e600020000000000000000056e",
"meta": {"symbol": "wstETH-wETH-ECLP"},
"fixedBoost": 2,
"fixedEmissions": 6000,
},
{
"pool_id": "0x5b89dc91e5a4dc6d4ab0d970af6a7f981971a443000000000000000000000572",
Expand All @@ -71,7 +86,6 @@
"pool_id": "0x7b54c44fbe6db6d97fd22b8756f89c0af16202cc00000000000000000000053c",
"meta": {"symbol": "ETHx-wstETH-ETH"},
"fixedBoost": 1.5,
"fixedEmissions": 3300,
},
{
"pool_id": "0x7272163a931dac5bbe1cb5fefaf959bb65f7346f000200000000000000000549",
Expand Down Expand Up @@ -145,8 +159,8 @@
[x.get("fixedEmissions", 0) for x in ACTIVE_POOLS_AND_OVERRIDES]
)
assert (
total_fixed_emissions == FIXED_INCENTIVE_TOKENS_PER_EPOCH
), f"Sum of fixed emissions configured:{total_fixed_emissions} does not equal FIXED_INCENTIVE_TOKENS_PER_EPOCH:{FIXED_INCENTIVE_TOKENS_PER_EPOCH} configured in constants.py"
total_fixed_emissions <= MAX_FIXED_INCENTIVE_TOKENS_PER_EPOCH
), f"Sum of fixed emissions configured:{total_fixed_emissions} does not equal FIXED_INCENTIVE_TOKENS_PER_EPOCH:{MAX_FIXED_INCENTIVE_TOKENS_PER_EPOCH} configured in constants.py"

# Load static boost data
boost_data = {}
Expand Down
5 changes: 2 additions & 3 deletions automation/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
CHAIN_NAME = "arbitrum"
CURRENT_YEAR = 2024
# How many incentives should be taken away from vote following to be distributed as fixed incentives? Per 2 week epoch
FIXED_INCENTIVE_TOKENS_PER_EPOCH = 15_300 ## Max 10k per 2 weeks or 20k per epoch
MAX_FIXED_INCENTIVE_TOKENS_PER_EPOCH = 20_000 ## Max 10k per 2 weeks or 20k per epoch
# Total number of tokens available per 2 week epoch
TOTAL_TOKENS_PER_EPOCH = 600_000 / (12 / 2) # 100k per epoch, 50k per week
TOTAL_TOKENS_PER_EPOCH = 600_000 / (12 / 2) # 100k per epoch, 50k per week - 12 weeks
DYNAMIC_BOOST_CAP = 3
MIN_BAL_IN_USD_FOR_BOOST = 200
TOKENS_TO_FOLLOW_VOTING = TOTAL_TOKENS_PER_EPOCH - FIXED_INCENTIVE_TOKENS_PER_EPOCH
DESIRED_DEFAULT_VOTE_CAP = 20
DEFAULT_PCT_TO_AURA = (
0 # Insufficent support from Aura team to execute a split well for this grant
Expand Down
35 changes: 23 additions & 12 deletions automation/lstGrant.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import copy
import json
from decimal import Decimal, ROUND_DOWN
import os
from collections import defaultdict
from datetime import datetime
from datetime import timedelta
from decimal import Decimal
from typing import Dict
from typing import List
from typing import Optional
Expand All @@ -19,7 +18,6 @@
import importlib

from automation.constants import TOTAL_TOKENS_PER_EPOCH
from automation.constants import TOKENS_TO_FOLLOW_VOTING
from automation.constants import BALANCER_GAUGE_CONTROLLER_ABI
from automation.constants import CHAIN_NAME
from automation.constants import DYNAMIC_BOOST_CAP
Expand All @@ -36,16 +34,18 @@

from .payload_builders import generate_and_save_aura_transaction
from .payload_builders import generate_and_save_bal_injector_transaction
from bal_addresses import AddrBook
from bal_tools import Subgraph
from bal_addresses import to_checksum_address

# import boost_data, cap_override_data and fixed_emissions_per_pool from the python file specified in POOL_CONFIG
pool_config = importlib.import_module(f"automation.{FILE_PREFIX}")
total_fixed_emissions = pool_config.total_fixed_emissions
boost_data = pool_config.boost_data
cap_override_data = pool_config.cap_override_data
fixed_emissions_per_pool = pool_config.fixed_emissions_per_pool
percent_to_aura_per_pool = pool_config.percent_to_aura
from bal_addresses import AddrBook
from bal_tools import Subgraph
from bal_addresses import to_checksum_address
tokens_to_follow_voting = TOTAL_TOKENS_PER_EPOCH - total_fixed_emissions

# Configure Library objects for chain
addressbook = AddrBook(CHAIN_NAME)
Expand Down Expand Up @@ -149,8 +149,9 @@ def recur_distribute_unspend_tokens(
Recursively distribute unspent tokens to uncapped gauges proportionally to their voting weight until
there is no unspent tokens left
"""
unspent_tokens = TOTAL_TOKENS_PER_EPOCH - sum(
[gauge["distribution"] for gauge in tokens_gauge_distributions.values()]
unspent_tokens = Decimal(
TOTAL_TOKENS_PER_EPOCH
- sum([gauge["distribution"] for gauge in tokens_gauge_distributions.values()])
)
print(f"recursively distributing {unspent_tokens} unspent tokens")
if unspent_tokens > 0:
Expand Down Expand Up @@ -180,7 +181,10 @@ def recur_distribute_unspend_tokens(
}.items():
# For each loop calculate unspent tokens
unspent_tokens = TOTAL_TOKENS_PER_EPOCH - sum(
[gauge["distribution"] for gauge in tokens_gauge_distributions.values()]
[
Decimal(gauge["distribution"]).to_integral_value(ROUND_DOWN)
for gauge in tokens_gauge_distributions.values()
]
)
# Don't distribute more than vote cap
distribution = min(
Expand Down Expand Up @@ -237,6 +241,7 @@ def run_stip_pipeline(end_date: int) -> None:
and pool["gauge"]["isKilled"] is False
and pool["id"].lower() in whitelist
):
print(f"Selecting pool {pool['id']}({pool['symbol']}) for STIP emissions")
_gauge_addr = to_checksum_address(pool["gauge"]["address"])
gauges[_gauge_addr] = {
"gaugeAddress": to_checksum_address(pool["gauge"]["address"]),
Expand Down Expand Up @@ -284,6 +289,7 @@ def run_stip_pipeline(end_date: int) -> None:
* 100
)
gauges[gauge_addr]["weightNoBoost"] = weight
print(f"Vote Weight for gauge {gauge_addr}({gauge_data['symbol']}) is {weight}")
# Calculate dynamic boost. Formula is `[Fees earned*multipler/value of bal emitted per pool]`
# Value of bal earned must always be >1 to allow for the desired effect from division.
dollar_value_of_bal_emitted = (
Expand All @@ -298,12 +304,16 @@ def run_stip_pipeline(end_date: int) -> None:
DYNAMIC_BOOST_CAP,
)
print(
f"Gauge {gauge_addr} has a fees of {pool_protocol_fees.get(gauge_addr, 0)} and earned {dollar_value_of_bal_emitted} in USD BAL rendering a raw dynamic boost of {dynamic_boost}"
f"Gauge {gauge_addr}({gauge_data['symbol']}) has a fees of {pool_protocol_fees.get(gauge_addr, 0)} and earned {dollar_value_of_bal_emitted} in USD BAL rendering a raw dynamic boost of {dynamic_boost}"
)
else:
dynamic_boost = 1.0
print(
f"Gauge {gauge_addr}({gauge_data['symbol']} has less than {MIN_BAL_IN_USD_FOR_BOOST} USD in earned BAL emissions this round. Skipping boost calculations. (Boost: 1.0)"
)
if dynamic_boost < 1:
dynamic_boost = 1.0
print("Dynamic boost for gauge is less than 1.0. Setting to 1.0")
dynamic_boosts[gauge_addr] = dynamic_boost

# Now calculate the final boost value, which uses formula - (dynamic boost + fixed boost) - 1
Expand All @@ -312,6 +322,7 @@ def run_stip_pipeline(end_date: int) -> None:
weight *= boost
vote_weights[gauge_addr] = weight
gauges[gauge_addr]["voteWeight"] = weight
print("---\n")
print(
f"Total boosted %veBAL vote weight across eligible ARB gauges: {sum(vote_weights.values())}"
)
Expand Down Expand Up @@ -339,7 +350,7 @@ def run_stip_pipeline(end_date: int) -> None:
gauge_addr = Web3.to_checksum_address(gauge_addr)
# Calculate distribution based on vote weight and total weight
to_distribute = (
TOKENS_TO_FOLLOW_VOTING * gauge_data["voteWeight"] / total_weight
tokens_to_follow_voting * gauge_data["voteWeight"] / total_weight
)
# Add in fixed incentives
to_distribute += fixed_emissions_per_pool.get(gauge_data["id"], 0)
Expand Down Expand Up @@ -377,7 +388,7 @@ def run_stip_pipeline(end_date: int) -> None:
}
recur_distribute_unspend_tokens(max_tokens_per_gauge, gauge_distributions)
print(
f"Unspent arb: {TOTAL_TOKENS_PER_EPOCH - sum([gauge['distribution'] for gauge in gauge_distributions.values()])}"
f"\n---\nUnspent arb: {TOTAL_TOKENS_PER_EPOCH - sum([gauge['distribution'] for gauge in gauge_distributions.values()])}"
)
print(
f"Tokens distributed: {sum([gauge['distribution'] for gauge in gauge_distributions.values()])}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
recipientGaugeAddr,poolAddress,symbol,distribution,pctDistribution,pctToAura,distroToAura,distroToBalancer,voteWeightNoBoost,staticBoost,dynamicBoost,boost,voteWeight,cap,fixedIncentive
0x96d7C70c80518Ee189CB6ba672FbD22E4fDD9c19,0x7967FA58B9501600D96bD843173b9334983EE6E6,ECLP-wstETH-WETH,14035.963367431807,14.035963367431807,0,0.0,14035.963367431807,0.36240487333187466,2.0,1.0,2.0,0.7248097466637493,20%,6000
0x06eaf7bAabEac962301eE21296e711B3052F2c0d,0xc2598280bFeA1Fe18dFcaBD21C7165c40c6859d3,wstETH/sfrxETH,10586.763767611817,10.586763767611817,0,0.0,10586.763767611817,0.6365874020357397,1.5,1.0,1.5,0.9548811030536095,20%,0
0x8ba2D53F34159C5C5e7add60B56C7dE3BBc1DA68,0xd0EC47c54cA5e20aaAe4616c25C825c7f48D4069,rETH/wETH BPT,8993.411453341663,8.993411453341663,0,0.0,8993.411453341663,0.8111674953071206,1.0,1.0,1.0,0.8111674953071206,20%,0
0x59907f88C360D576Aa38dba84F26578367F96b6C,0x90e6CB5249f5e1572afBF8A96D8A1ca6aCFFd739,rsETH/wETH,8982.23851858494,8.98223851858494,0,0.0,8982.23851858494,0.4493767421973714,1.0,1.0,1.0,0.4493767421973714,20%,4000
0x260cbb867359a1084eC97de4157d06ca74e89415,0x9791d590788598535278552EEcD4b211bFc790CB,wstETH-WETH-BPT,8152.829982977749,8.15282998297775,0,0.0,8152.829982977749,0.2451168729192139,1.0,3.0,3.0,0.7353506187576417,20%,0
0x050fBe33699E56B577c3D6f090eCE9870A0966bd,0x2CE4457aCac29dA4736aE6f5Cd9F583a6b335c27,sFRAX/4POOL,7282.7797647019415,7.2827797647019406,0,0.0,7282.7797647019415,0.6568757863748796,1.0,1.0,1.0,0.6568757863748796,20%,0
0xdB66fFFf713B1FA758E348e69E2f2e24595111cF,0xCDCef9765D369954a4A936064535710f7235110A,ECLP-weETH-wstETH,6854.20404869184,6.854204048691841,0,0.0,6854.20404869184,0.4121467186911519,1.5,1.0,1.5,0.6182200780367278,20%,0
0x5a0e92a55800BB5bFd5ec6C7340BfdE7f0947c3E,0x2d6CeD12420a9AF5a83765a8c48Be2aFcD1A8FEb,cbETH/rETH/wstETH,6749.181464187531,6.749181464187531,0,0.0,6749.181464187531,0.17392785348891682,1.5,3.0,3.5,0.6087474872112089,20%,0
0x7C4A6B0c16cA99e65822Cc531403cE2f8A20A912,0xB61371Ab661B1ACec81C699854D2f911070C059E,ezETH/wstETH,5436.0928662038705,5.436092866203871,0,0.0,5436.0928662038705,0.32687498378953406,1.5,1.0,1.5,0.4903124756843011,20%,0
0x40e86216712cB9871B9C698EA3AFB22f88c00E6e,0xef0c116A2818A5b1A5D836A291856A321f43C2Fb,ECLP-WOETH-WETH,4411.901456629227,4.411901456629227,0,0.0,4411.901456629227,0.3979347628742153,1.0,1.0,1.0,0.3979347628742153,20%,0
0x2b52a321Fc2ab77e9fC8488D792BB3CaEA966c0b,0x125bC5a031B2Db6733bfa35d914ffa428095978B,ECLP-AUSDC-AUSDT,4274.029536109555,4.274029536109555,0,0.0,4274.029536109555,0.2202853151625116,1.75,1.0,1.75,0.38549930153439527,20%,0
0x8f57378CaD866a46eA702B7ACAEBF21dd93B4804,0x7B54C44fBe6Db6D97FD22b8756f89c0aF16202Cc,ETHx/wstETH,3300.0,3.3000000000000003,0,0.0,3300.0,0.0,1.5,1.0,1.5,0.0,20%,3300
0xfC745035F31BCbaEb2D1a89aA9171495c671F6cE,0x3FD4954a851eaD144c2FF72B1f5a38Ea5976Bd54,ankrETH/wstETH-BPT,3149.9831117022113,3.1499831117022112,0,0.0,3149.9831117022113,0.1894100604822801,1.5,1.0,1.5,0.2841150907234201,20%,0
0x052597B6633814a0a6eA9020eE46E25Aa6936E49,0x6e822c64c00393b2078f2a5BB75c575aB505B55c,ECLP-GYD-AUSDC,2895.3103309129233,2.8953103309129236,0,0.0,2895.3103309129233,0.1492255360778304,1.75,1.0,1.75,0.2611446881362032,20%,0
0xd9647eb5D6457bd7Adb39B335ab89eC3a1Ea6d09,0x7272163A931DaC5BBe1CB5feFaF959BB65F7346F,ECLP-GYD-AUSDT,2895.3103309129233,2.8953103309129236,0,0.0,2895.3103309129233,0.1492255360778304,1.75,1.0,1.75,0.2611446881362032,20%,0
0x0CE9489bBD4bfA0Da7b5bb06E4dFa7a5947F76e8,0xE8a6026365254f779b6927f00f8724EA1B8aE5E0,gUSDC/USDC,2000.0,2.0,0,0.0,2000.0,0.0,1.75,1.0,1.75,0.0,20%,2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version": "1.0",
"chainId": "42161",
"createdAt": 1691667397141,
"meta": {
"name": "Transactions Batch",
"description": "",
"txBuilderVersion": "1.16.1",
"createdFromSafeAddress": "0xb6BfF54589f269E248f99D5956f1fDD5b014D50e",
"createdFromOwnerAddress": "",
"checksum": ""
},
"transactions": [
{
"to": "0xF23d8342881eDECcED51EA694AC21C2B68440929",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"name": "gaugeAddresses",
"type": "address[]",
"internalType": "address[]"
},
{
"name": "amountsPerPeriod",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "maxPeriods",
"type": "uint8[]",
"internalType": "uint8[]"
}
],
"name": "setRecipientList",
"payable": false
},
"contractInputsValues": {
"gaugeAddresses": "[0x5a0e92a55800BB5bFd5ec6C7340BfdE7f0947c3E,0xfC745035F31BCbaEb2D1a89aA9171495c671F6cE,0x052597B6633814a0a6eA9020eE46E25Aa6936E49,0x7C4A6B0c16cA99e65822Cc531403cE2f8A20A912,0x050fBe33699E56B577c3D6f090eCE9870A0966bd,0x0CE9489bBD4bfA0Da7b5bb06E4dFa7a5947F76e8,0x8ba2D53F34159C5C5e7add60B56C7dE3BBc1DA68,0x2b52a321Fc2ab77e9fC8488D792BB3CaEA966c0b,0x06eaf7bAabEac962301eE21296e711B3052F2c0d,0x40e86216712cB9871B9C698EA3AFB22f88c00E6e,0xd9647eb5D6457bd7Adb39B335ab89eC3a1Ea6d09,0x8f57378CaD866a46eA702B7ACAEBF21dd93B4804,0x59907f88C360D576Aa38dba84F26578367F96b6C,0x96d7C70c80518Ee189CB6ba672FbD22E4fDD9c19,0x260cbb867359a1084eC97de4157d06ca74e89415,0xdB66fFFf713B1FA758E348e69E2f2e24595111cF]",
"amountsPerPeriod": "[3374590732093750000000,1574991555851100000000,1447655165456450000000,2718046433101900000000,3641389882350950000000,1000000000000000000000,4496705726670800000000,2137014768054750000000,5293381883805900000000,2205950728314600000000,1447655165456450000000,1650000000000000000000,4491119259292450000000,7017981683715900000000,4076414991488850000000,3427102024345900000000]",
"maxPeriods": "[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]"
}
},
{
"to": "0x912ce59144191c1204e64559fe8253a0e49e6548",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"name": "to",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"name": "transfer",
"payable": false
},
"contractInputsValues": {
"to": "0xF23d8342881eDECcED51EA694AC21C2B68440929",
"amount": "49999999999999995805696"
}
}
]
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pandas>2.0,<2.3
gql[requests]
pycoingecko==3.1.0
python-dotenv
git+https://github.com/BalancerMaxis/[email protected].7
git+https://github.com/BalancerMaxis/[email protected].8

0 comments on commit f2e2fcd

Please sign in to comment.