diff --git a/package.json b/package.json index 1b02a19e..7b6e7c4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aperture_finance/uniswap-v3-automation-sdk", - "version": "3.10.3", + "version": "3.10.4", "description": "SDK for Aperture's CLMM automation platform", "author": "Aperture Finance ", "license": "MIT", diff --git a/src/viem/pool/getSlipStreamPools.ts b/src/viem/pool/getSlipStreamPools.ts index d936395e..9594bfab 100644 --- a/src/viem/pool/getSlipStreamPools.ts +++ b/src/viem/pool/getSlipStreamPools.ts @@ -10,6 +10,7 @@ export type SlipStreamPool = { token1: Address; fee: number; tickSpacing: number; + gaugeAddress: Address; }; export async function getSlipStreamPools( @@ -59,6 +60,25 @@ export async function getSlipStreamPools( }) ).map(({ result }) => result!); + const gaugeAddresses = ( + await publicClient.multicall({ + contracts: poolAddresses.map((address) => ({ + address, + abi: [ + { + inputs: [], + name: 'gauge', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + ] as const, + functionName: 'gauge', + ...opt, + })), + }) + ).map(({ result }) => result!); + const getPoolKeys = (address: Address) => { const poolOpt = { address, @@ -91,6 +111,7 @@ export async function getSlipStreamPools( token1, fee, tickSpacing, + gaugeAddress: gaugeAddresses[i], }); } diff --git a/src/viem/position/getSlipStreamStakePositions.ts b/src/viem/position/getSlipStreamStakePositions.ts index 8308d9ba..d566dae9 100644 --- a/src/viem/position/getSlipStreamStakePositions.ts +++ b/src/viem/position/getSlipStreamStakePositions.ts @@ -2,35 +2,22 @@ import { Address, PublicClient } from 'viem'; import { getSlipStreamPools } from '../pool'; +export type SlipStreamPosition = { + address: Address; + gaugeAddress: Address; +}; + export async function getSlipStreamStakePositions( owner: Address, publicClient: PublicClient, blockNumber?: bigint, ) { const pools = await getSlipStreamPools(publicClient, blockNumber); + const gaugeAddresses = pools.map((pool) => pool.gaugeAddress); const opt = { blockNumber, }; - const gaugeAddresses = ( - await publicClient.multicall({ - contracts: pools.map((pool) => ({ - address: pool.address, - abi: [ - { - inputs: [], - name: 'gauge', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', - }, - ] as const, - functionName: 'gauge', - ...opt, - })), - }) - ).map(({ result }) => result!); - const stakedPositions = ( await publicClient.multicall({ contracts: gaugeAddresses.map((address) => ({ @@ -55,11 +42,8 @@ export async function getSlipStreamStakePositions( }) ).map(({ result }) => result! ?? []); - const result: Map = new Map(); - stakedPositions.map((positionList, index) => - positionList.forEach((position) => - result.set(position, gaugeAddresses[index]), - ), + return stakedPositions.reduce( + (accumulator, value) => accumulator.concat(value), + [], ); - return result; } diff --git a/test/hardhat/hardhat.test.ts b/test/hardhat/hardhat.test.ts index 9efe5855..0a54f6c9 100644 --- a/test/hardhat/hardhat.test.ts +++ b/test/hardhat/hardhat.test.ts @@ -870,11 +870,7 @@ describe('Stake position tests', function () { client, blockNumber, ); - expect(stakedPositions.size).to.be.equal(1); - expect(stakedPositions.keys().next().value).to.be.equal(436963n); - expect(stakedPositions.values().next().value).to.be.equal( - '0xF33a96b5932D9E9B9A0eDA447AbD8C9d48d2e0c8', - ); + expect(stakedPositions.length).to.be.equal(1); }); });