예제 #1
0
def main():
    multi = MultiRewards.at(MULTIREWARDS_CONTRACT_ADDRESS)
    reward = Contract(REWARDTOKEN_CONTRACT_ADDRESS)

    # sanity check on the reward amount
    if REWARDS_AMOUNT < 10**reward.decimals():
        raise ValueError(
            "Reward amount is less than 1 token - are you sure this is correct?"
        )

    # ensure the reward admin has sufficient balance of the reward token
    if reward.balanceOf(REWARD_ADMIN) < REWARDS_AMOUNT:
        raise ValueError(
            "Rewards admin has insufficient balance to fund the contract")

    # ensure the reward contract has sufficient allowance to transfer the reward token
    if reward.allowance(REWARD_ADMIN, multi) < REWARDS_AMOUNT:
        reward.approve(multi, 2**256 - 1, {
            "from": REWARD_ADMIN,
            "gas_price": gas_strategy
        })

    # update the reward amount
    multi.notifyRewardAmount(reward, REWARDS_AMOUNT, {
        "from": REWARD_ADMIN,
        "gas_price": gas_strategy
    })

    print(
        f"Success! {REWARDS_AMOUNT/10**reward.decimals():.2f} {reward.symbol()} has been added"
    )
예제 #2
0
def main():
    rewards = StakingRewards.at(REWARDS_CONTRACT_ADDRESS)
    token = Contract(rewards.rewardsToken())

    # sanity check on the reward amount
    if REWARDS_AMOUNT < 10**token.decimals():
        raise ValueError(
            "Reward amount is less than 1 token - are you sure this is correct?"
        )

    # ensure the reward admin has sufficient balance of the reward token
    if token.balanceOf(REWARD_ADMIN) < REWARDS_AMOUNT:
        raise ValueError(
            "Rewards admin has insufficient balance to fund the contract")

    # check the reward duration and modify if needed
    if rewards.rewardsDuration() != REWARDS_DURATION:
        remaining_time = rewards.periodFinish() - chain[-1].timestamp
        if remaining_time > 0:
            raise ValueError(
                "Current reward period must finish before the period duration can be modified, "
                f"try again in {datetime.timedelta(seconds=remaining_time)}")
        rewards.setRewardsDuration(REWARDS_DURATION, {'from': OWNER})

    # ensure the reward contract has sufficient allowance to transfer the reward token
    if token.allowance(REWARD_ADMIN, rewards) < REWARDS_AMOUNT:
        token.approve(rewards, 2**256 - 1, {
            'from': REWARD_ADMIN,
            'gas_price': gas_strategy
        })

    # update the reward amount
    rewards.notifyRewardAmount(REWARDS_AMOUNT, {
        'from': REWARD_ADMIN,
        'gas_price': gas_strategy
    })

    print(
        f"Success! {REWARDS_AMOUNT/10**token.decimals():.2f} {token.symbol()} has been added to "
        f"the rewards contract, to be distributed over {REWARDS_DURATION/86400:.1f} days."
    )