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: allow $liq incentives via Paladin for Bunni marketplace #1488

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
85 changes: 68 additions & 17 deletions scripts/badger/bribe_ecosystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

# vote type. ref: https://etherscan.io/address/0x1b921dbd13a280ee14ba6361c1196eb72aaa094e#code#F6#L16
PALADIN_VOTE_TYPE_WHITELISTING = 2
PALADIN_VOTE_TYPE_BLACKLISTING = 1

# close type. ref: https://etherscan.io/address/0x1b921dbd13a280ee14ba6361c1196eb72aaa094e#code#F6#L27
PALADIN_CLOSE_TYPE_ROLLOVER = 1
Expand Down Expand Up @@ -204,24 +205,74 @@ def bribe_balancer(gauge, mantissa):
if bribes["bunni"] > 0:
# NOTE: Treasury decision is expressed in dollars
cg = CoinGeckoAPI(os.getenv("COINGECKO_API_KEY"))
badger_rate = Decimal(
cg.get_price(ids="badger-dao", vs_currencies="usd")["badger-dao"]["usd"]
)
if is_governance_incentive_token:
badger_rate = Decimal(
cg.get_price(ids="badger-dao", vs_currencies="usd")["badger-dao"]["usd"]
)
else:
liquis_rate = Decimal(
cg.get_price(ids="liquis", vs_currencies="usd")["liquis"]["usd"]
)

prop = web3.solidityKeccak(
["address"], [r.bunni.badger_wbtc_bunni_gauge_309720_332580]
)
print("prop", prop.hex())
mantissa = int(bribes["bunni"] / badger_rate * Decimal(1e18))
if liquis_incentive_in_paladin:
rate = badger_rate if is_governance_incentive_token else liquis_rate
mantissa = int(bribes["bunni"] / rate * Decimal(1e18))
platform_fee = int(
(Decimal(mantissa) * palading_quest_board_veliq.platformFeeRatio())
/ MAX_BPS
)

badger.approve(bribe_vault, mantissa)
bunni_briber.depositBribe(
prop, # bytes32 proposal
badger, # address token
mantissa, # uint256 amount
max_tokens_per_vote, # uint256 _maxTokensPerVote,
periods, # uint256 _periods
)
min_reward_per_vote = palading_quest_board_veliq.minRewardPerVotePerToken(
badger if is_governance_incentive_token else liquis
)

reward_per_vote_liquis = reward_per_vote_liquis * 1e18
objective = (Decimal(mantissa) * Decimal(1e18)) / Decimal(
reward_per_vote_liquis
)

assert reward_per_vote_liquis >= min_reward_per_vote
assert objective > palading_quest_board_veliq.objectiveMinimalThreshold()
assert duration_paladin_quest >= 1

# approve incentive token conditional based on flag
if is_governance_incentive_token:
badger.approve(palading_quest_board_veliq, mantissa + platform_fee)
else:
liquis.approve(palading_quest_board_veliq, mantissa + platform_fee)

# create incentive quest
palading_quest_board_veliq.createFixedQuest(
r.bunni.badger_wbtc_bunni_gauge_309720_332580, # address gauge
badger.address
if is_governance_incentive_token
else liquis.address, # address rewardToken
False, # bool startNextPeriod
duration_paladin_quest, # uint48 duration
reward_per_vote_liquis, # uint256 rewardPerVote
mantissa, # uint256 totalRewardAmount
platform_fee, # uint256 feeAmount
PALADIN_VOTE_TYPE_BLACKLISTING, # uint8 voteType
PALADIN_CLOSE_TYPE_ROLLOVER, # uint8 closeType
[
r.liquis.voter_proxy # NOTE: blacklistin vlLIQ voters, isolating the market for veLIT!
], # address[] memory voterList.
)
else:
prop = web3.solidityKeccak(
["address"], [r.bunni.badger_wbtc_bunni_gauge_309720_332580]
)
print("prop", prop.hex())
mantissa = int(bribes["bunni"] / badger_rate * Decimal(1e18))

badger.approve(bribe_vault, mantissa)
bunni_briber.depositBribe(
prop, # bytes32 proposal
badger, # address token
mantissa, # uint256 amount
max_tokens_per_vote, # uint256 _maxTokensPerVote,
periods, # uint256 _periods
)

if bribes["liquis"] > 0:
# NOTE: Treasury decision is expressed in dollars
Expand Down Expand Up @@ -268,7 +319,7 @@ def bribe_balancer(gauge, mantissa):
badger.address
if is_governance_incentive_token
else liquis.address, # address rewardToken
True, # bool startNextPeriod
False, # bool startNextPeriod
duration_paladin_quest, # uint48 duration
reward_per_vote_liquis, # uint256 rewardPerVote
mantissa, # uint256 totalRewardAmount
Expand Down
Loading