Exemple #1
0
def calc_geyser_stakes(key, geyser, periodStartBlock, periodEndBlock):
    console.print(
        " Geyser initial snapshot for " + geyser.address,
        {
            "from": globalStartBlock,
            "to": periodEndBlock
        },
    )
    console.print(
        " Rewards for " + geyser.address,
        {
            "from": periodStartBlock,
            "to": periodEndBlock
        },
    )

    globalStartTime = web3.eth.getBlock(globalStartBlock)["timestamp"]
    periodStartTime = web3.eth.getBlock(periodStartBlock)["timestamp"]
    periodEndTime = web3.eth.getBlock(periodEndBlock)["timestamp"]

    geyserMock = BadgerGeyserMock(key)
    geyserMock.set_current_period(periodStartTime, periodEndTime)

    # Collect actions from the total history
    console.print("\n[grey]Collect Actions: Entire History[/grey]")
    actions = collect_actions_from_events(geyser, globalStartBlock,
                                          periodEndBlock)

    # Process actions from the total history
    console.print("\n[grey]Process Actions: Entire History[/grey]")
    geyserMock = process_actions(geyserMock, actions, globalStartBlock,
                                 periodEndBlock)

    return calculate_token_distributions(geyser, geyserMock, periodStartTime,
                                         periodEndTime)
def get_distributed_in_range(key, geyser, startBlock, endBlock):
    periodEndTime = web3.eth.getBlock(endBlock)["timestamp"]
    periodStartTime = web3.eth.getBlock(startBlock)["timestamp"]

    geyserMock = BadgerGeyserMock(key)
    distributionTokens = geyser.getDistributionTokens()
    for token in distributionTokens:
        geyserMock.add_distribution_token(token)
        unlockSchedules = geyser.getUnlockSchedulesFor(token)
        for schedule in unlockSchedules:
            console.log("get_distributed_in_range", schedule)
            geyserMock.add_unlock_schedule(token, schedule)

    tokenDistributions = geyserMock.calc_token_distributions_in_range(
        periodStartTime, periodEndTime)

    return tokenDistributions