Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 165 additions & 13 deletions lib/contracts/abis/mainnet/Teller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,57 @@ export const Teller = <const>[
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',
},
{
Expand All @@ -53,6 +76,13 @@ export const Teller = <const>[
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' },
Expand All @@ -68,4 +98,126 @@ export const Teller = <const>[
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',
},
];
57 changes: 50 additions & 7 deletions lib/contracts/handlers/nucleus-teller-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 };
Expand Down
Loading