From 4cddbb094f27e60ffca0c6b4e0f2f4c58b53b889 Mon Sep 17 00:00:00 2001 From: Ivan Herger <36133712+iherger@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:21:05 +0100 Subject: [PATCH] feat: add StaderWithdrawals (#583) --- .changeset/fast-rats-draw.md | 7 + .../IStaderWithdrawalsPositionLib.abi.json | 129 +++++++++ .../abis/IStaderWithdrawalsPositionLib.sol | 14 + .../abis/src/IStaderWithdrawalsPositionLib.ts | 129 +++++++++ packages/abis/src/index.ts | 1 + packages/environment/src/contracts.ts | 2 + .../environment/src/deployments/arbitrum.ts | 3 + packages/environment/src/deployments/base.ts | 5 +- .../environment/src/deployments/ethereum.ts | 10 +- .../environment/src/deployments/polygon.ts | 3 + .../environment/src/deployments/testnet.ts | 2 + packages/environment/src/environment.ts | 1 + packages/environment/src/releases.ts | 3 + packages/sdk/src/Portfolio/Integrations.ts | 2 +- .../sdk/src/Portfolio/Integrations/Stader.ts | 248 ++++++++++++++++++ .../Portfolio/Integrations/StaderStaking.ts | 69 ----- .../{StaderStaking.test.ts => Stader.test.ts} | 4 +- 17 files changed, 558 insertions(+), 74 deletions(-) create mode 100644 .changeset/fast-rats-draw.md create mode 100644 packages/abis/abis/IStaderWithdrawalsPositionLib.abi.json create mode 100644 packages/abis/abis/IStaderWithdrawalsPositionLib.sol create mode 100644 packages/abis/src/IStaderWithdrawalsPositionLib.ts create mode 100644 packages/sdk/src/Portfolio/Integrations/Stader.ts delete mode 100644 packages/sdk/src/Portfolio/Integrations/StaderStaking.ts rename packages/sdk/test/tests/Portfolio/Integrations/{StaderStaking.test.ts => Stader.test.ts} (88%) diff --git a/.changeset/fast-rats-draw.md b/.changeset/fast-rats-draw.md new file mode 100644 index 00000000..416a4ddb --- /dev/null +++ b/.changeset/fast-rats-draw.md @@ -0,0 +1,7 @@ +--- +"@enzymefinance/environment": minor +"@enzymefinance/abis": minor +"@enzymefinance/sdk": minor +--- + +Add StaderWithdrawals diff --git a/packages/abis/abis/IStaderWithdrawalsPositionLib.abi.json b/packages/abis/abis/IStaderWithdrawalsPositionLib.abi.json new file mode 100644 index 00000000..fe65dc48 --- /dev/null +++ b/packages/abis/abis/IStaderWithdrawalsPositionLib.abi.json @@ -0,0 +1,129 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_userWithdrawalManagerAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "_ethxAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "_wethAddress", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "ETHX_ADDRESS", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "USER_WITHDRAWAL_MANAGER", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IStaderUserWithdrawalManager" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "WETH_ADDRESS", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDebtAssets", + "inputs": [], + "outputs": [ + { + "name": "assets_", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "amounts_", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "getManagedAssets", + "inputs": [], + "outputs": [ + { + "name": "assets_", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "amounts_", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "init", + "inputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "receiveCallFromVault", + "inputs": [ + { + "name": "_actionData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "error", + "name": "StaderWithdrawalsPositionLib__ReceiveCallFromVault__InvalidActionId", + "inputs": [] + } +] diff --git a/packages/abis/abis/IStaderWithdrawalsPositionLib.sol b/packages/abis/abis/IStaderWithdrawalsPositionLib.sol new file mode 100644 index 00000000..eee76f92 --- /dev/null +++ b/packages/abis/abis/IStaderWithdrawalsPositionLib.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.0 <0.9.0; + +interface IStaderWithdrawalsPositionLib { + error StaderWithdrawalsPositionLib__ReceiveCallFromVault__InvalidActionId(); + + function ETHX_ADDRESS() external view returns (address); + function USER_WITHDRAWAL_MANAGER() external view returns (address); + function WETH_ADDRESS() external view returns (address); + function getDebtAssets() external pure returns (address[] memory assets_, uint256[] memory amounts_); + function getManagedAssets() external view returns (address[] memory assets_, uint256[] memory amounts_); + function init(bytes memory) external; + function receiveCallFromVault(bytes memory _actionData) external; +} diff --git a/packages/abis/src/IStaderWithdrawalsPositionLib.ts b/packages/abis/src/IStaderWithdrawalsPositionLib.ts new file mode 100644 index 00000000..94053ae7 --- /dev/null +++ b/packages/abis/src/IStaderWithdrawalsPositionLib.ts @@ -0,0 +1,129 @@ +export const IStaderWithdrawalsPositionLib = [ + { + type: "constructor", + inputs: [ + { + name: "_userWithdrawalManagerAddress", + type: "address", + internalType: "address", + }, + { + name: "_ethxAddress", + type: "address", + internalType: "address", + }, + { + name: "_wethAddress", + type: "address", + internalType: "address", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "ETHX_ADDRESS", + inputs: [], + outputs: [ + { + name: "", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "USER_WITHDRAWAL_MANAGER", + inputs: [], + outputs: [ + { + name: "", + type: "address", + internalType: "contract IStaderUserWithdrawalManager", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "WETH_ADDRESS", + inputs: [], + outputs: [ + { + name: "", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getDebtAssets", + inputs: [], + outputs: [ + { + name: "assets_", + type: "address[]", + internalType: "address[]", + }, + { + name: "amounts_", + type: "uint256[]", + internalType: "uint256[]", + }, + ], + stateMutability: "pure", + }, + { + type: "function", + name: "getManagedAssets", + inputs: [], + outputs: [ + { + name: "assets_", + type: "address[]", + internalType: "address[]", + }, + { + name: "amounts_", + type: "uint256[]", + internalType: "uint256[]", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "init", + inputs: [ + { + name: "", + type: "bytes", + internalType: "bytes", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "receiveCallFromVault", + inputs: [ + { + name: "_actionData", + type: "bytes", + internalType: "bytes", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "error", + name: "StaderWithdrawalsPositionLib__ReceiveCallFromVault__InvalidActionId", + inputs: [], + }, +] as const; diff --git a/packages/abis/src/index.ts b/packages/abis/src/index.ts index 7c458ba2..346bd17b 100644 --- a/packages/abis/src/index.ts +++ b/packages/abis/src/index.ts @@ -127,6 +127,7 @@ export { ISolvV2BondBuyerPositionParser } from "./ISolvV2BondBuyerPositionParser export { ISolvV2BondIssuerPositionLib } from "./ISolvV2BondIssuerPositionLib.js"; export { ISolvV2BondIssuerPositionParser } from "./ISolvV2BondIssuerPositionParser.js"; export { IStaderStakingAdapter } from "./IStaderStakingAdapter.js"; +export { IStaderWithdrawalsPositionLib } from "./IStaderWithdrawalsPositionLib.js"; export { IStakeWiseV3StakingPositionLib } from "./IStakeWiseV3StakingPositionLib.js"; export { IStakeWiseV3StakingPositionParser } from "./IStakeWiseV3StakingPositionParser.js"; export { IStakingWrapper } from "./IStakingWrapper.js"; diff --git a/packages/environment/src/contracts.ts b/packages/environment/src/contracts.ts index 51605c16..9def4582 100644 --- a/packages/environment/src/contracts.ts +++ b/packages/environment/src/contracts.ts @@ -149,6 +149,8 @@ export interface SuluContracts extends CommonContracts { readonly SolvV2BondIssuerPositionParser: Address; readonly StaderSDPriceFeed: Address; readonly StaderStakingAdapter: Address; + readonly StaderWithdrawalsPositionLib: Address; + readonly StaderWithdrawalsPositionParser: Address; readonly StakeWiseV3StakingPositionLib: Address; readonly StakeWiseV3StakingPositionParser: Address; readonly SwellStakingAdapter: Address; diff --git a/packages/environment/src/deployments/arbitrum.ts b/packages/environment/src/deployments/arbitrum.ts index 2caee478..c6d94f13 100644 --- a/packages/environment/src/deployments/arbitrum.ts +++ b/packages/environment/src/deployments/arbitrum.ts @@ -46,6 +46,7 @@ export default defineDeployment({ paraswapV5TokenTransferProxy: "0x216b4b4ba9f3e719726886d34a177484278bfcae", pendlePtLpOracle: "0x0000000000000000000000000000000000000000", staderStakingPoolManager: "0x0000000000000000000000000000000000000000", + staderUserWithdrawManager: "0x0000000000000000000000000000000000000000", stakeWiseV3KeeperRewards: "0x0000000000000000000000000000000000000000", theGraphDelegationStakingProxy: "0x00669a4cf01450b64e8a2a20e9b1fcb71e61ef03", theGraphEpochManagerProxy: "0x5a843145c43d328b9bb7a4401d94918f131bb281", @@ -207,6 +208,8 @@ export default defineDeployment({ SolvV2BondIssuerPositionParser: "0x0000000000000000000000000000000000000000", StaderSDPriceFeed: "0x0000000000000000000000000000000000000000", StaderStakingAdapter: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionLib: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionParser: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionLib: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionParser: "0x0000000000000000000000000000000000000000", SwellStakingAdapter: "0x0000000000000000000000000000000000000000", diff --git a/packages/environment/src/deployments/base.ts b/packages/environment/src/deployments/base.ts index 3bcb95a2..d75349b5 100644 --- a/packages/environment/src/deployments/base.ts +++ b/packages/environment/src/deployments/base.ts @@ -44,6 +44,7 @@ export default defineDeployment({ paraswapV5TokenTransferProxy: "0x93aaae79a53759cd164340e4c8766e4db5331cd7", pendlePtLpOracle: "0x0000000000000000000000000000000000000000", stakeWiseV3KeeperRewards: "0x0000000000000000000000000000000000000000", + staderUserWithdrawManager: "0x0000000000000000000000000000000000000000", uniswapV3NonFungiblePositionManager: "0x0000000000000000000000000000000000000000", voteLockedConvexToken: "0x0000000000000000000000000000000000000000", votiumVoteProxy: "0x0000000000000000000000000000000000000000", @@ -201,8 +202,10 @@ export default defineDeployment({ SolvV2BondBuyerPositionParser: "0x0000000000000000000000000000000000000000", SolvV2BondIssuerPositionLib: "0x0000000000000000000000000000000000000000", SolvV2BondIssuerPositionParser: "0x0000000000000000000000000000000000000000", - StaderStakingAdapter: "0x0000000000000000000000000000000000000000", StaderSDPriceFeed: "0x0000000000000000000000000000000000000000", + StaderStakingAdapter: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionLib: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionParser: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionLib: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionParser: "0x0000000000000000000000000000000000000000", SwellStakingAdapter: "0x0000000000000000000000000000000000000000", diff --git a/packages/environment/src/deployments/ethereum.ts b/packages/environment/src/deployments/ethereum.ts index 237a3e65..e0e3bb3c 100644 --- a/packages/environment/src/deployments/ethereum.ts +++ b/packages/environment/src/deployments/ethereum.ts @@ -46,6 +46,7 @@ export default defineDeployment({ paraswapV5TokenTransferProxy: "0x216b4b4ba9f3e719726886d34a177484278bfcae", pendlePtLpOracle: "0x66a1096c6366b2529274df4f5d8247827fe4cea8", staderStakingPoolManager: "0xcf5ea1b38380f6af39068375516daf40ed70d299", + staderUserWithdrawManager: "0x9f0491b32dbce587c50c4c43ab303b06478193a7", stakeWiseV3KeeperRewards: "0x6b5815467da09daa7dc83db21c9239d98bb487b5", theGraphDelegationStakingProxy: "0xf55041e37e12cd407ad00ce2910b8269b01263b9", theGraphEpochManagerProxy: "0x64f990bf16552a693dcb043bb7bf3866c5e05ddb", @@ -79,6 +80,7 @@ export default defineDeployment({ cvx: "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", dai: "0x6b175474e89094c44da98b954eedeac495271d0f", diva: "0xbfabde619ed5c4311811cf422562709710db587d", + ethx: "0xa35b1b31ce002fbf2058d22f30f95d405200a15b", grt: "0xc944e90c64b2c07662a292be6244bdf05cda44a7", idle: "0x875773784af8135ea0ef43b5a374aad105c5d39e", lusd: "0x5f98805a4e8be255a32880fdec7f6728c6568ba0", @@ -226,6 +228,8 @@ export default defineDeployment({ SolvV2BondIssuerPositionParser: "0xc4b599043a5479398eb8af387b1e36d9a924f8c2", StaderSDPriceFeed: "0x9938b14a25a4910531d5cbdf3c41510b19aaf016", StaderStakingAdapter: "0x7f1b68d5ed183cda6788a66520506eaf3544001c", + StaderWithdrawalsPositionLib: "0x5cf43f5f8c1648db23948e3814d0099c408201a4", + StaderWithdrawalsPositionParser: "0xaefe3260dcbcfaa2a4b927a6494057837e6dd902", StakeWiseV3StakingPositionLib: "0xef268eb475a096adb95712b05b095acc1fc2d3ae", StakeWiseV3StakingPositionParser: "0x642348ee0c28c2943082f950f3a35db07bd4bbdf", SwellStakingAdapter: "0x50bae03333dd8495263c9049091a8925063b068e", @@ -394,7 +398,11 @@ export default defineDeployment({ subgraphs: { assets: { slug: "asset-universe", id: "4ZW3mDNgpDVy68RipQLJxvRw1FReJTfvA7nbB52J4Gjg" }, balances: { slug: "vault-balances", id: "HwR7jTExHWNvQetTxRYEMQ5hywHyUkierAYvnGS7pBUS" }, - core: { slug: "enzyme-core", id: "9DLBBLep5UyU16kUQRvxBCMqko4q9XzuE4XsMMpARhKK", devVersion: "version/latest" }, + core: { + slug: "enzyme-core", + id: "9DLBBLep5UyU16kUQRvxBCMqko4q9XzuE4XsMMpARhKK", + devVersion: "version/latest", + }, shares: { slug: "vault-shares", id: "6p2L2gQ4Hw4Dh2kxZFDJbcqtbv44vrJbrBEh3EjS7qVo" }, vaults: { slug: "vault-lineage", id: "5FdivFcUPmVSqCFkv3jqJh3QYjHjh1ztzd7GHiCAMP1h" }, }, diff --git a/packages/environment/src/deployments/polygon.ts b/packages/environment/src/deployments/polygon.ts index d1d856b0..114adfd5 100644 --- a/packages/environment/src/deployments/polygon.ts +++ b/packages/environment/src/deployments/polygon.ts @@ -43,6 +43,7 @@ export default defineDeployment({ morphoBlue: "0x0000000000000000000000000000000000000000", multicall: "0xca11bde05977b3631167028862be2a173976ca11", staderStakingPoolManager: "0x0000000000000000000000000000000000000000", + staderUserWithdrawManager: "0x0000000000000000000000000000000000000000", paraswapV5AugustusSwapper: "0xdef171fe48cf0115b1d80b88dc8eab59176fee57", paraswapV5TokenTransferProxy: "0x216b4b4ba9f3e719726886d34a177484278bfcae", pendlePtLpOracle: "0x0000000000000000000000000000000000000000", @@ -211,6 +212,8 @@ export default defineDeployment({ SolvV2BondIssuerPositionParser: "0x0000000000000000000000000000000000000000", StaderSDPriceFeed: "0x0000000000000000000000000000000000000000", StaderStakingAdapter: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionLib: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionParser: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionLib: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionParser: "0x0000000000000000000000000000000000000000", SwellStakingAdapter: "0x0000000000000000000000000000000000000000", diff --git a/packages/environment/src/deployments/testnet.ts b/packages/environment/src/deployments/testnet.ts index 337a92fc..7e7ee881 100644 --- a/packages/environment/src/deployments/testnet.ts +++ b/packages/environment/src/deployments/testnet.ts @@ -150,6 +150,8 @@ export default defineDeployment({ SolvV2BondIssuerPositionParser: "0x0000000000000000000000000000000000000000", StaderSDPriceFeed: "0x0000000000000000000000000000000000000000", StaderStakingAdapter: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionLib: "0x0000000000000000000000000000000000000000", + StaderWithdrawalsPositionParser: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionLib: "0x0000000000000000000000000000000000000000", StakeWiseV3StakingPositionParser: "0x0000000000000000000000000000000000000000", SwellStakingAdapter: "0x0000000000000000000000000000000000000000", diff --git a/packages/environment/src/environment.ts b/packages/environment/src/environment.ts index fdbcc82e..50695fc2 100644 --- a/packages/environment/src/environment.ts +++ b/packages/environment/src/environment.ts @@ -199,6 +199,7 @@ export class Environment, +) { + return readContract(client, { + ...Viem.extractBlockParameters(args), + abi: staderStakingPoolManagerAbi, + functionName: "previewDeposit", + address: args.staderStakingPoolManager, + args: [args.depositAmount], + }); +} + +const userWithdrawManagerAbi = [ + { + inputs: [{ internalType: "address", name: "_owner", type: "address" }], + name: "getRequestIdsByUser", + outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint256", name: "", type: "uint256" }], + name: "userWithdrawRequests", + outputs: [ + { internalType: "address payable", name: "owner", type: "address" }, + { internalType: "uint256", name: "ethXAmount", type: "uint256" }, + { internalType: "uint256", name: "ethExpected", type: "uint256" }, + { internalType: "uint256", name: "ethFinalized", type: "uint256" }, + { internalType: "uint256", name: "requestBlock", type: "uint256" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "nextRequestIdToFinalize", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, +] as const; + +export function getRequestIdsByUser( + client: Client, + args: Viem.ContractCallParameters<{ + userWithdrawManager: Address; + user: Address; + }>, +) { + return readContract(client, { + ...Viem.extractBlockParameters(args), + abi: userWithdrawManagerAbi, + functionName: "getRequestIdsByUser", + address: args.userWithdrawManager, + args: [args.user], + }); +} + +export async function getUserWithdrawRequests( + client: Client, + args: Viem.ContractCallParameters<{ + userWithdrawManager: Address; + requestId: bigint; + }>, +) { + const [owner, ethxAmount, ethExpected, ethFinalized, requestBlock] = await readContract(client, { + ...Viem.extractBlockParameters(args), + abi: userWithdrawManagerAbi, + functionName: "userWithdrawRequests", + address: args.userWithdrawManager, + args: [args.requestId], + }); + + return { owner, ethxAmount, ethExpected, ethFinalized, requestBlock }; +} + +export function getNextRequestIdToFinalize( + client: Client, + args: Viem.ContractCallParameters<{ + userWithdrawManager: Address; + }>, +) { + return readContract(client, { + ...Viem.extractBlockParameters(args), + abi: userWithdrawManagerAbi, + functionName: "nextRequestIdToFinalize", + address: args.userWithdrawManager, + }); +} + +export async function getRequestsWithDetailsByUser( + client: Client, + args: Viem.ContractCallParameters<{ + userWithdrawManager: Address; + user: Address; + }>, +) { + const [requestIds, nextRequestIdToFinalize] = await Promise.all([ + getRequestIdsByUser(client, { + userWithdrawManager: args.userWithdrawManager, + user: args.user, + }), + getNextRequestIdToFinalize(client, { userWithdrawManager: args.userWithdrawManager }), + ]); + + const requestDetails = await Promise.all( + requestIds.map((requestId) => + getUserWithdrawRequests(client, { userWithdrawManager: args.userWithdrawManager, requestId }), + ), + ); + + return requestIds.map((requestId, index) => { + return { + requestId, + ...requestDetails[index], + claimable: requestId < nextRequestIdToFinalize, + }; + }); +} diff --git a/packages/sdk/src/Portfolio/Integrations/StaderStaking.ts b/packages/sdk/src/Portfolio/Integrations/StaderStaking.ts deleted file mode 100644 index 33d20939..00000000 --- a/packages/sdk/src/Portfolio/Integrations/StaderStaking.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { type Address, type Client, type Hex, decodeAbiParameters, encodeAbiParameters } from "viem"; -import { readContract } from "viem/actions"; -import { Viem } from "../../Utils.js"; -import * as IntegrationManager from "../../_internal/IntegrationManager.js"; - -//-------------------------------------------------------------------------------------------- -// WRAP -//-------------------------------------------------------------------------------------------- - -export const wrap = IntegrationManager.makeUse(IntegrationManager.Selector.Wrap, wrapEncode); - -const wrapEncoding = [ - { - name: "outgoingAmount", - type: "uint256", - }, - { - name: "minIncomingAmount", - type: "uint256", - }, -] as const; - -export type WrapArgs = { - outgoingAmount: bigint; - minIncomingAmount: bigint; -}; - -export function wrapEncode(args: WrapArgs): Hex { - return encodeAbiParameters(wrapEncoding, [args.outgoingAmount, args.minIncomingAmount]); -} - -export function wrapDecode(encoded: Hex): WrapArgs { - const [outgoingAmount, minIncomingAmount] = decodeAbiParameters(wrapEncoding, encoded); - - return { - outgoingAmount, - minIncomingAmount, - }; -} - -//-------------------------------------------------------------------------------------------- -// EXTERNAL READ FUNCTIONS -//-------------------------------------------------------------------------------------------- - -const staderStakePoolsManagerAbi = [ - { - inputs: [{ internalType: "uint256", name: "_assets", type: "uint256" }], - name: "previewDeposit", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, -] as const; - -export function previewDeposit( - client: Client, - args: Viem.ContractCallParameters<{ - staderStakingPoolManager: Address; - depositAmount: bigint; - }>, -) { - return readContract(client, { - ...Viem.extractBlockParameters(args), - abi: staderStakePoolsManagerAbi, - functionName: "previewDeposit", - address: args.staderStakingPoolManager, - args: [args.depositAmount], - }); -} diff --git a/packages/sdk/test/tests/Portfolio/Integrations/StaderStaking.test.ts b/packages/sdk/test/tests/Portfolio/Integrations/Stader.test.ts similarity index 88% rename from packages/sdk/test/tests/Portfolio/Integrations/StaderStaking.test.ts rename to packages/sdk/test/tests/Portfolio/Integrations/Stader.test.ts index 5ffc6d23..1329673c 100644 --- a/packages/sdk/test/tests/Portfolio/Integrations/StaderStaking.test.ts +++ b/packages/sdk/test/tests/Portfolio/Integrations/Stader.test.ts @@ -22,14 +22,14 @@ test("create vault", async () => { }); test("wrap should work correctly", async () => { - const receivedEthx = await Portfolio.Integrations.StaderStaking.previewDeposit(environment.client, { + const receivedEthx = await Portfolio.Integrations.Stader.previewDeposit(environment.client, { staderStakingPoolManager: environment.constants.staderStakingPoolManager, depositAmount, }); await environment.send({ account: vaultOwner, - transaction: Portfolio.Integrations.StaderStaking.wrap({ + transaction: Portfolio.Integrations.Stader.wrap({ comptrollerProxy, integrationManager: environment.constants.integrationManager, integrationAdapter: environment.constants.staderStakingAdapter,