Skip to content

Commit

Permalink
feat: allow paladin incentives claims from voter and blend together s…
Browse files Browse the repository at this point in the history
…cript for HH + paladin claims in single script conditionally
  • Loading branch information
petrovska-petro committed Jan 17, 2024
1 parent e706aa8 commit 1090752
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 22 deletions.
63 changes: 63 additions & 0 deletions great_ape_safe/ape_api/badger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pandas as pd
from brownie import chain, interface, ZERO_ADDRESS
from eth_utils import to_checksum_address
from eth_abi import encode_abi

from helpers.addresses import r
Expand Down Expand Up @@ -49,9 +50,20 @@ def __init__(self, safe):
self.station = self.safe.contract(r.badger_wallets.gas_station)
self.rewards = self.safe.contract(r.hidden_hand.rewards_distributor)

# paladin
self.paladin_merkle_tree = self.safe.contract(
r.paladin.multi_merkle_distributor
)
self.paladin_merkle_tree_legacy = self.safe.contract(
r.paladin.merkle_distributor_legacy
)

# misc
self.api_url = "https://api.badger.com/v2/"
self.api_hh_url = f"https://api.hiddenhand.finance/reward/{chain.id}/"
self.api_paladin_claim_url = (
f"https://api.paladin.vote/quest/v2/copilot/claims/"
)

def claim_all(self, json_file_path=None):
"""
Expand Down Expand Up @@ -210,6 +222,57 @@ def transform_claimable(amount_string, n_decimals):

return dict(zip(aggregate["tokens"], aggregate["amounts"]))

def get_paladin_data(self, address=None):
"""
get hidden hand data for a particular address
"""
address = address if address else self.safe.address
url = self.api_paladin_claim_url + address
r = requests.get(url)
if not r.ok:
r.raise_for_status()
return r.json()["claims"]

def claim_bribes_from_paladin(self):
"""
grabs the available claimable tokens from Paladin endpoint,
shape the endpoint information and claims tokens for the safe.
"""
data = self.get_paladin_data()

claim_data = []
claim_data_legacy = []
for entry in data:
if (
to_checksum_address(entry["distributor"])
== self.paladin_merkle_tree.address
):
# https://etherscan.io/address/0xccd73d064ed07964ad2144fdfd1b99e7e6b5f626#code#F2#L162
claim_data.append(
(
entry["questId"],
entry["period"],
entry["index"],
entry["amount"],
entry["proofs"],
)
)
else:
claim_data_legacy.append(
(
entry["questId"],
entry["period"],
entry["index"],
entry["amount"],
entry["proofs"],
)
)

if len(claim_data) > 0:
self.paladin_merkle_tree.multiClaim(self.safe, claim_data)
if len(claim_data_legacy) > 0:
self.paladin_merkle_tree_legacy.multiClaim(self.safe, claim_data_legacy)

def sweep_reward_token(self, token_addr):
"""
Sweeps reward token from the vestedCVX strategy into
Expand Down
7 changes: 6 additions & 1 deletion helpers/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,12 @@
"rewards_pool_309720_332580": "0xB99ca33d35Ea7B520EC779F001C0C0b971aAb395",
},
"paladin": {
"quest_board_veliq": "0xcbd27bf506aB5580Ef86Fe6a169449bc24Be471B",
"quest_board_veliq": "0x1B921DBD13A280ee14BA6361c1196EB72aaa094e",
"merkle_distributor_legacy": "0x069B449d8fd744ef09cBC07FE871F52627FE22B0",
"multi_merkle_distributor": "0xCcD73d064Ed07964Ad2144fDFd1b99e7E6b5f626",
"_deprecated": {
"quest_board_veliq": "0xcbd27bf506aB5580Ef86Fe6a169449bc24Be471B",
},
},
}

Expand Down
21 changes: 0 additions & 21 deletions scripts/badger/claim_voter_hh.py

This file was deleted.

29 changes: 29 additions & 0 deletions scripts/badger/claim_voter_incentives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from great_ape_safe import GreatApeSafe
from helpers.addresses import r


def main():
voter = GreatApeSafe(r.badger_wallets.treasury_voter_multisig)
trops = GreatApeSafe(r.badger_wallets.treasury_ops_multisig)
voter.init_badger()

hh_data = voter.badger.get_hh_data()

# incentives tokens expected on epochs: $badger and/or $liquis
rewards = [r.treasury_tokens.BADGER, r.treasury_tokens.LIQ]

trops.take_snapshot(tokens=rewards)

if len(hh_data) > 0:
voter.badger.claim_bribes_hidden_hands(claim_from_strat=False)

voter.badger.claim_bribes_from_paladin()

for token in rewards:
token = voter.contract(token)
token_balance = token.balanceOf(voter)
if token_balance > 0:
token.transfer(trops, token_balance)

trops.print_snapshot()
voter.post_safe_tx()

0 comments on commit 1090752

Please sign in to comment.