Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beanstalk3-ui-sdks' into reseed-…
Browse files Browse the repository at this point in the history
…testnet-deployment
  • Loading branch information
Brean0 committed Sep 20, 2024
2 parents b9d231c + c753aeb commit 6a8c6a8
Show file tree
Hide file tree
Showing 31 changed files with 3,719 additions and 1,828 deletions.
6 changes: 6 additions & 0 deletions projects/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ export type {
AdvancedPipeCallStruct as AdvancedPipeStruct
} from "src/lib/depot";

export type {
ZeroExQuoteParams,
ZeroExQuoteResponse,
ZeroExAPIRequestParams
} from "src/lib/matcha/types";

// Utilities
export * as TestUtils from "./utils/TestUtils";
4 changes: 4 additions & 0 deletions projects/sdk/src/lib/BeanstalkSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import defaultSettings from "src/defaultSettings.json";
import { WellsSDK } from "@beanstalk/sdk-wells";
import { ChainId, ChainResolver } from "@beanstalk/sdk-core";
import { Field } from "./field";
import { ZeroX } from "./matcha";

export type Provider = ethers.providers.JsonRpcProvider;
export type Signer = ethers.Signer;
Expand All @@ -28,6 +29,7 @@ export type BeanstalkConfig = Partial<{
subgraphUrl: string;
source: DataSource;
DEBUG: boolean;
zeroXApiKey?: string;
}>;

type Reconfigurable = Pick<BeanstalkConfig, "source">;
Expand Down Expand Up @@ -55,6 +57,7 @@ export class BeanstalkSDK {
public readonly pools: Pools;
public readonly graphql: GraphQLClient;
public readonly queries: Queries;
public readonly zeroX: ZeroX;

public readonly farm: Farm;
public readonly silo: Silo;
Expand Down Expand Up @@ -83,6 +86,7 @@ export class BeanstalkSDK {
this.pools = new Pools(this);
this.graphql = new GraphQLClient(this.subgraphUrl);
this.queries = getQueries(this.graphql);
this.zeroX = new ZeroX(config?.zeroXApiKey);

// // Internal
this.events = new EventManager(this);
Expand Down
64 changes: 64 additions & 0 deletions projects/sdk/src/lib/farm/actions/PipelineConvert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ethers } from "ethers";
import { BasicPreparedResult, RunContext, StepClass } from "src/classes/Workflow";
import { BeanstalkSDK } from "src/lib/BeanstalkSDK";
import { ERC20Token } from "src/classes/Token";
import { TokenValue } from "@beanstalk/sdk-core";
import { AdvancedPipeCallStruct } from "src/lib/depot";

export class PipelineConvert extends StepClass<BasicPreparedResult> {
static sdk: BeanstalkSDK;
public name: string = "pipeline-convert";

constructor(
private _tokenIn: ERC20Token,
public readonly _stems: ethers.BigNumberish[],
public readonly _amounts: ethers.BigNumberish[],
private _tokenOut: ERC20Token,
private _amountIn: TokenValue,
private _minAmountOut: TokenValue,
public readonly advancedPipeStructs: AdvancedPipeCallStruct[]
) {
super();
}

async run(_amountInStep: ethers.BigNumber, context: RunContext) {
return {
name: this.name,
amountOut: _amountInStep,
prepare: () => {
PipelineConvert.sdk.debug(`[${this.name}.encode()]`, {
tokenIn: this._tokenIn,
amounts: this._amounts,
stems: this._stems,
tokenOut: this._tokenOut,
amountIn: this._amountIn,
minAmountOut: this._minAmountOut,
advancedPipeStructs: this.advancedPipeStructs
});
return {
target: PipelineConvert.sdk.contracts.beanstalk.address,
callData: PipelineConvert.sdk.contracts.beanstalk.interface.encodeFunctionData(
"pipelineConvert",
[
this._tokenIn.address,
this._stems,
this._amounts,
this._tokenOut.address,
this.advancedPipeStructs
]
)
};
},
decode: (data: string) =>
PipelineConvert.sdk.contracts.beanstalk.interface.decodeFunctionData(
"pipelineConvert",
data
),
decodeResult: (result: string) =>
PipelineConvert.sdk.contracts.beanstalk.interface.decodeFunctionResult(
"pipelineConvert",
result
)
};
}
}
2 changes: 2 additions & 0 deletions projects/sdk/src/lib/farm/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { UniswapV3Swap } from "./UniswapV3Swap";
import { DevDebug } from "./_DevDebug";
import { LidoWrapSteth } from "./LidoWrapSteth";
import { LidoUnwrapWstETH } from "./LidoUnwrapWstETH";
import { PipelineConvert } from "./PipelineConvert";

export {
// Approvals
Expand All @@ -44,6 +45,7 @@ export {
ClaimWithdrawal,
TransferDeposits,
TransferDeposit,
PipelineConvert,

// Lido
LidoWrapSteth,
Expand Down
3 changes: 3 additions & 0 deletions projects/sdk/src/lib/matcha/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./types";

export { ZeroX } from "./zeroX";
Loading

0 comments on commit 6a8c6a8

Please sign in to comment.