@pufferfinance/puffer-sdk 1.26.0 → 1.26.1

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.
@@ -62,6 +62,15 @@ class _ {
62
62
  const t = p[this.token][this.chain], n = v, e = { public: this.publicClient, wallet: this.walletClient };
63
63
  return w({ address: t, abi: n, client: e });
64
64
  }
65
+ /**
66
+ * Get the nonces for the given account.
67
+ *
68
+ * @param account Address of the account.
69
+ * @returns The nonces.
70
+ */
71
+ nonces(t) {
72
+ return this.getContract().read.nonces([t]);
73
+ }
65
74
  /**
66
75
  * Process and get permit signature for the given token to perform
67
76
  * transactions without calling `approve()`.
@@ -72,7 +81,7 @@ class _ {
72
81
  * @returns Permit signature in the form `{ r, s, v?, yParity }`.
73
82
  */
74
83
  async getPermitSignature(t, n, e) {
75
- const r = this.getContract(), a = await r.read.nonces([t]), o = {
84
+ const r = this.getContract(), a = await this.nonces(t), o = {
76
85
  name: await r.read.name(),
77
86
  version: this.getPermitVersion(this.token),
78
87
  chainId: this.chain,
@@ -1 +1 @@
1
- {"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\nimport { PermitData } from '../common/lib/types';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\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.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\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 = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\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 * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await contract.read.nonces([ownerAddress]);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Get the permit data for the given owner, spender and value.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value/amount to be permitted.\n * @returns Permit data in the form `{ r, s, v, deadline, amount }`.\n */\n public async getPermitData(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ): Promise<PermitData> {\n const { r, s, v, yParity, deadline } = await this.getPermitSignature(\n ownerAddress,\n spenderAddress,\n value,\n );\n\n /* istanbul ignore next */\n return { r, s, v: Number(v ?? yParity), deadline, amount: value };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","_b","_a","TOKENS_SALT"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,IAChD,CAACK,GAAGC,CAAO,KAAK,MAAM;AACxB,QAAIF,MAAe,KAAKA,MAAe;AACnC,aAAO,CAAC,QAAWA,CAAU;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAClD,GAAQ;AACJ,SAAI,OAAOC,IAAM,MACN;AAAA,IACH,GAAGE,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAAG;AAAA,IACA,SAAAC;AAAA,EACH,IACE;AAAA,IACH,GAA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,EAG5B,cAAcA,GAAiB;;AACrC,YAAOkB,KAAAC,IAAAC,MAAA,gBAAAD,EAAcnB,OAAd,gBAAAkB,EAAuB,KAAK;AAAA,EAAK;AAE5C;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"erc20-permit-handler.js","sources":["../../../node_modules/.pnpm/viem@2.33.1_typescript@5.8.2_zod@3.24.2/node_modules/viem/_esm/utils/signature/parseSignature.js","../../../lib/contracts/handlers/erc20-permit-handler.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { numberToHex, } from '../../utils/encoding/toHex.js';\n/**\n * @description Parses a hex formatted signature into a structured signature.\n *\n * @param signatureHex Signature in hex format.\n * @returns The structured signature.\n *\n * @example\n * parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')\n * // { r: '0x...', s: '0x...', v: 28n }\n */\nexport function parseSignature(signatureHex) {\n const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130));\n const yParityOrV = Number(`0x${signatureHex.slice(130)}`);\n const [v, yParity] = (() => {\n if (yParityOrV === 0 || yParityOrV === 1)\n return [undefined, yParityOrV];\n if (yParityOrV === 27)\n return [BigInt(yParityOrV), 0];\n if (yParityOrV === 28)\n return [BigInt(yParityOrV), 1];\n throw new Error('Invalid yParityOrV value');\n })();\n if (typeof v !== 'undefined')\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v,\n yParity,\n };\n return {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n yParity,\n };\n}\n//# sourceMappingURL=parseSignature.js.map","import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n parseSignature,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport {\n AnyToken,\n TOKENS_ADDRESSES,\n TOKENS_SALT,\n TOKENS_PERMIT_VERSION,\n Token,\n} from '../tokens';\nimport { getTimestampInSeconds } from '../../utils/time';\nimport { ERC20Permit } from '../abis/mainnet/ERC20Permit';\nimport { PermitData } from '../common/lib/types';\n\n/**\n * Handler for performing operations for and with ERC20Permit tokens.\n */\nexport class ERC20PermitHandler {\n private viemChain: ViemChain;\n private token: AnyToken;\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.token = Token.WETH;\n }\n\n /**\n * Set the token to use for executing transactions on the contract.\n *\n * @param token Token to use for the handler.\n * @returns The handler.\n */\n public withToken(token: AnyToken) {\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 = TOKENS_ADDRESSES[this.token][this.chain];\n const abi = ERC20Permit;\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 nonces for the given account.\n *\n * @param account Address of the account.\n * @returns The nonces.\n */\n public nonces(account: Address) {\n return this.getContract().read.nonces([account]);\n }\n\n /**\n * Process and get permit signature for the given token to perform\n * transactions without calling `approve()`.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value of the transaction.\n * @returns Permit signature in the form `{ r, s, v?, yParity }`.\n */\n public async getPermitSignature(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n const contract = this.getContract();\n\n const permitNonces = await this.nonces(ownerAddress);\n const name = await contract.read.name();\n const domain = <const>{\n name,\n version: this.getPermitVersion(this.token),\n chainId: this.chain,\n verifyingContract: TOKENS_ADDRESSES[this.token][this.chain],\n salt: this.getPermitSalt(this.token),\n };\n const types = <const>{\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n };\n // Valid for 2 hours.\n const deadline = BigInt(getTimestampInSeconds() + 60 * 60 * 2);\n\n const signature = await this.walletClient.signTypedData({\n account: ownerAddress,\n domain,\n types,\n primaryType: 'Permit',\n message: {\n owner: ownerAddress,\n spender: spenderAddress,\n value,\n nonce: permitNonces,\n deadline,\n },\n });\n\n return { ...parseSignature(signature), deadline };\n }\n\n /**\n * Get the permit data for the given owner, spender and value.\n *\n * @param ownerAddress Address of the token owner.\n * @param spenderAddress Address of the spender who needs the permit.\n * @param value Value/amount to be permitted.\n * @returns Permit data in the form `{ r, s, v, deadline, amount }`.\n */\n public async getPermitData(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ): Promise<PermitData> {\n const { r, s, v, yParity, deadline } = await this.getPermitSignature(\n ownerAddress,\n spenderAddress,\n value,\n );\n\n /* istanbul ignore next */\n return { r, s, v: Number(v ?? yParity), deadline, amount: value };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n\n private getPermitVersion(token: AnyToken): string {\n return TOKENS_PERMIT_VERSION[token];\n }\n\n private getPermitSalt(token: AnyToken) {\n return TOKENS_SALT?.[token]?.[this.chain];\n }\n}\n"],"names":["parseSignature","signatureHex","r","s","secp256k1","yParityOrV","v","yParity","numberToHex","ERC20PermitHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","Token","token","address","TOKENS_ADDRESSES","abi","ERC20Permit","client","getContract","account","ownerAddress","spenderAddress","value","contract","permitNonces","domain","types","deadline","getTimestampInSeconds","signature","TOKENS_PERMIT_VERSION","_b","_a","TOKENS_SALT"],"mappings":";;;;;;;;;AAYO,SAASA,EAAeC,GAAc;AACzC,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAG,IAAGC,EAAU,UAAU,YAAYH,EAAa,MAAM,GAAG,GAAG,CAAC,GACrEI,IAAa,CAAO,KAAKJ,EAAa,MAAM,GAAG,CAAC,IAChD,CAACK,GAAGC,CAAO,KAAK,MAAM;AACxB,QAAIF,MAAe,KAAKA,MAAe;AACnC,aAAO,CAAC,QAAWA,CAAU;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,QAAIA,MAAe;AACf,aAAO,CAAC,OAAOA,CAAU,GAAG,CAAC;AACjC,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAClD,GAAQ;AACJ,SAAI,OAAOC,IAAM,MACN;AAAA,IACH,GAAGE,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAAG;AAAA,IACA,SAAAC;AAAA,EACH,IACE;AAAA,IACH,GAAGC,EAAYN,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,GAAGM,EAAYL,GAAG,EAAE,MAAM,GAAE,CAAE;AAAA,IAC9B,SAAAI;AAAA,EACH;AACL;ACbO,MAAME,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa9B,YACUC,GACAC,GACAC,GACR;AAhBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK,GAClC,KAAK,QAAQK,EAAM;AAAA,EAAA;AAAA;AAAA;AAAA;AAA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,cAAc;AAAA,MACtD,SAAST;AAAA,MACT,QAAAK;AAAA,MACA,OAAAC;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,QACP,OAAON;AAAA,QACP,SAASC;AAAA,QACT,OAAAC;AAAA,QACA,OAAOE;AAAA,QACP,UAAAG;AAAA,MAAA;AAAA,IACF,CACD;AAED,WAAO,EAAE,GAAG/B,EAAeiC,CAAS,GAAG,UAAAF,EAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,MAAa,cACXP,GACAC,GACAC,GACqB;AACf,UAAA,EAAE,GAAG,GAAAvB,GAAG,GAAAG,GAAG,SAAAC,GAAS,UAAAwB,EAAS,IAAI,MAAM,KAAK;AAAA,MAChDP;AAAA,MACAC;AAAA,MACAC;AAAA,IACF;AAGO,WAAA,EAAE,GAAG,GAAAvB,GAAG,GAAG,OAAOG,KAAKC,CAAO,GAAG,UAAAwB,GAAU,QAAQL,EAAM;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW3D,QACLF,GACAC,GACAC,GACA;AACO,WAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,GAAgBC,CAAK,GAAG;AAAA,MAC/D,SAASF;AAAA,MACT,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA,EAGK,iBAAiBR,GAAyB;AAChD,WAAOkB,EAAsBlB,CAAK;AAAA,EAAA;AAAA,EAG5B,cAAcA,GAAiB;;AACrC,YAAOmB,KAAAC,IAAAC,MAAA,gBAAAD,EAAcpB,OAAd,gBAAAmB,EAAuB,KAAK;AAAA,EAAK;AAE5C;","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var o=(i,t,a)=>t in i?r(i,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[t]=a;var c=(i,t,a)=>o(i,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../constants-CxSgz27h.cjs"),u=require("../addresses.cjs"),m=require("../abis/mainnet/PufferVaultV2.cjs"),C=require("../../getContract-DUA3M2pm.cjs");class g{constructor(t,a,e){c(this,"viemChain");this.chain=t,this.walletClient=a,this.publicClient=e,this.viemChain=h.VIEM_CHAINS[t]}getContract(){const t=u.CONTRACT_ADDRESSES[this.chain].PufferVault,a=m.PufferVaultV2,e={public:this.publicClient,wallet:this.walletClient};return C.getContract({address:t,abi:a,client:e})}deposit(t,a){return{transact:async()=>await this.getContract().write.deposit([a,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.deposit([a,t],{account:t})}}depositETH(t){return{transact:async n=>await this.getContract().write.depositETH([t],{account:t,chain:this.viemChain,value:n}),estimate:async()=>await this.getContract().estimateGas.depositETH([t],{account:t})}}async balanceOf(t){return await this.getContract().read.balanceOf([t])}async getPufETHRate(){const t=BigInt(1e18);return await this.getContract().read.previewDeposit([t])}async getAllowance(t,a){return await this.getContract().read.allowance([t,a])}withdraw(t,a,e){return{transact:async()=>await this.getContract().write.withdraw([e,a,t],{account:a,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.withdraw([e,a,t],{account:a})}}previewRedeem(t){return this.getContract().read.previewRedeem([t])}maxRedeem(t){return this.getContract().read.maxRedeem([t])}getExitFeeBasisPoints(){return this.getContract().read.getExitFeeBasisPoints()}getRemainingAssetsDailyWithdrawalLimit(){return this.getContract().read.getRemainingAssetsDailyWithdrawalLimit()}redeem(t,a,e){return{transact:async()=>await this.getContract().write.redeem([e,a,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.redeem([e,a,t],{account:t})}}convertToAssets(t){return this.getContract().read.convertToAssets([t])}}exports.PufferVaultHandler=g;
1
+ "use strict";var r=Object.defineProperty;var o=(i,t,a)=>t in i?r(i,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[t]=a;var s=(i,t,a)=>o(i,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants-CxSgz27h.cjs"),h=require("../addresses.cjs"),C=require("../abis/mainnet/PufferVaultV5.cjs"),g=require("../../getContract-DUA3M2pm.cjs");class m{constructor(t,a,e){s(this,"viemChain");this.chain=t,this.walletClient=a,this.publicClient=e,this.viemChain=u.VIEM_CHAINS[t]}getContract(){const t=h.CONTRACT_ADDRESSES[this.chain].PufferVault,a=C.PufferVaultV5,e={public:this.publicClient,wallet:this.walletClient};return g.getContract({address:t,abi:a,client:e})}deposit(t,a){return{transact:async()=>await this.getContract().write.deposit([a,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.deposit([a,t],{account:t})}}depositETH(t){return{transact:async n=>await this.getContract().write.depositETH([t],{account:t,chain:this.viemChain,value:n}),estimate:async()=>await this.getContract().estimateGas.depositETH([t],{account:t})}}async balanceOf(t){return await this.getContract().read.balanceOf([t])}async getPufETHRate(){const t=BigInt(1e18);return await this.getContract().read.previewDeposit([t])}async getAllowance(t,a){return await this.getContract().read.allowance([t,a])}withdraw(t,a,e){return{transact:async()=>await this.getContract().write.withdraw([e,a,t],{account:a,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.withdraw([e,a,t],{account:a})}}previewRedeem(t){return this.getContract().read.previewRedeem([t])}maxRedeem(t){return this.getContract().read.maxRedeem([t])}getExitFeeBasisPoints(){return this.getContract().read.getExitFeeBasisPoints()}getTreasuryExitFeeBasisPoints(){return this.getContract().read.getTreasuryExitFeeBasisPoints()}getTotalExitFeeBasisPoints(){return this.getContract().read.getTotalExitFeeBasisPoints()}redeem(t,a,e){return{transact:async()=>await this.getContract().write.redeem([e,a,t],{account:t,chain:this.viemChain}),estimate:async()=>await this.getContract().estimateGas.redeem([e,a,t],{account:t})}}convertToAssets(t){return this.getContract().read.convertToAssets([t])}}exports.PufferVaultHandler=m;
2
2
  //# sourceMappingURL=puffer-vault-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"puffer-vault-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-vault-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 { PufferVaultV2 } from '../abis/mainnet/PufferVaultV2';\n\n/**\n * Handler for the `PufferVaultV2` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferVaultHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferVaultV2` 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 }\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].PufferVault as Address;\n const abi = PufferVaultV2;\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 tokens(e.g. WETH) 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 tokens from.\n * @param value Value of tokens to deposit.\n * @returns `transact: (value: bigint) => Promise<Address>` -\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public deposit(walletAddress: Address, value: bigint) {\n const transact = async () =>\n await this.getContract().write.deposit([value, walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n });\n\n const estimate = async () =>\n await this.getContract().estimateGas.deposit([value, walletAddress], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Deposit ETH 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 ETH from.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public depositETH(walletAddress: Address) {\n const transact = async (value: bigint) =>\n await this.getContract().write.depositETH([walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n value,\n });\n\n const estimate = async () =>\n await this.getContract().estimateGas.depositETH([walletAddress], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Check the pufETH balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns pufETH balance in wei.\n */\n public async balanceOf(walletAddress: Address) {\n return await this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the rate of pufETH compared to ETH.\n *\n * @returns Rate of pufETH compared to 1 ETH.\n */\n public async getPufETHRate() {\n const oneWei = BigInt(1e18);\n return await this.getContract().read.previewDeposit([oneWei]);\n }\n\n /**\n * Get the allowance for the given owner and spender.\n *\n * @param ownerAddress Address of the owner.\n * @param spenderAddress Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public async getAllowance(ownerAddress: Address, spenderAddress: Address) {\n return await this.getContract().read.allowance([\n ownerAddress,\n spenderAddress,\n ]);\n }\n\n /**\n * Withdraw pufETH to the given wallet address. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param ownerAddress Address of the owner.\n * @param walletAddress Address of the receiver.\n * @param value Value of pufETH to withdraw.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public withdraw(\n ownerAddress: Address,\n walletAddress: Address,\n value: bigint,\n ) {\n const transact = async () =>\n await this.getContract().write.withdraw(\n [value, walletAddress, ownerAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.withdraw(\n [value, walletAddress, ownerAddress],\n {\n account: walletAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Preview the amount of WETH that can be redeemed for the given\n * amount of pufETH using the `.redeem()` method.\n *\n * @param value Value of pufETH to redeem.\n * @returns Preview of the amount of WETH that can be redeemed.\n */\n public previewRedeem(value: bigint) {\n return this.getContract().read.previewRedeem([value]);\n }\n\n /**\n * Calculates the maximum amount of pufETH shares that can be redeemed\n * by the owner.\n *\n * @param ownerAddress Address of the owner's wallet.\n * @returns Maximum amount of pufETH shares that can be redeemed.\n */\n public maxRedeem(ownerAddress: Address) {\n return this.getContract().read.maxRedeem([ownerAddress]);\n }\n\n /**\n * Returns how many basis points of a fee there are when exiting. For\n * example, a 1% fee would mean 1% of the user's requested pufETH is\n * burned (which increases the value for all pufETH holders) before\n * the ETH is redeemed. i.e., you get 1% less ETH back.\n *\n * @returns Basis points of the exit fee.\n */\n public getExitFeeBasisPoints() {\n return this.getContract().read.getExitFeeBasisPoints();\n }\n\n /**\n * Returns how much WETH can still be withdrawn today.\n *\n * @returns Remaining WETH daily withdrawal limit.\n */\n public getRemainingAssetsDailyWithdrawalLimit() {\n return this.getContract().read.getRemainingAssetsDailyWithdrawalLimit();\n }\n\n /**\n * Redeems pufETH shares in exchange for WETH assets from the vault.\n * In the process, the pufETH shares of the owner are burned. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * @param ownerAddress Address of the owner of pufETH.\n * @param receiverAddress Address of the receiver of WETH.\n * @param shares Amount of pufETH shares to redeem.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public redeem(\n ownerAddress: Address,\n receiverAddress: Address,\n shares: bigint,\n ) {\n const transact = async () =>\n await this.getContract().write.redeem(\n [shares, receiverAddress, ownerAddress],\n {\n account: ownerAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.redeem(\n [shares, receiverAddress, ownerAddress],\n {\n account: ownerAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Gives exchange rate of pufETH relative to WETH.\n * This does not include any fees, as compared to previewRedeem method.\n *\n * @param amount Amount of pufETH to convert.\n * @returns Amount of equivalent WETH.\n */\n public convertToAssets(amount: bigint) {\n return this.getContract().read.convertToAssets([amount]);\n }\n}\n"],"names":["PufferVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferVaultV2","client","getContract","walletAddress","value","oneWei","ownerAddress","spenderAddress","receiverAddress","shares","amount"],"mappings":"6ZAeO,MAAMA,CAAmB,CAa9B,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,CAAA,CAS7B,aAAc,CACnB,MAAMK,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,YACzCC,EAAMC,EAAA,cACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CAmBtC,QAAQE,EAAwBC,EAAe,CAY7C,MAAA,CAAE,SAXQ,SACf,MAAM,KAAK,YAAA,EAAc,MAAM,QAAQ,CAACA,EAAOD,CAAa,EAAG,CAC7D,QAASA,EACT,MAAO,KAAK,SAAA,CACb,EAOgB,SALF,SACf,MAAM,KAAK,YAAA,EAAc,YAAY,QAAQ,CAACC,EAAOD,CAAa,EAAG,CACnE,QAASA,CAAA,CACV,CAEyB,CAAA,CAevB,WAAWA,EAAwB,CAajC,MAAA,CAAE,SAZQ,MAAOC,GACtB,MAAM,KAAK,YAAY,EAAE,MAAM,WAAW,CAACD,CAAa,EAAG,CACzD,QAASA,EACT,M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SACf,MAAM,KAAK,cAAc,YAAY,OACnC,CAACG,EAAQD,EAAiBF,CAAY,EACtC,CACE,QAASA,CAAA,CAEb,CAE0B,CAAA,CAUvB,gBAAgBI,EAAgB,CACrC,OAAO,KAAK,YAAY,EAAE,KAAK,gBAAgB,CAACA,CAAM,CAAC,CAAA,CAE3D"}
1
+ {"version":3,"file":"puffer-vault-handler.cjs","sources":["../../../lib/contracts/handlers/puffer-vault-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 { PufferVaultV5 } from '../abis/mainnet/PufferVaultV5';\n\n/**\n * Handler for the `PufferVaultV2` contract exposing methods to interact\n * with the contract.\n */\nexport class PufferVaultHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for the `PufferVaultV2` 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 }\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].PufferVault as Address;\n const abi = PufferVaultV5;\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 tokens(e.g. WETH) 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 tokens from.\n * @param value Value of tokens to deposit.\n * @returns `transact: (value: bigint) => Promise<Address>` -\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public deposit(walletAddress: Address, value: bigint) {\n const transact = async () =>\n await this.getContract().write.deposit([value, walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n });\n\n const estimate = async () =>\n await this.getContract().estimateGas.deposit([value, walletAddress], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Deposit ETH 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 ETH from.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public depositETH(walletAddress: Address) {\n const transact = async (value: bigint) =>\n await this.getContract().write.depositETH([walletAddress], {\n account: walletAddress,\n chain: this.viemChain,\n value,\n });\n\n const estimate = async () =>\n await this.getContract().estimateGas.depositETH([walletAddress], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Check the pufETH balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns pufETH balance in wei.\n */\n public async balanceOf(walletAddress: Address) {\n return await this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the rate of pufETH compared to ETH.\n *\n * @returns Rate of pufETH compared to 1 ETH.\n */\n public async getPufETHRate() {\n const oneWei = BigInt(1e18);\n return await this.getContract().read.previewDeposit([oneWei]);\n }\n\n /**\n * Get the allowance for the given owner and spender.\n *\n * @param ownerAddress Address of the owner.\n * @param spenderAddress Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public async getAllowance(ownerAddress: Address, spenderAddress: Address) {\n return await this.getContract().read.allowance([\n ownerAddress,\n spenderAddress,\n ]);\n }\n\n /**\n * Withdraw pufETH to the given wallet address. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param ownerAddress Address of the owner.\n * @param walletAddress Address of the receiver.\n * @param value Value of pufETH to withdraw.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public withdraw(\n ownerAddress: Address,\n walletAddress: Address,\n value: bigint,\n ) {\n const transact = async () =>\n await this.getContract().write.withdraw(\n [value, walletAddress, ownerAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.withdraw(\n [value, walletAddress, ownerAddress],\n {\n account: walletAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Preview the amount of WETH that can be redeemed for the given\n * amount of pufETH using the `.redeem()` method.\n *\n * @param value Value of pufETH to redeem.\n * @returns Preview of the amount of WETH that can be redeemed.\n */\n public previewRedeem(value: bigint) {\n return this.getContract().read.previewRedeem([value]);\n }\n\n /**\n * Calculates the maximum amount of pufETH shares that can be redeemed\n * by the owner.\n *\n * @param ownerAddress Address of the owner's wallet.\n * @returns Maximum amount of pufETH shares that can be redeemed.\n */\n public maxRedeem(ownerAddress: Address) {\n return this.getContract().read.maxRedeem([ownerAddress]);\n }\n\n /**\n * Returns how many basis points of a fee there are when exiting. For\n * example, a 1% fee would mean 1% of the user's requested pufETH is\n * burned (which increases the value for all pufETH holders) before\n * the ETH is redeemed. i.e., you get 1% less ETH back. i.e., you get\n * 1% less ETH back.\n *\n * @returns Basis points of the exit fee.\n */\n public getExitFeeBasisPoints() {\n return this.getContract().read.getExitFeeBasisPoints();\n }\n\n /**\n * Returns how many treasury basis points of a fee there are when\n * exiting. For example, a 1% fee would mean 1% of the user's\n * requested pufETH is burned (which increases the value for all\n * pufETH holders) before the ETH is redeemed.\n *\n * @returns Basis points of the exit fee.\n */\n public getTreasuryExitFeeBasisPoints() {\n return this.getContract().read.getTreasuryExitFeeBasisPoints();\n }\n\n /**\n * Returns how many basis points of a fee there are in total when\n * exiting. For example, a 1% fee would mean 1% of the user's\n * requested pufETH is burned (which increases the value for all\n * pufETH holders) before the ETH is redeemed. i.e., you get 1% less\n * ETH back.\n *\n * @returns Basis points of the exit fee.\n */\n public getTotalExitFeeBasisPoints() {\n return this.getContract().read.getTotalExitFeeBasisPoints();\n }\n\n /**\n * Redeems pufETH shares in exchange for WETH assets from the vault.\n * In the process, the pufETH shares of the owner are burned. This\n * doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * @param ownerAddress Address of the owner of pufETH.\n * @param receiverAddress Address of the receiver of WETH.\n * @param shares Amount of pufETH shares to redeem.\n * @returns `transact: (value: bigint) => Promise<Address>` - Used to\n * make the transaction with the given value.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public redeem(\n ownerAddress: Address,\n receiverAddress: Address,\n shares: bigint,\n ) {\n const transact = async () =>\n await this.getContract().write.redeem(\n [shares, receiverAddress, ownerAddress],\n {\n account: ownerAddress,\n chain: this.viemChain,\n },\n );\n\n const estimate = async () =>\n await this.getContract().estimateGas.redeem(\n [shares, receiverAddress, ownerAddress],\n {\n account: ownerAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Gives exchange rate of pufETH relative to WETH.\n * This does not include any fees, as compared to previewRedeem method.\n *\n * @param amount Amount of pufETH to convert.\n * @returns Amount of equivalent WETH.\n */\n public convertToAssets(amount: bigint) {\n return this.getContract().read.convertToAssets([amount]);\n }\n}\n"],"names":["PufferVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","CONTRACT_ADDRESSES","abi","PufferVaultV5","client","getContract","walletAddress","value","oneWei","ownerAddress","spenderAddress","receiverAddress","shares","amount"],"mappings":"6ZAeO,MAAMA,CAAmB,CAa9B,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,CAAA,CAS7B,aAAc,CACnB,MAAMK,EAAUC,EAAA,mBAAmB,KAAK,KAAK,EAAE,YACzCC,EAAMC,EAAA,cACNC,EAAS,CAAE,OAAQ,KAAK,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