From fb670a170bb2af3acc6bf7d35b92b4027fd0b060 Mon Sep 17 00:00:00 2001 From: KedziaPawel <67273035+KedziaPawel@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:11:24 +0200 Subject: [PATCH] feat: get idle speeds (#124) --- packages/sdk/src/index.ts | 3 +++ packages/sdk/src/reads/getIdleSpeeds.ts | 26 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 packages/sdk/src/reads/getIdleSpeeds.ts diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index aea1175c..d98f81a6 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -312,6 +312,9 @@ export { getGrossAssetValueInAsset } from "./reads/getGrossAssetValueInAsset.js" // ./reads/getIdleRate.js export { getIdleRate } from "./reads/getIdleRate.js"; +// ./reads/getIdleSpeeds.js +export { getIdleSpeeds } from "./reads/getIdleSpeeds.js"; + // ./reads/getLabelForPositionType.js export { getLabelForExternalPositionType } from "./reads/getLabelForPositionType.js"; diff --git a/packages/sdk/src/reads/getIdleSpeeds.ts b/packages/sdk/src/reads/getIdleSpeeds.ts new file mode 100644 index 00000000..65013ddd --- /dev/null +++ b/packages/sdk/src/reads/getIdleSpeeds.ts @@ -0,0 +1,26 @@ +import { type ReadContractParameters, readContractParameters } from "../utils/viem.js"; +import type { Address, PublicClient } from "viem"; + +const abi = { + inputs: [{ internalType: "address", name: "", type: "address" }], + name: "idleSpeeds", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", +} as const; + +export function getIdleSpeeds( + client: PublicClient, + args: ReadContractParameters<{ + idleController: Address; + idlePool: Address; + }>, +) { + return client.readContract({ + ...readContractParameters(args), + abi: [abi], + functionName: "idleSpeeds", + address: args.idleController, + args: [args.idlePool], + }); +}