Skip to content

Commit

Permalink
Fix contract functions (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
silochad authored Jun 27, 2023
2 parents 6399704 + f52ca0d commit 6e1bd3d
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 96 deletions.
10 changes: 9 additions & 1 deletion projects/sdk/src/lib/farm/actions/ClaimWithdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { BasicPreparedResult, RunContext, Step, StepClass } from "src/classes/Workflow";
import { BasicPreparedResult, RunContext, StepClass } from "src/classes/Workflow";
import { ethers } from "ethers";
import { FarmToMode } from "../types";

/**
* @deprecated The `claimWithdrawal` contract function was removed from regular
* usage in the Silo V3 upgrade to Beanstalk. The function remains on a legacy
* facet for backwards compatibility, but it's only use is to claim withdrawals
* that were initiated before the upgrade.
*
* See: contracts/beanstalk/silo/SiloFacet/LegacyClaimWithdrawalFacet.sol
*/
export class ClaimWithdrawal extends StepClass<BasicPreparedResult> {
public name: string = "claimWithdrawal";

Expand Down
8 changes: 8 additions & 0 deletions projects/sdk/src/lib/farm/actions/ClaimWithdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { BasicPreparedResult, RunContext, Step, StepClass } from "src/classes/Wo
import { ethers } from "ethers";
import { FarmToMode } from "../types";

/**
* @deprecated The `claimWithdrawals` contract function was removed from regular
* usage in the Silo V3 upgrade to Beanstalk. The function remains on a legacy
* facet for backwards compatibility, but it's only use is to claim withdrawals
* that were initiated before the upgrade.
*
* See: contracts/beanstalk/silo/SiloFacet/LegacyClaimWithdrawalFacet.sol
*/
export class ClaimWithdrawals extends StepClass<BasicPreparedResult> {
public name: string = "claimWithdrawals";

Expand Down
21 changes: 12 additions & 9 deletions projects/sdk/src/lib/farm/actions/WithdrawDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
import { BasicPreparedResult, RunContext, Step, StepClass } from "src/classes/Workflow";
import { ethers } from "ethers";
import { FarmToMode } from "src/lib/farm/types";

export class WithdrawDeposit extends StepClass<BasicPreparedResult> {
public name: string = "withdrawDeposit";

constructor(
public readonly _tokenIn: string,
public readonly _season: ethers.BigNumberish,
public readonly _amount: ethers.BigNumberish
public readonly _stem: ethers.BigNumberish,
public readonly _amount: ethers.BigNumberish,
public readonly _toMode: FarmToMode = FarmToMode.INTERNAL
) {
super();
}

async run(_amountInStep: ethers.BigNumber, context: RunContext) {
WithdrawDeposit.sdk.debug(`[${this.name}.run()]`, {
tokenIn: this._tokenIn,
seasons: this._season,
amounts: this._amount
stem: this._stem,
amount: this._amount
});
return {
name: this.name,
amountOut: _amountInStep,
prepare: () => {
WithdrawDeposit.sdk.debug(`[${this.name}.encode()]`, {
tokenIn: this._tokenIn,
seasons: this._season,
amounts: this._amount
stem: this._stem,
amount: this._amount
});
return {
target: WithdrawDeposit.sdk.contracts.beanstalk.address,
callData: WithdrawDeposit.sdk.contracts.beanstalk.interface.encodeFunctionData("withdrawDeposit", [
this._tokenIn, //
this._season, //
this._amount //
this._tokenIn,
this._stem,
this._amount,
this._toMode
])
};
},
Expand Down
17 changes: 10 additions & 7 deletions projects/sdk/src/lib/farm/actions/WithdrawDeposits.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { BasicPreparedResult, RunContext, Step, StepClass } from "src/classes/Workflow";
import { ethers } from "ethers";
import { FarmToMode } from "src/lib/farm/types";

export class WithdrawDeposits extends StepClass<BasicPreparedResult> {
public name: string = "withdrawDeposits";

constructor(
public readonly _tokenIn: string,
public readonly _seasons: ethers.BigNumberish[],
public readonly _amounts: ethers.BigNumberish[]
public readonly _stems: ethers.BigNumberish[],
public readonly _amounts: ethers.BigNumberish[],
public readonly _toMode: FarmToMode = FarmToMode.INTERNAL
) {
super();
}

async run(_amountInStep: ethers.BigNumber, context: RunContext) {
WithdrawDeposits.sdk.debug(`[${this.name}.run()]`, {
tokenIn: this._tokenIn,
seasons: this._seasons,
stems: this._stems,
amounts: this._amounts
});
return {
Expand All @@ -24,15 +26,16 @@ export class WithdrawDeposits extends StepClass<BasicPreparedResult> {
prepare: () => {
WithdrawDeposits.sdk.debug(`[${this.name}.encode()]`, {
tokenIn: this._tokenIn,
seasons: this._seasons,
stems: this._stems,
amounts: this._amounts
});
return {
target: WithdrawDeposits.sdk.contracts.beanstalk.address,
callData: WithdrawDeposits.sdk.contracts.beanstalk.interface.encodeFunctionData("withdrawDeposits", [
this._tokenIn, //
this._seasons, //
this._amounts //
this._tokenIn,
this._stems,
this._amounts,
this._toMode
])
};
},
Expand Down
57 changes: 35 additions & 22 deletions projects/sdk/src/lib/farm/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
import { AddLiquidity } from "./AddLiquidity";
import { ApproveERC20 } from "./ApproveERC20";
import { ClaimWithdrawals } from "./ClaimWithdrawals";
import { Deposit } from "./Deposit";
import { DevDebug } from "./_DevDebug";
import { Exchange } from "./Exchange";
import { ExchangeUnderlying } from "./ExchangeUnderlying";
import { PermitERC20 } from "./PermitERC20";
import { RemoveLiquidityOneToken } from "./RemoveLiquidityOneToken";
import { TransferToken } from "./TransferToken";
import { WrapEth } from "./WrapEth";
import { UnwrapEth } from "./UnwrapEth";
import { WellSwap } from "./WellSwap";
import { WellShift } from "./WellShift";
import { TransferToken } from "./TransferToken";
import { Deposit } from "./Deposit";
import { WithdrawDeposits } from "./WithdrawDeposits";
import { WithdrawDeposit } from "./WithdrawDeposit";
import { ClaimWithdrawals } from "./ClaimWithdrawals";
import { ClaimWithdrawal } from "./ClaimWithdrawal";
import { TransferDeposits } from "./TransferDeposits";
import { TransferDeposit } from "./TransferDeposit";
import { WrapEth } from "./WrapEth";
import { AddLiquidity } from "./AddLiquidity";
import { Exchange } from "./Exchange";
import { ExchangeUnderlying } from "./ExchangeUnderlying";
import { RemoveLiquidityOneToken } from "./RemoveLiquidityOneToken";
import { WellSwap } from "./WellSwap";
import { WellShift } from "./WellShift";
import { DevDebug } from "./_DevDebug";

export {
AddLiquidity,
// Approvals
ApproveERC20,
ClaimWithdrawals,
Deposit,
DevDebug,
Exchange,
ExchangeUnderlying,
PermitERC20,
RemoveLiquidityOneToken,
TransferToken,

// Wrappers
WrapEth,
UnwrapEth,
WellSwap,
WellShift,

// Beanstalk: Internal balances
TransferToken,

// Beanstalk: Silo
Deposit,
WithdrawDeposits,
WithdrawDeposit,
ClaimWithdrawals,
ClaimWithdrawal,
TransferDeposits,
TransferDeposit,
WrapEth

// DEX: Curve
AddLiquidity,
Exchange,
ExchangeUnderlying,
RemoveLiquidityOneToken,

// DEX: Wells
WellSwap,
WellShift,

// Developers
DevDebug
};
Loading

0 comments on commit 6e1bd3d

Please sign in to comment.