Skip to content

Commit

Permalink
Merge pull request #122 from Badger-Finance/ibbtc-wbtc-fix
Browse files Browse the repository at this point in the history
fix: change ibbtc-wbtc from half lp to full lp and fix incorrect price
  • Loading branch information
dapp-whisperer authored May 21, 2021
2 parents 71fa5bf + 2abff08 commit a10370f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
19 changes: 6 additions & 13 deletions assistant/rewards/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rich.console import Console
from assistant.rewards.aws_utils import upload_boosts
from assistant.subgraph.client import fetch_wallet_balances
from helpers.constants import BADGER, DIGG
from helpers.constants import BADGER, DIGG, SETT_BOOST_RATIOS, MAX_BOOST
from collections import OrderedDict
from assistant.rewards.rewards_utils import combine_balances, calculate_sett_balances
from assistant.badger_api.prices import (
Expand All @@ -15,23 +15,16 @@

prices = fetch_token_prices()
console = Console()
MAX_MULTIPLIER = 3


def convert_balances_to_usd(sett, userBalances):
def convert_balances_to_usd(sett,name, userBalances):
tokenAddress = sett.address
price = prices[tokenAddress]
decimals = interface.IERC20(tokenAddress).decimals()

price_ratio = 1
# Weight native lp by half
price_ratio = SETT_BOOST_RATIOS[name]

for user in userBalances:
if user.type[0] == "halfLP":
price_ratio = 0.5
else:
price_ratio = 1
user.balance = (price * user.balance) / (pow(10, decimals) * price_ratio)
user.balance = (price_ratio * price * user.balance) / (pow(10, decimals))

return userBalances

Expand All @@ -48,7 +41,7 @@ def calc_cumulative(l):
def calc_boost(percentages):
boosts = []
for p in percentages:
boost = MAX_MULTIPLIER - (p * (MAX_MULTIPLIER - 1))
boost = MAX_BOOST - (p * (MAX_BOOST - 1))
if boost < 1:
boost = 1
boosts.append(boost)
Expand Down Expand Up @@ -88,7 +81,7 @@ def badger_boost(badger, currentBlock):
if name in ["experimental.digg"]:
continue
balances = calculate_sett_balances(badger, name, currentBlock)
balances = convert_balances_to_usd(sett, balances)
balances = convert_balances_to_usd(sett, name, balances)
if name in ["native.uniDiggWbtc", "native.sushiDiggWbtc", "native.digg"]:
diggSetts = combine_balances([diggSetts, balances])
elif name in [
Expand Down
2 changes: 1 addition & 1 deletion assistant/rewards/rewards_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def calculate_sett_balances(badger, name, currentBlock):
settType = ["", ""]
if "uni" in name or "sushi" in name:
settType[0] = "halfLP"
elif "crv" in name:
if "crv" in name or name == "experimental.sushiIBbtcWbtc":
settType[0] = "fullLP"
if "badger" in name.lower() or "digg" in name.lower() or "eth" in name.lower():
settType[1] = "nonNative"
Expand Down
16 changes: 16 additions & 0 deletions helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@
"yearn.wbtc",
"experimental.sushiIBbtcWbtc",
]

SETT_BOOST_RATIOS = {
"native.uniDiggWbtc": 0.5,
"native.sushiDiggWbtc": 0.5,
"native.uniBadgerWbtc": 0.5,
"native.sushiBadgerWbtc": 0.5,
"native.badger": 1,
"native.digg": 1,
"native.renCrv": 1,
"native.sbtcCrv": 1,
"native.tbtcCrv": 1,
"harvest.renCrv": 1,
"native.sushiWbtcEth": 1,
"yearn.wbtc": 1,
"experimental.sushiIBbtcWbtc": 1
}

0 comments on commit a10370f

Please sign in to comment.