diff --git a/.changeset/cuddly-terms-rhyme.md b/.changeset/cuddly-terms-rhyme.md new file mode 100644 index 00000000..109637d7 --- /dev/null +++ b/.changeset/cuddly-terms-rhyme.md @@ -0,0 +1,5 @@ +--- +"@enzymefinance/sdk": patch +--- + +Add external calls for Balancer diff --git a/packages/sdk/src/internal/External/BalancerV2.ts b/packages/sdk/src/internal/External/BalancerV2.ts index 727c2efe..50425dad 100644 --- a/packages/sdk/src/internal/External/BalancerV2.ts +++ b/packages/sdk/src/internal/External/BalancerV2.ts @@ -1,24 +1,39 @@ import { Viem } from "@enzymefinance/sdk/Utils"; import { type Address, type PublicClient } from "viem"; -const mintAbi = { - inputs: [{ internalType: "address", name: "gauge", type: "address" }], - name: "mint", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", -} as const; +const minterAbi = [ + { + inputs: [{ internalType: "address", name: "gauge", type: "address" }], + name: "mint", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +const gaugeAbi = [ + { + inputs: [ + { internalType: "address", name: "user", type: "address" }, + { internalType: "address", name: "rewardToken", type: "address" }, + ], + name: "claimable_reward", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, +] as const; export async function getMinterRewards( client: PublicClient, args: Viem.ContractCallParameters<{ + minter: Address; beneficiary: Address; gauge: Address; - minter: Address; }>, ) { const { result } = await Viem.simulateContract(client, args, { - abi: [mintAbi], + abi: minterAbi, functionName: "mint", address: args.minter, args: [args.gauge], @@ -27,3 +42,19 @@ export async function getMinterRewards( return result; } + +export async function getClaimableRewards( + client: PublicClient, + args: Viem.ContractCallParameters<{ + gauge: Address; + user: Address; + rewardToken: Address; + }>, +) { + return Viem.readContract(client, args, { + abi: gaugeAbi, + functionName: "claimable_reward", + address: args.gauge, + args: [args.user, args.rewardToken], + }); +}