Skip to content

Commit

Permalink
feat: add uniswap v3 get pool (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
KedziaPawel authored Jan 29, 2024
1 parent b85a6b1 commit 0f3a059
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-nails-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@enzymefinance/sdk": patch
---

Add uniswap v3 get pool
19 changes: 18 additions & 1 deletion packages/sdk/src/Portfolio/Integrations/UniswapV3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Address, type Hex, PublicClient, decodeAbiParameters, encodeAbiParameters } from "viem";
import { type Address, type Hex, PublicClient, decodeAbiParameters, encodeAbiParameters, parseAbi } from "viem";
import { Viem } from "../../Utils.js";
import * as ExternalPositionManager from "../../_internal/ExternalPositionManager.js";
import * as IntegrationManager from "../../_internal/IntegrationManager.js";
Expand Down Expand Up @@ -527,3 +527,20 @@ export async function getPendingFees(

return { pendingFees0, pendingFees1 };
}

export function getPool(
client: PublicClient,
args: Viem.ContractCallParameters<{
factory: Address;
tokenA: Address;
tokenB: Address;
fee: number;
}>,
) {
return Viem.readContract(client, args, {
abi: parseAbi(["function getPool(address,address,uint24) view returns (address)"]),
functionName: "getPool",
address: args.factory,
args: [args.tokenA, args.tokenB, args.fee],
});
}

0 comments on commit 0f3a059

Please sign in to comment.