@steerprotocol/sdk 1.30.4 → 1.30.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/const/amm/configs/ammConfig.js +33 -34
- package/dist/cjs/const/amm/configs/ammConfig.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/index.js +0 -39
- package/dist/cjs/const/amm/configs/protocols/index.js.map +1 -1
- package/dist/cjs/const/stabilityVaults/index.js +1 -1
- package/dist/cjs/const/stabilityVaults/index.js.map +1 -1
- package/dist/esm/base/FeeManagerClient.js +26 -22
- package/dist/esm/base/FeeManagerClient.js.map +1 -1
- package/dist/esm/base/PoolClient.js +19 -15
- package/dist/esm/base/PoolClient.js.map +1 -1
- package/dist/esm/base/SmartRewardClient.js +10 -6
- package/dist/esm/base/SmartRewardClient.js.map +1 -1
- package/dist/esm/base/SmartRewards.js +11 -7
- package/dist/esm/base/SmartRewards.js.map +1 -1
- package/dist/esm/base/StakingClient.js +18 -14
- package/dist/esm/base/StakingClient.js.map +1 -1
- package/dist/esm/base/SubgraphClient.js +8 -4
- package/dist/esm/base/SubgraphClient.js.map +1 -1
- package/dist/esm/base/VaultClient.js +55 -37
- package/dist/esm/base/VaultClient.js.map +1 -1
- package/dist/esm/base/vault/deposit/index.js +42 -38
- package/dist/esm/base/vault/deposit/index.js.map +1 -1
- package/dist/esm/base/vault/deposit/types.js +2 -1
- package/dist/esm/base/vault/single-asset/calculateLimitPrice.js +39 -32
- package/dist/esm/base/vault/single-asset/calculateLimitPrice.js.map +1 -1
- package/dist/esm/base/vault/single-asset/calculateSwapAmount.js +8 -5
- package/dist/esm/base/vault/single-asset/calculateSwapAmount.js.map +1 -1
- package/dist/esm/base/vault/single-asset/estimateLpTokens.js +12 -7
- package/dist/esm/base/vault/single-asset/estimateLpTokens.js.map +1 -1
- package/dist/esm/base/vault/single-asset/index.js +32 -6
- package/dist/esm/base/vault/single-asset/index.js.map +1 -1
- package/dist/esm/base/vault/single-asset/simulateSwap.js +30 -24
- package/dist/esm/base/vault/single-asset/simulateSwap.js.map +1 -1
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js +33 -29
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js.map +1 -1
- package/dist/esm/base/vault/single-asset/types.js +5 -2
- package/dist/esm/base/vault/single-asset/types.js.map +1 -1
- package/dist/esm/base/vault/utils.js +16 -7
- package/dist/esm/base/vault/utils.js.map +1 -1
- package/dist/esm/base/vault/withdraw/index.js +10 -6
- package/dist/esm/base/vault/withdraw/index.js.map +1 -1
- package/dist/esm/base/vault/withdraw/types.js +2 -1
- package/dist/esm/client.js +15 -11
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/const/abis/UniswapPool.js +4 -1
- package/dist/esm/const/abis/UniswapPool.js.map +1 -1
- package/dist/esm/const/abis/erc1155.js +4 -1
- package/dist/esm/const/abis/erc1155.js.map +1 -1
- package/dist/esm/const/abis/erc20.js +4 -1
- package/dist/esm/const/abis/erc20.js.map +1 -1
- package/dist/esm/const/abis/erc721.js +4 -1
- package/dist/esm/const/abis/erc721.js.map +1 -1
- package/dist/esm/const/abis/feeManager.js +4 -1
- package/dist/esm/const/abis/feeManager.js.map +1 -1
- package/dist/esm/const/abis/index.js +24 -8
- package/dist/esm/const/abis/index.js.map +1 -1
- package/dist/esm/const/abis/quoter.js +9 -6
- package/dist/esm/const/abis/quoter.js.map +1 -1
- package/dist/esm/const/abis/singleTokenDeposit.js +4 -1
- package/dist/esm/const/abis/singleTokenDeposit.js.map +1 -1
- package/dist/esm/const/abis/vaultFees.js +4 -1
- package/dist/esm/const/abis/vaultFees.js.map +1 -1
- package/dist/esm/const/amm/configs/ammConfig.js +98 -95
- package/dist/esm/const/amm/configs/ammConfig.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/aerodrome-v2.js +12 -8
- package/dist/esm/const/amm/configs/protocols/aerodrome-v2.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/aerodrome.js +12 -8
- package/dist/esm/const/amm/configs/protocols/aerodrome.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/arthswap.js +14 -10
- package/dist/esm/const/amm/configs/protocols/arthswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/baseswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/baseswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/basex.js +12 -8
- package/dist/esm/const/amm/configs/protocols/basex.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/beam.js +11 -7
- package/dist/esm/const/amm/configs/protocols/beam.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/beamswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/beamswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/blackhole.js +12 -8
- package/dist/esm/const/amm/configs/protocols/blackhole.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/camelot.js +17 -13
- package/dist/esm/const/amm/configs/protocols/camelot.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/crust.js +11 -7
- package/dist/esm/const/amm/configs/protocols/crust.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/cypher.js +13 -9
- package/dist/esm/const/amm/configs/protocols/cypher.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/dodo.js +11 -7
- package/dist/esm/const/amm/configs/protocols/dodo.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/dragonswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/dragonswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/eddy.js +11 -7
- package/dist/esm/const/amm/configs/protocols/eddy.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/equilibre.js +11 -7
- package/dist/esm/const/amm/configs/protocols/equilibre.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/fenix.js +11 -7
- package/dist/esm/const/amm/configs/protocols/fenix.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/forge.js +13 -9
- package/dist/esm/const/amm/configs/protocols/forge.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/fusionx.js +12 -8
- package/dist/esm/const/amm/configs/protocols/fusionx.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/glyph.js +13 -9
- package/dist/esm/const/amm/configs/protocols/glyph.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/henjin.js +11 -7
- package/dist/esm/const/amm/configs/protocols/henjin.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/hercules.js +11 -7
- package/dist/esm/const/amm/configs/protocols/hercules.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/horiza.js +13 -9
- package/dist/esm/const/amm/configs/protocols/horiza.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/index.js +56 -79
- package/dist/esm/const/amm/configs/protocols/index.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/katana.js +10 -6
- package/dist/esm/const/amm/configs/protocols/katana.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/katanaIntegral.js +10 -6
- package/dist/esm/const/amm/configs/protocols/katanaIntegral.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/kim.js +15 -11
- package/dist/esm/const/amm/configs/protocols/kim.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/kinetix.js +14 -10
- package/dist/esm/const/amm/configs/protocols/kinetix.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/kodiak.js +14 -10
- package/dist/esm/const/amm/configs/protocols/kodiak.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/kyo.js +12 -8
- package/dist/esm/const/amm/configs/protocols/kyo.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/linehub.js +11 -7
- package/dist/esm/const/amm/configs/protocols/linehub.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/lynex.js +13 -9
- package/dist/esm/const/amm/configs/protocols/lynex.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/machinex.js +13 -9
- package/dist/esm/const/amm/configs/protocols/machinex.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/maia.js +13 -9
- package/dist/esm/const/amm/configs/protocols/maia.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/metavault.js +16 -12
- package/dist/esm/const/amm/configs/protocols/metavault.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/nest.js +12 -8
- package/dist/esm/const/amm/configs/protocols/nest.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/novaswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/novaswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/ocelex.js +11 -7
- package/dist/esm/const/amm/configs/protocols/ocelex.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/pancakeswap.js +17 -13
- package/dist/esm/const/amm/configs/protocols/pancakeswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/poolshark.js +11 -7
- package/dist/esm/const/amm/configs/protocols/poolshark.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/quickswap-algebra.js +12 -8
- package/dist/esm/const/amm/configs/protocols/quickswap-algebra.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/quickswap-integral.js +17 -13
- package/dist/esm/const/amm/configs/protocols/quickswap-integral.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/quickswap-univ3.js +20 -16
- package/dist/esm/const/amm/configs/protocols/quickswap-univ3.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/quickswap.js +18 -14
- package/dist/esm/const/amm/configs/protocols/quickswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/retro.js +13 -9
- package/dist/esm/const/amm/configs/protocols/retro.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/sailor.js +11 -7
- package/dist/esm/const/amm/configs/protocols/sailor.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/shadow.js +13 -9
- package/dist/esm/const/amm/configs/protocols/shadow.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/silverswap.js +15 -11
- package/dist/esm/const/amm/configs/protocols/silverswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/spark-integral.js +12 -8
- package/dist/esm/const/amm/configs/protocols/spark-integral.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/spark.js +11 -7
- package/dist/esm/const/amm/configs/protocols/spark.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/spark32.js +11 -7
- package/dist/esm/const/amm/configs/protocols/spark32.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/spookyswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/spookyswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/stellaswap.js +13 -9
- package/dist/esm/const/amm/configs/protocols/stellaswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/supswap.js +11 -7
- package/dist/esm/const/amm/configs/protocols/supswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/sushi.js +73 -69
- package/dist/esm/const/amm/configs/protocols/sushi.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/swapmode.js +11 -7
- package/dist/esm/const/amm/configs/protocols/swapmode.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/swapsicle.js +11 -7
- package/dist/esm/const/amm/configs/protocols/swapsicle.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/thena.js +13 -9
- package/dist/esm/const/amm/configs/protocols/thena.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/thick.js +12 -8
- package/dist/esm/const/amm/configs/protocols/thick.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/thickv2.js +12 -8
- package/dist/esm/const/amm/configs/protocols/thickv2.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/thruster.js +12 -8
- package/dist/esm/const/amm/configs/protocols/thruster.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/uniswap.js +83 -79
- package/dist/esm/const/amm/configs/protocols/uniswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/wasabee.js +11 -7
- package/dist/esm/const/amm/configs/protocols/wasabee.js.map +1 -1
- package/dist/esm/const/amm/index.js +19 -3
- package/dist/esm/const/amm/index.js.map +1 -1
- package/dist/esm/const/amm/utils/beacon.js +76 -70
- package/dist/esm/const/amm/utils/beacon.js.map +1 -1
- package/dist/esm/const/amm/utils/contracts.js +26 -16
- package/dist/esm/const/amm/utils/contracts.js.map +1 -1
- package/dist/esm/const/amm/utils/index.js +46 -22
- package/dist/esm/const/amm/utils/index.js.map +1 -1
- package/dist/esm/const/amm/utils/protocol.js +24 -16
- package/dist/esm/const/amm/utils/protocol.js.map +1 -1
- package/dist/esm/const/api.js +7 -3
- package/dist/esm/const/api.js.map +1 -1
- package/dist/esm/const/capabilities.js +20 -15
- package/dist/esm/const/capabilities.js.map +1 -1
- package/dist/esm/const/chain.js +12 -9
- package/dist/esm/const/chain.js.map +1 -1
- package/dist/esm/const/deployments/abis.js +4 -1
- package/dist/esm/const/deployments/abis.js.map +1 -1
- package/dist/esm/const/deployments/apechain.js +4 -1
- package/dist/esm/const/deployments/apechain.js.map +1 -1
- package/dist/esm/const/deployments/arbitrum.js +4 -1
- package/dist/esm/const/deployments/arbitrum.js.map +1 -1
- package/dist/esm/const/deployments/arbitrumgoerli.js +4 -1
- package/dist/esm/const/deployments/arbitrumgoerli.js.map +1 -1
- package/dist/esm/const/deployments/astar.js +4 -1
- package/dist/esm/const/deployments/astar.js.map +1 -1
- package/dist/esm/const/deployments/astarzkevm.js +4 -1
- package/dist/esm/const/deployments/astarzkevm.js.map +1 -1
- package/dist/esm/const/deployments/avalanche.js +4 -1
- package/dist/esm/const/deployments/avalanche.js.map +1 -1
- package/dist/esm/const/deployments/bartiotest.js +4 -1
- package/dist/esm/const/deployments/bartiotest.js.map +1 -1
- package/dist/esm/const/deployments/base.js +4 -1
- package/dist/esm/const/deployments/base.js.map +1 -1
- package/dist/esm/const/deployments/bera.js +4 -1
- package/dist/esm/const/deployments/bera.js.map +1 -1
- package/dist/esm/const/deployments/berachainbartio.js +4 -1
- package/dist/esm/const/deployments/berachainbartio.js.map +1 -1
- package/dist/esm/const/deployments/blast.js +4 -1
- package/dist/esm/const/deployments/blast.js.map +1 -1
- package/dist/esm/const/deployments/bsc.js +4 -1
- package/dist/esm/const/deployments/bsc.js.map +1 -1
- package/dist/esm/const/deployments/celo.js +4 -1
- package/dist/esm/const/deployments/celo.js.map +1 -1
- package/dist/esm/const/deployments/core.js +4 -1
- package/dist/esm/const/deployments/core.js.map +1 -1
- package/dist/esm/const/deployments/eth.js +4 -1
- package/dist/esm/const/deployments/eth.js.map +1 -1
- package/dist/esm/const/deployments/evmos.js +4 -1
- package/dist/esm/const/deployments/evmos.js.map +1 -1
- package/dist/esm/const/deployments/fantom.js +4 -1
- package/dist/esm/const/deployments/fantom.js.map +1 -1
- package/dist/esm/const/deployments/filecoin.js +4 -1
- package/dist/esm/const/deployments/filecoin.js.map +1 -1
- package/dist/esm/const/deployments/flare.js +4 -1
- package/dist/esm/const/deployments/flare.js.map +1 -1
- package/dist/esm/const/deployments/goerli.js +4 -1
- package/dist/esm/const/deployments/goerli.js.map +1 -1
- package/dist/esm/const/deployments/hemi.js +4 -1
- package/dist/esm/const/deployments/hemi.js.map +1 -1
- package/dist/esm/const/deployments/hyperevm.js +4 -1
- package/dist/esm/const/deployments/hyperevm.js.map +1 -1
- package/dist/esm/const/deployments/index.js +99 -48
- package/dist/esm/const/deployments/index.js.map +1 -1
- package/dist/esm/const/deployments/katana.js +4 -1
- package/dist/esm/const/deployments/katana.js.map +1 -1
- package/dist/esm/const/deployments/kava.js +4 -1
- package/dist/esm/const/deployments/kava.js.map +1 -1
- package/dist/esm/const/deployments/linea.js +4 -1
- package/dist/esm/const/deployments/linea.js.map +1 -1
- package/dist/esm/const/deployments/localhost.js +4 -1
- package/dist/esm/const/deployments/localhost.js.map +1 -1
- package/dist/esm/const/deployments/manta.js +4 -1
- package/dist/esm/const/deployments/manta.js.map +1 -1
- package/dist/esm/const/deployments/mantle.js +4 -1
- package/dist/esm/const/deployments/mantle.js.map +1 -1
- package/dist/esm/const/deployments/metis.js +4 -1
- package/dist/esm/const/deployments/metis.js.map +1 -1
- package/dist/esm/const/deployments/mode.js +4 -1
- package/dist/esm/const/deployments/mode.js.map +1 -1
- package/dist/esm/const/deployments/moonbeam.js +4 -1
- package/dist/esm/const/deployments/moonbeam.js.map +1 -1
- package/dist/esm/const/deployments/mumbai.js +4 -1
- package/dist/esm/const/deployments/mumbai.js.map +1 -1
- package/dist/esm/const/deployments/nibiru.js +4 -1
- package/dist/esm/const/deployments/nibiru.js.map +1 -1
- package/dist/esm/const/deployments/okxtestnet.js +4 -1
- package/dist/esm/const/deployments/okxtestnet.js.map +1 -1
- package/dist/esm/const/deployments/optimism.js +4 -1
- package/dist/esm/const/deployments/optimism.js.map +1 -1
- package/dist/esm/const/deployments/optimismgoerli.js +4 -1
- package/dist/esm/const/deployments/optimismgoerli.js.map +1 -1
- package/dist/esm/const/deployments/peaq.js +4 -1
- package/dist/esm/const/deployments/peaq.js.map +1 -1
- package/dist/esm/const/deployments/polygon.js +4 -1
- package/dist/esm/const/deployments/polygon.js.map +1 -1
- package/dist/esm/const/deployments/polyzkevm.js +4 -1
- package/dist/esm/const/deployments/polyzkevm.js.map +1 -1
- package/dist/esm/const/deployments/pyzkevm.js +4 -1
- package/dist/esm/const/deployments/pyzkevm.js.map +1 -1
- package/dist/esm/const/deployments/ronin.js +4 -1
- package/dist/esm/const/deployments/ronin.js.map +1 -1
- package/dist/esm/const/deployments/rootstock.js +4 -1
- package/dist/esm/const/deployments/rootstock.js.map +1 -1
- package/dist/esm/const/deployments/saga.js +4 -1
- package/dist/esm/const/deployments/saga.js.map +1 -1
- package/dist/esm/const/deployments/scroll.js +4 -1
- package/dist/esm/const/deployments/scroll.js.map +1 -1
- package/dist/esm/const/deployments/sei.js +4 -1
- package/dist/esm/const/deployments/sei.js.map +1 -1
- package/dist/esm/const/deployments/soneium.js +4 -1
- package/dist/esm/const/deployments/soneium.js.map +1 -1
- package/dist/esm/const/deployments/sonic.js +4 -1
- package/dist/esm/const/deployments/sonic.js.map +1 -1
- package/dist/esm/const/deployments/taiko.js +4 -1
- package/dist/esm/const/deployments/taiko.js.map +1 -1
- package/dist/esm/const/deployments/tataratestnet.js +4 -1
- package/dist/esm/const/deployments/tataratestnet.js.map +1 -1
- package/dist/esm/const/deployments/telos.js +4 -1
- package/dist/esm/const/deployments/telos.js.map +1 -1
- package/dist/esm/const/deployments/thundercore.js +4 -1
- package/dist/esm/const/deployments/thundercore.js.map +1 -1
- package/dist/esm/const/deployments/uni.js +4 -1
- package/dist/esm/const/deployments/uni.js.map +1 -1
- package/dist/esm/const/deployments/xlayer.js +4 -1
- package/dist/esm/const/deployments/xlayer.js.map +1 -1
- package/dist/esm/const/deployments/zeta.js +4 -1
- package/dist/esm/const/deployments/zeta.js.map +1 -1
- package/dist/esm/const/deployments/zircuit.js +4 -1
- package/dist/esm/const/deployments/zircuit.js.map +1 -1
- package/dist/esm/const/deployments/zklinknova.js +4 -1
- package/dist/esm/const/deployments/zklinknova.js.map +1 -1
- package/dist/esm/const/index.js +28 -12
- package/dist/esm/const/index.js.map +1 -1
- package/dist/esm/const/network.js +232 -223
- package/dist/esm/const/network.js.map +1 -1
- package/dist/esm/const/protocol.js +97 -83
- package/dist/esm/const/protocol.js.map +1 -1
- package/dist/esm/const/quoter.js +53 -42
- package/dist/esm/const/quoter.js.map +1 -1
- package/dist/esm/const/stabilityVaults/index.js +17 -1
- package/dist/esm/const/stabilityVaults/index.js.map +1 -1
- package/dist/esm/const/stabilityVaults/stabilityVaultsConfig.js +15 -10
- package/dist/esm/const/stabilityVaults/stabilityVaultsConfig.js.map +1 -1
- package/dist/esm/const/subgraph.js +60 -56
- package/dist/esm/const/subgraph.js.map +1 -1
- package/dist/esm/const/thegraph.js +5 -1
- package/dist/esm/const/thegraph.js.map +1 -1
- package/dist/esm/index.js +31 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/scripts/processDeployments.js +15 -10
- package/dist/esm/scripts/processDeployments.js.map +1 -1
- package/dist/esm/types.js +2 -1
- package/dist/esm/utils/PoolQueryAdapter.js +44 -38
- package/dist/esm/utils/PoolQueryAdapter.js.map +1 -1
- package/dist/esm/utils/SubgraphVaultClient.js +10 -6
- package/dist/esm/utils/SubgraphVaultClient.js.map +1 -1
- package/dist/esm/utils/subgraph-types.js +2 -1
- package/dist/types/const/amm/configs/ammConfig.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/index.d.ts +0 -39
- package/dist/types/const/amm/configs/protocols/index.d.ts.map +1 -1
- package/dist/types/const/stabilityVaults/index.d.ts +1 -1
- package/dist/types/const/stabilityVaults/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/const/amm/configs/ammConfig.ts +2 -3
- package/src/const/amm/configs/protocols/index.ts +1 -40
- package/src/const/stabilityVaults/index.ts +1 -1
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SingleAssetDepositClient = void 0;
|
|
4
|
+
const index_js_1 = require("../../../const/index.js");
|
|
5
|
+
const singleTokenDeposit_js_1 = require("../../../const/abis/singleTokenDeposit.js");
|
|
6
|
+
const UniswapPool_js_1 = require("../../../const/abis/UniswapPool.js");
|
|
7
|
+
const calculateLimitPrice_js_1 = require("./calculateLimitPrice.js");
|
|
8
|
+
const calculateSwapAmount_js_1 = require("./calculateSwapAmount.js");
|
|
9
|
+
const estimateLpTokens_js_1 = require("./estimateLpTokens.js");
|
|
10
|
+
const simulateSwap_js_1 = require("./simulateSwap.js");
|
|
11
|
+
const types_js_1 = require("./types.js");
|
|
12
|
+
const abis_js_1 = require("../../../const/deployments/abis.js");
|
|
13
|
+
const PERIPHERY_ABI = abis_js_1.abis.SteerPeriphery;
|
|
11
14
|
/**
|
|
12
15
|
* Main single-asset deposit client that orchestrates all the steps
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
class SingleAssetDepositClient {
|
|
15
18
|
constructor(publicClient, walletClient) {
|
|
16
19
|
this.publicClient = publicClient;
|
|
17
20
|
this.walletClient = walletClient;
|
|
@@ -46,7 +49,7 @@ export class SingleAssetDepositClient {
|
|
|
46
49
|
async previewDeposit(params, poolAddress) {
|
|
47
50
|
try {
|
|
48
51
|
const chainId = await this.publicClient.getChainId();
|
|
49
|
-
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(chainId, 'SingleAssetDeposit');
|
|
52
|
+
const singleAssentDeposit = params.singleAssetDepositContract || (0, index_js_1.getContractAddressByChainIdAndContractName)(chainId, 'SingleAssetDeposit');
|
|
50
53
|
// Step 1: Calculate swap amount
|
|
51
54
|
const swapAmountParams = {
|
|
52
55
|
depositAmount: params.assets,
|
|
@@ -56,7 +59,7 @@ export class SingleAssetDepositClient {
|
|
|
56
59
|
ammType: params.ammType,
|
|
57
60
|
singleAssetDepositContract: singleAssentDeposit
|
|
58
61
|
};
|
|
59
|
-
const swapAmountResult = await calculateSwapAmount(this.publicClient, swapAmountParams);
|
|
62
|
+
const swapAmountResult = await (0, calculateSwapAmount_js_1.calculateSwapAmount)(this.publicClient, swapAmountParams);
|
|
60
63
|
if (!swapAmountResult.success || !swapAmountResult.data) {
|
|
61
64
|
return {
|
|
62
65
|
data: null,
|
|
@@ -66,17 +69,17 @@ export class SingleAssetDepositClient {
|
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
const { swapAmount, sqrtPrice } = swapAmountResult.data;
|
|
69
|
-
const zeroForOne = determineSwapDirection(params.isToken0);
|
|
72
|
+
const zeroForOne = (0, simulateSwap_js_1.determineSwapDirection)(params.isToken0);
|
|
70
73
|
// Get token addresses from the pool contract
|
|
71
74
|
const [token0, token1] = await Promise.all([
|
|
72
75
|
this.publicClient.readContract({
|
|
73
76
|
address: poolAddress,
|
|
74
|
-
abi: UniswapV3PoolABI,
|
|
77
|
+
abi: UniswapPool_js_1.UniswapV3PoolABI,
|
|
75
78
|
functionName: 'token0'
|
|
76
79
|
}),
|
|
77
80
|
this.publicClient.readContract({
|
|
78
81
|
address: poolAddress,
|
|
79
|
-
abi: UniswapV3PoolABI,
|
|
82
|
+
abi: UniswapPool_js_1.UniswapV3PoolABI,
|
|
80
83
|
functionName: 'token1'
|
|
81
84
|
})
|
|
82
85
|
]);
|
|
@@ -89,7 +92,7 @@ export class SingleAssetDepositClient {
|
|
|
89
92
|
token0,
|
|
90
93
|
token1
|
|
91
94
|
};
|
|
92
|
-
const limitPriceResult = await calculateLimitPrice(this.publicClient, limitPriceParams);
|
|
95
|
+
const limitPriceResult = await (0, calculateLimitPrice_js_1.calculateLimitPrice)(this.publicClient, limitPriceParams);
|
|
93
96
|
if (!limitPriceResult.success || limitPriceResult.data === null) {
|
|
94
97
|
return {
|
|
95
98
|
data: null,
|
|
@@ -100,16 +103,16 @@ export class SingleAssetDepositClient {
|
|
|
100
103
|
}
|
|
101
104
|
const sqrtPriceLimitX96 = limitPriceResult.data;
|
|
102
105
|
let fee = 3000;
|
|
103
|
-
if (params.ammType === AMMType.UniswapV3) {
|
|
106
|
+
if (params.ammType === types_js_1.AMMType.UniswapV3) {
|
|
104
107
|
fee = await this.publicClient.readContract({
|
|
105
108
|
address: poolAddress,
|
|
106
|
-
abi: UniswapV3PoolABI,
|
|
109
|
+
abi: UniswapPool_js_1.UniswapV3PoolABI,
|
|
107
110
|
functionName: 'fee'
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
113
|
// Get pool fee from the contract
|
|
111
114
|
let vaultDetails;
|
|
112
|
-
const steerPeripheryAddress = getContractAddressByChainIdAndContractName(chainId, 'SteerPeriphery');
|
|
115
|
+
const steerPeripheryAddress = (0, index_js_1.getContractAddressByChainIdAndContractName)(chainId, 'SteerPeriphery');
|
|
113
116
|
if (!steerPeripheryAddress)
|
|
114
117
|
throw new Error('SteerPeriphery address not found');
|
|
115
118
|
let protocol;
|
|
@@ -121,7 +124,7 @@ export class SingleAssetDepositClient {
|
|
|
121
124
|
functionName: 'vaultDetailsByAddress',
|
|
122
125
|
args: [params.vault]
|
|
123
126
|
});
|
|
124
|
-
protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);
|
|
127
|
+
protocol = (0, index_js_1.getProtocolTypeByBeacon)(vaultDetails.vaultType);
|
|
125
128
|
}
|
|
126
129
|
catch (error) {
|
|
127
130
|
// If regular vault fails, try Algebra vault
|
|
@@ -131,7 +134,7 @@ export class SingleAssetDepositClient {
|
|
|
131
134
|
functionName: 'algebraVaultDetailsByAddress',
|
|
132
135
|
args: [params.vault]
|
|
133
136
|
});
|
|
134
|
-
protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);
|
|
137
|
+
protocol = (0, index_js_1.getProtocolTypeByBeacon)(vaultDetails.vaultType);
|
|
135
138
|
}
|
|
136
139
|
// Step 3: Simulate swap
|
|
137
140
|
const simulateSwapParams = {
|
|
@@ -146,7 +149,7 @@ export class SingleAssetDepositClient {
|
|
|
146
149
|
fee,
|
|
147
150
|
protocol
|
|
148
151
|
};
|
|
149
|
-
const swapSimulationResult = await simulateSwapWithSlippage(this.publicClient, simulateSwapParams, this.publicClient.chain?.id || 1 // Use chain ID from public client, fallback to mainnet
|
|
152
|
+
const swapSimulationResult = await (0, simulateSwap_js_1.simulateSwapWithSlippage)(this.publicClient, simulateSwapParams, this.publicClient.chain?.id || 1 // Use chain ID from public client, fallback to mainnet
|
|
150
153
|
);
|
|
151
154
|
if (!swapSimulationResult.success || !swapSimulationResult.data) {
|
|
152
155
|
return {
|
|
@@ -158,7 +161,7 @@ export class SingleAssetDepositClient {
|
|
|
158
161
|
}
|
|
159
162
|
const swapSimulation = swapSimulationResult.data;
|
|
160
163
|
// Step 4: Estimate LP tokens
|
|
161
|
-
const lpEstimationResult = await estimateLpTokens(this.publicClient, {
|
|
164
|
+
const lpEstimationResult = await (0, estimateLpTokens_js_1.estimateLpTokens)(this.publicClient, {
|
|
162
165
|
vault: params.vault,
|
|
163
166
|
originalAssets: params.assets,
|
|
164
167
|
swapAmount,
|
|
@@ -226,11 +229,11 @@ export class SingleAssetDepositClient {
|
|
|
226
229
|
if (!account[0]) {
|
|
227
230
|
throw new Error('No account found');
|
|
228
231
|
}
|
|
229
|
-
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(this.publicClient.chain?.id || 1, 'SingleAssetDeposit');
|
|
232
|
+
const singleAssentDeposit = params.singleAssetDepositContract || (0, index_js_1.getContractAddressByChainIdAndContractName)(this.publicClient.chain?.id || 1, 'SingleAssetDeposit');
|
|
230
233
|
// Prepare the transaction
|
|
231
234
|
const { request } = await this.publicClient.simulateContract({
|
|
232
235
|
address: singleAssentDeposit,
|
|
233
|
-
abi: singleTokenDepositAbi,
|
|
236
|
+
abi: singleTokenDeposit_js_1.singleTokenDepositAbi,
|
|
234
237
|
functionName: 'deposit',
|
|
235
238
|
args: [
|
|
236
239
|
params.assets,
|
|
@@ -274,7 +277,7 @@ export class SingleAssetDepositClient {
|
|
|
274
277
|
throw new Error('No account found');
|
|
275
278
|
}
|
|
276
279
|
const chainId = await this.publicClient.getChainId();
|
|
277
|
-
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(chainId, 'SingleAssetDeposit');
|
|
280
|
+
const singleAssentDeposit = params.singleAssetDepositContract || (0, index_js_1.getContractAddressByChainIdAndContractName)(chainId, 'SingleAssetDeposit');
|
|
278
281
|
// await this.publicClient.simulateContract({
|
|
279
282
|
// address: singleAssentDeposit as Address,
|
|
280
283
|
// abi: singleTokenDepositAbi,
|
|
@@ -293,7 +296,7 @@ export class SingleAssetDepositClient {
|
|
|
293
296
|
return {
|
|
294
297
|
data: {
|
|
295
298
|
address: params.singleAssetDepositContract || singleAssentDeposit,
|
|
296
|
-
abi: singleTokenDepositAbi,
|
|
299
|
+
abi: singleTokenDeposit_js_1.singleTokenDepositAbi,
|
|
297
300
|
functionName: 'deposit',
|
|
298
301
|
args: [
|
|
299
302
|
params.assets,
|
|
@@ -343,9 +346,10 @@ export class SingleAssetDepositClient {
|
|
|
343
346
|
if (params.swapSlippageBP > 10000) {
|
|
344
347
|
throw new Error('Swap slippage BP cannot exceed 10000 (100%)');
|
|
345
348
|
}
|
|
346
|
-
if (!Object.values(AMMType).includes(params.ammType)) {
|
|
349
|
+
if (!Object.values(types_js_1.AMMType).includes(params.ammType)) {
|
|
347
350
|
throw new Error('Invalid AMM type');
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
353
|
}
|
|
354
|
+
exports.SingleAssetDepositClient = SingleAssetDepositClient;
|
|
351
355
|
//# sourceMappingURL=singleAssetDeposit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleAssetDeposit.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/singleAssetDeposit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0CAA0C,EAAE,uBAAuB,EAAY,MAAM,yBAAyB,CAAC;AACxH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAA0B,MAAM,mBAAmB,CAAC;AAO7G,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACnC,YACmB,YAA0B,EAC1B,YAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAA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AAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { Address, Hash, PublicClient, WalletClient } from 'viem';\nimport { getContractAddressByChainIdAndContractName, getProtocolTypeByBeacon, Protocol } from '../../../const/index.js';\nimport { singleTokenDepositAbi } from '../../../const/abis/singleTokenDeposit.js';\nimport { UniswapV3PoolABI } from '../../../const/abis/UniswapPool.js';\nimport { AlgebraVaultDetails, SteerResponse, VaultDetails } from '../../../types.js';\nimport { calculateLimitPrice } from './calculateLimitPrice.js';\nimport { calculateSwapAmount } from './calculateSwapAmount.js';\nimport { estimateLpTokens } from './estimateLpTokens.js';\nimport { determineSwapDirection, simulateSwapWithSlippage, SwapWithSlippageParams } from './simulateSwap.js';\nimport type {\n CalculateLimitPriceParams,\n CalculateSwapAmountParams,\n SingleAssetDepositParams,\n SingleAssetDepositPreview\n} from './types.js';\nimport { AMMType } from './types.js';\nimport { abis } from '../../../const/deployments/abis.js';\n\nconst PERIPHERY_ABI = abis.SteerPeriphery;\n\n/**\n * Main single-asset deposit client that orchestrates all the steps\n */\nexport class SingleAssetDepositClient {\n constructor(\n private readonly publicClient: PublicClient,\n private readonly walletClient: WalletClient\n ) {}\n\n /**\n * Previews a single-asset deposit by running all simulation steps\n * This allows users to see the expected outcome before executing the transaction\n * \n * @param params - Single-asset deposit parameters\n * @param poolAddress - Address of the pool (must be provided separately)\n * @returns Promise resolving to the complete deposit preview\n * \n * @example\n * ```typescript\n * const preview = await client.previewDeposit({\n * assets: parseEther('100'),\n * receiver: userAddress,\n * vault: vaultAddress,\n * isToken0: true,\n * depositSlippagePercent: 5n,\n * swapSlippageBP: 500,\n * ammType: AMMType.UniswapV3,\n * singleAssetDepositContract: contractAddress\n * }, poolAddress);\n * \n * if (preview.success) {\n * console.log('Expected LP tokens:', preview.data.lpEstimation.lpTokens);\n * console.log('Swap amount:', preview.data.swapAmount);\n * }\n * ```\n */\n public async previewDeposit(\n params: SingleAssetDepositParams,\n poolAddress: `0x${string}`\n ): Promise<SteerResponse<SingleAssetDepositPreview>> {\n try {\n\n const chainId = await this.publicClient.getChainId();\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n chainId,\n 'SingleAssetDeposit'\n )\n\n // Step 1: Calculate swap amount\n const swapAmountParams: CalculateSwapAmountParams = {\n depositAmount: params.assets,\n isToken0: params.isToken0,\n vault: params.vault,\n pool: poolAddress,\n ammType: params.ammType,\n singleAssetDepositContract: singleAssentDeposit as Address\n };\n\n\n const swapAmountResult = await calculateSwapAmount(this.publicClient, swapAmountParams);\n if (!swapAmountResult.success || !swapAmountResult.data) {\n return {\n data: null,\n status: swapAmountResult.status,\n success: false,\n error: swapAmountResult.error || 'Failed to calculate swap amount'\n };\n }\n\n const { swapAmount, sqrtPrice } = swapAmountResult.data;\n const zeroForOne = determineSwapDirection(params.isToken0);\n\n // Get token addresses from the pool contract\n const [token0, token1] = await Promise.all([\n this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'token0'\n }) as Promise<`0x${string}`>,\n this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'token1'\n }) as Promise<`0x${string}`>\n ]);\n\n // Step 2: Calculate limit price\n const limitPriceParams: CalculateLimitPriceParams = {\n pool: poolAddress,\n slippageBP: params.swapSlippageBP,\n zeroForOne,\n ammType: params.ammType,\n token0,\n token1\n };\n\n const limitPriceResult = await calculateLimitPrice(this.publicClient, limitPriceParams);\n if (!limitPriceResult.success || limitPriceResult.data === null) {\n return {\n data: null,\n status: limitPriceResult.status,\n success: false,\n error: limitPriceResult.error || 'Failed to calculate limit price'\n };\n }\n\n const sqrtPriceLimitX96 = limitPriceResult.data;\n\n let fee = 3000;\n if (params.ammType === AMMType.UniswapV3) {\n fee = await this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'fee'\n }) as number;\n }\n // Get pool fee from the contract\n\n let vaultDetails: VaultDetails | AlgebraVaultDetails;\n const steerPeripheryAddress = getContractAddressByChainIdAndContractName(chainId, 'SteerPeriphery');\n if (!steerPeripheryAddress) throw new Error('SteerPeriphery address not found');\n\n let protocol: Protocol | null;\n\n try {\n // First try regular vault\n vaultDetails = await this.publicClient.readContract({\n address: params.vault,\n abi: PERIPHERY_ABI,\n functionName: 'vaultDetailsByAddress',\n args: [params.vault]\n }) as VaultDetails;\n\n protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);\n } catch (error) {\n // If regular vault fails, try Algebra vault\n vaultDetails = await this.publicClient.readContract({\n address: steerPeripheryAddress as Address,\n abi: PERIPHERY_ABI,\n functionName: 'algebraVaultDetailsByAddress',\n args: [params.vault]\n }) as AlgebraVaultDetails;\n\n protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);\n }\n // Step 3: Simulate swap\n const simulateSwapParams: SwapWithSlippageParams = {\n poolAddress: poolAddress,\n recipient: params.receiver, // For simulation, use receiver address\n zeroForOne,\n amountSpecified: swapAmount,\n sqrtPriceLimitX96,\n ammType: params.ammType,\n tokenIn: zeroForOne ? token0 : token1,\n tokenOut: zeroForOne ? token1 : token0,\n fee,\n protocol\n };\n\n const swapSimulationResult = await simulateSwapWithSlippage(\n this.publicClient, \n simulateSwapParams, \n this.publicClient.chain?.id || 1 // Use chain ID from public client, fallback to mainnet\n );\n if (!swapSimulationResult.success || !swapSimulationResult.data) {\n return {\n data: null,\n status: swapSimulationResult.status,\n success: false,\n error: swapSimulationResult.error || 'Failed to simulate swap'\n };\n }\n\n const swapSimulation = swapSimulationResult.data;\n\n // Step 4: Estimate LP tokens\n const lpEstimationResult = await estimateLpTokens(this.publicClient, {\n vault: params.vault,\n originalAssets: params.assets,\n swapAmount,\n swapResult: swapSimulation.swapSimulation,\n isToken0: params.isToken0\n });\n\n if (!lpEstimationResult.success || !lpEstimationResult.data) {\n return {\n data: null,\n status: lpEstimationResult.status,\n success: false,\n error: lpEstimationResult.error || 'Failed to estimate LP tokens'\n };\n }\n\n const lpEstimation = lpEstimationResult.data;\n\n return {\n data: {\n swapAmount,\n currentSqrtPrice: sqrtPrice,\n sqrtPriceLimitX96,\n swapSimulation,\n lpEstimation,\n zeroForOne\n },\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to preview single-asset deposit'\n };\n }\n }\n\n /**\n * Executes a single-asset deposit transaction\n * \n * @param params - Single-asset deposit parameters\n * @returns Promise resolving to the transaction hash\n * \n * @example\n * ```typescript\n * const result = await client.deposit({\n * assets: parseEther('100'),\n * receiver: userAddress,\n * vault: vaultAddress,\n * isToken0: true,\n * depositSlippagePercent: 5n,\n * swapSlippageBP: 500,\n * ammType: AMMType.UniswapV3,\n * singleAssetDepositContract: contractAddress\n * });\n * \n * if (result.success) {\n * console.log('Transaction hash:', result.data);\n * }\n * ```\n */\n public async deposit(params: SingleAssetDepositParams): Promise<SteerResponse<Hash>> {\n try {\n const account = await this.walletClient.getAddresses();\n if (!account[0]) {\n throw new Error('No account found');\n }\n\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n this.publicClient.chain?.id || 1,\n 'SingleAssetDeposit'\n )\n\n // Prepare the transaction\n const { request } = await this.publicClient.simulateContract({\n address: singleAssentDeposit as Address,\n abi: singleTokenDepositAbi,\n functionName: 'deposit',\n args: [\n params.assets,\n params.receiver,\n params.vault,\n params.isToken0,\n params.depositSlippagePercent,\n params.swapSlippageBP,\n params.ammType\n ],\n account: account[0]\n });\n\n // Execute the transaction\n const hash = await this.walletClient.writeContract(request);\n\n return {\n data: hash,\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to execute single-asset deposit'\n };\n }\n }\n\n /**\n * Prepares a single-asset deposit transaction without executing it\n * Useful for batching transactions or custom execution logic\n * \n * @param params - Single-asset deposit parameters\n * @returns Promise resolving to the prepared transaction data\n */\n public async prepareDepositTx(params: SingleAssetDepositParams) {\n try {\n const account = await this.walletClient.getAddresses();\n if (!account[0]) {\n throw new Error('No account found');\n }\n\n const chainId = await this.publicClient.getChainId();\n\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n chainId,\n 'SingleAssetDeposit'\n )\n // await this.publicClient.simulateContract({\n // address: singleAssentDeposit as Address,\n // abi: singleTokenDepositAbi,\n // functionName: 'deposit',\n // args: [\n // params.assets,\n // params.receiver,\n // params.vault,\n // params.isToken0,\n // params.depositSlippagePercent,\n // params.swapSlippageBP,\n // params.ammType\n // ],\n // account: account[0]\n // });\n\n return {\n data: {\n address: params.singleAssetDepositContract || singleAssentDeposit,\n abi: singleTokenDepositAbi,\n functionName: 'deposit' as const,\n args: [\n params.assets,\n params.receiver,\n params.vault,\n params.isToken0,\n params.depositSlippagePercent,\n params.swapSlippageBP,\n params.ammType\n ] as const\n },\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to prepare single-asset deposit transaction'\n };\n }\n }\n\n /**\n * Validates single-asset deposit parameters\n * \n * @param params - Parameters to validate\n * @throws Error if parameters are invalid\n */\n public validateDepositParams(params: SingleAssetDepositParams): void {\n if (params.assets <= 0n) {\n throw new Error('Assets amount must be greater than 0');\n }\n\n if (!params.vault || params.vault === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid vault address');\n }\n\n if (!params.receiver || params.receiver === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid receiver address');\n }\n\n if (!params.singleAssetDepositContract || params.singleAssetDepositContract === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid single-asset deposit contract address');\n }\n\n if (params.depositSlippagePercent > 100n) {\n throw new Error('Deposit slippage percent cannot exceed 100%');\n }\n\n if (params.swapSlippageBP > 10000) {\n throw new Error('Swap slippage BP cannot exceed 10000 (100%)');\n }\n\n if (!Object.values(AMMType).includes(params.ammType)) {\n throw new Error('Invalid AMM type');\n }\n }\n} "]}
|
|
1
|
+
{"version":3,"file":"singleAssetDeposit.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/singleAssetDeposit.ts"],"names":[],"mappings":";;;AACA,sDAAwH;AACxH,qFAAkF;AAClF,uEAAsE;AAEtE,qEAA+D;AAC/D,qEAA+D;AAC/D,+DAAyD;AACzD,uDAA6G;AAO7G,yCAAqC;AACrC,gEAA0D;AAE1D,MAAM,aAAa,GAAG,cAAI,CAAC,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAa,wBAAwB;IACnC,YACmB,YAA0B,EAC1B,YAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,KAAK,CAAC,cAAc,CACzB,MAAgC,EAChC,WAA0B;QAE1B,IAAI,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;YACrD,MAAM,mBAAmB,GAAG,MAAM,CAAC,0BAA0B,IAAI,IAAA,qDAA0C,EACzG,OAAO,EACP,oBAAoB,CACrB,CAAA;YAED,gCAAgC;YAChC,MAAM,gBAAgB,GAA8B;gBAClD,aAAa,EAAE,MAAM,CAAC,MAAM;gBAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,0BAA0B,EAAE,mBAA8B;aAC3D,CAAC;YAGF,MAAM,gBAAgB,GAAG,MAAM,IAAA,4CAAmB,EAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,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AAK,KAAK,4CAA4C,EAAE,CAAC;YACnF,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,4CAA4C,EAAE,CAAC;YACzF,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,0BAA0B,IAAI,MAAM,CAAC,0BAA0B,KAAK,4CAA4C,EAAE,CAAC;YAC7H,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,MAAM,CAAC,sBAAsB,GAAG,IAAI,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,MAAM,CAAC,cAAc,GAAG,KAAK,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF;AAnYD,4DAmYC","sourcesContent":["import type { Address, Hash, PublicClient, WalletClient } from 'viem';\nimport { getContractAddressByChainIdAndContractName, getProtocolTypeByBeacon, Protocol } from '../../../const/index.js';\nimport { singleTokenDepositAbi } from '../../../const/abis/singleTokenDeposit.js';\nimport { UniswapV3PoolABI } from '../../../const/abis/UniswapPool.js';\nimport { AlgebraVaultDetails, SteerResponse, VaultDetails } from '../../../types.js';\nimport { calculateLimitPrice } from './calculateLimitPrice.js';\nimport { calculateSwapAmount } from './calculateSwapAmount.js';\nimport { estimateLpTokens } from './estimateLpTokens.js';\nimport { determineSwapDirection, simulateSwapWithSlippage, SwapWithSlippageParams } from './simulateSwap.js';\nimport type {\n CalculateLimitPriceParams,\n CalculateSwapAmountParams,\n SingleAssetDepositParams,\n SingleAssetDepositPreview\n} from './types.js';\nimport { AMMType } from './types.js';\nimport { abis } from '../../../const/deployments/abis.js';\n\nconst PERIPHERY_ABI = abis.SteerPeriphery;\n\n/**\n * Main single-asset deposit client that orchestrates all the steps\n */\nexport class SingleAssetDepositClient {\n constructor(\n private readonly publicClient: PublicClient,\n private readonly walletClient: WalletClient\n ) {}\n\n /**\n * Previews a single-asset deposit by running all simulation steps\n * This allows users to see the expected outcome before executing the transaction\n * \n * @param params - Single-asset deposit parameters\n * @param poolAddress - Address of the pool (must be provided separately)\n * @returns Promise resolving to the complete deposit preview\n * \n * @example\n * ```typescript\n * const preview = await client.previewDeposit({\n * assets: parseEther('100'),\n * receiver: userAddress,\n * vault: vaultAddress,\n * isToken0: true,\n * depositSlippagePercent: 5n,\n * swapSlippageBP: 500,\n * ammType: AMMType.UniswapV3,\n * singleAssetDepositContract: contractAddress\n * }, poolAddress);\n * \n * if (preview.success) {\n * console.log('Expected LP tokens:', preview.data.lpEstimation.lpTokens);\n * console.log('Swap amount:', preview.data.swapAmount);\n * }\n * ```\n */\n public async previewDeposit(\n params: SingleAssetDepositParams,\n poolAddress: `0x${string}`\n ): Promise<SteerResponse<SingleAssetDepositPreview>> {\n try {\n\n const chainId = await this.publicClient.getChainId();\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n chainId,\n 'SingleAssetDeposit'\n )\n\n // Step 1: Calculate swap amount\n const swapAmountParams: CalculateSwapAmountParams = {\n depositAmount: params.assets,\n isToken0: params.isToken0,\n vault: params.vault,\n pool: poolAddress,\n ammType: params.ammType,\n singleAssetDepositContract: singleAssentDeposit as Address\n };\n\n\n const swapAmountResult = await calculateSwapAmount(this.publicClient, swapAmountParams);\n if (!swapAmountResult.success || !swapAmountResult.data) {\n return {\n data: null,\n status: swapAmountResult.status,\n success: false,\n error: swapAmountResult.error || 'Failed to calculate swap amount'\n };\n }\n\n const { swapAmount, sqrtPrice } = swapAmountResult.data;\n const zeroForOne = determineSwapDirection(params.isToken0);\n\n // Get token addresses from the pool contract\n const [token0, token1] = await Promise.all([\n this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'token0'\n }) as Promise<`0x${string}`>,\n this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'token1'\n }) as Promise<`0x${string}`>\n ]);\n\n // Step 2: Calculate limit price\n const limitPriceParams: CalculateLimitPriceParams = {\n pool: poolAddress,\n slippageBP: params.swapSlippageBP,\n zeroForOne,\n ammType: params.ammType,\n token0,\n token1\n };\n\n const limitPriceResult = await calculateLimitPrice(this.publicClient, limitPriceParams);\n if (!limitPriceResult.success || limitPriceResult.data === null) {\n return {\n data: null,\n status: limitPriceResult.status,\n success: false,\n error: limitPriceResult.error || 'Failed to calculate limit price'\n };\n }\n\n const sqrtPriceLimitX96 = limitPriceResult.data;\n\n let fee = 3000;\n if (params.ammType === AMMType.UniswapV3) {\n fee = await this.publicClient.readContract({\n address: poolAddress,\n abi: UniswapV3PoolABI,\n functionName: 'fee'\n }) as number;\n }\n // Get pool fee from the contract\n\n let vaultDetails: VaultDetails | AlgebraVaultDetails;\n const steerPeripheryAddress = getContractAddressByChainIdAndContractName(chainId, 'SteerPeriphery');\n if (!steerPeripheryAddress) throw new Error('SteerPeriphery address not found');\n\n let protocol: Protocol | null;\n\n try {\n // First try regular vault\n vaultDetails = await this.publicClient.readContract({\n address: params.vault,\n abi: PERIPHERY_ABI,\n functionName: 'vaultDetailsByAddress',\n args: [params.vault]\n }) as VaultDetails;\n\n protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);\n } catch (error) {\n // If regular vault fails, try Algebra vault\n vaultDetails = await this.publicClient.readContract({\n address: steerPeripheryAddress as Address,\n abi: PERIPHERY_ABI,\n functionName: 'algebraVaultDetailsByAddress',\n args: [params.vault]\n }) as AlgebraVaultDetails;\n\n protocol = getProtocolTypeByBeacon(vaultDetails.vaultType);\n }\n // Step 3: Simulate swap\n const simulateSwapParams: SwapWithSlippageParams = {\n poolAddress: poolAddress,\n recipient: params.receiver, // For simulation, use receiver address\n zeroForOne,\n amountSpecified: swapAmount,\n sqrtPriceLimitX96,\n ammType: params.ammType,\n tokenIn: zeroForOne ? token0 : token1,\n tokenOut: zeroForOne ? token1 : token0,\n fee,\n protocol\n };\n\n const swapSimulationResult = await simulateSwapWithSlippage(\n this.publicClient, \n simulateSwapParams, \n this.publicClient.chain?.id || 1 // Use chain ID from public client, fallback to mainnet\n );\n if (!swapSimulationResult.success || !swapSimulationResult.data) {\n return {\n data: null,\n status: swapSimulationResult.status,\n success: false,\n error: swapSimulationResult.error || 'Failed to simulate swap'\n };\n }\n\n const swapSimulation = swapSimulationResult.data;\n\n // Step 4: Estimate LP tokens\n const lpEstimationResult = await estimateLpTokens(this.publicClient, {\n vault: params.vault,\n originalAssets: params.assets,\n swapAmount,\n swapResult: swapSimulation.swapSimulation,\n isToken0: params.isToken0\n });\n\n if (!lpEstimationResult.success || !lpEstimationResult.data) {\n return {\n data: null,\n status: lpEstimationResult.status,\n success: false,\n error: lpEstimationResult.error || 'Failed to estimate LP tokens'\n };\n }\n\n const lpEstimation = lpEstimationResult.data;\n\n return {\n data: {\n swapAmount,\n currentSqrtPrice: sqrtPrice,\n sqrtPriceLimitX96,\n swapSimulation,\n lpEstimation,\n zeroForOne\n },\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to preview single-asset deposit'\n };\n }\n }\n\n /**\n * Executes a single-asset deposit transaction\n * \n * @param params - Single-asset deposit parameters\n * @returns Promise resolving to the transaction hash\n * \n * @example\n * ```typescript\n * const result = await client.deposit({\n * assets: parseEther('100'),\n * receiver: userAddress,\n * vault: vaultAddress,\n * isToken0: true,\n * depositSlippagePercent: 5n,\n * swapSlippageBP: 500,\n * ammType: AMMType.UniswapV3,\n * singleAssetDepositContract: contractAddress\n * });\n * \n * if (result.success) {\n * console.log('Transaction hash:', result.data);\n * }\n * ```\n */\n public async deposit(params: SingleAssetDepositParams): Promise<SteerResponse<Hash>> {\n try {\n const account = await this.walletClient.getAddresses();\n if (!account[0]) {\n throw new Error('No account found');\n }\n\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n this.publicClient.chain?.id || 1,\n 'SingleAssetDeposit'\n )\n\n // Prepare the transaction\n const { request } = await this.publicClient.simulateContract({\n address: singleAssentDeposit as Address,\n abi: singleTokenDepositAbi,\n functionName: 'deposit',\n args: [\n params.assets,\n params.receiver,\n params.vault,\n params.isToken0,\n params.depositSlippagePercent,\n params.swapSlippageBP,\n params.ammType\n ],\n account: account[0]\n });\n\n // Execute the transaction\n const hash = await this.walletClient.writeContract(request);\n\n return {\n data: hash,\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to execute single-asset deposit'\n };\n }\n }\n\n /**\n * Prepares a single-asset deposit transaction without executing it\n * Useful for batching transactions or custom execution logic\n * \n * @param params - Single-asset deposit parameters\n * @returns Promise resolving to the prepared transaction data\n */\n public async prepareDepositTx(params: SingleAssetDepositParams) {\n try {\n const account = await this.walletClient.getAddresses();\n if (!account[0]) {\n throw new Error('No account found');\n }\n\n const chainId = await this.publicClient.getChainId();\n\n const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(\n chainId,\n 'SingleAssetDeposit'\n )\n // await this.publicClient.simulateContract({\n // address: singleAssentDeposit as Address,\n // abi: singleTokenDepositAbi,\n // functionName: 'deposit',\n // args: [\n // params.assets,\n // params.receiver,\n // params.vault,\n // params.isToken0,\n // params.depositSlippagePercent,\n // params.swapSlippageBP,\n // params.ammType\n // ],\n // account: account[0]\n // });\n\n return {\n data: {\n address: params.singleAssetDepositContract || singleAssentDeposit,\n abi: singleTokenDepositAbi,\n functionName: 'deposit' as const,\n args: [\n params.assets,\n params.receiver,\n params.vault,\n params.isToken0,\n params.depositSlippagePercent,\n params.swapSlippageBP,\n params.ammType\n ] as const\n },\n status: 200,\n success: true\n };\n\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to prepare single-asset deposit transaction'\n };\n }\n }\n\n /**\n * Validates single-asset deposit parameters\n * \n * @param params - Parameters to validate\n * @throws Error if parameters are invalid\n */\n public validateDepositParams(params: SingleAssetDepositParams): void {\n if (params.assets <= 0n) {\n throw new Error('Assets amount must be greater than 0');\n }\n\n if (!params.vault || params.vault === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid vault address');\n }\n\n if (!params.receiver || params.receiver === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid receiver address');\n }\n\n if (!params.singleAssetDepositContract || params.singleAssetDepositContract === '0x0000000000000000000000000000000000000000') {\n throw new Error('Invalid single-asset deposit contract address');\n }\n\n if (params.depositSlippagePercent > 100n) {\n throw new Error('Deposit slippage percent cannot exceed 100%');\n }\n\n if (params.swapSlippageBP > 10000) {\n throw new Error('Swap slippage BP cannot exceed 10000 (100%)');\n }\n\n if (!Object.values(AMMType).includes(params.ammType)) {\n throw new Error('Invalid AMM type');\n }\n }\n} "]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AMMType = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* AMM Types supported by single-asset deposits
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
var AMMType;
|
|
5
8
|
(function (AMMType) {
|
|
6
9
|
AMMType[AMMType["UniswapV3"] = 0] = "UniswapV3";
|
|
7
10
|
AMMType[AMMType["Algebra"] = 1] = "Algebra";
|
|
@@ -9,5 +12,5 @@ export var AMMType;
|
|
|
9
12
|
AMMType[AMMType["AlgebraVE33"] = 3] = "AlgebraVE33";
|
|
10
13
|
AMMType[AMMType["AlgebraIntegral"] = 4] = "AlgebraIntegral";
|
|
11
14
|
AMMType[AMMType["Aerodrome"] = 5] = "Aerodrome";
|
|
12
|
-
})(AMMType || (AMMType = {}));
|
|
15
|
+
})(AMMType || (exports.AMMType = AMMType = {}));
|
|
13
16
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/types.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,+CAAa,CAAA;IACb,2CAAW,CAAA;IACX,iEAAsB,CAAA;IACtB,mDAAe,CAAA;IACf,2DAAmB,CAAA;IACnB,+CAAa,CAAA;AAEf,CAAC,EARW,OAAO,uBAAP,OAAO,QAQlB","sourcesContent":["import type { Address } from 'viem';\nimport { SwapWithSlippageResponse } from './simulateSwap.js';\nimport { Protocol } from '../../../const/index.js';\n\n/**\n * AMM Types supported by single-asset deposits\n */\nexport enum AMMType {\n UniswapV3 = 0,\n Algebra = 1,\n AlgebraDirectional = 2,\n AlgebraVE33 = 3,\n AlgebraIntegral = 4,\n Aerodrome = 5\n \n}\n\n/**\n * Parameters for single-asset deposit\n */\nexport interface SingleAssetDepositParams {\n /** Amount of input token provided by the user */\n assets: bigint;\n /** Address to receive LP tokens */\n receiver: Address;\n /** Address of the vault to deposit into */\n vault: Address;\n /** true if input token is token0, false if token1 */\n isToken0: boolean;\n /** Maximum allowed slippage during deposit (in %) */\n depositSlippagePercent: bigint;\n /** Slippage tolerance for internal swap (in basis points) */\n swapSlippageBP: number;\n /** Type of AMM */\n ammType: AMMType;\n /** Address of the single-asset deposit contract */\n singleAssetDepositContract?: Address;\n}\n\n/**\n * Parameters for calculating swap amount\n */\nexport interface CalculateSwapAmountParams {\n /** Amount of tokens being deposited */\n depositAmount: bigint;\n /** true if depositing token0, false if token1 */\n isToken0: boolean;\n /** Address of the vault */\n vault: Address;\n /** Address of the pool */\n pool: Address;\n /** Type of AMM */\n ammType: AMMType;\n /** Address of the single-asset deposit contract */\n singleAssetDepositContract: Address;\n}\n\n/**\n * Response from calculateSwapAmount\n */\nexport interface SwapAmountResponse {\n /** Amount to be swapped from the input token */\n swapAmount: bigint;\n /** Current sqrt price (used for internal calculation) */\n sqrtPrice: bigint;\n}\n\n/**\n * Parameters for calculating sqrt price limit\n */\nexport interface CalculateLimitPriceParams {\n /** Address of the pool */\n pool: Address;\n /** Slippage tolerance in basis points */\n slippageBP: number;\n /** true if swapping token0 for token1, false otherwise */\n zeroForOne: boolean;\n /** Type of AMM */\n ammType: AMMType;\n /** Address of token0 */\n token0: Address;\n /** Address of token1 */\n token1: Address;\n}\n\n/**\n * Parameters for simulating a swap\n */\nexport interface SimulateSwapParams {\n /** Address of the pool */\n pool: Address;\n /** Address that will receive the swap output (or address(this) for simulation) */\n recipient: Address;\n /** true if swapping token0 → token1, else false */\n zeroForOne: boolean;\n /** Value from calculateSwapAmount */\n amountSpecified: bigint;\n /** Slippage-adjusted limit price */\n sqrtPriceLimitX96: bigint;\n /** AMM type */\n ammType: AMMType;\n /** Input token address (required for Quoter) */\n tokenIn: Address;\n /** Output token address (required for Quoter) */\n tokenOut: Address;\n /** Pool fee (required for Quoter) */\n fee: number;\n /** Quoter contract address (optional - will use default if not provided) */\n quoterAddress?: Address;\n /*** Tick spacing */\n tickSpacing: number;\n\n /** Protocol */\n protocol?: Protocol | null;\n}\n\n/**\n * Response from swap simulation\n */\nexport interface SwapSimulationResponse {\n /** Final token0 amount after swap */\n amount0: bigint;\n /** Final token1 amount after swap */\n amount1: bigint;\n\n sqrtPriceX96After: bigint\n}\n\n/**\n * Parameters for estimating LP tokens\n */\nexport interface EstimateLpTokensParams {\n /** Address of the vault */\n vault: Address;\n /** Original deposit amount */\n originalAssets: bigint;\n /** Amount that was swapped internally */\n swapAmount: bigint;\n /** Tokens received from the swap (amount0 and amount1) */\n swapResult: SwapSimulationResponse;\n /** true if original deposit was token0, false if token1 */\n isToken0: boolean;\n}\n\n/**\n * Response from LP token estimation\n */\nexport interface LpTokenEstimationResponse {\n /** Estimated amount of LP tokens to be received */\n lpTokens: bigint;\n /** Final amount of token0 that will be deposited */\n finalAmount0: bigint;\n /** Final amount of token1 that will be deposited */\n finalAmount1: bigint;\n}\n\n/**\n * Comprehensive single-asset deposit preview\n */\nexport interface SingleAssetDepositPreview {\n /** Amount to be swapped internally */\n swapAmount: bigint;\n /** Current sqrt price */\n currentSqrtPrice: bigint;\n /** Slippage-adjusted limit price for swap */\n sqrtPriceLimitX96: bigint;\n /** Simulated swap result */\n swapSimulation: SwapWithSlippageResponse;\n /** LP token estimation */\n lpEstimation: LpTokenEstimationResponse;\n /** Whether the swap direction is token0 → token1 */\n zeroForOne: boolean;\n}\n\n/**\n * Pool slot0 data structure for UniswapV3\n */\nexport interface PoolSlot0 {\n sqrtPriceX96: bigint;\n tick: number;\n observationIndex: number;\n observationCardinality: number;\n observationCardinalityNext: number;\n feeProtocol: number;\n unlocked: boolean;\n} "]}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSlot0 = getSlot0;
|
|
4
|
+
exports.getGlobalState = getGlobalState;
|
|
5
|
+
exports.getGlobalStatePoolShark = getGlobalStatePoolShark;
|
|
6
|
+
exports.getGlobalStateAlgebraIntegral = getGlobalStateAlgebraIntegral;
|
|
7
|
+
exports.getPoolState = getPoolState;
|
|
8
|
+
exports.getPoolPrice = getPoolPrice;
|
|
9
|
+
exports.getPoolStateWithPrice = getPoolStateWithPrice;
|
|
1
10
|
// const SLOT0_ABI: any = [
|
|
2
11
|
// {
|
|
3
12
|
// inputs: [],
|
|
@@ -158,7 +167,7 @@ const POOLSHARK_GLOBAL_STATE_ABI = [
|
|
|
158
167
|
* Gets slot0 data from a standard Uniswap V3 pool
|
|
159
168
|
* @param poolAddress The pool address
|
|
160
169
|
*/
|
|
161
|
-
|
|
170
|
+
async function getSlot0(publicClient, poolAddress) {
|
|
162
171
|
try {
|
|
163
172
|
const slot0 = await publicClient.readContract({
|
|
164
173
|
address: poolAddress,
|
|
@@ -209,7 +218,7 @@ export async function getSlot0(publicClient, poolAddress) {
|
|
|
209
218
|
* @param poolAddress The pool address
|
|
210
219
|
* @param isDirectional Whether the pool is directional
|
|
211
220
|
*/
|
|
212
|
-
|
|
221
|
+
async function getGlobalState(publicClient, poolAddress, isDirectional = false) {
|
|
213
222
|
try {
|
|
214
223
|
try {
|
|
215
224
|
const globalState = await publicClient.readContract({
|
|
@@ -265,7 +274,7 @@ export async function getGlobalState(publicClient, poolAddress, isDirectional =
|
|
|
265
274
|
* Gets global state from a PoolShark pool
|
|
266
275
|
* @param poolAddress The pool address
|
|
267
276
|
*/
|
|
268
|
-
|
|
277
|
+
async function getGlobalStatePoolShark(publicClient, poolAddress) {
|
|
269
278
|
try {
|
|
270
279
|
const globalState = await publicClient.readContract({
|
|
271
280
|
address: poolAddress,
|
|
@@ -327,7 +336,7 @@ export async function getGlobalStatePoolShark(publicClient, poolAddress) {
|
|
|
327
336
|
* @param poolAddress The pool address
|
|
328
337
|
* @param isDirectional Whether the pool is directional
|
|
329
338
|
*/
|
|
330
|
-
|
|
339
|
+
async function getGlobalStateAlgebraIntegral(publicClient, poolAddress, isDirectional = false) {
|
|
331
340
|
try {
|
|
332
341
|
try {
|
|
333
342
|
const globalState = await publicClient.readContract({
|
|
@@ -408,7 +417,7 @@ export async function getGlobalStateAlgebraIntegral(publicClient, poolAddress, i
|
|
|
408
417
|
* });
|
|
409
418
|
* ```
|
|
410
419
|
*/
|
|
411
|
-
|
|
420
|
+
async function getPoolState(publicClient, params) {
|
|
412
421
|
try {
|
|
413
422
|
let stateResponse;
|
|
414
423
|
// Handle different protocol types following the same logic as getPoolInstance
|
|
@@ -493,7 +502,7 @@ export async function getPoolState(publicClient, params) {
|
|
|
493
502
|
* }
|
|
494
503
|
* ```
|
|
495
504
|
*/
|
|
496
|
-
|
|
505
|
+
function getPoolPrice(poolStateData, params) {
|
|
497
506
|
try {
|
|
498
507
|
let price;
|
|
499
508
|
// Extract price based on AMM type - following the same logic as getPoolInstance
|
|
@@ -541,7 +550,7 @@ export function getPoolPrice(poolStateData, params) {
|
|
|
541
550
|
* }
|
|
542
551
|
* ```
|
|
543
552
|
*/
|
|
544
|
-
|
|
553
|
+
async function getPoolStateWithPrice(publicClient, params) {
|
|
545
554
|
try {
|
|
546
555
|
const stateResponse = await getPoolState(publicClient, params);
|
|
547
556
|
if (!stateResponse.success || !stateResponse.data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/base/vault/utils.ts"],"names":[],"mappings":"AAmBA,2BAA2B;AAC3B,MAAM;AACN,kBAAkB;AAClB,qBAAqB;AACrB,iBAAiB;AACjB,4EAA4E;AAC5E,gEAAgE;AAChE,8EAA8E;AAC9E,oFAAoF;AACpF,wFAAwF;AACxF,uEAAuE;AACvE,kEAAkE;AAClE,SAAS;AACT,+BAA+B;AAC/B,wBAAwB;AACxB,OAAO;AACP,cAAc;AAEd,MAAM,gBAAgB,GAAG;IACvB;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAC3D,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;YACtD,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE;YACrE,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,KAA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C,YAAY,CAAC;QACrC,CAAC;QAED,OAAO,KAAK,IAAI,IAAI,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,YAA0B,EAC1B,MAAuB;IAEvB,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;YAClD,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,aAAa,CAAC,KAAK,IAAI,0BAA0B;aACzD,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO;YACL,IAAI,EAAE;gBACJ,KAAK,EAAE,aAAa,CAAC,IAAI;gBACzB,KAAK;aACN;YACD,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC;SACtF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Address, PublicClient } from 'viem';\nimport { PoolSharkGlobalState, Slot0, SteerResponse } from '../../types.js';\n\n/**\n * Parameters for getting pool state across different AMM types\n */\nexport interface PoolStateParams {\n /** The pool address */\n poolAddress: Address;\n /** Whether the pool is an Algebra pool */\n isAlgebraPool?: boolean;\n /** Whether the pool is an Algebra directional pool */\n isAlgebraDirectionPool?: boolean;\n /** Whether the pool is a PoolShark pool */\n isPoolSharkPool?: boolean;\n /** Whether the pool is an Algebra Integral pool */\n isAlgebraIntegralPool?: boolean;\n}\n\n// const SLOT0_ABI: any = [\n// {\n// inputs: [],\n// name: 'slot0',\n// outputs: [\n// { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' },\n// { internalType: 'int24', name: 'tick', type: 'int24' },\n// { internalType: 'uint16', name: 'observationIndex', type: 'uint16' },\n// { internalType: 'uint16', name: 'observationCardinality', type: 'uint16' },\n// { internalType: 'uint16', name: 'observationCardinalityNext', type: 'uint16' },\n// { internalType: 'uint8', name: 'feeProtocol', type: 'uint8' },\n// { internalType: 'bool', name: 'unlocked', type: 'bool' },\n// ],\n// stateMutability: 'view',\n// type: 'function',\n// },\n// ] as const;\n\nconst GLOBAL_STATE_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'int24', name: 'prevInitializedTick', type: 'int24' },\n { internalType: 'uint16', name: 'fee', type: 'uint16' },\n { internalType: 'uint16', name: 'timepointIndex', type: 'uint16' },\n { internalType: 'uint8', name: 'communityFee', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst GLOBAL_STATE_ABI_INTEGRAL_V_1 = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n {\n internalType: 'uint160',\n name: 'price',\n type: 'uint160',\n },\n {\n internalType: 'int24',\n name: 'tick',\n type: 'int24',\n },\n {\n internalType: 'uint16',\n name: 'lastFee',\n type: 'uint16',\n },\n {\n internalType: 'uint8',\n name: 'pluginConfig',\n type: 'uint8',\n },\n {\n internalType: 'uint16',\n name: 'communityFee',\n type: 'uint16',\n },\n {\n internalType: 'bool',\n name: 'unlocked',\n type: 'bool',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst GLOBAL_STATE_DIRECTIONAL_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'uint16', name: 'feeZto', type: 'uint16' },\n { internalType: 'uint16', name: 'feeOtz', type: 'uint16' },\n { internalType: 'uint16', name: 'timepointIndex', type: 'uint16' },\n { internalType: 'uint8', name: 'communityFeeToken0', type: 'uint8' },\n { internalType: 'uint8', name: 'communityFeeToken1', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst POOLSHARK_GLOBAL_STATE_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n {\n components: [\n {\n components: [\n { internalType: 'uint16', name: 'index', type: 'uint16' },\n { internalType: 'uint16', name: 'count', type: 'uint16' },\n { internalType: 'uint16', name: 'countMax', type: 'uint16' },\n ],\n internalType: 'struct PoolsharkStructs.SampleState',\n name: 'samples',\n type: 'tuple',\n },\n { internalType: 'uint200', name: 'feeGrowthGlobal0', type: 'uint200' },\n { internalType: 'uint200', name: 'feeGrowthGlobal1', type: 'uint200' },\n { internalType: 'uint160', name: 'secondsPerLiquidityAccum', type: 'uint160' },\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'int56', name: 'tickSecondsAccum', type: 'int56' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n { internalType: 'uint16', name: 'protocolSwapFee0', type: 'uint16' },\n { internalType: 'uint16', name: 'protocolSwapFee1', type: 'uint16' },\n ],\n internalType: 'struct PoolsharkStructs.RangePoolState',\n name: 'pool',\n type: 'tuple',\n },\n {\n components: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'uint128', name: 'protocolFees', type: 'uint128' },\n { internalType: 'uint16', name: 'protocolFillFee', type: 'uint16' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n ],\n internalType: 'struct PoolsharkStructs.LimitPoolState',\n name: 'pool0',\n type: 'tuple',\n },\n {\n components: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'uint128', name: 'protocolFees', type: 'uint128' },\n { internalType: 'uint16', name: 'protocolFillFee', type: 'uint16' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n ],\n internalType: 'struct PoolsharkStructs.LimitPoolState',\n name: 'pool1',\n type: 'tuple',\n },\n { internalType: 'uint128', name: 'liquidityGlobal', type: 'uint128' },\n { internalType: 'uint32', name: 'positionIdNext', type: 'uint32' },\n { internalType: 'uint32', name: 'epoch', type: 'uint32' },\n { internalType: 'uint8', name: 'unlocked', type: 'uint8' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\n/**\n * Gets slot0 data from a standard Uniswap V3 pool\n * @param poolAddress The pool address\n */\nexport async function getSlot0(\n publicClient: PublicClient,\n poolAddress: Address\n): Promise<SteerResponse<Slot0>> {\n try {\n const slot0 = await publicClient.readContract({\n address: poolAddress,\n abi: [\n {\n inputs: [],\n name: 'slot0',\n outputs: [\n { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'uint16', name: 'observationIndex', type: 'uint16' },\n { internalType: 'uint16', name: 'observationCardinality', type: 'uint16' },\n { internalType: 'uint16', name: 'observationCardinalityNext', type: 'uint16' },\n { internalType: 'uint8', name: 'feeProtocol', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ],\n functionName: 'slot0',\n });\n\n return {\n data: {\n sqrtPriceX96: slot0[0],\n tick: Number(slot0[1]),\n observationIndex: slot0[2],\n observationCardinality: slot0[3],\n observationCardinalityNext: slot0[4],\n feeProtocol: slot0[5],\n unlocked: slot0[6],\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from an Algebra pool\n * @param poolAddress The pool address\n * @param isDirectional Whether the pool is directional\n */\nexport async function getGlobalState(\n publicClient: PublicClient,\n poolAddress: Address,\n isDirectional = false\n): Promise<SteerResponse<Slot0>> {\n try {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: isDirectional ? GLOBAL_STATE_DIRECTIONAL_ABI : GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: globalState[4], // timepointIndex\n observationCardinality: 0, // Not available in Algebra\n observationCardinalityNext: 0, // Not available in Algebra\n feeProtocol: isDirectional ? Number(globalState[2]) : Number(globalState[3]), // fee or feeZto\n unlocked: Boolean(globalState[isDirectional ? 7 : 6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: GLOBAL_STATE_ABI_INTEGRAL_V_1,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: false,\n },\n status: 200,\n success: true,\n };\n }\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from a PoolShark pool\n * @param poolAddress The pool address\n */\nexport async function getGlobalStatePoolShark(\n publicClient: PublicClient,\n poolAddress: Address\n): Promise<SteerResponse<PoolSharkGlobalState>> {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: POOLSHARK_GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n pool: {\n samples: {\n index: globalState[0].samples.index,\n count: globalState[0].samples.count,\n countMax: globalState[0].samples.countMax,\n },\n feeGrowthGlobal0: globalState[0].feeGrowthGlobal0,\n feeGrowthGlobal1: globalState[0].feeGrowthGlobal1,\n secondsPerLiquidityAccum: globalState[0].secondsPerLiquidityAccum,\n price: globalState[0].price,\n liquidity: globalState[0].liquidity,\n tickSecondsAccum: Number(globalState[0].tickSecondsAccum),\n tickAtPrice: globalState[0].tickAtPrice,\n protocolSwapFee0: globalState[0].protocolSwapFee0,\n protocolSwapFee1: globalState[0].protocolSwapFee1,\n },\n pool0: {\n price: globalState[1].price,\n liquidity: globalState[1].liquidity,\n protocolFees: globalState[1].protocolFees,\n protocolFillFee: globalState[1].protocolFillFee,\n tickAtPrice: globalState[1].tickAtPrice,\n },\n pool1: {\n price: globalState[2].price,\n liquidity: globalState[2].liquidity,\n protocolFees: globalState[2].protocolFees,\n protocolFillFee: globalState[2].protocolFillFee,\n tickAtPrice: globalState[2].tickAtPrice,\n },\n liquidityGlobal: globalState[3],\n positionIdNext: Number(globalState[4]),\n epoch: Number(globalState[5]),\n unlocked: Number(globalState[6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from an Algebra Integral pool\n * @param poolAddress The pool address\n * @param isDirectional Whether the pool is directional\n */\nexport async function getGlobalStateAlgebraIntegral(\n publicClient: PublicClient,\n poolAddress: Address,\n isDirectional = false\n): Promise<SteerResponse<Slot0>> {\n try {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: isDirectional ? GLOBAL_STATE_DIRECTIONAL_ABI : GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: globalState[4], // timepointIndex\n observationCardinality: 0, // Not available in Algebra Integral\n observationCardinalityNext: 0, // Not available in Algebra Integral\n feeProtocol: isDirectional ? Number(globalState[2]) : Number(globalState[3]), // fee or feeZto\n unlocked: Boolean(globalState[isDirectional ? 7 : 6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: GLOBAL_STATE_ABI_INTEGRAL_V_1,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: false,\n },\n status: 200,\n success: true,\n };\n }\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Unified method to get pool state across different AMM types\n * Automatically calls the correct function based on pool type parameters\n *\n * @param publicClient - The public client for blockchain reads\n * @param params - Parameters specifying the pool and its type\n * @returns Promise resolving to standardized pool state data\n *\n * @example\n * ```typescript\n * // For Uniswap V3 pool\n * const uniV3State = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * });\n *\n * // For Algebra pool\n * const algebraState = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true,\n * isAlgebraDirectionPool: false\n * });\n *\n * // For PoolShark pool\n * const poolSharkState = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isPoolSharkPool: true\n * });\n * ```\n */\nexport async function getPoolState(\n publicClient: PublicClient,\n params: PoolStateParams\n): Promise<SteerResponse<Slot0>> {\n try {\n let stateResponse: SteerResponse<Slot0 | PoolSharkGlobalState>;\n\n // Handle different protocol types following the same logic as getPoolInstance\n if (params.isAlgebraIntegralPool) {\n // For Algebra Integral pools\n stateResponse = await getGlobalStateAlgebraIntegral(\n publicClient,\n params.poolAddress,\n params.isAlgebraDirectionPool || false\n );\n } else if (params.isPoolSharkPool) {\n // For PoolShark pools - convert to standardized format\n const poolSharkResponse = await getGlobalStatePoolShark(publicClient, params.poolAddress);\n if (poolSharkResponse.success && poolSharkResponse.data) {\n stateResponse = {\n success: true,\n status: 200,\n data: {\n sqrtPriceX96: poolSharkResponse.data.pool.price,\n tick: poolSharkResponse.data.pool.tickAtPrice,\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: poolSharkResponse.data.unlocked === 1,\n },\n };\n } else {\n stateResponse = {\n data: null,\n status: poolSharkResponse.status,\n success: false,\n error: poolSharkResponse.error,\n };\n }\n } else if (params.isAlgebraPool) {\n // For Algebra pools\n stateResponse = await getGlobalState(\n publicClient,\n params.poolAddress,\n params.isAlgebraDirectionPool || false\n );\n } else {\n // For standard Uniswap V3 pools\n\n stateResponse = await getSlot0(publicClient, params.poolAddress);\n }\n\n if (!stateResponse.success || !stateResponse.data) {\n throw new Error(stateResponse.error || 'Failed to read pool state');\n }\n\n return {\n data: stateResponse.data as Slot0,\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to get pool state',\n };\n }\n}\n\n/**\n * Extracts the appropriate price value from pool state based on AMM type\n * Different AMM protocols store price information in different fields\n *\n * @param poolStateData - The pool state data returned from getPoolState\n * @param params - Pool type parameters to determine which price field to use\n * @returns The price as bigint, or null if price cannot be extracted\n *\n * @example\n * ```typescript\n * const stateResponse = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true\n * });\n *\n * if (stateResponse.success && stateResponse.data) {\n * const price = getPoolPrice(stateResponse.data, {\n * isAlgebraPool: true,\n * isAlgebraDirectionPool: false\n * });\n * console.log('Pool price:', price);\n * }\n * ```\n */\nexport function getPoolPrice(\n poolStateData: Slot0,\n params: Pick<PoolStateParams, 'isAlgebraPool' | 'isAlgebraIntegralPool' | 'isPoolSharkPool'>\n): bigint | null {\n try {\n let price: bigint | undefined;\n\n // Extract price based on AMM type - following the same logic as getPoolInstance\n if (params.isAlgebraPool && !params.isAlgebraIntegralPool) {\n // For Algebra pools (non-integral)\n price = poolStateData?.price;\n } else if (params.isAlgebraIntegralPool) {\n // For Algebra Integral pools\n price = poolStateData?.price;\n } else if (params.isPoolSharkPool) {\n // For PoolShark pools - price is stored in a nested structure\n price = (poolStateData.tick as unknown as { price: bigint })?.price;\n } else {\n // For standard Uniswap V3 pools\n price = poolStateData.sqrtPriceX96;\n }\n\n return price || null;\n } catch (error) {\n console.error('Error extracting pool price:', error);\n return null;\n }\n}\n\n/**\n * Combined method to get both pool state and extract price in one call\n * Convenience method that combines getPoolState and getPoolPrice\n *\n * @param publicClient - The public client for blockchain reads\n * @param params - Parameters specifying the pool and its type\n * @returns Promise resolving to object containing both state and price\n *\n * @example\n * ```typescript\n * const result = await getPoolStateWithPrice(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true\n * });\n *\n * if (result.success && result.data) {\n * console.log('Pool state:', result.data.state);\n * console.log('Pool price:', result.data.price);\n * }\n * ```\n */\nexport async function getPoolStateWithPrice(\n publicClient: PublicClient,\n params: PoolStateParams\n): Promise<SteerResponse<{ state: Slot0; price: bigint | null }>> {\n try {\n const stateResponse = await getPoolState(publicClient, params);\n\n if (!stateResponse.success || !stateResponse.data) {\n return {\n data: null,\n status: stateResponse.status,\n success: false,\n error: stateResponse.error || 'Failed to get pool state',\n };\n }\n\n const price = getPoolPrice(stateResponse.data, params);\n\n return {\n data: {\n state: stateResponse.data,\n price,\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to get pool state with price',\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/base/vault/utils.ts"],"names":[],"mappings":";;AAwLA,4BAgDC;AAOD,wCAuDC;AAMD,0DA2DC;AAOD,sEAuDC;AA+B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A0B;aACzD,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO;YACL,IAAI,EAAE;gBACJ,KAAK,EAAE,aAAa,CAAC,IAAI;gBACzB,KAAK;aACN;YACD,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC;SACtF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Address, PublicClient } from 'viem';\nimport { PoolSharkGlobalState, Slot0, SteerResponse } from '../../types.js';\n\n/**\n * Parameters for getting pool state across different AMM types\n */\nexport interface PoolStateParams {\n /** The pool address */\n poolAddress: Address;\n /** Whether the pool is an Algebra pool */\n isAlgebraPool?: boolean;\n /** Whether the pool is an Algebra directional pool */\n isAlgebraDirectionPool?: boolean;\n /** Whether the pool is a PoolShark pool */\n isPoolSharkPool?: boolean;\n /** Whether the pool is an Algebra Integral pool */\n isAlgebraIntegralPool?: boolean;\n}\n\n// const SLOT0_ABI: any = [\n// {\n// inputs: [],\n// name: 'slot0',\n// outputs: [\n// { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' },\n// { internalType: 'int24', name: 'tick', type: 'int24' },\n// { internalType: 'uint16', name: 'observationIndex', type: 'uint16' },\n// { internalType: 'uint16', name: 'observationCardinality', type: 'uint16' },\n// { internalType: 'uint16', name: 'observationCardinalityNext', type: 'uint16' },\n// { internalType: 'uint8', name: 'feeProtocol', type: 'uint8' },\n// { internalType: 'bool', name: 'unlocked', type: 'bool' },\n// ],\n// stateMutability: 'view',\n// type: 'function',\n// },\n// ] as const;\n\nconst GLOBAL_STATE_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'int24', name: 'prevInitializedTick', type: 'int24' },\n { internalType: 'uint16', name: 'fee', type: 'uint16' },\n { internalType: 'uint16', name: 'timepointIndex', type: 'uint16' },\n { internalType: 'uint8', name: 'communityFee', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst GLOBAL_STATE_ABI_INTEGRAL_V_1 = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n {\n internalType: 'uint160',\n name: 'price',\n type: 'uint160',\n },\n {\n internalType: 'int24',\n name: 'tick',\n type: 'int24',\n },\n {\n internalType: 'uint16',\n name: 'lastFee',\n type: 'uint16',\n },\n {\n internalType: 'uint8',\n name: 'pluginConfig',\n type: 'uint8',\n },\n {\n internalType: 'uint16',\n name: 'communityFee',\n type: 'uint16',\n },\n {\n internalType: 'bool',\n name: 'unlocked',\n type: 'bool',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst GLOBAL_STATE_DIRECTIONAL_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'uint16', name: 'feeZto', type: 'uint16' },\n { internalType: 'uint16', name: 'feeOtz', type: 'uint16' },\n { internalType: 'uint16', name: 'timepointIndex', type: 'uint16' },\n { internalType: 'uint8', name: 'communityFeeToken0', type: 'uint8' },\n { internalType: 'uint8', name: 'communityFeeToken1', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\nconst POOLSHARK_GLOBAL_STATE_ABI = [\n {\n inputs: [],\n name: 'globalState',\n outputs: [\n {\n components: [\n {\n components: [\n { internalType: 'uint16', name: 'index', type: 'uint16' },\n { internalType: 'uint16', name: 'count', type: 'uint16' },\n { internalType: 'uint16', name: 'countMax', type: 'uint16' },\n ],\n internalType: 'struct PoolsharkStructs.SampleState',\n name: 'samples',\n type: 'tuple',\n },\n { internalType: 'uint200', name: 'feeGrowthGlobal0', type: 'uint200' },\n { internalType: 'uint200', name: 'feeGrowthGlobal1', type: 'uint200' },\n { internalType: 'uint160', name: 'secondsPerLiquidityAccum', type: 'uint160' },\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'int56', name: 'tickSecondsAccum', type: 'int56' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n { internalType: 'uint16', name: 'protocolSwapFee0', type: 'uint16' },\n { internalType: 'uint16', name: 'protocolSwapFee1', type: 'uint16' },\n ],\n internalType: 'struct PoolsharkStructs.RangePoolState',\n name: 'pool',\n type: 'tuple',\n },\n {\n components: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'uint128', name: 'protocolFees', type: 'uint128' },\n { internalType: 'uint16', name: 'protocolFillFee', type: 'uint16' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n ],\n internalType: 'struct PoolsharkStructs.LimitPoolState',\n name: 'pool0',\n type: 'tuple',\n },\n {\n components: [\n { internalType: 'uint160', name: 'price', type: 'uint160' },\n { internalType: 'uint128', name: 'liquidity', type: 'uint128' },\n { internalType: 'uint128', name: 'protocolFees', type: 'uint128' },\n { internalType: 'uint16', name: 'protocolFillFee', type: 'uint16' },\n { internalType: 'int24', name: 'tickAtPrice', type: 'int24' },\n ],\n internalType: 'struct PoolsharkStructs.LimitPoolState',\n name: 'pool1',\n type: 'tuple',\n },\n { internalType: 'uint128', name: 'liquidityGlobal', type: 'uint128' },\n { internalType: 'uint32', name: 'positionIdNext', type: 'uint32' },\n { internalType: 'uint32', name: 'epoch', type: 'uint32' },\n { internalType: 'uint8', name: 'unlocked', type: 'uint8' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const;\n\n/**\n * Gets slot0 data from a standard Uniswap V3 pool\n * @param poolAddress The pool address\n */\nexport async function getSlot0(\n publicClient: PublicClient,\n poolAddress: Address\n): Promise<SteerResponse<Slot0>> {\n try {\n const slot0 = await publicClient.readContract({\n address: poolAddress,\n abi: [\n {\n inputs: [],\n name: 'slot0',\n outputs: [\n { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' },\n { internalType: 'int24', name: 'tick', type: 'int24' },\n { internalType: 'uint16', name: 'observationIndex', type: 'uint16' },\n { internalType: 'uint16', name: 'observationCardinality', type: 'uint16' },\n { internalType: 'uint16', name: 'observationCardinalityNext', type: 'uint16' },\n { internalType: 'uint8', name: 'feeProtocol', type: 'uint8' },\n { internalType: 'bool', name: 'unlocked', type: 'bool' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ],\n functionName: 'slot0',\n });\n\n return {\n data: {\n sqrtPriceX96: slot0[0],\n tick: Number(slot0[1]),\n observationIndex: slot0[2],\n observationCardinality: slot0[3],\n observationCardinalityNext: slot0[4],\n feeProtocol: slot0[5],\n unlocked: slot0[6],\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from an Algebra pool\n * @param poolAddress The pool address\n * @param isDirectional Whether the pool is directional\n */\nexport async function getGlobalState(\n publicClient: PublicClient,\n poolAddress: Address,\n isDirectional = false\n): Promise<SteerResponse<Slot0>> {\n try {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: isDirectional ? GLOBAL_STATE_DIRECTIONAL_ABI : GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: globalState[4], // timepointIndex\n observationCardinality: 0, // Not available in Algebra\n observationCardinalityNext: 0, // Not available in Algebra\n feeProtocol: isDirectional ? Number(globalState[2]) : Number(globalState[3]), // fee or feeZto\n unlocked: Boolean(globalState[isDirectional ? 7 : 6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: GLOBAL_STATE_ABI_INTEGRAL_V_1,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: false,\n },\n status: 200,\n success: true,\n };\n }\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from a PoolShark pool\n * @param poolAddress The pool address\n */\nexport async function getGlobalStatePoolShark(\n publicClient: PublicClient,\n poolAddress: Address\n): Promise<SteerResponse<PoolSharkGlobalState>> {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: POOLSHARK_GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n pool: {\n samples: {\n index: globalState[0].samples.index,\n count: globalState[0].samples.count,\n countMax: globalState[0].samples.countMax,\n },\n feeGrowthGlobal0: globalState[0].feeGrowthGlobal0,\n feeGrowthGlobal1: globalState[0].feeGrowthGlobal1,\n secondsPerLiquidityAccum: globalState[0].secondsPerLiquidityAccum,\n price: globalState[0].price,\n liquidity: globalState[0].liquidity,\n tickSecondsAccum: Number(globalState[0].tickSecondsAccum),\n tickAtPrice: globalState[0].tickAtPrice,\n protocolSwapFee0: globalState[0].protocolSwapFee0,\n protocolSwapFee1: globalState[0].protocolSwapFee1,\n },\n pool0: {\n price: globalState[1].price,\n liquidity: globalState[1].liquidity,\n protocolFees: globalState[1].protocolFees,\n protocolFillFee: globalState[1].protocolFillFee,\n tickAtPrice: globalState[1].tickAtPrice,\n },\n pool1: {\n price: globalState[2].price,\n liquidity: globalState[2].liquidity,\n protocolFees: globalState[2].protocolFees,\n protocolFillFee: globalState[2].protocolFillFee,\n tickAtPrice: globalState[2].tickAtPrice,\n },\n liquidityGlobal: globalState[3],\n positionIdNext: Number(globalState[4]),\n epoch: Number(globalState[5]),\n unlocked: Number(globalState[6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Gets global state from an Algebra Integral pool\n * @param poolAddress The pool address\n * @param isDirectional Whether the pool is directional\n */\nexport async function getGlobalStateAlgebraIntegral(\n publicClient: PublicClient,\n poolAddress: Address,\n isDirectional = false\n): Promise<SteerResponse<Slot0>> {\n try {\n try {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: isDirectional ? GLOBAL_STATE_DIRECTIONAL_ABI : GLOBAL_STATE_ABI,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: globalState[4], // timepointIndex\n observationCardinality: 0, // Not available in Algebra Integral\n observationCardinalityNext: 0, // Not available in Algebra Integral\n feeProtocol: isDirectional ? Number(globalState[2]) : Number(globalState[3]), // fee or feeZto\n unlocked: Boolean(globalState[isDirectional ? 7 : 6]),\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n const globalState = await publicClient.readContract({\n address: poolAddress,\n abi: GLOBAL_STATE_ABI_INTEGRAL_V_1,\n functionName: 'globalState',\n });\n\n return {\n data: {\n price: globalState[0],\n tick: Number(globalState[1]),\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: false,\n },\n status: 200,\n success: true,\n };\n }\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n}\n\n/**\n * Unified method to get pool state across different AMM types\n * Automatically calls the correct function based on pool type parameters\n *\n * @param publicClient - The public client for blockchain reads\n * @param params - Parameters specifying the pool and its type\n * @returns Promise resolving to standardized pool state data\n *\n * @example\n * ```typescript\n * // For Uniswap V3 pool\n * const uniV3State = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * });\n *\n * // For Algebra pool\n * const algebraState = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true,\n * isAlgebraDirectionPool: false\n * });\n *\n * // For PoolShark pool\n * const poolSharkState = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isPoolSharkPool: true\n * });\n * ```\n */\nexport async function getPoolState(\n publicClient: PublicClient,\n params: PoolStateParams\n): Promise<SteerResponse<Slot0>> {\n try {\n let stateResponse: SteerResponse<Slot0 | PoolSharkGlobalState>;\n\n // Handle different protocol types following the same logic as getPoolInstance\n if (params.isAlgebraIntegralPool) {\n // For Algebra Integral pools\n stateResponse = await getGlobalStateAlgebraIntegral(\n publicClient,\n params.poolAddress,\n params.isAlgebraDirectionPool || false\n );\n } else if (params.isPoolSharkPool) {\n // For PoolShark pools - convert to standardized format\n const poolSharkResponse = await getGlobalStatePoolShark(publicClient, params.poolAddress);\n if (poolSharkResponse.success && poolSharkResponse.data) {\n stateResponse = {\n success: true,\n status: 200,\n data: {\n sqrtPriceX96: poolSharkResponse.data.pool.price,\n tick: poolSharkResponse.data.pool.tickAtPrice,\n observationIndex: 0,\n observationCardinality: 0,\n observationCardinalityNext: 0,\n feeProtocol: 0,\n unlocked: poolSharkResponse.data.unlocked === 1,\n },\n };\n } else {\n stateResponse = {\n data: null,\n status: poolSharkResponse.status,\n success: false,\n error: poolSharkResponse.error,\n };\n }\n } else if (params.isAlgebraPool) {\n // For Algebra pools\n stateResponse = await getGlobalState(\n publicClient,\n params.poolAddress,\n params.isAlgebraDirectionPool || false\n );\n } else {\n // For standard Uniswap V3 pools\n\n stateResponse = await getSlot0(publicClient, params.poolAddress);\n }\n\n if (!stateResponse.success || !stateResponse.data) {\n throw new Error(stateResponse.error || 'Failed to read pool state');\n }\n\n return {\n data: stateResponse.data as Slot0,\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to get pool state',\n };\n }\n}\n\n/**\n * Extracts the appropriate price value from pool state based on AMM type\n * Different AMM protocols store price information in different fields\n *\n * @param poolStateData - The pool state data returned from getPoolState\n * @param params - Pool type parameters to determine which price field to use\n * @returns The price as bigint, or null if price cannot be extracted\n *\n * @example\n * ```typescript\n * const stateResponse = await getPoolState(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true\n * });\n *\n * if (stateResponse.success && stateResponse.data) {\n * const price = getPoolPrice(stateResponse.data, {\n * isAlgebraPool: true,\n * isAlgebraDirectionPool: false\n * });\n * console.log('Pool price:', price);\n * }\n * ```\n */\nexport function getPoolPrice(\n poolStateData: Slot0,\n params: Pick<PoolStateParams, 'isAlgebraPool' | 'isAlgebraIntegralPool' | 'isPoolSharkPool'>\n): bigint | null {\n try {\n let price: bigint | undefined;\n\n // Extract price based on AMM type - following the same logic as getPoolInstance\n if (params.isAlgebraPool && !params.isAlgebraIntegralPool) {\n // For Algebra pools (non-integral)\n price = poolStateData?.price;\n } else if (params.isAlgebraIntegralPool) {\n // For Algebra Integral pools\n price = poolStateData?.price;\n } else if (params.isPoolSharkPool) {\n // For PoolShark pools - price is stored in a nested structure\n price = (poolStateData.tick as unknown as { price: bigint })?.price;\n } else {\n // For standard Uniswap V3 pools\n price = poolStateData.sqrtPriceX96;\n }\n\n return price || null;\n } catch (error) {\n console.error('Error extracting pool price:', error);\n return null;\n }\n}\n\n/**\n * Combined method to get both pool state and extract price in one call\n * Convenience method that combines getPoolState and getPoolPrice\n *\n * @param publicClient - The public client for blockchain reads\n * @param params - Parameters specifying the pool and its type\n * @returns Promise resolving to object containing both state and price\n *\n * @example\n * ```typescript\n * const result = await getPoolStateWithPrice(publicClient, {\n * poolAddress: '0x...',\n * isAlgebraPool: true\n * });\n *\n * if (result.success && result.data) {\n * console.log('Pool state:', result.data.state);\n * console.log('Pool price:', result.data.price);\n * }\n * ```\n */\nexport async function getPoolStateWithPrice(\n publicClient: PublicClient,\n params: PoolStateParams\n): Promise<SteerResponse<{ state: Slot0; price: bigint | null }>> {\n try {\n const stateResponse = await getPoolState(publicClient, params);\n\n if (!stateResponse.success || !stateResponse.data) {\n return {\n data: null,\n status: stateResponse.status,\n success: false,\n error: stateResponse.error || 'Failed to get pool state',\n };\n }\n\n const price = getPoolPrice(stateResponse.data, params);\n\n return {\n data: {\n state: stateResponse.data,\n price,\n },\n status: 200,\n success: true,\n };\n } catch (error) {\n return {\n data: null,\n status: 500,\n success: false,\n error: error instanceof Error ? error.message : 'Failed to get pool state with price',\n };\n }\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VaultWithdrawClient = void 0;
|
|
4
|
+
const abis_js_1 = require("../../../const/deployments/abis.js");
|
|
5
|
+
const network_js_1 = require("../../../const/network.js");
|
|
6
|
+
const VAULT_ABI = abis_js_1.abis.QuickSwapUniv3MultiPositionLiquidityManager;
|
|
7
|
+
const PERIPHERY_ABI = abis_js_1.abis.SteerPeriphery;
|
|
8
|
+
class VaultWithdrawClient {
|
|
6
9
|
constructor(publicClient, walletClient) {
|
|
7
10
|
this.publicClient = publicClient;
|
|
8
11
|
this.walletClient = walletClient;
|
|
@@ -101,7 +104,7 @@ export class VaultWithdrawClient {
|
|
|
101
104
|
try {
|
|
102
105
|
// Get chain ID and periphery address
|
|
103
106
|
const chainId = await this.publicClient.getChainId();
|
|
104
|
-
const steerPeripheryAddress = getContractAddressByChainIdAndContractName(chainId, 'SteerPeriphery');
|
|
107
|
+
const steerPeripheryAddress = (0, network_js_1.getContractAddressByChainIdAndContractName)(chainId, 'SteerPeriphery');
|
|
105
108
|
if (!steerPeripheryAddress)
|
|
106
109
|
throw new Error('SteerPeriphery address not found');
|
|
107
110
|
// Try to get vault details, first attempt with regular vault
|
|
@@ -150,4 +153,5 @@ export class VaultWithdrawClient {
|
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
155
|
}
|
|
156
|
+
exports.VaultWithdrawClient = VaultWithdrawClient;
|
|
153
157
|
//# sourceMappingURL=index.js.map
|