diff --git a/docs/docs/handlers/index.mdx b/docs/docs/handlers/index.mdx index 49d7306..2957c04 100644 --- a/docs/docs/handlers/index.mdx +++ b/docs/docs/handlers/index.mdx @@ -14,8 +14,6 @@ We currently have the following handlers. For interacting with the `ERC20Permit` contract for any supported token. - [PufLockerHandler](../api/contracts/handlers/puf-locker-handler.md)\ For interacting with Puffer's `PufLocker` contract. -- [PufTokenHandler](../api/contracts/handlers/puf-token-handler.md)\ - For interacting with Puffer's `PufToken` contract for wrapped tokens. - [PufferDepositorHandler](../api/contracts/handlers/puffer-depositor-handler.md)\ For interacting with Puffer's `PufferDepositor` contract. - [PufferL2DepositorHandler](../api/contracts/handlers/puffer-l2-depositor-handler.md)\ @@ -26,6 +24,14 @@ We currently have the following handlers. For interacting with Puffer's `L1RewardManager` contract. - [L2RewardManagerHandler](../api/contracts/handlers/l2-reward-manager-handler.md)\ For interacting with Puffer's `L2RewardManager` contract. +- [L2RewardManagerHandler](../api/contracts/handlers/l2-reward-manager-handler.md)\ + For interacting with Puffer's `L2RewardManager` contract. +- [NucleusBoringVaultHandler](../api/contracts/handlers/nucleus-boring-vault-handler.md)\ + For interacting with Nucleus's `BoringVault` contract. +- [NucleusTellerHandler](../api/contracts/handlers/nucleus-teller-handler.md)\ + For interacting with Nucleus's `Teller` contract. +- [NucleusAccountantHandler](../api/contracts/handlers/nucleus-accountant-handler.md)\ + For interacting with Nucleus's `Accountant` contract. More details about each handler can be found in their respective API documentation. diff --git a/lib/api/puffer-client.ts b/lib/api/puffer-client.ts index 2be5454..53e4612 100644 --- a/lib/api/puffer-client.ts +++ b/lib/api/puffer-client.ts @@ -8,13 +8,16 @@ import { import { Chain, VIEM_CHAINS } from '../chains/constants'; import { PufferVaultHandler } from '../contracts/handlers/puffer-vault-handler'; import { PufferDepositorHandler } from '../contracts/handlers/puffer-depositor-handler'; -import { PufTokenHandler } from '../contracts/handlers/puf-token-handler'; import { PufferL2DepositorHandler } from '../contracts/handlers/puffer-l2-depositor-handler'; import { ERC20PermitHandler } from '../contracts/handlers/erc20-permit-handler'; import { PufLockerHandler } from '../contracts/handlers/puf-locker-handler'; import { L2RewardManagerHandler } from '../contracts/handlers/l2-reward-manager-handler'; import { L1RewardManagerHandler } from '../contracts/handlers/l1-reward-manager-handler'; import { PufferWithdrawalManagerHandler } from '../contracts/handlers/puffer-withdrawal-manager-handler'; +import { NucleusBoringVaultHandler } from '../contracts/handlers/nucleus-boring-vault-handler'; +import { NucleusTellerHandler } from '../contracts/handlers/nucleus-teller-handler'; +import { NucleusAccountantHandler } from '../contracts/handlers/nucleus-accountant-handler'; + /** * The core class and the main entry point of the Puffer SDK. */ @@ -31,8 +34,6 @@ export class PufferClient { public depositor: PufferDepositorHandler; /** Handler for the `PufferL2Depositor` contract. */ public l2Depositor: PufferL2DepositorHandler; - /** Handler for the `PufToken` contract. */ - public pufToken: PufTokenHandler; /** Handler for the `PufLocker` contract. */ public pufLocker: PufLockerHandler; /** Handler for the `L2RewardManager` contract. */ @@ -41,6 +42,12 @@ export class PufferClient { public l1RewardManager: L1RewardManagerHandler; /** Handler for the `PufferWithdrawalManager` contract. */ public pufferWithdrawalManager: PufferWithdrawalManagerHandler; + /** Handler for the `NucleusBoringVault` contract. */ + public nucleusBoringVault: NucleusBoringVaultHandler; + /** Handler for the `NucleusTeller` contract. */ + public nucleusTeller: NucleusTellerHandler; + /** Handler for the `NucleusAccountant` contract. */ + public nucleusAccountant: NucleusAccountantHandler; /** * Create the Puffer Client. @@ -87,11 +94,6 @@ export class PufferClient { this.walletClient, this.publicClient, ); - this.pufToken = new PufTokenHandler( - chain, - this.walletClient, - this.publicClient, - ); this.l2Depositor = new PufferL2DepositorHandler( chain, this.walletClient, @@ -117,6 +119,21 @@ export class PufferClient { this.walletClient, this.publicClient, ); + this.nucleusBoringVault = new NucleusBoringVaultHandler( + chain, + this.walletClient, + this.publicClient, + ); + this.nucleusTeller = new NucleusTellerHandler( + chain, + this.walletClient, + this.publicClient, + ); + this.nucleusAccountant = new NucleusAccountantHandler( + chain, + this.walletClient, + this.publicClient, + ); } /** diff --git a/lib/contracts/abis/mainnet/Accountant.ts b/lib/contracts/abis/mainnet/Accountant.ts new file mode 100644 index 0000000..ea8797d --- /dev/null +++ b/lib/contracts/abis/mainnet/Accountant.ts @@ -0,0 +1,490 @@ +export const Accountant = [ + { + inputs: [ + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'address', name: '_vault', type: 'address' }, + { internalType: 'address', name: 'payoutAddress', type: 'address' }, + { internalType: 'uint96', name: 'startingExchangeRate', type: 'uint96' }, + { internalType: 'address', name: '_base', type: 'address' }, + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeUpper', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeLower', + type: 'uint16', + }, + { + internalType: 'uint32', + name: 'minimumUpdateDelayInSeconds', + type: 'uint32', + }, + { internalType: 'uint16', name: 'managementFee', type: 'uint16' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'AccountantWithRateProviders__LowerBoundTooLarge', + type: 'error', + }, + { + inputs: [], + name: 'AccountantWithRateProviders__ManagementFeeTooLarge', + type: 'error', + }, + { + inputs: [], + name: 'AccountantWithRateProviders__OnlyCallableByBoringVault', + type: 'error', + }, + { inputs: [], name: 'AccountantWithRateProviders__Paused', type: 'error' }, + { + inputs: [], + name: 'AccountantWithRateProviders__UpdateDelayTooLarge', + type: 'error', + }, + { + inputs: [], + name: 'AccountantWithRateProviders__UpperBoundTooSmall', + type: 'error', + }, + { + inputs: [], + name: 'AccountantWithRateProviders__ZeroFeesOwed', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'AuthorityUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint32', + name: 'oldDelay', + type: 'uint32', + }, + { + indexed: false, + internalType: 'uint32', + name: 'newDelay', + type: 'uint32', + }, + ], + name: 'DelayInSecondsUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint96', + name: 'oldRate', + type: 'uint96', + }, + { + indexed: false, + internalType: 'uint96', + name: 'newRate', + type: 'uint96', + }, + { + indexed: false, + internalType: 'uint64', + name: 'currentTime', + type: 'uint64', + }, + ], + name: 'ExchangeRateUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'feeAsset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'FeesClaimed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint16', + name: 'oldBound', + type: 'uint16', + }, + { + indexed: false, + internalType: 'uint16', + name: 'newBound', + type: 'uint16', + }, + ], + name: 'LowerBoundUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint16', + name: 'oldFee', + type: 'uint16', + }, + { + indexed: false, + internalType: 'uint16', + name: 'newFee', + type: 'uint16', + }, + ], + name: 'ManagementFeeUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Paused', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'oldPayout', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'newPayout', + type: 'address', + }, + ], + name: 'PayoutAddressUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { indexed: false, internalType: 'bool', name: 'isPegged', type: 'bool' }, + { + indexed: false, + internalType: 'address', + name: 'rateProvider', + type: 'address', + }, + ], + name: 'RateProviderUpdated', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Unpaused', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint16', + name: 'oldBound', + type: 'uint16', + }, + { + indexed: false, + internalType: 'uint16', + name: 'newBound', + type: 'uint16', + }, + ], + name: 'UpperBoundUpdated', + type: 'event', + }, + { + inputs: [], + name: 'accountantState', + outputs: [ + { internalType: 'address', name: 'payoutAddress', type: 'address' }, + { internalType: 'uint128', name: 'feesOwedInBase', type: 'uint128' }, + { + internalType: 'uint128', + name: 'totalSharesLastUpdate', + type: 'uint128', + }, + { internalType: 'uint96', name: 'exchangeRate', type: 'uint96' }, + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeUpper', + type: 'uint16', + }, + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeLower', + type: 'uint16', + }, + { internalType: 'uint64', name: 'lastUpdateTimestamp', type: 'uint64' }, + { internalType: 'bool', name: 'isPaused', type: 'bool' }, + { + internalType: 'uint32', + name: 'minimumUpdateDelayInSeconds', + type: 'uint32', + }, + { internalType: 'uint16', name: 'managementFee', type: 'uint16' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'authority', + outputs: [ + { internalType: 'contract Authority', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'base', + outputs: [{ internalType: 'contract ERC20', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'feeAsset', type: 'address' }, + ], + name: 'claimFees', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getRate', + outputs: [{ internalType: 'uint256', name: 'rate', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'quote', type: 'address' }, + ], + name: 'getRateInQuote', + outputs: [ + { internalType: 'uint256', name: 'rateInQuote', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'quote', type: 'address' }, + ], + name: 'getRateInQuoteSafe', + outputs: [ + { internalType: 'uint256', name: 'rateInQuote', type: 'uint256' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getRateSafe', + outputs: [{ internalType: 'uint256', name: 'rate', type: 'uint256' }], + 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: 'contract ERC20', name: '', type: 'address' }], + name: 'rateProviderData', + outputs: [ + { internalType: 'bool', name: 'isPeggedToBase', type: 'bool' }, + { + internalType: 'contract IRateProvider', + name: 'rateProvider', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'setAuthority', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + { internalType: 'bool', name: 'isPeggedToBase', type: 'bool' }, + { internalType: 'address', name: 'rateProvider', type: 'address' }, + ], + name: 'setRateProviderData', + outputs: [], + stateMutability: 'nonpayable', + 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: [ + { + internalType: 'uint32', + name: 'minimumUpdateDelayInSeconds', + type: 'uint32', + }, + ], + name: 'updateDelay', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint96', name: 'newExchangeRate', type: 'uint96' }, + ], + name: 'updateExchangeRate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeLower', + type: 'uint16', + }, + ], + name: 'updateLower', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint16', name: 'managementFee', type: 'uint16' }], + name: 'updateManagementFee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'payoutAddress', type: 'address' }, + ], + name: 'updatePayoutAddress', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint16', + name: 'allowedExchangeRateChangeUpper', + type: 'uint16', + }, + ], + name: 'updateUpper', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'vault', + outputs: [ + { internalType: 'contract BoringVault', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, +]; diff --git a/lib/contracts/abis/mainnet/BoringVault.ts b/lib/contracts/abis/mainnet/BoringVault.ts new file mode 100644 index 0000000..2bc372d --- /dev/null +++ b/lib/contracts/abis/mainnet/BoringVault.ts @@ -0,0 +1,403 @@ +export const BoringVault = [ + { + inputs: [ + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'string', name: '_name', type: 'string' }, + { internalType: 'string', name: '_symbol', type: 'string' }, + { internalType: 'uint8', name: '_decimals', type: 'uint8' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [{ internalType: 'address', name: 'target', type: 'address' }], + name: 'AddressEmptyCode', + type: 'error', + }, + { inputs: [], name: 'FailedCall', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'balance', type: 'uint256' }, + { internalType: 'uint256', name: 'needed', type: 'uint256' }, + ], + name: 'InsufficientBalance', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'AuthorityUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Enter', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Exit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'from', type: 'address' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + ], + name: 'allowance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'approve', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'authority', + outputs: [ + { internalType: 'contract Authority', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'balanceOf', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'assetAmount', type: 'uint256' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'shareAmount', type: 'uint256' }, + ], + name: 'enter', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + { internalType: 'uint256', name: 'assetAmount', type: 'uint256' }, + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'uint256', name: 'shareAmount', type: 'uint256' }, + ], + name: 'exit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'hook', + outputs: [ + { + internalType: 'contract BeforeTransferHook', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address[]', name: 'targets', type: 'address[]' }, + { internalType: 'bytes[]', name: 'data', type: 'bytes[]' }, + { internalType: 'uint256[]', name: 'values', type: 'uint256[]' }, + ], + name: 'manage', + outputs: [{ internalType: 'bytes[]', name: 'results', type: 'bytes[]' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'target', type: 'address' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + ], + name: 'manage', + outputs: [{ internalType: 'bytes', name: 'result', type: 'bytes' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'nonces', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'uint256[]', name: '', type: 'uint256[]' }, + { internalType: 'uint256[]', name: '', type: 'uint256[]' }, + { internalType: 'bytes', name: '', type: 'bytes' }, + ], + name: 'onERC1155BatchReceived', + outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'uint256', name: '', type: 'uint256' }, + { internalType: 'uint256', name: '', type: 'uint256' }, + { internalType: 'bytes', name: '', type: 'bytes' }, + ], + name: 'onERC1155Received', + outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'uint256', name: '', type: 'uint256' }, + { internalType: 'bytes', name: '', type: 'bytes' }, + ], + name: 'onERC721Received', + outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'owner', type: 'address' }, + { internalType: 'address', name: 'spender', type: 'address' }, + { internalType: 'uint256', name: 'value', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + { internalType: 'uint8', name: 'v', type: 'uint8' }, + { internalType: 'bytes32', name: 'r', type: 'bytes32' }, + { internalType: 'bytes32', name: 's', type: 'bytes32' }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'setAuthority', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_hook', type: 'address' }], + name: 'setBeforeTransferHook', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }], + name: 'supportsInterface', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'from', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { stateMutability: 'payable', type: 'receive' }, +]; diff --git a/lib/contracts/abis/mainnet/PufToken.ts b/lib/contracts/abis/mainnet/PufToken.ts deleted file mode 100644 index a124321..0000000 --- a/lib/contracts/abis/mainnet/PufToken.ts +++ /dev/null @@ -1,879 +0,0 @@ -export const PufToken = [ - { - type: 'constructor', - inputs: [ - { - name: 'token', - type: 'address', - internalType: 'address', - }, - { - name: 'tokenName', - type: 'string', - internalType: 'string', - }, - { - name: 'tokenSymbol', - type: 'string', - internalType: 'string', - }, - { - name: 'depositCap', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'DOMAIN_SEPARATOR', - inputs: [], - outputs: [ - { - name: '', - type: 'bytes32', - internalType: 'bytes32', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'PUFFER_FACTORY', - inputs: [], - outputs: [ - { - name: '', - type: 'address', - internalType: 'contract PufferL2Depositor', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'TOKEN', - inputs: [], - outputs: [ - { - name: '', - type: 'address', - internalType: 'contract ERC20', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'allowance', - inputs: [ - { - name: 'owner', - type: 'address', - internalType: 'address', - }, - { - name: 'spender', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'approve', - inputs: [ - { - name: 'spender', - type: 'address', - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [ - { - name: '', - type: 'bool', - internalType: 'bool', - }, - ], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'balanceOf', - inputs: [ - { - name: 'account', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'decimals', - inputs: [], - outputs: [ - { - name: '', - type: 'uint8', - internalType: 'uint8', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'deposit', - inputs: [ - { - name: 'from', - type: 'address', - internalType: 'address', - }, - { - name: 'account', - type: 'address', - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'eip712Domain', - inputs: [], - outputs: [ - { - name: 'fields', - type: 'bytes1', - internalType: 'bytes1', - }, - { - name: 'name', - type: 'string', - internalType: 'string', - }, - { - name: 'version', - type: 'string', - internalType: 'string', - }, - { - name: 'chainId', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'verifyingContract', - type: 'address', - internalType: 'address', - }, - { - name: 'salt', - type: 'bytes32', - internalType: 'bytes32', - }, - { - name: 'extensions', - type: 'uint256[]', - internalType: 'uint256[]', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'migrate', - inputs: [ - { - name: 'amount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'migratorContract', - type: 'address', - internalType: 'address', - }, - { - name: 'destination', - type: 'address', - internalType: 'address', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'migrateWithSignature', - inputs: [ - { - name: 'depositor', - type: 'address', - internalType: 'address', - }, - { - name: 'migratorContract', - type: 'address', - internalType: 'address', - }, - { - name: 'destination', - type: 'address', - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'signatureExpiry', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'stakerSignature', - type: 'bytes', - internalType: 'bytes', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'name', - inputs: [], - outputs: [ - { - name: '', - type: 'string', - internalType: 'string', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'nonces', - inputs: [ - { - name: 'owner', - type: 'address', - internalType: 'address', - }, - ], - outputs: [ - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'permit', - inputs: [ - { - name: 'owner', - type: 'address', - internalType: 'address', - }, - { - name: 'spender', - type: 'address', - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'deadline', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'v', - type: 'uint8', - internalType: 'uint8', - }, - { - name: 'r', - type: 'bytes32', - internalType: 'bytes32', - }, - { - name: 's', - type: 'bytes32', - internalType: 'bytes32', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'setDepositCap', - inputs: [ - { - name: 'newDepositCap', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'symbol', - inputs: [], - outputs: [ - { - name: '', - type: 'string', - internalType: 'string', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'totalDepositCap', - inputs: [], - outputs: [ - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'totalSupply', - inputs: [], - outputs: [ - { - name: '', - type: 'uint256', - internalType: 'uint256', - }, - ], - stateMutability: 'view', - }, - { - type: 'function', - name: 'transfer', - inputs: [ - { - name: 'to', - type: 'address', - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [ - { - name: '', - type: 'bool', - internalType: 'bool', - }, - ], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'transferFrom', - inputs: [ - { - name: 'from', - type: 'address', - internalType: 'address', - }, - { - name: 'to', - type: 'address', - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [ - { - name: '', - type: 'bool', - internalType: 'bool', - }, - ], - stateMutability: 'nonpayable', - }, - { - type: 'function', - name: 'withdraw', - inputs: [ - { - name: 'recipient', - type: 'address', - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - internalType: 'uint256', - }, - ], - outputs: [], - stateMutability: 'nonpayable', - }, - { - type: 'event', - name: 'Approval', - inputs: [ - { - name: 'owner', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'spender', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'event', - name: 'DepositCapChanged', - inputs: [ - { - name: 'oldDepositCap', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - { - name: 'newDepositCap', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'event', - name: 'Deposited', - inputs: [ - { - name: 'from', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'to', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'event', - name: 'EIP712DomainChanged', - inputs: [], - anonymous: false, - }, - { - type: 'event', - name: 'Migrated', - inputs: [ - { - name: 'depositor', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'destination', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'migratorContract', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'event', - name: 'Transfer', - inputs: [ - { - name: 'from', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'to', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'value', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'event', - name: 'Withdrawn', - inputs: [ - { - name: 'from', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'to', - type: 'address', - indexed: true, - internalType: 'address', - }, - { - name: 'amount', - type: 'uint256', - indexed: false, - internalType: 'uint256', - }, - ], - anonymous: false, - }, - { - type: 'error', - name: 'AddressEmptyCode', - inputs: [ - { - name: 'target', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'AddressInsufficientBalance', - inputs: [ - { - name: 'account', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ECDSAInvalidSignature', - inputs: [], - }, - { - type: 'error', - name: 'ECDSAInvalidSignatureLength', - inputs: [ - { - name: 'length', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - type: 'error', - name: 'ECDSAInvalidSignatureS', - inputs: [ - { - name: 's', - type: 'bytes32', - internalType: 'bytes32', - }, - ], - }, - { - type: 'error', - name: 'ERC20InsufficientAllowance', - inputs: [ - { - name: 'spender', - type: 'address', - internalType: 'address', - }, - { - name: 'allowance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'needed', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - type: 'error', - name: 'ERC20InsufficientBalance', - inputs: [ - { - name: 'sender', - type: 'address', - internalType: 'address', - }, - { - name: 'balance', - type: 'uint256', - internalType: 'uint256', - }, - { - name: 'needed', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - type: 'error', - name: 'ERC20InvalidApprover', - inputs: [ - { - name: 'approver', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ERC20InvalidReceiver', - inputs: [ - { - name: 'receiver', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ERC20InvalidSender', - inputs: [ - { - name: 'sender', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ERC20InvalidSpender', - inputs: [ - { - name: 'spender', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ERC2612ExpiredSignature', - inputs: [ - { - name: 'deadline', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - type: 'error', - name: 'ERC2612InvalidSigner', - inputs: [ - { - name: 'signer', - type: 'address', - internalType: 'address', - }, - { - name: 'owner', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'ExpiredSignature', - inputs: [], - }, - { - type: 'error', - name: 'FailedInnerCall', - inputs: [], - }, - { - type: 'error', - name: 'InvalidAccount', - inputs: [], - }, - { - type: 'error', - name: 'InvalidAccountNonce', - inputs: [ - { - name: 'account', - type: 'address', - internalType: 'address', - }, - { - name: 'currentNonce', - type: 'uint256', - internalType: 'uint256', - }, - ], - }, - { - type: 'error', - name: 'InvalidAmount', - inputs: [], - }, - { - type: 'error', - name: 'InvalidShortString', - inputs: [], - }, - { - type: 'error', - name: 'InvalidSignature', - inputs: [], - }, - { - type: 'error', - name: 'MigratorContractNotAllowed', - inputs: [ - { - name: 'migrator', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'SafeERC20FailedOperation', - inputs: [ - { - name: 'token', - type: 'address', - internalType: 'address', - }, - ], - }, - { - type: 'error', - name: 'StringTooLong', - inputs: [ - { - name: 'str', - type: 'string', - internalType: 'string', - }, - ], - }, - { - type: 'error', - name: 'TotalDepositCapReached', - inputs: [], - }, - { - type: 'error', - name: 'Unauthorized', - inputs: [], - }, -]; diff --git a/lib/contracts/abis/mainnet/Teller.ts b/lib/contracts/abis/mainnet/Teller.ts new file mode 100644 index 0000000..3259c79 --- /dev/null +++ b/lib/contracts/abis/mainnet/Teller.ts @@ -0,0 +1,446 @@ +export const Teller = [ + { + inputs: [ + { internalType: 'address', name: '_owner', type: 'address' }, + { internalType: 'address', name: '_vault', type: 'address' }, + { internalType: 'address', name: '_accountant', type: 'address' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__AssetNotSupported', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__BadDepositHash', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__MinimumAssetsNotMet', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__MinimumMintNotMet', + type: 'error', + }, + { inputs: [], name: 'TellerWithMultiAssetSupport__Paused', type: 'error' }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__PermitFailedAndAllowanceTooLow', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__ShareLockPeriodTooLong', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__SharesAreLocked', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__SharesAreUnLocked', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__ZeroAssets', + type: 'error', + }, + { + inputs: [], + name: 'TellerWithMultiAssetSupport__ZeroShares', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'AssetAdded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + ], + name: 'AssetRemoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'contract Authority', + name: 'newAuthority', + type: 'address', + }, + ], + name: 'AuthorityUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'depositAmount', + type: 'uint256', + }, + ], + name: 'BulkDeposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'asset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shareAmount', + type: 'uint256', + }, + ], + name: 'BulkWithdraw', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + indexed: true, + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'depositAsset', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'depositAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shareAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'depositTimestamp', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shareLockPeriodAtTimeOfDeposit', + type: 'uint256', + }, + ], + name: 'Deposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bytes32', + name: 'depositHash', + type: 'bytes32', + }, + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + ], + name: 'DepositRefunded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'user', type: 'address' }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Paused', type: 'event' }, + { anonymous: false, inputs: [], name: 'Unpaused', type: 'event' }, + { + inputs: [], + name: 'accountant', + outputs: [ + { + internalType: 'contract AccountantWithRateProviders', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'asset', type: 'address' }, + ], + name: 'addAsset', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'authority', + outputs: [ + { internalType: 'contract Authority', name: '', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'from', type: 'address' }], + name: 'beforeTransfer', + outputs: [], + stateMutability: 'view', + type: 'function', + }, + { + 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: [ + { + 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', + }, + { + inputs: [ + { internalType: 'contract ERC20', name: 'depositAsset', type: 'address' }, + { internalType: 'uint256', name: 'depositAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'minimumMint', type: 'uint256' }, + ], + name: 'deposit', + outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + 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' }, + { internalType: 'uint256', name: 'depositAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'minimumMint', type: 'uint256' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + { internalType: 'uint8', name: 'v', type: 'uint8' }, + { internalType: 'bytes32', name: 'r', type: 'bytes32' }, + { internalType: 'bytes32', name: 's', type: 'bytes32' }, + ], + name: 'depositWithPermit', + outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + 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/abis/nucleus-accountant-abis.ts b/lib/contracts/abis/nucleus-accountant-abis.ts new file mode 100644 index 0000000..2268a01 --- /dev/null +++ b/lib/contracts/abis/nucleus-accountant-abis.ts @@ -0,0 +1,6 @@ +import { Chain } from '../../chains/constants'; +import { Accountant } from './mainnet/Accountant'; + +export const NUCLEUS_ACCOUNTANT_ABIS = { + [Chain.Mainnet]: { Accountant }, +}; diff --git a/lib/contracts/abis/nucleus-boring-vault-abis.ts b/lib/contracts/abis/nucleus-boring-vault-abis.ts new file mode 100644 index 0000000..5bd0e70 --- /dev/null +++ b/lib/contracts/abis/nucleus-boring-vault-abis.ts @@ -0,0 +1,6 @@ +import { Chain } from '../../chains/constants'; +import { BoringVault } from './mainnet/BoringVault'; + +export const NUCLEUS_BORING_VAULT_ABIS = { + [Chain.Mainnet]: { BoringVault }, +}; diff --git a/lib/contracts/abis/nucleus-teller-abis.ts b/lib/contracts/abis/nucleus-teller-abis.ts new file mode 100644 index 0000000..83ac8e0 --- /dev/null +++ b/lib/contracts/abis/nucleus-teller-abis.ts @@ -0,0 +1,6 @@ +import { Chain } from '../../chains/constants'; +import { Teller } from './mainnet/Teller'; + +export const NUCLEUS_TELLER_ABIS = { + [Chain.Mainnet]: { Teller }, +}; diff --git a/lib/contracts/abis/puf-token-abis.ts b/lib/contracts/abis/puf-token-abis.ts deleted file mode 100644 index e5b4732..0000000 --- a/lib/contracts/abis/puf-token-abis.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Chain } from '../../chains/constants'; -import { PufToken } from './mainnet/PufToken'; - -export const PUF_TOKEN_ABIS = { - [Chain.Mainnet]: { PufToken }, - [Chain.Holesky]: { PufToken }, -}; diff --git a/lib/contracts/addresses.ts b/lib/contracts/addresses.ts index d331c08..beff0d4 100644 --- a/lib/contracts/addresses.ts +++ b/lib/contracts/addresses.ts @@ -14,6 +14,9 @@ export const CONTRACT_ADDRESSES = { // Deployed on a fork // https://dashboard.tenderly.co/explorer/fork/f7fd7621-7280-47e5-8521-81b24142814f/transactions. PufferWithdrawalManager: '0x8a253974f1de9f64d79f1eaaf850faf406802fce', + NucleusBoringVault: '0x196ead472583bc1e9af7a05f860d9857e1bd3dcc', + NucleusAccountant: '0xa9fb7e2922216debe3fd5e1bbe7591ee446dc21c', + NucleusTeller: '0x08eb2eccdf6ebd7aba601791f23ec5b5f68a1d53', }, [Chain.Holesky]: { PufferVault: '0x9196830bB4c05504E0A8475A0aD566AceEB6BeC9', @@ -22,7 +25,11 @@ export const CONTRACT_ADDRESSES = { PufLocker: '0xa58983ad0899a452b7420bc57228e329d7ba92b6', L1RewardManager: '0x10f970bcb84B82B82a65eBCbF45F26dD26D69F12', L2RewardManager: '0x58C046794f69A8830b0BE737022a45b4acd01dE5', + // Nucleus contracts are not deployed to holesky. PufferWithdrawalManager: '0x5A3E1069B66800c0ecbc91bd81b1AE4D1804DBc4', + NucleusBoringVault: '0x0000000000000000000000000000000000000000', + NucleusAccountant: '0x0000000000000000000000000000000000000000', + NucleusTeller: '0x0000000000000000000000000000000000000000', }, [Chain.Base]: { L2RewardManager: '0xF9Dd335bF363b2E4ecFe3c94A86EBD7Dd3Dcf0e7', diff --git a/lib/contracts/handlers/erc20-permit-handler.ts b/lib/contracts/handlers/erc20-permit-handler.ts index 4b748eb..336610c 100644 --- a/lib/contracts/handlers/erc20-permit-handler.ts +++ b/lib/contracts/handlers/erc20-permit-handler.ts @@ -73,7 +73,7 @@ export class ERC20PermitHandler { /** * Process and get permit signature for the given token to perform - * transactions through the `PufferDepositor` contract. + * transactions without calling `approve()`. * * @param ownerAddress Address of the token owner. * @param spenderAddress Address of the spender who needs the permit. @@ -125,10 +125,6 @@ export class ERC20PermitHandler { return { ...parseSignature(signature), deadline }; } - private getPermitVersion(token: AnyToken): string { - return TOKENS_PERMIT_VERSION[token]; - } - /** * Approve transaction for the spender to spend the owner's tokens. * @@ -148,6 +144,10 @@ export class ERC20PermitHandler { }); } + private getPermitVersion(token: AnyToken): string { + return TOKENS_PERMIT_VERSION[token]; + } + private getPermitSalt(token: AnyToken) { return TOKENS_SALT?.[token]?.[this.chain]; } diff --git a/lib/contracts/handlers/nucleus-accountant-handler.ts b/lib/contracts/handlers/nucleus-accountant-handler.ts new file mode 100644 index 0000000..36ff1e0 --- /dev/null +++ b/lib/contracts/handlers/nucleus-accountant-handler.ts @@ -0,0 +1,108 @@ +/* istanbul ignore file */ + +import { + WalletClient, + PublicClient, + getContract, + Address, + GetContractReturnType, +} from 'viem'; +import { Chain } from '../../chains/constants'; +import { CONTRACT_ADDRESSES } from '../addresses'; +import { NUCLEUS_ACCOUNTANT_ABIS } from '../abis/nucleus-accountant-abis'; + +/** + * Handler for the `Accountant` contract from nucleus. + */ +export class NucleusAccountantHandler { + /** + * Create the handler for processing tokens. + * + * @param chain Chain to use for the client. + * @param walletClient The wallet client to use for wallet + * interactions. + * @param publicClient The public client to use for public + * interactions. + */ + constructor( + private chain: Chain, + private walletClient: WalletClient, + private publicClient: PublicClient, + ) {} + + /** + * Get the contract. This is a method because the typings are complex + * and lost when trying to make it a member. + * + * @returns The viem contract. + */ + public getContract() { + const address = CONTRACT_ADDRESSES[this.chain].NucleusAccountant as Address; + const abi = NUCLEUS_ACCOUNTANT_ABIS[this.chain].Accountant; + const client = { public: this.publicClient, wallet: this.walletClient }; + + return getContract({ address, abi, client }) as GetContractReturnType< + typeof abi, + typeof client, + Address + >; + } + + /** + * Get the rate provider data for the given token address. + * + * @param tokenAddress Address of the token. + * @returns Rate provider data for the given token address. + */ + public async rateProviderData(tokenAddress: Address) { + const [isPeggedToBase, rateProvider] = + await this.getContract().read.rateProviderData([tokenAddress]); + + return { isPeggedToBase, rateProvider }; + } + + /** + * Get the vault for the given token address. + * + * @returns Vault for the given token address. + */ + public vault() { + return this.getContract().read.vault(); + } + + /** + * Get the rate for the given token address. + * + * @returns Rate for the given token address. + */ + public getRate() { + return this.getContract().read.getRate(); + } + + /** + * Get the rate for the given token address for safe. + * + * @returns Rate for the given token address for safe. + */ + public getRateSafe() { + return this.getContract().read.getRateSafe(); + } + + /** + * Get the rate from the given quote address. + * + * @returns Rate for the given quote address. + */ + public getRateInQuote(quoteAddress: Address) { + return this.getContract().read.getRateInQuote([quoteAddress]); + } + + /** + * Get the rate from the given quote address for safe. + * + * @returns Rate for the given quote address for safe. + */ + public getRateInQuoteSafe(quoteAddress: Address) { + return this.getContract().read.getRateInQuoteSafe([quoteAddress]); + } +} diff --git a/lib/contracts/handlers/nucleus-boring-vault-handler.ts b/lib/contracts/handlers/nucleus-boring-vault-handler.ts new file mode 100644 index 0000000..5ea4673 --- /dev/null +++ b/lib/contracts/handlers/nucleus-boring-vault-handler.ts @@ -0,0 +1,221 @@ +/* istanbul ignore file */ + +import { + WalletClient, + PublicClient, + getContract, + Address, + GetContractReturnType, +} from 'viem'; +import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants'; +import { NUCLEUS_BORING_VAULT_ABIS } from '../abis/nucleus-boring-vault-abis'; +import { CONTRACT_ADDRESSES } from '../addresses'; + +export type PermitParams = { + owner: Address; + spender: Address; + value: bigint; + deadline: bigint; + v: number; + r: Address; + s: Address; +}; + +/** + * Handler for the `BoringVault` contract for a given token exposing + * methods to interact with the contract. + */ +export class NucleusBoringVaultHandler { + private viemChain: ViemChain; + + /** + * Create the handler for processing UniFi tokens. + * + * @param chain Chain to use for the client. + * @param walletClient The wallet client to use for wallet + * interactions. + * @param publicClient The public client to use for public + * interactions. + */ + constructor( + private chain: Chain, + private walletClient: WalletClient, + private publicClient: PublicClient, + ) { + this.viemChain = VIEM_CHAINS[chain]; + } + + /** + * Get the contract. This is a method because the typings are complex + * and lost when trying to make it a member. + * + * @returns The viem contract. + */ + public getContract() { + const address = CONTRACT_ADDRESSES[this.chain] + .NucleusBoringVault as Address; + const abi = NUCLEUS_BORING_VAULT_ABIS[this.chain].BoringVault; + const client = { public: this.publicClient, wallet: this.walletClient }; + + return getContract({ address, abi, client }) as GetContractReturnType< + typeof abi, + typeof client, + Address + >; + } + + /** + * Get the allowance for the given owner and spender. + * + * @param owner Address of the owner. + * @param spender Address of the spender. + * @returns Allowance for the given owner and spender. + */ + public getAllowance(owner: Address, spender: Address) { + return this.getContract().read.allowance([owner, spender]); + } + + /** + * Get the total supply of the token. + * + * @returns Total supply of the token. + */ + public getTotalSupply() { + return this.getContract().read.totalSupply(); + } + + /** + * Check the token balance of the wallet. + * + * @param walletAddress Wallet address to check the balance of. + * @returns Token balance in wei. + */ + public balanceOf(walletAddress: Address) { + return this.getContract().read.balanceOf([walletAddress]); + } + + /** + * Get the total supply of the token. + * + * @returns Total supply of the token. + */ + public totalSupply() { + return this.getContract().read.totalSupply(); + } + + /** + * Approve transaction for the spender to spend the owner's tokens. + * + * @param walletAddress Address of the caller of the transaction. + * @param spenderAddress Address of the spender. + * @param value Value to approve for the spender. + * @returns Hash of the transaction. + */ + public approve( + walletAddress: Address, + spenderAddress: Address, + value: bigint, + ) { + return this.getContract().write.approve([spenderAddress, value], { + account: walletAddress, + chain: this.viemChain, + }); + } + + /** + * Transfer tokens from the owner's wallet to the given address. + * + * @param walletAddress Address of the owner's wallet. + * @param toAddress Address to transfer the tokens to. + * @param value Value to transfer. + * @returns `transact: () => Promise
` - Used to make the + * transaction with the given value. + * + * `estimate: () => Promise` - Gas estimate of the + * transaction. + */ + public transfer(walletAddress: Address, toAddress: Address, value: bigint) { + const transact = () => + this.getContract().write.transfer([toAddress, value], { + account: walletAddress, + chain: this.viemChain, + }); + const estimate = () => + this.getContract().estimateGas.transfer([toAddress, value], { + account: walletAddress, + }); + + return { transact, estimate }; + } + + /** + * Transfer tokens from the given address to another address. + * + * @param walletAddress Address of the caller of the transaction. + * @param fromAddress Address to transfer the tokens from. + * @param toAddress Address to transfer the tokens to. + * @param value Value to transfer. + * @returns `transact: () => Promise
` - Used to + * make the transaction with the given value. + * + * `estimate: () => Promise` - Gas estimate of the + * transaction. + */ + public transferFrom( + walletAddress: Address, + fromAddress: Address, + toAddress: Address, + value: bigint, + ) { + const transact = () => + this.getContract().write.transferFrom([fromAddress, toAddress, value], { + account: walletAddress, + chain: this.viemChain, + }); + const estimate = () => + this.getContract().estimateGas.transfer([toAddress, value], { + account: walletAddress, + }); + + return { transact, estimate }; + } + + /** + * Get permit to be able to use the token. + * + * @param walletAddress Address of the caller of the transaction. + * @param params Permit parameters. + * @param params.owner Address of the owner. + * @param params.spender Address of the spender. + * @param params.value Value to approve for the spender. + * @param params.deadline Deadline for the permit. + * @param params.v v value of the permit. + * @param params.r r value of the permit. + * @param params.s s value of the permit. + * @returns `transact: () => Promise
` - Used to make the + * transaction with the given value. + * + * `estimate: () => Promise` - Gas estimate of the + * transaction. + */ + public permit(walletAddress: Address, params: PermitParams) { + const { owner, spender, value, deadline, v, r, s } = params; + const transact = () => + this.getContract().write.permit( + [owner, spender, value, deadline, v, r, s], + { + account: walletAddress, + chain: this.viemChain, + }, + ); + const estimate = () => + this.getContract().estimateGas.permit( + [owner, spender, value, deadline, v, r, s], + { + account: walletAddress, + }, + ); + + return { transact, estimate }; + } +} diff --git a/lib/contracts/handlers/nucleus-teller-handler.ts b/lib/contracts/handlers/nucleus-teller-handler.ts new file mode 100644 index 0000000..d0dc056 --- /dev/null +++ b/lib/contracts/handlers/nucleus-teller-handler.ts @@ -0,0 +1,198 @@ +/* istanbul ignore file */ + +import { + WalletClient, + PublicClient, + getContract, + Address, + GetContractReturnType, +} from 'viem'; +import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants'; +import { CONTRACT_ADDRESSES } from '../addresses'; +import { NUCLEUS_TELLER_ABIS } from '../abis/nucleus-teller-abis'; +import { Token, TOKENS_ADDRESSES } from '../tokens'; + +export type DepositWithPermitParams = { + account: Address; + depositAsset: Address; + depositAmount: bigint; + minimumMint: bigint; + deadline: bigint; + v: number; + r: Address; + s: Address; +}; + +/** + * Handler for the `Teller` contract from nucleus. + */ +export class NucleusTellerHandler { + private viemChain: ViemChain; + + /** + * Create the handler for processing tokens. + * + * @param chain Chain to use for the client. + * @param walletClient The wallet client to use for wallet + * interactions. + * @param publicClient The public client to use for public + * interactions. + */ + constructor( + private chain: Chain, + private walletClient: WalletClient, + private publicClient: PublicClient, + ) { + this.viemChain = VIEM_CHAINS[chain]; + } + + /** + * Get the contract. This is a method because the typings are complex + * and lost when trying to make it a member. + * + * @returns The viem contract. + */ + public getContract() { + const address = CONTRACT_ADDRESSES[this.chain].NucleusTeller as Address; + const abi = NUCLEUS_TELLER_ABIS[this.chain].Teller; + const client = { public: this.publicClient, wallet: this.walletClient }; + + return getContract({ address, abi, client }) as GetContractReturnType< + typeof abi, + typeof client, + Address + >; + } + + /** + * Get the address of the `Accountant` contract. + * + * @returns The address of the `Accountant` contract. + */ + public accountant() { + return this.getContract().read.accountant(); + } + + /** + * Get the address of the `BoringVault` contract. + * + * @returns The address of the `BoringVault` contract. + */ + public vault() { + return this.getContract().read.vault(); + } + + /** + * Get the share lock period. + * + * @returns The share lock period. + */ + public shareLockPeriod() { + return this.getContract().read.shareLockPeriod(); + } + + /** + * Get the share unlock time for the given wallet address. + * + * @param walletAddress Address of the wallet. + * @returns The share unlock time. + */ + public shareUnlockTime(walletAddress: Address) { + return this.getContract().read.shareUnlockTime([walletAddress]); + } + + /** + * Get the paused state of the contract. + * + * @returns The paused state of the contract. + */ + public isPaused() { + return this.getContract().read.isPaused(); + } + + /** + * Deposit the given token for staking. + * + * @param walletAddress Address of the caller of the transaction. + * @param token Token to deposit. + * @param amount Amount of the token to deposit. + * @param minimumMint Minimum amount of shares to mint. + * @returns `transact: () => Promise
` - Used to make the + * transaction with the given value. + * + * `estimate: () => Promise` - Gas estimate of the + * transaction. + */ + public deposit( + walletAddress: Address, + token: Token, + amount: bigint, + minimumMint: bigint, + ) { + const tokenAddress = TOKENS_ADDRESSES[token][this.chain]; + + const transact = () => + this.getContract().write.deposit([tokenAddress, amount, minimumMint], { + account: walletAddress, + chain: this.viemChain, + }); + const estimate = () => + this.getContract().estimateGas.deposit( + [tokenAddress, amount, minimumMint], + { + account: walletAddress, + }, + ); + + return { transact, estimate }; + } + + /** + * Deposit an asset/token for staking with a permit. + * + * @param params Permit parameters. + * @param params.account Address of the caller of the transaction. + * @param params.depositAsset Address of the asset/token to deposit. + * @param params.depositAmount Amount of the asset/token to deposit. + * @param params.minimumMint Minimum amount of shares to mint. + * @param params.deadline Deadline for the permit. + * @param params.v v value of the permit. + * @param params.r r value of the permit. + * @param params.s s value of the permit. + * @returns `transact: () => Promise
` - Used to make the + * transaction with the given value. + * + * `estimate: () => Promise` - Gas estimate of the + * transaction. + */ + public depositWithPermit(params: DepositWithPermitParams) { + const { + account, + depositAsset, + depositAmount, + minimumMint, + deadline, + v, + r, + s, + } = params; + + const transact = () => + this.getContract().write.depositWithPermit( + [depositAsset, depositAmount, minimumMint, deadline, v, r, s], + { + account, + chain: this.viemChain, + }, + ); + const estimate = () => + this.getContract().estimateGas.depositWithPermit( + [depositAsset, depositAmount, minimumMint, deadline, v, r, s], + { + account, + }, + ); + + return { transact, estimate }; + } +} diff --git a/lib/contracts/handlers/puf-locker-handler.test.ts b/lib/contracts/handlers/puf-locker-handler.test.ts index b29d437..e41f3bc 100644 --- a/lib/contracts/handlers/puf-locker-handler.test.ts +++ b/lib/contracts/handlers/puf-locker-handler.test.ts @@ -7,7 +7,7 @@ import { import { mockAccount, testingUtils } from '../../../test/setup-tests'; import { Chain } from '../../chains/constants'; import { PUF_LOCKER_ABIS } from '../abis/puf-locker-abis'; -import { PufToken } from '../tokens'; +import { UnifiToken } from '../tokens'; import { PufLockerHandler } from './puf-locker-handler'; describe('PufTokenHandler', () => { @@ -28,7 +28,7 @@ describe('PufTokenHandler', () => { contractTestingUtils.mockCall('getAllDeposits', [[mockDeposit]]); const allDeposits = await handler.getAllDeposits( - PufToken.pufWETH, + UnifiToken.unifiETH, mockAccount, ); @@ -40,7 +40,7 @@ describe('PufTokenHandler', () => { contractTestingUtils.mockCall('getDeposits', [[mockDeposit]]); const allDeposits = await handler.getDeposits( - PufToken.pufWETH, + UnifiToken.unifiETH, mockAccount, 0n, 1n, @@ -66,7 +66,7 @@ describe('PufTokenHandler', () => { .mockReturnValue(Promise.resolve(mockPermitSignature)); const { transact, estimate } = await handler.deposit({ - token: PufToken.pufWETH, + token: UnifiToken.unifiETH, account: mockAccount, recipient: mockAccount, value: 1n, @@ -85,7 +85,7 @@ describe('PufTokenHandler', () => { .mockReturnValue(Promise.resolve(mockPermitSignature)); const { transact, estimate } = await handler.deposit({ - token: PufToken.pufWETH, + token: UnifiToken.unifiETH, account: mockAccount, recipient: mockAccount, value: 1n, @@ -100,7 +100,7 @@ describe('PufTokenHandler', () => { contractTestingUtils.mockTransaction('withdraw'); const { transact, estimate } = handler.withdraw( - PufToken.pufWETH, + UnifiToken.unifiETH, mockAccount, mockAccount, [0n], diff --git a/lib/contracts/handlers/puf-locker-handler.ts b/lib/contracts/handlers/puf-locker-handler.ts index cdb458c..137089f 100644 --- a/lib/contracts/handlers/puf-locker-handler.ts +++ b/lib/contracts/handlers/puf-locker-handler.ts @@ -9,11 +9,11 @@ import { import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants'; import { PUF_LOCKER_ABIS } from '../abis/puf-locker-abis'; import { CONTRACT_ADDRESSES } from '../addresses'; -import { PufToken, TOKENS_ADDRESSES } from '../tokens'; +import { UnifiToken, TOKENS_ADDRESSES } from '../tokens'; import { ERC20PermitHandler } from './erc20-permit-handler'; export type LockerDepositParams = { - token: PufToken; + token: UnifiToken; account: Address; recipient: Address; value: bigint; @@ -77,7 +77,7 @@ export class PufLockerHandler { * @param walletAddress The wallet address to get the deposits for. * @returns The amount and deposits of the given account address. */ - public getAllDeposits(pufToken: PufToken, walletAddress: Address) { + public getAllDeposits(pufToken: UnifiToken, walletAddress: Address) { return this.getContract().read.getAllDeposits([ TOKENS_ADDRESSES[pufToken][this.chain], walletAddress, @@ -94,7 +94,7 @@ export class PufLockerHandler { * @returns The amount and release time of the deposits. */ public getDeposits( - pufToken: PufToken, + pufToken: UnifiToken, userAddress: Address, start: bigint, limit: bigint, @@ -205,7 +205,7 @@ export class PufLockerHandler { * @returns Hash of the withdrawal transaction. */ public withdraw( - pufToken: PufToken, + pufToken: UnifiToken, walletAddress: Address, recipient: Address, depositIndexes: bigint[], diff --git a/lib/contracts/handlers/puf-token-handler.test.ts b/lib/contracts/handlers/puf-token-handler.test.ts deleted file mode 100644 index 38d4415..0000000 --- a/lib/contracts/handlers/puf-token-handler.test.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { isHash, padHex } from 'viem'; -import { - setupTestWalletClient, - setupTestPublicClient, -} from '../../../test/setup-test-clients'; -import { mockAccount, testingUtils } from '../../../test/setup-tests'; -import { Chain } from '../../chains/constants'; -import { PUF_TOKEN_ABIS } from '../abis/puf-token-abis'; -import { PufTokenHandler } from './puf-token-handler'; -import { PufToken, TOKENS_ADDRESSES } from '../tokens'; - -describe('PufTokenHandler', () => { - const contractTestingUtils = testingUtils.generateContractUtils( - PUF_TOKEN_ABIS[Chain.Holesky].PufToken, - ); - let handler: PufTokenHandler; - - beforeEach(() => { - const walletClient = setupTestWalletClient(); - const publicClient = setupTestPublicClient(); - - handler = new PufTokenHandler(Chain.Holesky, walletClient, publicClient); - }); - - it('should check the balance of the given token', async () => { - const mockBalance = 10n; - contractTestingUtils.mockCall('balanceOf', [mockBalance]); - - const balance = await handler.balanceOf(mockAccount); - expect(balance).toBe(mockBalance); - }); - - it('should get the allowance of the given token', async () => { - const mockAllowance = 10n; - contractTestingUtils.mockCall('allowance', [mockAllowance]); - - const allowance = await handler.getAllowance( - '0xEB77D02f8122B32273444a1b544C147Fb559CB41', - '0x92e01fbccae21eed10ab2f278f47905d482df202', - ); - expect(allowance).toBe(mockAllowance); - }); - - it('should get the total deposit cap of the given token', async () => { - const mockDepositCap = 10n; - contractTestingUtils.mockCall('totalDepositCap', [mockDepositCap]); - - const totalDepositCap = await handler.getTotalDepositCap(); - expect(totalDepositCap).toBe(mockDepositCap); - }); - - it('should get the total supply of the given token', async () => { - const mockSupply = 10n; - contractTestingUtils.mockCall('totalSupply', [mockSupply]); - - const totalSupply = await handler.getTotalSupply(); - expect(totalSupply).toBe(mockSupply); - }); - - it('should withdraw the given token', async () => { - contractTestingUtils.mockTransaction('withdraw'); - - const { transact, estimate } = handler.withdraw(mockAccount, 10n); - - expect(typeof (await estimate())).toBe('bigint'); - expect(isHash(await transact())).toBe(true); - }); - - it('should deposit the given token', async () => { - contractTestingUtils.mockTransaction('deposit'); - - const { transact, estimate } = handler.deposit( - mockAccount, - mockAccount, - 10n, - ); - - expect(typeof (await estimate())).toBe('bigint'); - expect(isHash(await transact())).toBe(true); - }); - - it('should migrate token using the given migrator contract', async () => { - const mockMigratorContract = '0x1234567890123456789012345678901234567890'; - contractTestingUtils.mockTransaction('migrate'); - - const { transact, estimate } = handler.migrate( - mockAccount, - mockMigratorContract, - 10n, - ); - - expect(typeof (await estimate())).toBe('bigint'); - expect(isHash(await transact())).toBe(true); - }); - - it('should request for approval', async () => { - contractTestingUtils.mockTransaction('approve'); - const mockSpender = padHex('0x', { size: 20 }); - - const txHash = await handler.approve(mockAccount, mockSpender, 10n); - expect(isHash(txHash)).toBe(true); - }); - - it('should use the contract of the selected token', () => { - const contract = handler.withPufToken(PufToken.pufALT).getContract(); - - expect(contract.address).toBe( - TOKENS_ADDRESSES[PufToken.pufALT][Chain.Holesky], - ); - }); -}); diff --git a/lib/contracts/handlers/puf-token-handler.ts b/lib/contracts/handlers/puf-token-handler.ts deleted file mode 100644 index c2d0b1c..0000000 --- a/lib/contracts/handlers/puf-token-handler.ts +++ /dev/null @@ -1,230 +0,0 @@ -import { - WalletClient, - PublicClient, - getContract, - GetContractReturnType, - Address, -} from 'viem'; -import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants'; -import { PUF_TOKEN_ABIS } from '../abis/puf-token-abis'; -import { PufToken, TOKENS_ADDRESSES } from '../tokens'; - -/** - * Handler for the `PufToken` contract exposing methods to interact with - * the contract for each of the wrapped PufTokens (like pufWETH, - * pufstETH, pufwstETH etc.). - */ -export class PufTokenHandler { - private viemChain: ViemChain; - private pufToken: PufToken; - - /** - * Create the handler for the `PufToken` contract exposing methods to - * interact with the contract. - * - * @param chain Chain to use for the client. - * @param walletClient The wallet client to use for wallet - * interactions. - * @param publicClient The public client to use for public - * interactions. - */ - constructor( - private chain: Chain, - private walletClient: WalletClient, - private publicClient: PublicClient, - ) { - this.pufToken = PufToken.pufWETH; - this.viemChain = VIEM_CHAINS[chain]; - } - - /** - * Set the PufToken to use for executing transactions on the contract. - * - * @param pufToken The PufToken to use for the handler. - * @returns The handler. - */ - public withPufToken(pufToken: PufToken) { - this.pufToken = pufToken; - return this; - } - - /** - * Get the contract. This is a method because the typings are complex - * and lost when trying to make it a member. - * - * @returns The viem contract. - */ - public getContract() { - const address = TOKENS_ADDRESSES[this.pufToken][this.chain]; - const abi = PUF_TOKEN_ABIS[this.chain].PufToken; - const client = { public: this.publicClient, wallet: this.walletClient }; - - return getContract({ address, abi, client }) as GetContractReturnType< - typeof abi, - typeof client, - Address - >; - } - - /** - * Check the wrapped token (PufToken) balance of the wallet. - * - * @param walletAddress Wallet address to check the balance of. - * @returns The wrapped token's (PufToken) balance in wei. - */ - public balanceOf(walletAddress: Address) { - return this.getContract().read.balanceOf([walletAddress]); - } - - /** - * Get the allowance for the spender to spend the owner's tokens. - * - * @param ownerAddress Address of the owner. - * @param spenderAddress Address of the spender. - * @returns Allowance that can be used by the spender. - */ - public getAllowance(ownerAddress: Address, spenderAddress: Address) { - return this.getContract().read.allowance([ownerAddress, spenderAddress]); - } - - /** - * Get the total cap of the PufToken that can be deposited. - * - * @returns Total cap of the PufToken that can be deposited. - */ - public getTotalDepositCap() { - return this.getContract().read.totalDepositCap(); - } - - /** - * Get the total supply of the PufToken. - * - * @returns Total supply of the PufToken. - */ - public getTotalSupply() { - return this.getContract().read.totalSupply(); - } - - /** - * Withdraws the PufToken and returns the underlying token to the - * given wallet. This doesn't make the transaction but returns two - * methods namely `transact` and `estimate`. - * - * @param walletAddress Wallet address to withdraw the PufToken from. - * @param value Value of the withdrawal. - * @returns `transact: () => Promise
` - Used to make the - * transaction. - * - * `estimate: () => Promise` - Gas estimate of the - * transaction. - */ - public withdraw(walletAddress: Address, value: bigint) { - const transact = () => - this.getContract().write.withdraw([walletAddress, value], { - account: walletAddress, - chain: this.viemChain, - }); - const estimate = () => - this.getContract().estimateGas.withdraw([walletAddress, value], { - account: walletAddress, - }); - - return { transact, estimate }; - } - - /** - * Deposits the underlying token in exchange for the wrapped PufToken. - * This doesn't make the transaction but returns two methods namely - * `transact` and `estimate`. - * - * @param depositorAddress Depositor of the underlying token. - * @param walletAddress Wallet address of the recipient of the - * deposit. - * @param value Value of the deposit. - * @returns `transact: () => Promise
` - Used to make the - * transaction. - * - * `estimate: () => Promise` - Gas estimate of the - * transaction. - */ - public deposit( - depositorAddress: Address, - walletAddress: Address, - value: bigint, - ) { - const transact = () => - this.getContract().write.deposit( - [depositorAddress, walletAddress, value], - { - account: walletAddress, - chain: this.viemChain, - }, - ); - const estimate = () => - this.getContract().estimateGas.deposit( - [depositorAddress, walletAddress, value], - { - account: walletAddress, - }, - ); - - return { transact, estimate }; - } - - /** - * Migrate tokens using an allowed `migratorContract` to the given - * wallet address. This doesn't make the transaction but returns two - * methods namely `transact` and `estimate`. - * - * @param walletAddress Address to migrate the tokens to. - * @param migratorContract Address of the migrator contract. - * @param value Value of the tokens to migrate. - * @returns `transact: () => Promise
` - Used to make the - * transaction. - * - * `estimate: () => Promise` - Gas estimate of the - * transaction. - */ - public migrate( - walletAddress: Address, - migratorContract: Address, - value: bigint, - ) { - const transact = () => - this.getContract().write.migrate( - [value, migratorContract, walletAddress], - { - account: walletAddress, - chain: this.viemChain, - }, - ); - const estimate = () => - this.getContract().estimateGas.migrate( - [value, migratorContract, walletAddress], - { - account: walletAddress, - }, - ); - - return { transact, estimate }; - } - - /** - * Approve transaction for the spender to spend the owner's tokens. - * - * @param ownerAddress Address of the caller of the transaction. - * @param spenderAddress Address of the spender. - * @param value Value to approve for the spender. - * @returns Hash of the transaction. - */ - public approve( - ownerAddress: Address, - spenderAddress: Address, - value: bigint, - ) { - return this.getContract().write.approve([spenderAddress, value], { - account: ownerAddress, - chain: this.viemChain, - }); - } -} diff --git a/lib/contracts/tokens.ts b/lib/contracts/tokens.ts index c2febcb..fa3a909 100644 --- a/lib/contracts/tokens.ts +++ b/lib/contracts/tokens.ts @@ -14,33 +14,11 @@ export enum Token { pufETH = 'pufETH', } -export enum PufToken { - pufUSDT = 'pufUSDT', - pufUSDC = 'pufUSDC', - pufDAI = 'pufDAI', - pufpufETH = 'pufpufETH', - pufWETH = 'pufWETH', - pufstETH = 'pufstETH', - pufwstETH = 'pufwstETH', - pufALT = 'pufALT', - pufeETH = 'pufeETH', - pufpufETHwstE = 'pufpufETHwstE', +export enum UnifiToken { + unifiETH = 'unifiETH', } -export type AnyToken = Token | PufToken; - -export const TOKEN_TO_PUF_TOKEN_MAP = { - [Token.USDT]: PufToken.pufUSDT, - [Token.USDC]: PufToken.pufUSDC, - [Token.DAI]: PufToken.pufDAI, - [Token.WETH]: PufToken.pufWETH, - [Token.stETH]: PufToken.pufstETH, - [Token.wstETH]: PufToken.pufwstETH, - [Token.ALT]: PufToken.pufALT, - [Token.eETH]: PufToken.pufeETH, - [Token.pufETHwstE]: PufToken.pufpufETHwstE, - [Token.pufETH]: PufToken.pufpufETH, -}; +export type AnyToken = Token | UnifiToken; export const TOKENS_ADDRESSES: { [key in AnyToken]: { [chain in Chain]: Address }; @@ -89,47 +67,11 @@ export const TOKENS_ADDRESSES: { // TODO: Update the addresses once the contracts are deployed on chain. // See https://dev.azure.com/pufferfi/Frontend/_workitems/edit/1797. - // Wrapped PufTokens. - [PufToken.pufUSDT]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x61e7C87c387178D6e0aE6c04748b7FF753fC9b81', - }, - [PufToken.pufUSDC]: { - [Chain.Mainnet]: '0x2f0d8e30df0c598b90b34cd68b5e3981b7af3881', - [Chain.Holesky]: '0x6D900a9f5784A2cA0004B5c3D3e08D7A9cE4A1b3', - }, - [PufToken.pufDAI]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x2D6B705e118198A02F00490BA323B17eC5D58109', - }, - [PufToken.pufWETH]: { - [Chain.Mainnet]: '0x2b36f6bfd223f460e7e43ef49bc487481648948c', - [Chain.Holesky]: '0x5335f231C22d472Ab31CC2690A2247d25efd76a5', - }, - [PufToken.pufstETH]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x0000000000000000000000000000000000000000', - }, - [PufToken.pufwstETH]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', + // UniFi Tokens + [UnifiToken.unifiETH]: { + [Chain.Mainnet]: '0x196ead472583bc1e9af7a05f860d9857e1bd3dcc', [Chain.Holesky]: '0x0000000000000000000000000000000000000000', }, - [PufToken.pufALT]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x0000000000000000000000000000000000000000', - }, - [PufToken.pufeETH]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x0000000000000000000000000000000000000000', - }, - [PufToken.pufpufETHwstE]: { - [Chain.Mainnet]: '0xf374014f6fa86bad50d52e6240a117b0830663cb', - [Chain.Holesky]: '0x0000000000000000000000000000000000000000', - }, - [PufToken.pufpufETH]: { - [Chain.Mainnet]: '0x0000000000000000000000000000000000000000', - [Chain.Holesky]: '0x638fd1Fe8205285E8497Eb8E6037c8254EDdB0ae', - }, }; export const TOKENS_PERMIT_VERSION: { [key in AnyToken]: string } = { @@ -149,17 +91,8 @@ export const TOKENS_PERMIT_VERSION: { [key in AnyToken]: string } = { [Token.pufETHwstE]: 'v7.0.0', [Token.pufETH]: '1', - // Wrapped PufTokens - [PufToken.pufUSDT]: '1', - [PufToken.pufUSDC]: '1', - [PufToken.pufDAI]: '1', - [PufToken.pufWETH]: '1', - [PufToken.pufstETH]: '1', - [PufToken.pufwstETH]: '1', - [PufToken.pufALT]: '1', - [PufToken.pufeETH]: '1', - [PufToken.pufpufETHwstE]: '1', - [PufToken.pufpufETH]: '1', + // UniFi Tokens + [UnifiToken.unifiETH]: '', }; export const TOKENS_SALT: Partial<{ diff --git a/lib/main.ts b/lib/main.ts index 225bef7..887aa0e 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -7,7 +7,6 @@ export * from './contracts/handlers/erc20-permit-handler'; export * from './contracts/handlers/l1-reward-manager-handler'; export * from './contracts/handlers/l2-reward-manager-handler'; export * from './contracts/handlers/puf-locker-handler'; -export * from './contracts/handlers/puf-token-handler'; export * from './contracts/handlers/puffer-depositor-handler'; export * from './contracts/handlers/puffer-l2-depositor-handler'; export * from './contracts/handlers/puffer-vault-handler';