Skip to content

Commit

Permalink
fix overall silo withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
soilking committed Sep 24, 2024
1 parent ed093f7 commit fd03aa6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ export function handleWhitelistToken_v4(event: WhitelistToken): void {
/// Withdrawal is a legacy feature from replant, but these events were still present until the reseed ///
// Replanted -> Reseed
export function handleRemoveWithdrawal(event: RemoveWithdrawal): void {
updateClaimedWithdraw(event.params.account, event.params.token, event.params.season, event.block);
updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.season, event.block);
}

// Replanted -> Reseed
export function handleRemoveWithdrawals(event: RemoveWithdrawals): void {
for (let i = 0; i < event.params.seasons.length; i++) {
updateClaimedWithdraw(event.params.account, event.params.token, event.params.seasons[i], event.block);
updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.seasons[i], event.block);
}
}
19 changes: 10 additions & 9 deletions projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts";
import { loadSilo, loadSiloAsset, loadSiloWithdraw } from "../../entities/Silo";
import { takeSiloAssetSnapshots } from "../../entities/snapshots/SiloAsset";
import { loadSilo, loadSiloWithdraw } from "../../entities/Silo";
import { loadBeanstalk } from "../../entities/Beanstalk";
import { updateStalkBalances } from "../Silo";
import { addWithdrawToSiloAsset, updateStalkBalances } from "../Silo";
import { Replanted } from "../../../generated/Beanstalk-ABIs/Replanted";
import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants";
import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals";
import { toAddress } from "../../../../subgraph-core/utils/Bytes";
import { takeSiloSnapshots } from "../../entities/snapshots/Silo";
import { PrevFarmerGerminatingEvent } from "../../../generated/schema";

export function updateClaimedWithdraw(account: Address, token: Address, withdrawSeason: BigInt, block: ethereum.Block): void {
export function updateClaimedWithdraw(
protocol: Address,
account: Address,
token: Address,
withdrawSeason: BigInt,
block: ethereum.Block
): void {
let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32());
withdraw.claimed = true;
withdraw.save();

let asset = loadSiloAsset(account, token);
asset.withdrawnAmount = asset.withdrawnAmount.minus(withdraw.amount);
takeSiloAssetSnapshots(asset, block);
asset.save();
addWithdrawToSiloAsset(protocol, account, token, withdraw.amount.neg(), block);
}

// Replanted -> SiloV3
Expand Down

0 comments on commit fd03aa6

Please sign in to comment.