@pufferfinance/puffer-sdk 1.25.3 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/puffer-client.cjs +1 -1
- package/dist/api/puffer-client.cjs.map +1 -1
- package/dist/api/puffer-client.d.ts +3 -0
- package/dist/api/puffer-client.js +28 -21
- package/dist/api/puffer-client.js.map +1 -1
- package/dist/contracts/abis/mainnet/vlPUFFER.cjs +2 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.d.ts +437 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.js +269 -0
- package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -0
- package/dist/contracts/common/lib/types.cjs +2 -0
- package/dist/contracts/common/lib/types.cjs.map +1 -0
- package/dist/contracts/common/lib/types.d.ts +8 -0
- package/dist/contracts/common/lib/types.js +2 -0
- package/dist/contracts/common/lib/types.js.map +1 -0
- package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.d.ts +10 -0
- package/dist/contracts/handlers/erc20-permit-handler.js +56 -40
- package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
- package/dist/contracts/handlers/lagoon-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/lagoon-vault-handler.cjs.map +1 -1
- package/dist/contracts/handlers/lagoon-vault-handler.d.ts +51 -0
- package/dist/contracts/handlers/lagoon-vault-handler.js +87 -6
- package/dist/contracts/handlers/lagoon-vault-handler.js.map +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +2 -6
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js +17 -17
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.d.ts +2 -6
- package/dist/contracts/handlers/nucleus-teller-handler.js +11 -20
- package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
- package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
- package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puf-locker-handler.js +31 -40
- package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.js +26 -38
- package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js +28 -37
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-protocol-handler.d.ts +49 -55
- package/dist/contracts/handlers/puffer-protocol-handler.js.map +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +21 -27
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
- package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
- package/dist/contracts/handlers/validator-ticket-handler.d.ts +1 -7
- package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
- package/dist/contracts/handlers/vl-puffer-handler.cjs +2 -0
- package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -0
- package/dist/contracts/handlers/vl-puffer-handler.d.ts +14802 -0
- package/dist/contracts/handlers/vl-puffer-handler.js +357 -0
- package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -0
- package/dist/contracts/tokens.cjs +1 -1
- package/dist/contracts/tokens.cjs.map +1 -1
- package/dist/contracts/tokens.d.ts +2 -1
- package/dist/contracts/tokens.js +8 -3
- package/dist/contracts/tokens.js.map +1 -1
- package/dist/utils/version.cjs +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nucleus-teller-handler.js","sources":["../../../lib/contracts/handlers/nucleus-teller-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { Token, TOKENS_ADDRESSES, UnifiToken } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Teller } from '../abis/mainnet/Teller';\n\nexport type DepositParams = {\n account: Address;\n token: Token;\n unifiToken: UnifiToken;\n amount: bigint;\n minimumMint: bigint;\n isPreapproved?: boolean;\n};\n\nexport type DepositWithPermitParams = {\n account: Address;\n depositAsset: Address;\n depositAmount: bigint;\n minimumMint: bigint;\n deadline: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\n/**\n * Handler for the `Teller` contract from nucleus.\n */\nexport class NucleusTellerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n this.token = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusTeller as Address;\n const abi = Teller;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get the address of the `Accountant` contract.\n *\n * @returns The address of the `Accountant` contract.\n */\n public accountant() {\n return this.getContract().read.accountant();\n }\n\n /**\n * Get the address of the `BoringVault` contract.\n *\n * @returns The address of the `BoringVault` contract.\n */\n public vault() {\n return this.getContract().read.vault();\n }\n\n /**\n * Get the share lock period.\n *\n * @returns The share lock period.\n */\n public shareLockPeriod() {\n return this.getContract().read.shareLockPeriod();\n }\n\n /**\n * Get the share unlock time for the given wallet address.\n *\n * @param walletAddress Address of the wallet.\n * @returns The share unlock time.\n */\n public shareUnlockTime(walletAddress: Address) {\n return this.getContract().read.shareUnlockTime([walletAddress]);\n }\n\n /**\n * Get the paused state of the contract.\n *\n * @returns The paused state of the contract.\n */\n public isPaused() {\n return this.getContract().read.isPaused();\n }\n\n /**\n * Deposit the given token for staking. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param params Deposit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.token Token to deposit.\n * @param params.unifiToken UniFi token to get in return of the deposit.\n * @param params.amount Amount of the token to deposit.\n * @param params.minimumMint Minimum amount of shares to mint.\n * @param params.isPreapproved Whether the token is preapproved.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(params: DepositParams) {\n const {\n token,\n unifiToken,\n account,\n amount,\n minimumMint,\n isPreapproved = false,\n } = params;\n const tokenAddress = TOKENS_ADDRESSES[token][this.chain];\n\n if (isPreapproved) {\n return {\n transact: () =>\n this.getContract().write.deposit(\n [tokenAddress, amount, minimumMint],\n {\n account,\n chain: this.viemChain,\n },\n ),\n estimate: () =>\n this.getContract().estimateGas.deposit(\n [tokenAddress, amount, minimumMint],\n { account },\n ),\n };\n }\n\n const { r, s, v, deadline } = await this.erc20PermitHandler\n .withToken(token)\n .getPermitSignature(\n account,\n // The UniFi token contract is the spender.\n TOKENS_ADDRESSES[unifiToken][this.chain],\n amount,\n );\n\n const depositArgs = <const>[\n tokenAddress,\n amount,\n minimumMint,\n deadline,\n Number(v),\n r,\n s,\n ];\n\n const transact = () =>\n this.getContract().write.depositWithPermit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.depositWithPermit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Deposit an asset/token for staking with a permit.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.depositAsset Address of the asset/token to deposit.\n * @param params.depositAmount Amount of the asset/token to deposit.\n * @param params.minimumMint Minimum amount of shares to mint.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public depositWithPermit(params: DepositWithPermitParams) {\n const {\n account,\n depositAsset,\n depositAmount,\n minimumMint,\n deadline,\n v,\n r,\n s,\n } = params;\n\n const transact = () =>\n this.getContract().write.depositWithPermit(\n [depositAsset, depositAmount, minimumMint, deadline, v, r, s],\n {\n account,\n chain: this.viemChain,\n },\n );\n const estimate = () =>\n this.getContract().estimateGas.depositWithPermit(\n [depositAsset, depositAmount, minimumMint, deadline, v, r, s],\n {\n account,\n },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusTellerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","UnifiToken","token","address","VAULTS_ADDRESSES","abi","Teller","client","getContract","walletAddress","params","unifiToken","account","amount","minimumMint","isPreapproved","tokenAddress","TOKENS_ADDRESSES","r","s","v","deadline","depositArgs","depositAsset","depositAmount"],"mappings":";;;;;;;;;AAoCO,MAAMA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAchC,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,qBAAqB,IAAIK;AAAA,MAC5BL;AAAA,MACAC;AAAA,MACAC;AAAA,IACF,GACA,KAAK,QAAQI,EAAW;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUnB,UAAUC,GAAmB;AAClC,gBAAK,QAAQA,GACN;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASF,cAAc;AACnB,UAAMC,IAAUC,EAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,eACGC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAL,GAAS,KAAAE,GAAK,QAAAE,GAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtC,aAAa;AAClB,WAAO,KAAK,cAAc,KAAK,WAAW;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrC,QAAQ;AACb,WAAO,KAAK,cAAc,KAAK,MAAM;AAAA,E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AAAA,MACAH;AAAA,MACAC;AAAA,MACAO;AAAA,MACA,OAAOD,CAAC;AAAA,MACRF;AAAA,MACAC;AAAA,IACF;AAYO,WAAA,EAAE,UAVQ,MACf,KAAK,YAAc,EAAA,MAAM,kBAAkBG,GAAa;AAAA,MACtD,SAAAV;AAAA,MACA,OAAO,KAAK;AAAA,IAAA,CACb,GAMgB,UALF,MACf,KAAK,YAAc,EAAA,YAAY,kBAAkBU,GAAa;AAAA,MAC5D,SAAAV;AAAA,IAAA,CACD,EAEyB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBvB,kBAAkBF,GAAiC;AAClD,UAAA;AAAA,MACJ,SAAAE;AAAA,MACA,cAAAW;AAAA,MACA,eAAAC;AAAA,MACA,aAAAV;AAAA,MACA,UAAAO;AAAA,MACA,GAAAD;AAAA,MACA,GAAAF;AAAA,MACA,GAAAC;AAAA,IAAA,IACET;AAkBG,WAAA,EAAE,UAhBQ,MACf,KAAK,cAAc,MAAM;AAAA,MACvB,CAACa,GAAcC,GAAeV,GAAaO,GAAUD,GAAGF,GAAGC,CAAC;AAAA,MAC5D;AAAA,QACE,SAAAP;AAAA,QACA,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB,GASiB,UARF,MACf,KAAK,cAAc,YAAY;AAAA,MAC7B,CAACW,GAAcC,GAAeV,GAAaO,GAAUD,GAAGF,GAAGC,CAAC;AAAA,MAC5D;AAAA,QACE,SAAAP;AAAA,MAAA;AAAA,IAEJ,EAE0B;AAAA,EAAA;AAEhC;"}
|
|
1
|
+
{"version":3,"file":"nucleus-teller-handler.js","sources":["../../../lib/contracts/handlers/nucleus-teller-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\nimport { Token, TOKENS_ADDRESSES, UnifiToken } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Teller } from '../abis/mainnet/Teller';\nimport { PermitData } from '../common/lib/types';\n\nexport type DepositParams = {\n account: Address;\n token: Token;\n unifiToken: UnifiToken;\n amount: bigint;\n minimumMint: bigint;\n isPreapproved?: boolean;\n};\n\nexport type DepositWithPermitParams = PermitData & {\n account: Address;\n depositAsset: Address;\n minimumMint: bigint;\n};\n\n/**\n * Handler for the `Teller` contract from nucleus.\n */\nexport class NucleusTellerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing tokens.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n this.token = UnifiToken.unifiETH;\n }\n\n /**\n * Set the UniFi token to use for executing transactions on the\n * contract.\n *\n * @param token UniFi token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: UnifiToken) {\n this.token = token;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = VAULTS_ADDRESSES[this.token][this.chain]\n .NucleusTeller as Address;\n const abi = Teller;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get the address of the `Accountant` contract.\n *\n * @returns The address of the `Accountant` contract.\n */\n public accountant() {\n return this.getContract().read.accountant();\n }\n\n /**\n * Get the address of the `BoringVault` contract.\n *\n * @returns The address of the `BoringVault` contract.\n */\n public vault() {\n return this.getContract().read.vault();\n }\n\n /**\n * Get the share lock period.\n *\n * @returns The share lock period.\n */\n public shareLockPeriod() {\n return this.getContract().read.shareLockPeriod();\n }\n\n /**\n * Get the share unlock time for the given wallet address.\n *\n * @param walletAddress Address of the wallet.\n * @returns The share unlock time.\n */\n public shareUnlockTime(walletAddress: Address) {\n return this.getContract().read.shareUnlockTime([walletAddress]);\n }\n\n /**\n * Get the paused state of the contract.\n *\n * @returns The paused state of the contract.\n */\n public isPaused() {\n return this.getContract().read.isPaused();\n }\n\n /**\n * Deposit the given token for staking. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param params Deposit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.token Token to deposit.\n * @param params.unifiToken UniFi token to get in return of the deposit.\n * @param params.amount Amount of the token to deposit.\n * @param params.minimumMint Minimum amount of shares to mint.\n * @param params.isPreapproved Whether the token is preapproved.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(params: DepositParams) {\n const {\n token,\n unifiToken,\n account,\n amount,\n minimumMint,\n isPreapproved = false,\n } = params;\n const tokenAddress = TOKENS_ADDRESSES[token][this.chain];\n\n if (isPreapproved) {\n return {\n transact: () =>\n this.getContract().write.deposit(\n [tokenAddress, amount, minimumMint],\n {\n account,\n chain: this.viemChain,\n },\n ),\n estimate: () =>\n this.getContract().estimateGas.deposit(\n [tokenAddress, amount, minimumMint],\n { account },\n ),\n };\n }\n\n const { r, s, v, deadline } = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n // The UniFi token contract is the spender.\n TOKENS_ADDRESSES[unifiToken][this.chain],\n amount,\n );\n\n const depositArgs = <const>[\n tokenAddress,\n amount,\n minimumMint,\n deadline,\n v,\n r,\n s,\n ];\n\n const transact = () =>\n this.getContract().write.depositWithPermit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.depositWithPermit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Deposit an asset/token for staking with a permit.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.depositAsset Address of the asset/token to deposit.\n * @param params.depositAmount Amount of the asset/token to deposit.\n * @param params.minimumMint Minimum amount of shares to mint.\n * @param params.deadline Deadline for the permit.\n * @param params.v v value of the permit.\n * @param params.r r value of the permit.\n * @param params.s s value of the permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public depositWithPermit(params: DepositWithPermitParams) {\n const { account, depositAsset, amount, minimumMint, deadline, v, r, s } =\n params;\n\n const transact = () =>\n this.getContract().write.depositWithPermit(\n [depositAsset, amount, minimumMint, deadline, v, r, s],\n {\n account,\n chain: this.viemChain,\n },\n );\n const estimate = () =>\n this.getContract().estimateGas.depositWithPermit(\n [depositAsset, amount, minimumMint, deadline, v, r, s],\n {\n account,\n },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusTellerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","UnifiToken","token","address","VAULTS_ADDRESSES","abi","Teller","client","getContract","walletAddress","params","unifiToken","account","amount","minimumMint","isPreapproved","tokenAddress","TOKENS_ADDRESSES","r","s","v","deadline","depositArgs","depositAsset"],"mappings":";;;;;;;;;AAgCO,MAAMA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAchC,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,qBAAqB,IAAIK;AAAA,MAC5BL;AAAA,MACAC;A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AE,UAhBQ,MACf,KAAK,cAAc,MAAM;AAAA,MACvB,CAACa,GAAcV,GAAQC,GAAaO,GAAUD,GAAGF,GAAGC,CAAC;AAAA,MACrD;AAAA,QACE,SAAAP;AAAA,QACA,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB,GASiB,UARF,MACf,KAAK,cAAc,YAAY;AAAA,MAC7B,CAACW,GAAcV,GAAQC,GAAaO,GAAUD,GAAGF,GAAGC,CAAC;AAAA,MACrD;AAAA,QACE,SAAAP;AAAA,MAAA;AAAA,IAEJ,EAE0B;AAAA,EAAA;AAEhC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var g=(r,t,e)=>t in r?C(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>g(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../constants-CxSgz27h.cjs"),S=require("../addresses.cjs"),n=require("../tokens.cjs"),m=require("./erc20-permit-handler.cjs"),D=require("../abis/mainnet/PufLocker.cjs"),E=require("../../getContract-DUA3M2pm.cjs");class p{constructor(t,e,i){c(this,"viemChain");c(this,"erc20PermitHandler");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=o.VIEM_CHAINS[t],this.erc20PermitHandler=new m.ERC20PermitHandler(t,e,i)}getContract(){const t=S.CONTRACT_ADDRESSES[this.chain].PufLocker,e=D.PufLocker,i={public:this.publicClient,wallet:this.walletClient};return E.getContract({address:t,abi:e,client:i})}getAllDeposits(t,e){return this.getContract().read.getAllDeposits([n.TOKENS_ADDRESSES[t][this.chain],e])}getDeposits(t,e,i,s){return this.getContract().read.getDeposits([e,n.TOKENS_ADDRESSES[t][this.chain],i,s])}getLockPeriods(){return this.getContract().read.getLockPeriods()}async deposit(t){const{token:e,account:i,recipient:s,value:a,lockPeriod:h,isPreapproved:d=!1}=t;let u={r:o.padHex("0x",{size:32}),s:o.padHex("0x",{size:32}),v:0,deadline:0n,amount:a};d||(u=await this.erc20PermitHandler.withToken(e).getPermitData(i,S.CONTRACT_ADDRESSES[this.chain].PufLocker,a));const l=[n.TOKENS_ADDRESSES[e][this.chain],s,h,u];return{transact:()=>this.getContract().write.deposit(l,{account:i,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit(l,{account:i})}}withdraw(t,e,i,s){const a=[n.TOKENS_ADDRESSES[t][this.chain],s,i];return{transact:()=>this.getContract().write.withdraw(a,{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.withdraw(a,{account:e})}}}exports.PufLockerHandler=p;
|
|
2
2
|
//# sourceMappingURL=puf-locker-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puf-locker-handler.cjs","sources":["../../../lib/contracts/handlers/puf-locker-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { AnyToken, TOKENS_ADDRESSES } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufLocker } from '../abis/mainnet/PufLocker';\n\nexport type LockerDepositParams = {\n token: AnyToken;\n account: Address;\n recipient: Address;\n value: bigint;\n lockPeriod: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufLocker` contract exposing methods to interact\n * with the contract.\n */\nexport class PufLockerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufLocker` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufLocker as Address;\n const abi = PufLocker;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get all deposits of the given account address.\n *\n * @param pufToken The PufToken to get the deposits for.\n * @param walletAddress The wallet address to get the deposits for.\n * @returns The amount and deposits of the given account address.\n */\n public getAllDeposits(pufToken: AnyToken, walletAddress: Address) {\n return this.getContract().read.getAllDeposits([\n TOKENS_ADDRESSES[pufToken][this.chain],\n walletAddress,\n ]);\n }\n\n /**\n * Get the user's deposits for the given token and deposit index.\n *\n * @param pufToken PufToken to get the deposits of.\n * @param userAddress User address to get the deposits for.\n * @param start The starting index of the deposits.\n * @param limit The maximum number of deposits to retrieve.\n * @returns The amount and release time of the deposits.\n */\n public getDeposits(\n pufToken: AnyToken,\n userAddress: Address,\n start: bigint,\n limit: bigint,\n ) {\n return this.getContract().read.getDeposits([\n userAddress,\n TOKENS_ADDRESSES[pufToken][this.chain],\n start,\n limit,\n ]);\n }\n\n /**\n * Get the minimum and maximum lock periods allowed for deposits.\n *\n * @returns The minimum and maximum lock period in seconds.\n * (`[minLock, maxLock]`)\n */\n public getLockPeriods() {\n return this.getContract().read.getLockPeriods();\n }\n\n /**\n * Deposit the given PufToken into the locker. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param depositParams.pufToken PufToken to deposit.\n * @param depositParams.account Wallet address of the depositor.\n * @param depositParams.recipient Recipient of the deposit.\n * @param depositParams.value Amount of the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: LockerDepositParams) {\n const {\n token,\n account,\n recipient,\n value,\n lockPeriod,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n
|
|
1
|
+
{"version":3,"file":"puf-locker-handler.cjs","sources":["../../../lib/contracts/handlers/puf-locker-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { AnyToken, TOKENS_ADDRESSES } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufLocker } from '../abis/mainnet/PufLocker';\nimport { PermitData } from '../common/lib/types';\n\nexport type LockerDepositParams = {\n token: AnyToken;\n account: Address;\n recipient: Address;\n value: bigint;\n lockPeriod: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufLocker` contract exposing methods to interact\n * with the contract.\n */\nexport class PufLockerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufLocker` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufLocker as Address;\n const abi = PufLocker;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get all deposits of the given account address.\n *\n * @param pufToken The PufToken to get the deposits for.\n * @param walletAddress The wallet address to get the deposits for.\n * @returns The amount and deposits of the given account address.\n */\n public getAllDeposits(pufToken: AnyToken, walletAddress: Address) {\n return this.getContract().read.getAllDeposits([\n TOKENS_ADDRESSES[pufToken][this.chain],\n walletAddress,\n ]);\n }\n\n /**\n * Get the user's deposits for the given token and deposit index.\n *\n * @param pufToken PufToken to get the deposits of.\n * @param userAddress User address to get the deposits for.\n * @param start The starting index of the deposits.\n * @param limit The maximum number of deposits to retrieve.\n * @returns The amount and release time of the deposits.\n */\n public getDeposits(\n pufToken: AnyToken,\n userAddress: Address,\n start: bigint,\n limit: bigint,\n ) {\n return this.getContract().read.getDeposits([\n userAddress,\n TOKENS_ADDRESSES[pufToken][this.chain],\n start,\n limit,\n ]);\n }\n\n /**\n * Get the minimum and maximum lock periods allowed for deposits.\n *\n * @returns The minimum and maximum lock period in seconds.\n * (`[minLock, maxLock]`)\n */\n public getLockPeriods() {\n return this.getContract().read.getLockPeriods();\n }\n\n /**\n * Deposit the given PufToken into the locker. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param depositParams.pufToken PufToken to deposit.\n * @param depositParams.account Wallet address of the depositor.\n * @param depositParams.recipient Recipient of the deposit.\n * @param depositParams.value Amount of the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: LockerDepositParams) {\n const {\n token,\n account,\n recipient,\n value,\n lockPeriod,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData: PermitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n permitData = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n CONTRACT_ADDRESSES[this.chain].PufLocker as Address,\n value,\n );\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n recipient,\n lockPeriod,\n permitData,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Withdraw the deposits identified by the deposit indexes from the\n * locker.\n *\n * @param pufToken PufToken to withdraw.\n * @param walletAddress Address of the account making the transaction.\n * @param recipient Recipient of the withdrawal.\n * @param depositIndexes Deposit indexes to withdraw.\n * @returns Hash of the withdrawal transaction.\n */\n public withdraw(\n pufToken: AnyToken,\n walletAddress: Address,\n recipient: Address,\n depositIndexes: bigint[],\n ) {\n const withdrawArgs = <const>[\n TOKENS_ADDRESSES[pufToken][this.chain],\n depositIndexes,\n recipient,\n ];\n\n const transact = () =>\n this.getContract().write.withdraw(withdrawArgs, {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.withdraw(withdrawArgs, {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufLockerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufLocker","client","getContract","pufToken","walletAddress","TOKENS_ADDRESSES","userAddress","start","limit","depositParams","token","account","recipient","value","lockPeriod","isPreapproved","permitData","padHex","depositArgs","depositIndexes","withdrawArgs"],"mappings":"4dA4BO,MAAMA,CAAiB,CA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BK,CAAK,EAAE,KAAK,KAAK,EAClCE,EACAE,EACAE,CACF,EAYO,MAAA,CAAE,SAVQ,IACf,KAAK,YAAc,EAAA,MAAM,QAAQE,EAAa,CAC5C,QAAAP,EACA,MAAO,KAAK,SAAA,CACb,EAMgB,SALF,IACf,KAAK,YAAc,EAAA,YAAY,QAAQO,EAAa,CAClD,QAAAP,CAAA,CACD,CAEyB,CAAA,CAavB,SACLR,EACAC,EACAQ,EACAO,EACA,CACA,MAAMC,EAAsB,CAC1Bf,EAAAA,iBAAiBF,CAAQ,EAAE,KAAK,KAAK,EACrCgB,EACAP,CACF,EAYO,MAAA,CAAE,SAVQ,IACf,KAAK,YAAc,EAAA,MAAM,SAASQ,EAAc,CAC9C,QAAShB,EACT,MAAO,KAAK,SAAA,CACb,EAMgB,SALF,IACf,KAAK,YAAc,EAAA,YAAY,SAASgB,EAAc,CACpD,QAAShB,CAAA,CACV,CAEyB,CAAA,CAEhC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (r, t, e) =>
|
|
4
|
-
import { V as
|
|
5
|
-
import { CONTRACT_ADDRESSES as
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var C = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var o = (r, t, e) => C(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { V as u, p } from "../../constants-C9YZ6Ewc.js";
|
|
5
|
+
import { CONTRACT_ADDRESSES as l } from "../addresses.js";
|
|
6
6
|
import { TOKENS_ADDRESSES as n } from "../tokens.js";
|
|
7
|
-
import { ERC20PermitHandler as
|
|
8
|
-
import { PufLocker as
|
|
9
|
-
import { g as
|
|
10
|
-
class
|
|
7
|
+
import { ERC20PermitHandler as w } from "./erc20-permit-handler.js";
|
|
8
|
+
import { PufLocker as P } from "../abis/mainnet/PufLocker.js";
|
|
9
|
+
import { g as f } from "../../getContract-DEPNMZxg.js";
|
|
10
|
+
class R {
|
|
11
11
|
/**
|
|
12
12
|
* Create the handler for the `PufLocker` contract exposing methods to
|
|
13
13
|
* interact with the contract.
|
|
@@ -21,7 +21,7 @@ class _ {
|
|
|
21
21
|
constructor(t, e, i) {
|
|
22
22
|
o(this, "viemChain");
|
|
23
23
|
o(this, "erc20PermitHandler");
|
|
24
|
-
this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain =
|
|
24
|
+
this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain = u[t], this.erc20PermitHandler = new w(
|
|
25
25
|
t,
|
|
26
26
|
e,
|
|
27
27
|
i
|
|
@@ -34,8 +34,8 @@ class _ {
|
|
|
34
34
|
* @returns The viem contract.
|
|
35
35
|
*/
|
|
36
36
|
getContract() {
|
|
37
|
-
const t =
|
|
38
|
-
return
|
|
37
|
+
const t = l[this.chain].PufLocker, e = P, i = { public: this.publicClient, wallet: this.walletClient };
|
|
38
|
+
return f({ address: t, abi: e, client: i });
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Get all deposits of the given account address.
|
|
@@ -59,12 +59,12 @@ class _ {
|
|
|
59
59
|
* @param limit The maximum number of deposits to retrieve.
|
|
60
60
|
* @returns The amount and release time of the deposits.
|
|
61
61
|
*/
|
|
62
|
-
getDeposits(t, e, i,
|
|
62
|
+
getDeposits(t, e, i, s) {
|
|
63
63
|
return this.getContract().read.getDeposits([
|
|
64
64
|
e,
|
|
65
65
|
n[t][this.chain],
|
|
66
66
|
i,
|
|
67
|
-
|
|
67
|
+
s
|
|
68
68
|
]);
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
@@ -99,35 +99,26 @@ class _ {
|
|
|
99
99
|
const {
|
|
100
100
|
token: e,
|
|
101
101
|
account: i,
|
|
102
|
-
recipient:
|
|
103
|
-
value:
|
|
102
|
+
recipient: s,
|
|
103
|
+
value: a,
|
|
104
104
|
lockPeriod: c,
|
|
105
105
|
isPreapproved: h = !1
|
|
106
106
|
} = t;
|
|
107
107
|
let m = {
|
|
108
|
-
r:
|
|
109
|
-
s:
|
|
108
|
+
r: p("0x", { size: 32 }),
|
|
109
|
+
s: p("0x", { size: 32 }),
|
|
110
110
|
v: 0,
|
|
111
111
|
deadline: 0n,
|
|
112
|
-
amount:
|
|
112
|
+
amount: a
|
|
113
113
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
);
|
|
120
|
-
m = {
|
|
121
|
-
r: u,
|
|
122
|
-
s: g,
|
|
123
|
-
v: Number(C ?? w),
|
|
124
|
-
deadline: P,
|
|
125
|
-
amount: s
|
|
126
|
-
};
|
|
127
|
-
}
|
|
114
|
+
h || (m = await this.erc20PermitHandler.withToken(e).getPermitData(
|
|
115
|
+
i,
|
|
116
|
+
l[this.chain].PufLocker,
|
|
117
|
+
a
|
|
118
|
+
));
|
|
128
119
|
const d = [
|
|
129
120
|
n[e][this.chain],
|
|
130
|
-
|
|
121
|
+
s,
|
|
131
122
|
c,
|
|
132
123
|
m
|
|
133
124
|
];
|
|
@@ -148,21 +139,21 @@ class _ {
|
|
|
148
139
|
* @param depositIndexes Deposit indexes to withdraw.
|
|
149
140
|
* @returns Hash of the withdrawal transaction.
|
|
150
141
|
*/
|
|
151
|
-
withdraw(t, e, i,
|
|
152
|
-
const
|
|
142
|
+
withdraw(t, e, i, s) {
|
|
143
|
+
const a = [
|
|
153
144
|
n[t][this.chain],
|
|
154
|
-
|
|
145
|
+
s,
|
|
155
146
|
i
|
|
156
147
|
];
|
|
157
|
-
return { transact: () => this.getContract().write.withdraw(
|
|
148
|
+
return { transact: () => this.getContract().write.withdraw(a, {
|
|
158
149
|
account: e,
|
|
159
150
|
chain: this.viemChain
|
|
160
|
-
}), estimate: () => this.getContract().estimateGas.withdraw(
|
|
151
|
+
}), estimate: () => this.getContract().estimateGas.withdraw(a, {
|
|
161
152
|
account: e
|
|
162
153
|
}) };
|
|
163
154
|
}
|
|
164
155
|
}
|
|
165
156
|
export {
|
|
166
|
-
|
|
157
|
+
R as PufLockerHandler
|
|
167
158
|
};
|
|
168
159
|
//# sourceMappingURL=puf-locker-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puf-locker-handler.js","sources":["../../../lib/contracts/handlers/puf-locker-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { AnyToken, TOKENS_ADDRESSES } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufLocker } from '../abis/mainnet/PufLocker';\n\nexport type LockerDepositParams = {\n token: AnyToken;\n account: Address;\n recipient: Address;\n value: bigint;\n lockPeriod: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufLocker` contract exposing methods to interact\n * with the contract.\n */\nexport class PufLockerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufLocker` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufLocker as Address;\n const abi = PufLocker;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get all deposits of the given account address.\n *\n * @param pufToken The PufToken to get the deposits for.\n * @param walletAddress The wallet address to get the deposits for.\n * @returns The amount and deposits of the given account address.\n */\n public getAllDeposits(pufToken: AnyToken, walletAddress: Address) {\n return this.getContract().read.getAllDeposits([\n TOKENS_ADDRESSES[pufToken][this.chain],\n walletAddress,\n ]);\n }\n\n /**\n * Get the user's deposits for the given token and deposit index.\n *\n * @param pufToken PufToken to get the deposits of.\n * @param userAddress User address to get the deposits for.\n * @param start The starting index of the deposits.\n * @param limit The maximum number of deposits to retrieve.\n * @returns The amount and release time of the deposits.\n */\n public getDeposits(\n pufToken: AnyToken,\n userAddress: Address,\n start: bigint,\n limit: bigint,\n ) {\n return this.getContract().read.getDeposits([\n userAddress,\n TOKENS_ADDRESSES[pufToken][this.chain],\n start,\n limit,\n ]);\n }\n\n /**\n * Get the minimum and maximum lock periods allowed for deposits.\n *\n * @returns The minimum and maximum lock period in seconds.\n * (`[minLock, maxLock]`)\n */\n public getLockPeriods() {\n return this.getContract().read.getLockPeriods();\n }\n\n /**\n * Deposit the given PufToken into the locker. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param depositParams.pufToken PufToken to deposit.\n * @param depositParams.account Wallet address of the depositor.\n * @param depositParams.recipient Recipient of the deposit.\n * @param depositParams.value Amount of the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: LockerDepositParams) {\n const {\n token,\n account,\n recipient,\n value,\n lockPeriod,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n
|
|
1
|
+
{"version":3,"file":"puf-locker-handler.js","sources":["../../../lib/contracts/handlers/puf-locker-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { AnyToken, TOKENS_ADDRESSES } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufLocker } from '../abis/mainnet/PufLocker';\nimport { PermitData } from '../common/lib/types';\n\nexport type LockerDepositParams = {\n token: AnyToken;\n account: Address;\n recipient: Address;\n value: bigint;\n lockPeriod: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufLocker` contract exposing methods to interact\n * with the contract.\n */\nexport class PufLockerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufLocker` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufLocker as Address;\n const abi = PufLocker;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get all deposits of the given account address.\n *\n * @param pufToken The PufToken to get the deposits for.\n * @param walletAddress The wallet address to get the deposits for.\n * @returns The amount and deposits of the given account address.\n */\n public getAllDeposits(pufToken: AnyToken, walletAddress: Address) {\n return this.getContract().read.getAllDeposits([\n TOKENS_ADDRESSES[pufToken][this.chain],\n walletAddress,\n ]);\n }\n\n /**\n * Get the user's deposits for the given token and deposit index.\n *\n * @param pufToken PufToken to get the deposits of.\n * @param userAddress User address to get the deposits for.\n * @param start The starting index of the deposits.\n * @param limit The maximum number of deposits to retrieve.\n * @returns The amount and release time of the deposits.\n */\n public getDeposits(\n pufToken: AnyToken,\n userAddress: Address,\n start: bigint,\n limit: bigint,\n ) {\n return this.getContract().read.getDeposits([\n userAddress,\n TOKENS_ADDRESSES[pufToken][this.chain],\n start,\n limit,\n ]);\n }\n\n /**\n * Get the minimum and maximum lock periods allowed for deposits.\n *\n * @returns The minimum and maximum lock period in seconds.\n * (`[minLock, maxLock]`)\n */\n public getLockPeriods() {\n return this.getContract().read.getLockPeriods();\n }\n\n /**\n * Deposit the given PufToken into the locker. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param depositParams.pufToken PufToken to deposit.\n * @param depositParams.account Wallet address of the depositor.\n * @param depositParams.recipient Recipient of the deposit.\n * @param depositParams.value Amount of the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: LockerDepositParams) {\n const {\n token,\n account,\n recipient,\n value,\n lockPeriod,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData: PermitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n permitData = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n CONTRACT_ADDRESSES[this.chain].PufLocker as Address,\n value,\n );\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n recipient,\n lockPeriod,\n permitData,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Withdraw the deposits identified by the deposit indexes from the\n * locker.\n *\n * @param pufToken PufToken to withdraw.\n * @param walletAddress Address of the account making the transaction.\n * @param recipient Recipient of the withdrawal.\n * @param depositIndexes Deposit indexes to withdraw.\n * @returns Hash of the withdrawal transaction.\n */\n public withdraw(\n pufToken: AnyToken,\n walletAddress: Address,\n recipient: Address,\n depositIndexes: bigint[],\n ) {\n const withdrawArgs = <const>[\n TOKENS_ADDRESSES[pufToken][this.chain],\n depositIndexes,\n recipient,\n ];\n\n const transact = () =>\n this.getContract().write.withdraw(withdrawArgs, {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.withdraw(withdrawArgs, {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufLockerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufLocker","client","getContract","pufToken","walletAddress","TOKENS_ADDRESSES","userAddress","start","limit","depositParams","token","account","recipient","value","lockPeriod","isPreapproved","permitData","padHex","depositArgs","depositIndexes","withdrawArgs"],"mappings":";;;;;;;;;AA4BO,MAAMA,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc5B,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAaE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,qBAAqB,IAAIK;AAAA,MAC5BL;AAAA,MACAC;AAAA,MACAC;AAAA,IACF;AAAA,EAAA;AAAA;AAAA;AA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UAAU;AAAA,MACV,QAAQJ;AAAA,IACV;AAEA,IAAKE,MACHC,IAAa,MAAM,KAAK,mBACrB,UAAUN,CAAK,EACf;AAAA,MACCC;AAAA,MACAb,EAAmB,KAAK,KAAK,EAAE;AAAA,MAC/Be;AAAA,IACF;AAGJ,UAAMK,IAAqB;AAAA,MACzBb,EAAiBK,CAAK,EAAE,KAAK,KAAK;AAAA,MAClCE;AAAA,MACAE;AAAA,MACAE;AAAA,IACF;AAYO,WAAA,EAAE,UAVQ,MACf,KAAK,YAAc,EAAA,MAAM,QAAQE,GAAa;AAAA,MAC5C,SAAAP;AAAA,MACA,OAAO,KAAK;AAAA,IAAA,CACb,GAMgB,UALF,MACf,KAAK,YAAc,EAAA,YAAY,QAAQO,GAAa;AAAA,MAClD,SAAAP;AAAA,IAAA,CACD,EAEyB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAavB,SACLR,GACAC,GACAQ,GACAO,GACA;AACA,UAAMC,IAAsB;AAAA,MAC1Bf,EAAiBF,CAAQ,EAAE,KAAK,KAAK;AAAA,MACrCgB;AAAA,MACAP;AAAA,IACF;AAYO,WAAA,EAAE,UAVQ,MACf,KAAK,YAAc,EAAA,MAAM,SAASQ,GAAc;AAAA,MAC9C,SAAShB;AAAA,MACT,OAAO,KAAK;AAAA,IAAA,CACb,GAMgB,UALF,MACf,KAAK,YAAc,EAAA,YAAY,SAASgB,GAAc;AAAA,MACpD,SAAShB;AAAA,IAAA,CACV,EAEyB;AAAA,EAAA;AAEhC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var u=(a,t,e)=>t in a?h(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var n=(a,t,e)=>u(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants-CxSgz27h.cjs"),r=require("../addresses.cjs"),C=require("./erc20-permit-handler.cjs"),s=require("../tokens.cjs"),T=require("../abis/mainnet/PufferDepositor.cjs"),p=require("../../getContract-DUA3M2pm.cjs");class D{constructor(t,e,i){n(this,"viemChain");n(this,"erc20PermitHandler");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=m.VIEM_CHAINS[t],this.erc20PermitHandler=new C.ERC20PermitHandler(t,e,i)}getContract(){const t=r.CONTRACT_ADDRESSES[this.chain].PufferDepositor,e=T.PufferDepositor,i={public:this.publicClient,wallet:this.walletClient};return p.getContract({address:t,abi:e,client:i})}async depositStETH(t,e){const i=await this.erc20PermitHandler.withToken(s.Token.stETH).getPermitData(t,r.CONTRACT_ADDRESSES[this.chain].PufferDepositor,e);return{transact:async()=>await this.getContract().write.depositStETH([i,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.depositStETH([i,t],{account:t})}}async depositWstETH(t,e){const i=await this.erc20PermitHandler.withToken(s.Token.wstETH).getPermitData(t,r.CONTRACT_ADDRESSES[this.chain].PufferDepositor,e);return{transact:async()=>await this.getContract().write.depositWstETH([i,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.depositWstETH([i,t],{account:t})}}}exports.PufferDepositorHandler=D;
|
|
2
2
|
//# sourceMappingURL=puffer-depositor-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address;\n const abi = PufferDepositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositStETH(walletAddress: Address, value: bigint) {\n const
|
|
1
|
+
{"version":3,"file":"puffer-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address;\n const abi = PufferDepositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositStETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.stETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositStETH([permitData, walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = async () =>\n await this.getContract().estimateGas.depositStETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Deposit wstETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the wstETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositWstETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.wstETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositWstETH(\n [permitData, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n const estimate = async () =>\n await this.getContract().estimateGas.depositWstETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferDepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferDepositor","client","getContract","walletAddress","value","permitData","Token"],"mappings":"keAiBO,MAAMA,CAAuB,CAclC,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,2BAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,mBAAqB,IAAIK,EAAA,mBAC5BL,EACAC,EACAC,CACF,CAAA,CASK,aAAc,CACnB,MAAMI,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,gBACzCC,EAAMC,EAAA,gBACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CAoB7C,MAAa,aAAaE,EAAwBC,EAAe,CAC/D,MAAMC,EAAa,MAAM,KAAK,mBAC3B,UAAUC,EAAA,MAAM,KAAK,EACrB,cACCH,EACAL,qBAAmB,KAAK,KAAK,EAAE,gBAC/BM,CACF,EAaK,MAAA,CAAE,SAXQ,SACf,MAAM,KAAK,YAAA,EAAc,MAAM,aAAa,CAACC,EAAYF,CAAa,EAAG,CACvE,QAASA,EACT,MAAO,KAAK,SAAA,CACb,EAOgB,SANF,SACf,MAAM,KAAK,cAAc,YAAY,aACnC,CAACE,EAAYF,CAAa,EAC1B,CAAE,QAASA,CAAc,CAC3B,CAE0B,CAAA,CAgB9B,MAAa,cAAcA,EAAwBC,EAAe,CAChE,MAAMC,EAAa,MAAM,KAAK,mBAC3B,UAAUC,EAAA,MAAM,MAAM,EACtB,cACCH,EACAL,qBAAmB,KAAK,KAAK,EAAE,gBAC/BM,CACF,EAgBK,MAAA,CAAE,SAdQ,SACf,MAAM,KAAK,cAAc,MAAM,cAC7B,CAACC,EAAYF,CAAa,EAC1B,CACE,QAASA,EACT,MAAO,KAAK,SAAA,CAEhB,EAOiB,SANF,SACf,MAAM,KAAK,cAAc,YAAY,cACnC,CAACE,EAAYF,CAAa,EAC1B,CAAE,QAASA,CAAc,CAC3B,CAE0B,CAAA,CAEhC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { V as
|
|
5
|
-
import { CONTRACT_ADDRESSES as
|
|
6
|
-
import { ERC20PermitHandler as
|
|
7
|
-
import { Token as
|
|
8
|
-
import { PufferDepositor as
|
|
9
|
-
import { g } from "../../getContract-DEPNMZxg.js";
|
|
10
|
-
class
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var h = (e, t, i) => t in e ? m(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var r = (e, t, i) => h(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { V as p } from "../../constants-C9YZ6Ewc.js";
|
|
5
|
+
import { CONTRACT_ADDRESSES as n } from "../addresses.js";
|
|
6
|
+
import { ERC20PermitHandler as f } from "./erc20-permit-handler.js";
|
|
7
|
+
import { Token as o } from "../tokens.js";
|
|
8
|
+
import { PufferDepositor as C } from "../abis/mainnet/PufferDepositor.js";
|
|
9
|
+
import { g as u } from "../../getContract-DEPNMZxg.js";
|
|
10
|
+
class w {
|
|
11
11
|
/**
|
|
12
12
|
* Create the handler for the `PufferDepositor` contract exposing
|
|
13
13
|
* methods to interact with the contract.
|
|
@@ -19,9 +19,9 @@ class k {
|
|
|
19
19
|
* interactions.
|
|
20
20
|
*/
|
|
21
21
|
constructor(t, i, a) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.chain = t, this.walletClient = i, this.publicClient = a, this.viemChain =
|
|
22
|
+
r(this, "viemChain");
|
|
23
|
+
r(this, "erc20PermitHandler");
|
|
24
|
+
this.chain = t, this.walletClient = i, this.publicClient = a, this.viemChain = p[t], this.erc20PermitHandler = new f(
|
|
25
25
|
t,
|
|
26
26
|
i,
|
|
27
27
|
a
|
|
@@ -34,8 +34,8 @@ class k {
|
|
|
34
34
|
* @returns The viem contract.
|
|
35
35
|
*/
|
|
36
36
|
getContract() {
|
|
37
|
-
const t =
|
|
38
|
-
return
|
|
37
|
+
const t = n[this.chain].PufferDepositor, i = C, a = { public: this.publicClient, wallet: this.walletClient };
|
|
38
|
+
return u({ address: t, abi: i, client: a });
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Deposit stETH in exchange for pufETH. This doesn't make the
|
|
@@ -51,22 +51,16 @@ class k {
|
|
|
51
51
|
* transaction.
|
|
52
52
|
*/
|
|
53
53
|
async depositStETH(t, i) {
|
|
54
|
-
const
|
|
54
|
+
const a = await this.erc20PermitHandler.withToken(o.stETH).getPermitData(
|
|
55
55
|
t,
|
|
56
|
-
|
|
56
|
+
n[this.chain].PufferDepositor,
|
|
57
57
|
i
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
s: n,
|
|
61
|
-
v: Number(o ?? s),
|
|
62
|
-
deadline: c,
|
|
63
|
-
amount: i
|
|
64
|
-
};
|
|
65
|
-
return { transact: async () => await this.getContract().write.depositStETH([r, t], {
|
|
58
|
+
);
|
|
59
|
+
return { transact: async () => await this.getContract().write.depositStETH([a, t], {
|
|
66
60
|
account: t,
|
|
67
61
|
chain: this.viemChain
|
|
68
62
|
}), estimate: async () => await this.getContract().estimateGas.depositStETH(
|
|
69
|
-
[
|
|
63
|
+
[a, t],
|
|
70
64
|
{ account: t }
|
|
71
65
|
) };
|
|
72
66
|
}
|
|
@@ -84,30 +78,24 @@ class k {
|
|
|
84
78
|
* transaction.
|
|
85
79
|
*/
|
|
86
80
|
async depositWstETH(t, i) {
|
|
87
|
-
const
|
|
81
|
+
const a = await this.erc20PermitHandler.withToken(o.wstETH).getPermitData(
|
|
88
82
|
t,
|
|
89
|
-
|
|
83
|
+
n[this.chain].PufferDepositor,
|
|
90
84
|
i
|
|
91
|
-
)
|
|
92
|
-
r: a,
|
|
93
|
-
s: n,
|
|
94
|
-
v: Number(o ?? s),
|
|
95
|
-
deadline: c,
|
|
96
|
-
amount: i
|
|
97
|
-
};
|
|
85
|
+
);
|
|
98
86
|
return { transact: async () => await this.getContract().write.depositWstETH(
|
|
99
|
-
[
|
|
87
|
+
[a, t],
|
|
100
88
|
{
|
|
101
89
|
account: t,
|
|
102
90
|
chain: this.viemChain
|
|
103
91
|
}
|
|
104
92
|
), estimate: async () => await this.getContract().estimateGas.depositWstETH(
|
|
105
|
-
[
|
|
93
|
+
[a, t],
|
|
106
94
|
{ account: t }
|
|
107
95
|
) };
|
|
108
96
|
}
|
|
109
97
|
}
|
|
110
98
|
export {
|
|
111
|
-
|
|
99
|
+
w as PufferDepositorHandler
|
|
112
100
|
};
|
|
113
101
|
//# sourceMappingURL=puffer-depositor-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address;\n const abi = PufferDepositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositStETH(walletAddress: Address, value: bigint) {\n const
|
|
1
|
+
{"version":3,"file":"puffer-depositor-handler.js","sources":["../../../lib/contracts/handlers/puffer-depositor-handler.ts"],"sourcesContent":["import {\n Address,\n GetContractReturnType,\n PublicClient,\n WalletClient,\n getContract,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { Token } from '../tokens';\nimport { PufferDepositor } from '../abis/mainnet/PufferDepositor';\n\n/**\n * Handler for the `PufferDepositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferDepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferDepositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address;\n const abi = PufferDepositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit stETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the stETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositStETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.stETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositStETH([permitData, walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = async () =>\n await this.getContract().estimateGas.depositStETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Deposit wstETH in exchange for pufETH. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param walletAddress Wallet address to get the stETH from.\n * @param value Value in wei of the wstETH to deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async depositWstETH(walletAddress: Address, value: bigint) {\n const permitData = await this.erc20PermitHandler\n .withToken(Token.wstETH)\n .getPermitData(\n walletAddress,\n CONTRACT_ADDRESSES[this.chain].PufferDepositor as Address,\n value,\n );\n\n const transact = async () =>\n await this.getContract().write.depositWstETH(\n [permitData, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n const estimate = async () =>\n await this.getContract().estimateGas.depositWstETH(\n [permitData, walletAddress],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferDepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferDepositor","client","getContract","walletAddress","value","permitData","Token"],"mappings":";;;;;;;;;AAiBO,MAAMA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAclC,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAaE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,qBAAqB,IAAIK;AAAA,MAC5BL;AAAA,MACAC;AAAA,MACAC;AAAA,IACF;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASK,cAAc;AACnB,UAAMI,IAAUC,EAAmB,KAAK,KAAK,EAAE,iBACzCC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAL,GA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object.defineProperty;var C=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var s=(i,t,e)=>C(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants-CxSgz27h.cjs"),l=require("../addresses.cjs"),f=require("../tokens.cjs"),m=require("./erc20-permit-handler.cjs"),P=require("../abis/mainnet/PufferL2Depositor.cjs"),D=require("../../getContract-DUA3M2pm.cjs");class S{constructor(t,e,r){s(this,"viemChain");s(this,"erc20PermitHandler");this.chain=t,this.walletClient=e,this.publicClient=r,this.viemChain=n.VIEM_CHAINS[t],this.erc20PermitHandler=new m.ERC20PermitHandler(t,e,r)}getContract(){const t=l.CONTRACT_ADDRESSES[this.chain].PufferL2Depositor,e=P.PufferL2Depositor,r={public:this.publicClient,wallet:this.walletClient};return D.getContract({address:t,abi:e,client:r})}async deposit(t){const{token:e,account:r,value:a,referralCode:d=0n,lockPeriod:h=0n,isPreapproved:u=!1}=t;let o={r:n.padHex("0x",{size:32}),s:n.padHex("0x",{size:32}),v:0,deadline:0n,amount:a};u||(o=await this.erc20PermitHandler.withToken(e).getPermitData(r,l.CONTRACT_ADDRESSES[this.chain].PufferL2Depositor,a));const c=[f.TOKENS_ADDRESSES[e][this.chain],r,o,d,h];return{transact:()=>this.getContract().write.deposit(c,{account:r,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit(c,{account:r})}}}exports.PufferL2DepositorHandler=S;
|
|
2
2
|
//# sourceMappingURL=puffer-l2-depositor-handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puffer-l2-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n
|
|
1
|
+
{"version":3,"file":"puffer-l2-depositor-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-l2-depositor-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { TOKENS_ADDRESSES, Token } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\nimport { PufferL2Depositor } from '../abis/mainnet/PufferL2Depositor';\n\nexport type L2DepositParams = {\n token: Token;\n account: Address;\n value: bigint;\n referralCode?: bigint;\n lockPeriod?: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufferL2Depositor` contract exposing methods to\n * interact with the contract.\n */\nexport class PufferL2DepositorHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufferL2Depositor` contract exposing\n * methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufferL2Depositor as Address;\n const abi = PufferL2Depositor;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Deposit the given token in exchange for the wrapped PufToken. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * Note that not all token contracts support permit signatures (e.g.\n * USDC). If a token's contract doesn't support permit signatures, use\n * `Token.approve()` and be sure to set the option `isPreapproved` to\n * `true`.\n *\n * @param depositParams.token Token to deposit.\n * @param depositParams.account Wallet address to take the token from.\n * @param depositParams.value Value in wei of the token to deposit.\n * @param depositParams.referralCode Referral code for the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: L2DepositParams) {\n const {\n token,\n account,\n value,\n referralCode = 0n,\n lockPeriod = 0n,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n permitData = await this.erc20PermitHandler\n .withToken(token)\n .getPermitData(\n account,\n CONTRACT_ADDRESSES[this.chain].PufferL2Depositor as Address,\n value,\n );\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n account,\n permitData,\n referralCode,\n lockPeriod,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufferL2DepositorHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PufferL2Depositor","client","getContract","depositParams","token","account","value","referralCode","lockPeriod","isPreapproved","permitData","padHex","depositArgs","TOKENS_ADDRESSES"],"mappings":"oeA2BO,MAAMA,CAAyB,CAcpC,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,2BAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,mBAAqB,IAAIK,EAAA,mBAC5BL,EACAC,EACAC,CACF,CAAA,CASK,aAAc,CACnB,MAAMI,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,kBACzCC,EAAMC,EAAA,kBACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CA+B7C,MAAa,QAAQE,EAAgC,CAC7C,KAAA,CACJ,MAAAC,EACA,QAAAC,EACA,MAAAC,EACA,aAAAC,EAAe,GACf,WAAAC,EAAa,GACb,cAAAC,EAAgB,EAAA,EACdN,EAIJ,IAAIO,EAAa,CACf,EAAGC,EAAAA,OAAO,KAAM,CAAE,KAAM,GAAI,EAC5B,EAAGA,EAAAA,OAAO,KAAM,CAAE,KAAM,GAAI,EAC5B,EAAG,EACH,SAAU,GACV,OAAQL,CACV,EAEKG,IACHC,EAAa,MAAM,KAAK,mBACrB,UAAUN,CAAK,EACf,cACCC,EACAP,qBAAmB,KAAK,KAAK,EAAE,kBAC/BQ,CACF,GAGJ,MAAMM,EAAqB,CACzBC,EAAAA,iBAAiBT,CAAK,EAAE,KAAK,KAAK,EAClCC,EACAK,EACAH,EACAC,CACF,EAYO,MAAA,CAAE,SAVQ,I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