From 6af34704b30f015a9c95675e38274df94666af58 Mon Sep 17 00:00:00 2001 From: Fawad Ali Date: Fri, 10 Apr 2026 13:36:54 +0200 Subject: [PATCH] Add bulkWithdraw to NucleusTeller contract --- lib/contracts/abis/mainnet/Teller.ts | 178 ++++++++++++++++-- .../handlers/nucleus-teller-handler.ts | 57 +++++- 2 files changed, 215 insertions(+), 20 deletions(-) diff --git a/lib/contracts/abis/mainnet/Teller.ts b/lib/contracts/abis/mainnet/Teller.ts index 86fb9a18..41b4f5a1 100644 --- a/lib/contracts/abis/mainnet/Teller.ts +++ b/lib/contracts/abis/mainnet/Teller.ts @@ -12,34 +12,57 @@ export const Teller = [ stateMutability: 'view', type: 'function', }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + ], + name: 'addAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [], - name: 'vault', + name: 'authority', outputs: [ - { internalType: 'contract BoringVault', name: '', type: 'address' }, + { internalType: 'contract Authority', name: '', type: 'address' }, ], stateMutability: 'view', type: 'function', }, { - inputs: [], - name: 'shareLockPeriod', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + inputs: [{ internalType: 'address', name: 'from', type: 'address' }], + name: 'beforeTransfer', + outputs: [], stateMutability: 'view', type: 'function', }, { - inputs: [{ internalType: 'address', name: '', type: 'address' }], - name: 'shareUnlockTime', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', + inputs: [ + { internalType: 'contract ERC20', name: 'depositAsset', type: 'address' }, + { internalType: 'uint256', name: 'depositAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'minimumMint', type: 'uint256' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'bulkDeposit', + outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + stateMutability: 'nonpayable', type: 'function', }, { - inputs: [], - name: 'isPaused', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', + inputs: [ + { + internalType: 'contract ERC20', + name: 'withdrawAsset', + type: 'address', + }, + { internalType: 'uint256', name: 'shareAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'minimumAssets', type: 'uint256' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'bulkWithdraw', + outputs: [{ internalType: 'uint256', name: 'assetsOut', type: 'uint256' }], + stateMutability: 'nonpayable', type: 'function', }, { @@ -53,6 +76,13 @@ export const Teller = [ stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [], + name: 'depositNonce', + outputs: [{ internalType: 'uint96', name: '', type: 'uint96' }], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { internalType: 'contract ERC20', name: 'depositAsset', type: 'address' }, @@ -68,4 +98,126 @@ export const Teller = [ stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [], + name: 'isPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'contract ERC20', name: '', type: 'address' }], + name: 'isSupported', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + name: 'publicDepositHistory', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'nonce', type: 'uint256' }, + { internalType: 'address', name: 'receiver', type: 'address' }, + { internalType: 'address', name: 'depositAsset', type: 'address' }, + { internalType: 'uint256', name: 'depositAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'shareAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'depositTimestamp', type: 'uint256' }, + { + internalType: 'uint256', + name: 'shareLockUpPeriodAtTimeOfDeposit', + type: 'uint256', + }, + ], + name: 'refundDeposit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + ], + name: 'removeAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'setAuthority', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint64', name: '_shareLockPeriod', type: 'uint64' }, + ], + name: 'setShareLockPeriod', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'shareLockPeriod', + outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'shareUnlockTime', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'unpause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'vault', + outputs: [ + { internalType: 'contract BoringVault', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, ]; diff --git a/lib/contracts/handlers/nucleus-teller-handler.ts b/lib/contracts/handlers/nucleus-teller-handler.ts index d2302f51..3be20c60 100644 --- a/lib/contracts/handlers/nucleus-teller-handler.ts +++ b/lib/contracts/handlers/nucleus-teller-handler.ts @@ -27,6 +27,20 @@ export type DepositWithPermitParams = PermitData & { minimumMint: bigint; }; +export type BulkDepositParams = { + account: Address; + depositAsset: Address; + depositAmount: bigint; + minimumMint: bigint; +}; + +export type BulkWithdrawParams = { + account: Address; + withdrawAsset: Address; + shareAmount: bigint; + minimumAssets: bigint; +}; + /** * Handler for the `Teller` contract from nucleus. */ @@ -239,17 +253,46 @@ export class NucleusTellerHandler { const transact = () => this.getContract().write.depositWithPermit( [depositAsset, amount, minimumMint, deadline, v, r, s], - { - account, - chain: this.viemChain, - }, + { account, chain: this.viemChain }, ); const estimate = () => this.getContract().estimateGas.depositWithPermit( [depositAsset, amount, minimumMint, deadline, v, r, s], - { - account, - }, + { account }, + ); + + return { transact, estimate }; + } + + public async bulkWithdraw(params: BulkWithdrawParams) { + const { account, withdrawAsset, shareAmount, minimumAssets } = params; + + const transact = () => + this.getContract().write.bulkWithdraw( + [withdrawAsset, shareAmount, minimumAssets, account], + { account, chain: this.viemChain }, + ); + const estimate = () => + this.getContract().estimateGas.bulkWithdraw( + [withdrawAsset, shareAmount, minimumAssets, account], + { account }, + ); + + return { transact, estimate }; + } + + public async bulkDeposit(params: BulkDepositParams) { + const { account, depositAsset, depositAmount, minimumMint } = params; + + const transact = () => + this.getContract().write.bulkDeposit( + [depositAsset, depositAmount, minimumMint, account], + { account, chain: this.viemChain }, + ); + const estimate = () => + this.getContract().estimateGas.bulkDeposit( + [depositAsset, depositAmount, minimumMint, account], + { account }, ); return { transact, estimate };