Skip to content

Commit da3bc02

Browse files
committed
Add bulkWithdraw to NucleusTeller contract
1 parent 313e38d commit da3bc02

2 files changed

Lines changed: 215 additions & 20 deletions

File tree

lib/contracts/abis/mainnet/Teller.ts

Lines changed: 165 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,57 @@ export const Teller = <const>[
1212
stateMutability: 'view',
1313
type: 'function',
1414
},
15+
{
16+
inputs: [
17+
{ internalType: 'contract ERC20', name: 'asset', type: 'address' },
18+
],
19+
name: 'addAsset',
20+
outputs: [],
21+
stateMutability: 'nonpayable',
22+
type: 'function',
23+
},
1524
{
1625
inputs: [],
17-
name: 'vault',
26+
name: 'authority',
1827
outputs: [
19-
{ internalType: 'contract BoringVault', name: '', type: 'address' },
28+
{ internalType: 'contract Authority', name: '', type: 'address' },
2029
],
2130
stateMutability: 'view',
2231
type: 'function',
2332
},
2433
{
25-
inputs: [],
26-
name: 'shareLockPeriod',
27-
outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
34+
inputs: [{ internalType: 'address', name: 'from', type: 'address' }],
35+
name: 'beforeTransfer',
36+
outputs: [],
2837
stateMutability: 'view',
2938
type: 'function',
3039
},
3140
{
32-
inputs: [{ internalType: 'address', name: '', type: 'address' }],
33-
name: 'shareUnlockTime',
34-
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
35-
stateMutability: 'view',
41+
inputs: [
42+
{ internalType: 'contract ERC20', name: 'depositAsset', type: 'address' },
43+
{ internalType: 'uint256', name: 'depositAmount', type: 'uint256' },
44+
{ internalType: 'uint256', name: 'minimumMint', type: 'uint256' },
45+
{ internalType: 'address', name: 'to', type: 'address' },
46+
],
47+
name: 'bulkDeposit',
48+
outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }],
49+
stateMutability: 'nonpayable',
3650
type: 'function',
3751
},
3852
{
39-
inputs: [],
40-
name: 'isPaused',
41-
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
42-
stateMutability: 'view',
53+
inputs: [
54+
{
55+
internalType: 'contract ERC20',
56+
name: 'withdrawAsset',
57+
type: 'address',
58+
},
59+
{ internalType: 'uint256', name: 'shareAmount', type: 'uint256' },
60+
{ internalType: 'uint256', name: 'minimumAssets', type: 'uint256' },
61+
{ internalType: 'address', name: 'to', type: 'address' },
62+
],
63+
name: 'bulkWithdraw',
64+
outputs: [{ internalType: 'uint256', name: 'assetsOut', type: 'uint256' }],
65+
stateMutability: 'nonpayable',
4366
type: 'function',
4467
},
4568
{
@@ -53,6 +76,13 @@ export const Teller = <const>[
5376
stateMutability: 'nonpayable',
5477
type: 'function',
5578
},
79+
{
80+
inputs: [],
81+
name: 'depositNonce',
82+
outputs: [{ internalType: 'uint96', name: '', type: 'uint96' }],
83+
stateMutability: 'view',
84+
type: 'function',
85+
},
5686
{
5787
inputs: [
5888
{ internalType: 'contract ERC20', name: 'depositAsset', type: 'address' },
@@ -68,4 +98,126 @@ export const Teller = <const>[
6898
stateMutability: 'nonpayable',
6999
type: 'function',
70100
},
101+
{
102+
inputs: [],
103+
name: 'isPaused',
104+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
105+
stateMutability: 'view',
106+
type: 'function',
107+
},
108+
{
109+
inputs: [{ internalType: 'contract ERC20', name: '', type: 'address' }],
110+
name: 'isSupported',
111+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
112+
stateMutability: 'view',
113+
type: 'function',
114+
},
115+
{
116+
inputs: [],
117+
name: 'owner',
118+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
119+
stateMutability: 'view',
120+
type: 'function',
121+
},
122+
{
123+
inputs: [],
124+
name: 'pause',
125+
outputs: [],
126+
stateMutability: 'nonpayable',
127+
type: 'function',
128+
},
129+
{
130+
inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
131+
name: 'publicDepositHistory',
132+
outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
133+
stateMutability: 'view',
134+
type: 'function',
135+
},
136+
{
137+
inputs: [
138+
{ internalType: 'uint256', name: 'nonce', type: 'uint256' },
139+
{ internalType: 'address', name: 'receiver', type: 'address' },
140+
{ internalType: 'address', name: 'depositAsset', type: 'address' },
141+
{ internalType: 'uint256', name: 'depositAmount', type: 'uint256' },
142+
{ internalType: 'uint256', name: 'shareAmount', type: 'uint256' },
143+
{ internalType: 'uint256', name: 'depositTimestamp', type: 'uint256' },
144+
{
145+
internalType: 'uint256',
146+
name: 'shareLockUpPeriodAtTimeOfDeposit',
147+
type: 'uint256',
148+
},
149+
],
150+
name: 'refundDeposit',
151+
outputs: [],
152+
stateMutability: 'nonpayable',
153+
type: 'function',
154+
},
155+
{
156+
inputs: [
157+
{ internalType: 'contract ERC20', name: 'asset', type: 'address' },
158+
],
159+
name: 'removeAsset',
160+
outputs: [],
161+
stateMutability: 'nonpayable',
162+
type: 'function',
163+
},
164+
{
165+
inputs: [
166+
{
167+
internalType: 'contract Authority',
168+
name: 'newAuthority',
169+
type: 'address',
170+
},
171+
],
172+
name: 'setAuthority',
173+
outputs: [],
174+
stateMutability: 'nonpayable',
175+
type: 'function',
176+
},
177+
{
178+
inputs: [
179+
{ internalType: 'uint64', name: '_shareLockPeriod', type: 'uint64' },
180+
],
181+
name: 'setShareLockPeriod',
182+
outputs: [],
183+
stateMutability: 'nonpayable',
184+
type: 'function',
185+
},
186+
{
187+
inputs: [],
188+
name: 'shareLockPeriod',
189+
outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
190+
stateMutability: 'view',
191+
type: 'function',
192+
},
193+
{
194+
inputs: [{ internalType: 'address', name: '', type: 'address' }],
195+
name: 'shareUnlockTime',
196+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
197+
stateMutability: 'view',
198+
type: 'function',
199+
},
200+
{
201+
inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
202+
name: 'transferOwnership',
203+
outputs: [],
204+
stateMutability: 'nonpayable',
205+
type: 'function',
206+
},
207+
{
208+
inputs: [],
209+
name: 'unpause',
210+
outputs: [],
211+
stateMutability: 'nonpayable',
212+
type: 'function',
213+
},
214+
{
215+
inputs: [],
216+
name: 'vault',
217+
outputs: [
218+
{ internalType: 'contract BoringVault', name: '', type: 'address' },
219+
],
220+
stateMutability: 'view',
221+
type: 'function',
222+
},
71223
];

lib/contracts/handlers/nucleus-teller-handler.ts

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ export type DepositWithPermitParams = PermitData & {
2727
minimumMint: bigint;
2828
};
2929

30+
export type BulkDepositParams = {
31+
account: Address;
32+
depositAsset: Address;
33+
depositAmount: bigint;
34+
minimumMint: bigint;
35+
};
36+
37+
export type BulkWithdrawParams = {
38+
account: Address;
39+
withdrawAsset: Address;
40+
shareAmount: bigint;
41+
minimumAssets: bigint;
42+
};
43+
3044
/**
3145
* Handler for the `Teller` contract from nucleus.
3246
*/
@@ -239,17 +253,46 @@ export class NucleusTellerHandler {
239253
const transact = () =>
240254
this.getContract().write.depositWithPermit(
241255
[depositAsset, amount, minimumMint, deadline, v, r, s],
242-
{
243-
account,
244-
chain: this.viemChain,
245-
},
256+
{ account, chain: this.viemChain },
246257
);
247258
const estimate = () =>
248259
this.getContract().estimateGas.depositWithPermit(
249260
[depositAsset, amount, minimumMint, deadline, v, r, s],
250-
{
251-
account,
252-
},
261+
{ account },
262+
);
263+
264+
return { transact, estimate };
265+
}
266+
267+
public async bulkWithdraw(params: BulkWithdrawParams) {
268+
const { account, withdrawAsset, shareAmount, minimumAssets } = params;
269+
270+
const transact = () =>
271+
this.getContract().write.bulkWithdraw(
272+
[withdrawAsset, shareAmount, minimumAssets, account],
273+
{ account, chain: this.viemChain },
274+
);
275+
const estimate = () =>
276+
this.getContract().estimateGas.bulkWithdraw(
277+
[withdrawAsset, shareAmount, minimumAssets, account],
278+
{ account },
279+
);
280+
281+
return { transact, estimate };
282+
}
283+
284+
public async bulkDeposit(params: BulkDepositParams) {
285+
const { account, depositAsset, depositAmount, minimumMint } = params;
286+
287+
const transact = () =>
288+
this.getContract().write.bulkDeposit(
289+
[depositAsset, depositAmount, minimumMint, account],
290+
{ account, chain: this.viemChain },
291+
);
292+
const estimate = () =>
293+
this.getContract().estimateGas.bulkDeposit(
294+
[depositAsset, depositAmount, minimumMint, account],
295+
{ account },
253296
);
254297

255298
return { transact, estimate };

0 commit comments

Comments
 (0)