@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.
Files changed (70) hide show
  1. package/dist/api/puffer-client.cjs +1 -1
  2. package/dist/api/puffer-client.cjs.map +1 -1
  3. package/dist/api/puffer-client.d.ts +3 -0
  4. package/dist/api/puffer-client.js +28 -21
  5. package/dist/api/puffer-client.js.map +1 -1
  6. package/dist/contracts/abis/mainnet/vlPUFFER.cjs +2 -0
  7. package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -0
  8. package/dist/contracts/abis/mainnet/vlPUFFER.d.ts +437 -0
  9. package/dist/contracts/abis/mainnet/vlPUFFER.js +269 -0
  10. package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -0
  11. package/dist/contracts/common/lib/types.cjs +2 -0
  12. package/dist/contracts/common/lib/types.cjs.map +1 -0
  13. package/dist/contracts/common/lib/types.d.ts +8 -0
  14. package/dist/contracts/common/lib/types.js +2 -0
  15. package/dist/contracts/common/lib/types.js.map +1 -0
  16. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  17. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  18. package/dist/contracts/handlers/erc20-permit-handler.d.ts +10 -0
  19. package/dist/contracts/handlers/erc20-permit-handler.js +56 -40
  20. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  21. package/dist/contracts/handlers/lagoon-vault-handler.cjs +1 -1
  22. package/dist/contracts/handlers/lagoon-vault-handler.cjs.map +1 -1
  23. package/dist/contracts/handlers/lagoon-vault-handler.d.ts +51 -0
  24. package/dist/contracts/handlers/lagoon-vault-handler.js +87 -6
  25. package/dist/contracts/handlers/lagoon-vault-handler.js.map +1 -1
  26. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  27. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
  28. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +2 -6
  29. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +17 -17
  30. package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
  31. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  32. package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
  33. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +2 -6
  34. package/dist/contracts/handlers/nucleus-teller-handler.js +11 -20
  35. package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
  36. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  37. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
  38. package/dist/contracts/handlers/puf-locker-handler.js +31 -40
  39. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
  40. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  41. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
  42. package/dist/contracts/handlers/puffer-depositor-handler.js +26 -38
  43. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
  44. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  45. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
  46. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +28 -37
  47. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
  48. package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
  49. package/dist/contracts/handlers/puffer-protocol-handler.d.ts +49 -55
  50. package/dist/contracts/handlers/puffer-protocol-handler.js.map +1 -1
  51. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  52. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
  53. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +21 -27
  54. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
  55. package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
  56. package/dist/contracts/handlers/validator-ticket-handler.d.ts +1 -7
  57. package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
  58. package/dist/contracts/handlers/vl-puffer-handler.cjs +2 -0
  59. package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -0
  60. package/dist/contracts/handlers/vl-puffer-handler.d.ts +14802 -0
  61. package/dist/contracts/handlers/vl-puffer-handler.js +357 -0
  62. package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -0
  63. package/dist/contracts/tokens.cjs +1 -1
  64. package/dist/contracts/tokens.cjs.map +1 -1
  65. package/dist/contracts/tokens.d.ts +2 -1
  66. package/dist/contracts/tokens.js +8 -3
  67. package/dist/contracts/tokens.js.map +1 -1
  68. package/dist/utils/version.cjs +1 -1
  69. package/dist/utils/version.js +1 -1
  70. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  var r = Object.defineProperty;
2
- var o = (a, t, e) => t in a ? r(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var n = (a, t, e) => o(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { V as s } from "../../constants-C9YZ6Ewc.js";
5
- import { LagoonVault as c } from "../abis/mainnet/LagoonVault.js";
2
+ var s = (a, t, e) => t in a ? r(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var n = (a, t, e) => s(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { V as c } from "../../constants-C9YZ6Ewc.js";
5
+ import { LagoonVault as o } from "../abis/mainnet/LagoonVault.js";
6
6
  import { Token as h } from "../tokens.js";
7
7
  import { VAULTS_ADDRESSES as l } from "../vaults-addresses.js";
8
8
  import { g as u } from "../../getContract-DEPNMZxg.js";
@@ -18,7 +18,7 @@ class v {
18
18
  */
19
19
  constructor(t, e, i) {
20
20
  n(this, "viemChain");
21
- this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain = s[t];
21
+ this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain = c[t];
22
22
  }
23
23
  /**
24
24
  * Get the contract.
@@ -26,7 +26,7 @@ class v {
26
26
  * @returns The viem contract.
27
27
  */
28
28
  getContract() {
29
- const t = l[h.tacpufETH][this.chain].LagoonVault, e = c, i = { public: this.publicClient, wallet: this.walletClient };
29
+ const t = l[h.tacpufETH][this.chain].LagoonVault, e = o, i = { public: this.publicClient, wallet: this.walletClient };
30
30
  return u({ address: t, abi: e, client: i });
31
31
  }
32
32
  /**
@@ -143,6 +143,20 @@ class v {
143
143
  }
144
144
  );
145
145
  }
146
+ /**
147
+ * Get the pending deposit request for the request id and controller.
148
+ *
149
+ * @param requestId The request id. Use `0` as wild card.
150
+ * @param controller The controller. Usually the depositor or user who
151
+ * initiated the deposit.
152
+ * @returns The pending deposit request.
153
+ */
154
+ pendingDepositRequest(t = 0n, e) {
155
+ return this.getContract().read.pendingDepositRequest([
156
+ t,
157
+ e
158
+ ]);
159
+ }
146
160
  /**
147
161
  * Withdraw an amount of the shares (pufETH) so the receiver
148
162
  * gets the assets (pufETH).
@@ -194,6 +208,20 @@ class v {
194
208
  }
195
209
  );
196
210
  }
211
+ /**
212
+ * Get the pending redeem request for the request id and controller.
213
+ *
214
+ * @param requestId The request id. Use `0` as wild card.
215
+ * @param controller The controller. Usually the redeemer or user who
216
+ * initiated the redeem.
217
+ * @returns The pending redeem request.
218
+ */
219
+ pendingRedeemRequest(t = 0n, e) {
220
+ return this.getContract().read.pendingRedeemRequest([
221
+ t,
222
+ e
223
+ ]);
224
+ }
197
225
  /**
198
226
  * Provides a preview of the number of shares that would be minted for
199
227
  * a given deposit amount, after fees.
@@ -246,6 +274,59 @@ class v {
246
274
  convertToShares(t, e) {
247
275
  return e ? this.getContract().read.convertToShares([t, e]) : this.getContract().read.convertToShares([t]);
248
276
  }
277
+ /**
278
+ * Get the claimable deposit request for the request id and controller.
279
+ *
280
+ * @param requestId The request id. Use `0` as wild card.
281
+ * @param controller The controller. Usually the depositor or user who
282
+ * initiated the deposit.
283
+ * @returns The claimable deposit request.
284
+ */
285
+ claimableDepositRequest(t = 0n, e) {
286
+ return this.getContract().read.claimableDepositRequest([
287
+ t,
288
+ e
289
+ ]);
290
+ }
291
+ /**
292
+ * Get the claimable redeem request for the request id and controller.
293
+ *
294
+ * @param requestId The request id. Use `0` as wild card.
295
+ * @param controller The controller. Usually the redeemer or user who
296
+ * initiated the redeem.
297
+ * @returns The claimable redeem request.
298
+ */
299
+ claimableRedeemRequest(t = 0n, e) {
300
+ return this.getContract().read.claimableRedeemRequest([
301
+ t,
302
+ e
303
+ ]);
304
+ }
305
+ /**
306
+ * Claim shares and request a redeem of an amount of the shares (tacpufETH)
307
+ * so the receiver gets the assets (pufETH).
308
+ *
309
+ * @param shares The amount of shares (tacpufETH) to claim.
310
+ * @returns The transaction.
311
+ */
312
+ claimSharesAndRequestRedeem(t) {
313
+ return this.getContract().write.claimSharesAndRequestRedeem([t], {
314
+ account: this.walletClient.account,
315
+ chain: this.viemChain
316
+ });
317
+ }
318
+ /**
319
+ * Claim shares on behalf of multiple controllers.
320
+ *
321
+ * @param controllers The controllers to claim shares on behalf of.
322
+ * @returns The transaction.
323
+ */
324
+ claimSharesOnBehalf(t) {
325
+ return this.getContract().write.claimSharesOnBehalf([t], {
326
+ account: this.walletClient.account,
327
+ chain: this.viemChain
328
+ });
329
+ }
249
330
  }
250
331
  export {
251
332
  v as LagoonVaultHandler
@@ -1 +1 @@
1
- {"version":3,"file":"lagoon-vault-handler.js","sources":["../../../lib/contracts/handlers/lagoon-vault-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { LagoonVault } from '../abis/mainnet/LagoonVault';\nimport { Token } from '../tokens';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\n\n/**\n * Handler for the `LagoonVault` contract exposing methods to interact\n * with the contract.\n */\nexport class LagoonVaultHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for processing Lagoon vault.\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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = VAULTS_ADDRESSES[Token.tacpufETH][this.chain]\n .LagoonVault as Address;\n const abi = LagoonVault;\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 * Approve a spender to spend the token.\n *\n * @param spender The spender of the token.\n * @param amount The amount to approve.\n * @returns The transaction.\n */\n public approve(spender: Address, amount: bigint) {\n return this.getContract().write.approve([spender, amount], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the allowance of the owner for the spender.\n *\n * @param owner The owner of the allowance.\n * @param spender The spender of the allowance.\n * @returns The allowance.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Get the balance for the address.\n *\n * @param address The address to get the balance of.\n * @returns The balance.\n */\n public getBalance(address: Address) {\n return this.getContract().read.balanceOf([address]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns The total supply.\n */\n public getTotalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Check if the total assets are valid. Used for checking if\n * synchronous deposit is possible.\n *\n * @returns True if the total assets are valid, false otherwise.\n */\n public isTotalAssetsValid() {\n return this.getContract().read.isTotalAssetsValid();\n }\n\n /**\n * Get the symbol of the token. (tacpufETH)\n *\n * @returns The symbol.\n */\n public symbol() {\n return this.getContract().read.symbol();\n }\n\n /**\n * Deposit an amount of the assets (pufETH) to the vault to get shares\n * (tacpufETH).\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param controller The optional controller of the deposit. Set to\n * the receiver if not sure.\n * @returns The transaction.\n */\n public deposit(amount: bigint, receiver: Address, controller?: Address) {\n if (controller) {\n return this.getContract().write.deposit([amount, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n return this.getContract().write.deposit([amount, receiver], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Synchronously deposit an amount of the assets (pufETH) to the vault\n * to get shares (tacpufETH). This is only possible if `isTotalAssetsValid`\n * is true.\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param referral The referral of the deposit. Falls back to the\n * receiver if not provided.\n * @returns The transaction.\n */\n public syncDeposit(\n amount: bigint,\n receiver: Address,\n referral: Address = receiver,\n ) {\n return this.getContract().write.syncDeposit([amount, receiver, referral], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Request an asynchronous deposit of an amount of the assets (pufETH)\n * to the vault to get shares (tacpufETH). This should be used if\n * `isTotalAssetsValid` is false.\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param controller The optional controller of the deposit. Falls back\n * to the receiver if not provided.\n * @returns The transaction.\n */\n public requestDeposit(\n amount: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.requestDeposit(\n [amount, receiver, controller],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n value: amount,\n },\n );\n }\n\n /**\n * Withdraw an amount of the shares (pufETH) so the receiver\n * gets the assets (pufETH).\n *\n * @param assets The amount of assets (pufETH) to withdraw.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the withdrawal. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public withdraw(\n assets: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.withdraw([assets, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Redeem an amount of the shares (tacpufETH) so the receiver\n * gets the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the withdrawal. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public redeem(\n shares: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.redeem([shares, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Request an asynchronous redeem of an amount of the shares (tacpufETH)\n * so the receiver gets the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the redemption. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public requestRedeem(\n shares: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.requestRedeem(\n [shares, receiver, controller],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Provides a preview of the number of shares that would be minted for\n * a given deposit amount, after fees.\n *\n * @param amount The amount to deposit.\n * @returns The preview.\n */\n public previewDeposit(amount: bigint) {\n return this.getContract().read.previewDeposit([amount]);\n }\n\n /**\n * Provides a preview of the number of shares (tacpufETH) that would be\n * burned for the given amount of assets (pufETH).\n *\n * @param assets The amount of assets (pufETH) to withdraw.\n * @returns The preview.\n */\n public previewWithdraw(assets: bigint) {\n return this.getContract().read.previewWithdraw([assets]);\n }\n\n /**\n * Provides a preview of the amount of assets (pufETH) that would be redeemed\n * for the given shares (tacpufETH), after withdrawal fees. Subtracts\n * the withdrawal fee from the share amount to determine the net\n * shares for asset conversion.\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @returns The preview.\n */\n public previewRedeem(shares: bigint) {\n return this.getContract().read.previewRedeem([shares]);\n }\n\n /**\n * Convert an amount of the shares (tacpufETH) to the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to convert.\n * @param requestId An optional request id for the conversion.\n * @returns The amount of assets (pufETH).\n */\n public convertToAssets(shares: bigint, requestId?: bigint) {\n if (requestId) {\n return this.getContract().read.convertToAssets([shares, requestId]);\n }\n\n return this.getContract().read.convertToAssets([shares]);\n }\n\n /**\n * Convert an amount of the assets (pufETH) to the shares (tacpufETH).\n *\n * @param assets The amount of assets (pufETH) to convert.\n * @param requestId An optional request id for the conversion.\n * @returns The amount of shares (tacpufETH).\n */\n public convertToShares(assets: bigint, requestId?: bigint) {\n if (requestId) {\n return this.getContract().read.convertToShares([assets, requestId]);\n }\n\n return this.getContract().read.convertToShares([assets]);\n }\n}\n"],"names":["LagoonVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","VAULTS_ADDRESSES","Token","abi","LagoonVault","client","getContract","spender","amount","owner","receiver","controller","referral","assets","shares","requestId"],"mappings":";;;;;;;;AAiBO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY9B,YACUC,GACAC,GACAC,GACR;AAfM,IAAAC,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,cAAc;AACnB,UAAMK,IAAUC,EAAiBC,EAAM,SAAS,EAAE,KAAK,KAAK,EACzD,aACGC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAN,GAAS,KAAAG,GAAK,QAAAE,GAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EActC,QAAQE,GAAkBC,GAAgB;AACxC,WAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,GAASC,CAAM,GAAG;AAAA,MACzD,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EA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,CAACA,CAAM,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUjD,gBAAgBK,GAAgB;AACrC,WAAO,KAAK,YAAY,EAAE,KAAK,gBAAgB,CAACA,CAAM,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYlD,cAAcC,GAAgB;AACnC,WAAO,KAAK,YAAY,EAAE,KAAK,cAAc,CAACA,CAAM,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUhD,gBAAgBA,GAAgBC,GAAoB;AACzD,WAAIA,IACK,KAAK,cAAc,KAAK,gBAAgB,CAACD,GAAQC,CAAS,CAAC,IAG7D,KAAK,YAAY,EAAE,KAAK,gBAAgB,CAACD,CAAM,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlD,gBAAgBD,GAAgBE,GAAoB;AACzD,WAAIA,IACK,KAAK,cAAc,KAAK,gBAAgB,CAACF,GAAQE,CAAS,CAAC,IAG7D,KAAK,YAAY,EAAE,KAAK,gBAAgB,CAACF,CAAM,CAAC;AAAA,EAAA;AAE3D;"}
1
+ {"version":3,"file":"lagoon-vault-handler.js","sources":["../../../lib/contracts/handlers/lagoon-vault-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n GetContractReturnType,\n Account,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { LagoonVault } from '../abis/mainnet/LagoonVault';\nimport { Token } from '../tokens';\nimport { VAULTS_ADDRESSES } from '../vaults-addresses';\n\n/**\n * Handler for the `LagoonVault` contract exposing methods to interact\n * with the contract.\n */\nexport class LagoonVaultHandler {\n private viemChain: ViemChain;\n\n /**\n * Create the handler for processing Lagoon vault.\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.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = VAULTS_ADDRESSES[Token.tacpufETH][this.chain]\n .LagoonVault as Address;\n const abi = LagoonVault;\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 * Approve a spender to spend the token.\n *\n * @param spender The spender of the token.\n * @param amount The amount to approve.\n * @returns The transaction.\n */\n public approve(spender: Address, amount: bigint) {\n return this.getContract().write.approve([spender, amount], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the allowance of the owner for the spender.\n *\n * @param owner The owner of the allowance.\n * @param spender The spender of the allowance.\n * @returns The allowance.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Get the balance for the address.\n *\n * @param address The address to get the balance of.\n * @returns The balance.\n */\n public getBalance(address: Address) {\n return this.getContract().read.balanceOf([address]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns The total supply.\n */\n public getTotalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Check if the total assets are valid. Used for checking if\n * synchronous deposit is possible.\n *\n * @returns True if the total assets are valid, false otherwise.\n */\n public isTotalAssetsValid() {\n return this.getContract().read.isTotalAssetsValid();\n }\n\n /**\n * Get the symbol of the token. (tacpufETH)\n *\n * @returns The symbol.\n */\n public symbol() {\n return this.getContract().read.symbol();\n }\n\n /**\n * Deposit an amount of the assets (pufETH) to the vault to get shares\n * (tacpufETH).\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param controller The optional controller of the deposit. Set to\n * the receiver if not sure.\n * @returns The transaction.\n */\n public deposit(amount: bigint, receiver: Address, controller?: Address) {\n if (controller) {\n return this.getContract().write.deposit([amount, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n return this.getContract().write.deposit([amount, receiver], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Synchronously deposit an amount of the assets (pufETH) to the vault\n * to get shares (tacpufETH). This is only possible if `isTotalAssetsValid`\n * is true.\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param referral The referral of the deposit. Falls back to the\n * receiver if not provided.\n * @returns The transaction.\n */\n public syncDeposit(\n amount: bigint,\n receiver: Address,\n referral: Address = receiver,\n ) {\n return this.getContract().write.syncDeposit([amount, receiver, referral], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Request an asynchronous deposit of an amount of the assets (pufETH)\n * to the vault to get shares (tacpufETH). This should be used if\n * `isTotalAssetsValid` is false.\n *\n * @param amount The amount to deposit.\n * @param receiver The receiver of the tacpufETH.\n * @param controller The optional controller of the deposit. Falls back\n * to the receiver if not provided.\n * @returns The transaction.\n */\n public requestDeposit(\n amount: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.requestDeposit(\n [amount, receiver, controller],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n value: amount,\n },\n );\n }\n\n /**\n * Get the pending deposit request for the request id and controller.\n *\n * @param requestId The request id. Use `0` as wild card.\n * @param controller The controller. Usually the depositor or user who\n * initiated the deposit.\n * @returns The pending deposit request.\n */\n public pendingDepositRequest(requestId: bigint = 0n, controller: Address) {\n return this.getContract().read.pendingDepositRequest([\n requestId,\n controller,\n ]);\n }\n\n /**\n * Withdraw an amount of the shares (pufETH) so the receiver\n * gets the assets (pufETH).\n *\n * @param assets The amount of assets (pufETH) to withdraw.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the withdrawal. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public withdraw(\n assets: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.withdraw([assets, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Redeem an amount of the shares (tacpufETH) so the receiver\n * gets the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the withdrawal. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public redeem(\n shares: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.redeem([shares, receiver, controller], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Request an asynchronous redeem of an amount of the shares (tacpufETH)\n * so the receiver gets the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @param receiver The receiver of the assets.\n * @param controller The controller of the redemption. Falls back to\n * the receiver if not provided.\n * @returns The transaction.\n */\n public requestRedeem(\n shares: bigint,\n receiver: Address,\n controller: Address = receiver,\n ) {\n return this.getContract().write.requestRedeem(\n [shares, receiver, controller],\n {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Get the pending redeem request for the request id and controller.\n *\n * @param requestId The request id. Use `0` as wild card.\n * @param controller The controller. Usually the redeemer or user who\n * initiated the redeem.\n * @returns The pending redeem request.\n */\n public pendingRedeemRequest(requestId: bigint = 0n, controller: Address) {\n return this.getContract().read.pendingRedeemRequest([\n requestId,\n controller,\n ]);\n }\n\n /**\n * Provides a preview of the number of shares that would be minted for\n * a given deposit amount, after fees.\n *\n * @param amount The amount to deposit.\n * @returns The preview.\n */\n public previewDeposit(amount: bigint) {\n return this.getContract().read.previewDeposit([amount]);\n }\n\n /**\n * Provides a preview of the number of shares (tacpufETH) that would be\n * burned for the given amount of assets (pufETH).\n *\n * @param assets The amount of assets (pufETH) to withdraw.\n * @returns The preview.\n */\n public previewWithdraw(assets: bigint) {\n return this.getContract().read.previewWithdraw([assets]);\n }\n\n /**\n * Provides a preview of the amount of assets (pufETH) that would be redeemed\n * for the given shares (tacpufETH), after withdrawal fees. Subtracts\n * the withdrawal fee from the share amount to determine the net\n * shares for asset conversion.\n *\n * @param shares The amount of shares (tacpufETH) to redeem.\n * @returns The preview.\n */\n public previewRedeem(shares: bigint) {\n return this.getContract().read.previewRedeem([shares]);\n }\n\n /**\n * Convert an amount of the shares (tacpufETH) to the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to convert.\n * @param requestId An optional request id for the conversion.\n * @returns The amount of assets (pufETH).\n */\n public convertToAssets(shares: bigint, requestId?: bigint) {\n if (requestId) {\n return this.getContract().read.convertToAssets([shares, requestId]);\n }\n\n return this.getContract().read.convertToAssets([shares]);\n }\n\n /**\n * Convert an amount of the assets (pufETH) to the shares (tacpufETH).\n *\n * @param assets The amount of assets (pufETH) to convert.\n * @param requestId An optional request id for the conversion.\n * @returns The amount of shares (tacpufETH).\n */\n public convertToShares(assets: bigint, requestId?: bigint) {\n if (requestId) {\n return this.getContract().read.convertToShares([assets, requestId]);\n }\n\n return this.getContract().read.convertToShares([assets]);\n }\n\n /**\n * Get the claimable deposit request for the request id and controller.\n *\n * @param requestId The request id. Use `0` as wild card.\n * @param controller The controller. Usually the depositor or user who\n * initiated the deposit.\n * @returns The claimable deposit request.\n */\n public claimableDepositRequest(requestId: bigint = 0n, controller: Address) {\n return this.getContract().read.claimableDepositRequest([\n requestId,\n controller,\n ]);\n }\n\n /**\n * Get the claimable redeem request for the request id and controller.\n *\n * @param requestId The request id. Use `0` as wild card.\n * @param controller The controller. Usually the redeemer or user who\n * initiated the redeem.\n * @returns The claimable redeem request.\n */\n public claimableRedeemRequest(requestId: bigint = 0n, controller: Address) {\n return this.getContract().read.claimableRedeemRequest([\n requestId,\n controller,\n ]);\n }\n\n /**\n * Claim shares and request a redeem of an amount of the shares (tacpufETH)\n * so the receiver gets the assets (pufETH).\n *\n * @param shares The amount of shares (tacpufETH) to claim.\n * @returns The transaction.\n */\n public claimSharesAndRequestRedeem(shares: bigint) {\n return this.getContract().write.claimSharesAndRequestRedeem([shares], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n\n /**\n * Claim shares on behalf of multiple controllers.\n *\n * @param controllers The controllers to claim shares on behalf of.\n * @returns The transaction.\n */\n public claimSharesOnBehalf(controllers: Address[]) {\n return this.getContract().write.claimSharesOnBehalf([controllers], {\n account: this.walletClient.account as Account,\n chain: this.viemChain,\n });\n }\n}\n"],"names":["LagoonVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","address","VAULTS_ADDRESSES","Token","abi","LagoonVault","client","getContract","spender","amount","owner","receiver","controller","referral","requestId","assets","shares","controllers"],"mappings":";;;;;;;;AAiBO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY9B,YACUC,GACAC,GACAC,GACR;AAfM,IAAAC,EAAA;AAYE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,eAAAC,GAEH,KAAA,YAAYE,EAAYJ,CAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,cAAc;AACnB,UAAMK,IAAUC,EAAiBC,EAAM,SAAS,EAAE,KAAK,KAAK,EACzD,aACGC,IAAMC,GACNC,IAAS,EAAE,QAAQ,KAAK,cAAc,QAAQ,KAAK,aAAa;AAEtE,WAAOC,EAAY,EAAE,SAAAN,GAAS,KAAAG,GAAK,QAAAE,GAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EActC,QAAQE,GAAkBC,GAAgB;AACxC,WAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,GAASC,CAAM,GAAG;AAAA,MACzD,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUI,aAAaC,G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AA,IAAA,CACD;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWI,uBAAuBE,IAAoB,IAAIF,GAAqB;AACzE,WAAO,KAAK,cAAc,KAAK,uBAAuB;AAAA,MACpDE;AAAA,MACAF;AAAA,IAAA,CACD;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUI,4BAA4BI,GAAgB;AACjD,WAAO,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAACA,CAAM,GAAG;AAAA,MACpE,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,oBAAoBC,GAAwB;AACjD,WAAO,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAACA,CAAW,GAAG;AAAA,MACjE,SAAS,KAAK,aAAa;AAAA,MAC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EAAA;AAEL;"}
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var C=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var c=(a,t,e)=>C(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants-CxSgz27h.cjs"),g=require("../vaults-addresses.cjs"),p=require("../tokens.cjs"),f=require("../abis/mainnet/BoringVault.cjs"),v=require("../../getContract-DUA3M2pm.cjs");class b{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=m.VIEM_CHAINS[t],this.token=p.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=g.VAULTS_ADDRESSES[this.token][this.chain].NucleusBoringVault,e=f.BoringVault,n={public:this.publicClient,wallet:this.walletClient};return v.getContract({address:t,abi:e,client:n})}getAllowance(t,e){return this.getContract().read.allowance([t,e])}balanceOf(t){return this.getContract().read.balanceOf([t])}totalSupply(){return this.getContract().read.totalSupply()}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}transfer(t,e,n){return{transact:()=>this.getContract().write.transfer([e,n],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transfer([e,n],{account:t})}}transferFrom(t,e,n,i){return{transact:()=>this.getContract().write.transferFrom([e,n,i],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transferFrom([e,n,i],{account:t})}}permit(t){const{account:e,owner:n,spender:i,value:r,deadline:s,v:o,r:u,s:h}=t;return{transact:()=>this.getContract().write.permit([n,i,r,s,o,u,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.permit([n,i,r,s,o,u,h],{account:e})}}}exports.NucleusBoringVaultHandler=b;
1
+ "use strict";var l=Object.defineProperty;var C=(a,t,e)=>t in a?l(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var c=(a,t,e)=>C(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../constants-CxSgz27h.cjs"),g=require("../vaults-addresses.cjs"),p=require("../tokens.cjs"),f=require("../abis/mainnet/BoringVault.cjs"),b=require("../../getContract-DUA3M2pm.cjs");class v{constructor(t,e,n){c(this,"viemChain");c(this,"token");this.chain=t,this.walletClient=e,this.publicClient=n,this.viemChain=m.VIEM_CHAINS[t],this.token=p.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=g.VAULTS_ADDRESSES[this.token][this.chain].NucleusBoringVault,e=f.BoringVault,n={public:this.publicClient,wallet:this.walletClient};return b.getContract({address:t,abi:e,client:n})}getAllowance(t,e){return this.getContract().read.allowance([t,e])}balanceOf(t){return this.getContract().read.balanceOf([t])}totalSupply(){return this.getContract().read.totalSupply()}approve(t,e,n){return this.getContract().write.approve([e,n],{account:t,chain:this.viemChain})}transfer(t,e,n){return{transact:()=>this.getContract().write.transfer([e,n],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transfer([e,n],{account:t})}}transferFrom(t,e,n,i){return{transact:()=>this.getContract().write.transferFrom([e,n,i],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.transferFrom([e,n,i],{account:t})}}permit(t){const{account:e,owner:n,spender:i,amount:r,deadline:s,v:o,r:u,s:h}=t;return{transact:()=>this.getContract().write.permit([n,i,r,s,o,u,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.permit([n,i,r,s,o,u,h],{account:e})}}}exports.NucleusBoringVaultHandler=v;
2
2
  //# sourceMappingURL=nucleus-boring-vault-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nucleus-boring-vault-handler.cjs","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\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 { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\n\nexport type PermitParams = {\n account: Address;\n owner: Address;\n spender: Address;\n value: bigint;\n deadline: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = 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 .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\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 transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => 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 transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\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 permit(params: PermitParams) {\n const { account, owner, spender, value, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, value, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, value, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","deadline","v","r","s"],"mappings":"6bA6BO,MAAMA,C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D,EAAWD,CAAK,EAAG,CACrE,QAASF,EACT,MAAO,KAAK,SAAA,CACb,EAOgB,SANF,IACf,KAAK,cAAc,YAAY,aAC7B,CAACI,EAAaD,EAAWD,CAAK,EAC9B,CAAE,QAASF,CAAc,CAC3B,CAE0B,CAAA,CAqBvB,OAAOK,EAAsB,CAC5B,KAAA,CAAE,QAAAC,EAAS,MAAAR,EAAO,QAAAC,EAAS,MAAAG,EAAO,SAAAK,EAAU,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,EAAML,EAYvD,MAAA,CAAE,SAXQ,IACf,KAAK,cAAc,MAAM,OACvB,CAACP,EAAOC,EAASG,EAAOK,EAAUC,EAAGC,EAAGC,CAAC,EACzC,CAAE,QAAAJ,EAAS,MAAO,KAAK,SAAU,CACnC,EAOiB,SANF,IACf,KAAK,cAAc,YAAY,OAC7B,CAACR,EAAOC,EAASG,EAAOK,EAAUC,EAAGC,EAAGC,CAAC,EACzC,CAAE,QAAAJ,CAAQ,CACZ,CAE0B,CAAA,CAEhC"}
1
+ {"version":3,"file":"nucleus-boring-vault-handler.cjs","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\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 { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\nimport { PermitData } from '../common/lib/types';\n\nexport type PermitParams = PermitData & {\n account: Address;\n owner: Address;\n spender: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = 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 .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\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 transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => 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 transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\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 permit(params: PermitParams) {\n const { account, owner, spender, amount, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","amount","deadline","v","r","s"],"mappings":"6bAyBO,MAAMA,CAA0B,CAarC,YACUC,EACAC,EACAC,EACR,CAhBMC,EAAA,kBACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,MAAQK,EAAAA,WAAW,QAAA,CAUnB,UAAUC,EAAmB,CAClC,YAAK,MAAQA,EACN,IAAA,CASF,aAAc,CACnB,MAAMC,EAAUC,EAAAA,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,mBACGC,EAAMC,EAAA,YACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CActC,aAAaE,EAAgBC,EAAkB,CAC7C,OAAA,KAAK,cAAc,KAAK,UAAU,CAACD,EAAOC,CAAO,CAAC,CAAA,CASpD,UAAUC,EAAwB,CACvC,OAAO,KAAK,YAAY,EAAE,KAAK,UAAU,CAACA,CAAa,CAAC,CAAA,CAQnD,aAAc,CACnB,OAAO,KAAK,cAAc,KAAK,YAAY,CAAA,CAWtC,QACLA,EACAC,EACAC,EACA,CACO,OAAA,KAAK,cAAc,MAAM,QAAQ,CAACD,EAAgBC,CAAK,EAAG,CAC/D,QAASF,EACT,MAAO,KAAK,SAAA,CACb,CAAA,CAeI,SAASA,EAAwBG,EAAoBD,EAAe,CAWlE,MAAA,CAAE,SAVQ,IACf,KAAK,YAAY,EAAE,MAAM,SAAS,CAACC,EAAWD,CAAK,EAAG,CACpD,QAASF,EACT,MAAO,KAAK,SAAA,CACb,EAMgB,SALF,IACf,KAAK,YAAY,EAAE,YAAY,SAAS,CAACG,EAAWD,CAAK,EAAG,CAC1D,QAASF,CAAA,CACV,CAEyB,CAAA,CAgBvB,aACLA,EACAI,EACAD,EACAD,EACA,CAYO,MAAA,CAAE,SAXQ,IACf,KAAK,cAAc,MAAM,aAAa,CAACE,EAAaD,EAAWD,CAAK,EAAG,CACrE,QAASF,EACT,MAAO,KAAK,SAAA,CACb,EAOgB,SANF,IACf,KAAK,cAAc,YAAY,aAC7B,CAACI,EAAaD,EAAWD,CAAK,EAC9B,CAAE,QAASF,CAAc,CAC3B,CAE0B,CAAA,CAqBvB,OAAOK,EAAsB,CAC5B,KAAA,CAAE,QAAAC,EAAS,MAAAR,EAAO,QAAAC,EAAS,OAAAQ,EAAQ,SAAAC,EAAU,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,EAAMN,EAYxD,MAAA,CAAE,SAXQ,IACf,KAAK,cAAc,MAAM,OACvB,CAACP,EAAOC,EAASQ,EAAQC,EAAUC,EAAGC,EAAGC,CAAC,EAC1C,CAAE,QAAAL,EAAS,MAAO,KAAK,SAAU,CACnC,EAOiB,SANF,IACf,KAAK,cAAc,YAAY,OAC7B,CAACR,EAAOC,EAASQ,EAAQC,EAAUC,EAAGC,EAAGC,CAAC,EAC1C,CAAE,QAAAL,CAAQ,CACZ,CAE0B,CAAA,CAEhC"}
@@ -1,15 +1,11 @@
1
1
  import { WalletClient, PublicClient, Address, GetContractReturnType } from 'viem';
2
2
  import { Chain, ViemChain } from '../../chains/constants';
3
3
  import { UnifiToken } from '../tokens';
4
- export type PermitParams = {
4
+ import { PermitData } from '../common/lib/types';
5
+ export type PermitParams = PermitData & {
5
6
  account: Address;
6
7
  owner: Address;
7
8
  spender: Address;
8
- value: bigint;
9
- deadline: bigint;
10
- v: number;
11
- r: Address;
12
- s: Address;
13
9
  };
14
10
  /**
15
11
  * Handler for the `BoringVault` contract for a given token exposing
@@ -1,6 +1,6 @@
1
1
  var u = Object.defineProperty;
2
- var l = (a, t, n) => t in a ? u(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n;
3
- var c = (a, t, n) => l(a, typeof t != "symbol" ? t + "" : t, n);
2
+ var l = (e, t, n) => t in e ? u(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var c = (e, t, n) => l(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { V as C } from "../../constants-C9YZ6Ewc.js";
5
5
  import { VAULTS_ADDRESSES as p } from "../vaults-addresses.js";
6
6
  import { UnifiToken as g } from "../tokens.js";
@@ -16,10 +16,10 @@ class F {
16
16
  * @param publicClient The public client to use for public
17
17
  * interactions.
18
18
  */
19
- constructor(t, n, e) {
19
+ constructor(t, n, a) {
20
20
  c(this, "viemChain");
21
21
  c(this, "token");
22
- this.chain = t, this.walletClient = n, this.publicClient = e, this.viemChain = C[t], this.token = g.unifiETH;
22
+ this.chain = t, this.walletClient = n, this.publicClient = a, this.viemChain = C[t], this.token = g.unifiETH;
23
23
  }
24
24
  /**
25
25
  * Set the UniFi token to use for executing transactions on the
@@ -38,8 +38,8 @@ class F {
38
38
  * @returns The viem contract.
39
39
  */
40
40
  getContract() {
41
- const t = p[this.token][this.chain].NucleusBoringVault, n = f, e = { public: this.publicClient, wallet: this.walletClient };
42
- return w({ address: t, abi: n, client: e });
41
+ const t = p[this.token][this.chain].NucleusBoringVault, n = f, a = { public: this.publicClient, wallet: this.walletClient };
42
+ return w({ address: t, abi: n, client: a });
43
43
  }
44
44
  /**
45
45
  * Get the allowance for the given owner and spender.
@@ -76,8 +76,8 @@ class F {
76
76
  * @param value Value to approve for the spender.
77
77
  * @returns Hash of the transaction.
78
78
  */
79
- approve(t, n, e) {
80
- return this.getContract().write.approve([n, e], {
79
+ approve(t, n, a) {
80
+ return this.getContract().write.approve([n, a], {
81
81
  account: t,
82
82
  chain: this.viemChain
83
83
  });
@@ -94,11 +94,11 @@ class F {
94
94
  * `estimate: () => Promise<bigint>` - Gas estimate of the
95
95
  * transaction.
96
96
  */
97
- transfer(t, n, e) {
98
- return { transact: () => this.getContract().write.transfer([n, e], {
97
+ transfer(t, n, a) {
98
+ return { transact: () => this.getContract().write.transfer([n, a], {
99
99
  account: t,
100
100
  chain: this.viemChain
101
- }), estimate: () => this.getContract().estimateGas.transfer([n, e], {
101
+ }), estimate: () => this.getContract().estimateGas.transfer([n, a], {
102
102
  account: t
103
103
  }) };
104
104
  }
@@ -115,12 +115,12 @@ class F {
115
115
  * `estimate: () => Promise<bigint>` - Gas estimate of the
116
116
  * transaction.
117
117
  */
118
- transferFrom(t, n, e, i) {
119
- return { transact: () => this.getContract().write.transferFrom([n, e, i], {
118
+ transferFrom(t, n, a, i) {
119
+ return { transact: () => this.getContract().write.transferFrom([n, a, i], {
120
120
  account: t,
121
121
  chain: this.viemChain
122
122
  }), estimate: () => this.getContract().estimateGas.transferFrom(
123
- [n, e, i],
123
+ [n, a, i],
124
124
  { account: t }
125
125
  ) };
126
126
  }
@@ -143,12 +143,12 @@ class F {
143
143
  * transaction.
144
144
  */
145
145
  permit(t) {
146
- const { account: n, owner: e, spender: i, value: r, deadline: s, v: o, r: h, s: m } = t;
146
+ const { account: n, owner: a, spender: i, amount: r, deadline: s, v: o, r: h, s: m } = t;
147
147
  return { transact: () => this.getContract().write.permit(
148
- [e, i, r, s, o, h, m],
148
+ [a, i, r, s, o, h, m],
149
149
  { account: n, chain: this.viemChain }
150
150
  ), estimate: () => this.getContract().estimateGas.permit(
151
- [e, i, r, s, o, h, m],
151
+ [a, i, r, s, o, h, m],
152
152
  { account: n }
153
153
  ) };
154
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nucleus-boring-vault-handler.js","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\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 { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\n\nexport type PermitParams = {\n account: Address;\n owner: Address;\n spender: Address;\n value: bigint;\n deadline: bigint;\n v: number;\n r: Address;\n s: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = 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 .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\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 transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => 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 transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\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 permit(params: PermitParams) {\n const { account, owner, spender, value, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, value, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, value, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","deadline","v","r","s"],"mappings":";;;;;;;;AA6BO,MAAMA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarC,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,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,oBACGC,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;AAAA;A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AAc,YAAY;AAAA,MAC7B,CAACI,GAAaD,GAAWD,CAAK;AAAA,MAC9B,EAAE,SAASF,EAAc;AAAA,IAC3B,EAE0B;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBvB,OAAOK,GAAsB;AAC5B,UAAA,EAAE,SAAAC,GAAS,OAAAR,GAAO,SAAAC,GAAS,OAAAG,GAAO,UAAAK,GAAU,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,IAAML;AAYvD,WAAA,EAAE,UAXQ,MACf,KAAK,cAAc,MAAM;AAAA,MACvB,CAACP,GAAOC,GAASG,GAAOK,GAAUC,GAAGC,GAAGC,CAAC;AAAA,MACzC,EAAE,SAAAJ,GAAS,OAAO,KAAK,UAAU;AAAA,IACnC,GAOiB,UANF,MACf,KAAK,cAAc,YAAY;AAAA,MAC7B,CAACR,GAAOC,GAASG,GAAOK,GAAUC,GAAGC,GAAGC,CAAC;AAAA,MACzC,EAAE,SAAAJ,EAAQ;AAAA,IACZ,EAE0B;AAAA,EAAA;AAEhC;"}
1
+ {"version":3,"file":"nucleus-boring-vault-handler.js","sources":["../../../lib/contracts/handlers/nucleus-boring-vault-handler.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport {\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 { UnifiToken } from '../tokens';\nimport { BoringVault } from '../abis/mainnet/BoringVault';\nimport { PermitData } from '../common/lib/types';\n\nexport type PermitParams = PermitData & {\n account: Address;\n owner: Address;\n spender: Address;\n};\n\n/**\n * Handler for the `BoringVault` contract for a given token exposing\n * methods to interact with the contract.\n */\nexport class NucleusBoringVaultHandler {\n private viemChain: ViemChain;\n private token: UnifiToken;\n\n /**\n * Create the handler for processing UniFi 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 = 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 .NucleusBoringVault as Address;\n const abi = BoringVault;\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 allowance for the given owner and spender.\n *\n * @param owner Address of the owner.\n * @param spender Address of the spender.\n * @returns Allowance for the given owner and spender.\n */\n public getAllowance(owner: Address, spender: Address) {\n return this.getContract().read.allowance([owner, spender]);\n }\n\n /**\n * Check the token balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns Token balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the total supply of the token.\n *\n * @returns Total supply of the token.\n */\n public totalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param walletAddress 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 walletAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n }\n\n /**\n * Transfer tokens from the owner's wallet to the given address.\n *\n * @param walletAddress Address of the owner's wallet.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\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 transfer(walletAddress: Address, toAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.transfer([toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transfer([toAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Transfer tokens from the given address to another address.\n *\n * @param walletAddress Address of the caller of the transaction.\n * @param fromAddress Address to transfer the tokens from.\n * @param toAddress Address to transfer the tokens to.\n * @param value Value to transfer.\n * @returns `transact: () => 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 transferFrom(\n walletAddress: Address,\n fromAddress: Address,\n toAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.transferFrom([fromAddress, toAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.transferFrom(\n [fromAddress, toAddress, value],\n { account: walletAddress },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Get permit to be able to use the token.\n *\n * @param params Permit parameters.\n * @param params.account Address of the caller of the transaction.\n * @param params.owner Address of the owner.\n * @param params.spender Address of the spender.\n * @param params.value Value to approve for the spender.\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 permit(params: PermitParams) {\n const { account, owner, spender, amount, deadline, v, r, s } = params;\n const transact = () =>\n this.getContract().write.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account, chain: this.viemChain },\n );\n const estimate = () =>\n this.getContract().estimateGas.permit(\n [owner, spender, amount, deadline, v, r, s],\n { account },\n );\n\n return { transact, estimate };\n }\n}\n"],"names":["NucleusBoringVaultHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","UnifiToken","token","address","VAULTS_ADDRESSES","abi","BoringVault","client","getContract","owner","spender","walletAddress","spenderAddress","value","toAddress","fromAddress","params","account","amount","deadline","v","r","s"],"mappings":";;;;;;;;AAyBO,MAAMA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarC,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,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,oBACGC,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;AAAA;AAAA,EActC,aAAaE,GAAgBC,GAAkB;AAC7C,WAAA,KAAK,cAAc,KAAK,UAAU,CAACD,GAAOC,CAAO,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpD,UAAUC,GAAwB;AACvC,WAAO,KAAK,YAAY,EAAE,KAAK,UAAU,CAACA,CAAa,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;A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AE,SAAAC,GAAS,OAAAR,GAAO,SAAAC,GAAS,QAAAQ,GAAQ,UAAAC,GAAU,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,IAAMN;AAYxD,WAAA,EAAE,UAXQ,MACf,KAAK,cAAc,MAAM;AAAA,MACvB,CAACP,GAAOC,GAASQ,GAAQC,GAAUC,GAAGC,GAAGC,CAAC;AAAA,MAC1C,EAAE,SAAAL,GAAS,OAAO,KAAK,UAAU;AAAA,IACnC,GAOiB,UANF,MACf,KAAK,cAAc,YAAY;AAAA,MAC7B,CAACR,GAAOC,GAASQ,GAAQC,GAAUC,GAAGC,GAAGC,CAAC;AAAA,MAC1C,EAAE,SAAAL,EAAQ;AAAA,IACZ,EAE0B;AAAA,EAAA;AAEhC;"}
@@ -1,2 +1,2 @@
1
- "use strict";var P=Object.defineProperty;var p=(r,t,e)=>t in r?P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>p(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../constants-CxSgz27h.cjs"),T=require("../vaults-addresses.cjs"),l=require("../tokens.cjs"),k=require("./erc20-permit-handler.cjs"),v=require("../abis/mainnet/Teller.cjs"),_=require("../../getContract-DUA3M2pm.cjs");class E{constructor(t,e,i){u(this,"viemChain");u(this,"erc20PermitHandler");u(this,"token");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=S.VIEM_CHAINS[t],this.erc20PermitHandler=new k.ERC20PermitHandler(t,e,i),this.token=l.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=T.VAULTS_ADDRESSES[this.token][this.chain].NucleusTeller,e=v.Teller,i={public:this.publicClient,wallet:this.walletClient};return _.getContract({address:t,abi:e,client:i})}accountant(){return this.getContract().read.accountant()}vault(){return this.getContract().read.vault()}shareLockPeriod(){return this.getContract().read.shareLockPeriod()}shareUnlockTime(t){return this.getContract().read.shareUnlockTime([t])}isPaused(){return this.getContract().read.isPaused()}async deposit(t){const{token:e,unifiToken:i,account:s,amount:n,minimumMint:a,isPreapproved:o=!1}=t,c=l.TOKENS_ADDRESSES[e][this.chain];if(o)return{transact:()=>this.getContract().write.deposit([c,n,a],{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit([c,n,a],{account:s})};const{r:h,s:d,v:m,deadline:g}=await this.erc20PermitHandler.withToken(e).getPermitSignature(s,l.TOKENS_ADDRESSES[i][this.chain],n),C=[c,n,a,g,Number(m),h,d];return{transact:()=>this.getContract().write.depositWithPermit(C,{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit(C,{account:s})}}depositWithPermit(t){const{account:e,depositAsset:i,depositAmount:s,minimumMint:n,deadline:a,v:o,r:c,s:h}=t;return{transact:()=>this.getContract().write.depositWithPermit([i,s,n,a,o,c,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit([i,s,n,a,o,c,h],{account:e})}}}exports.NucleusTellerHandler=E;
1
+ "use strict";var P=Object.defineProperty;var T=(r,t,e)=>t in r?P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>T(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../constants-CxSgz27h.cjs"),p=require("../vaults-addresses.cjs"),l=require("../tokens.cjs"),S=require("./erc20-permit-handler.cjs"),v=require("../abis/mainnet/Teller.cjs"),_=require("../../getContract-DUA3M2pm.cjs");class E{constructor(t,e,i){u(this,"viemChain");u(this,"erc20PermitHandler");u(this,"token");this.chain=t,this.walletClient=e,this.publicClient=i,this.viemChain=k.VIEM_CHAINS[t],this.erc20PermitHandler=new S.ERC20PermitHandler(t,e,i),this.token=l.UnifiToken.unifiETH}withToken(t){return this.token=t,this}getContract(){const t=p.VAULTS_ADDRESSES[this.token][this.chain].NucleusTeller,e=v.Teller,i={public:this.publicClient,wallet:this.walletClient};return _.getContract({address:t,abi:e,client:i})}accountant(){return this.getContract().read.accountant()}vault(){return this.getContract().read.vault()}shareLockPeriod(){return this.getContract().read.shareLockPeriod()}shareUnlockTime(t){return this.getContract().read.shareUnlockTime([t])}isPaused(){return this.getContract().read.isPaused()}async deposit(t){const{token:e,unifiToken:i,account:s,amount:n,minimumMint:a,isPreapproved:o=!1}=t,c=l.TOKENS_ADDRESSES[e][this.chain];if(o)return{transact:()=>this.getContract().write.deposit([c,n,a],{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit([c,n,a],{account:s})};const{r:h,s:d,v:m,deadline:g}=await this.erc20PermitHandler.withToken(e).getPermitData(s,l.TOKENS_ADDRESSES[i][this.chain],n),C=[c,n,a,g,m,h,d];return{transact:()=>this.getContract().write.depositWithPermit(C,{account:s,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit(C,{account:s})}}depositWithPermit(t){const{account:e,depositAsset:i,amount:s,minimumMint:n,deadline:a,v:o,r:c,s:h}=t;return{transact:()=>this.getContract().write.depositWithPermit([i,s,n,a,o,c,h],{account:e,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.depositWithPermit([i,s,n,a,o,c,h],{account:e})}}}exports.NucleusTellerHandler=E;
2
2
  //# sourceMappingURL=nucleus-teller-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nucleus-teller-handler.cjs","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":"geAoCO,MAAMA,CAAqB,CAchC,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,2BACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,mBAAqB,IAAIK,EAAA,mBAC5BL,EACAC,EACAC,CACF,EACA,KAAK,MAAQI,EAAAA,WAAW,QAAA,CAUnB,UAAUC,EAAmB,CAClC,YAAK,MAAQA,EACN,IAAA,CASF,aAAc,CACnB,MAAMC,EAAUC,EAAAA,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,cACGC,EAAMC,EAAA,OACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,O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ACf,KAAK,YAAc,EAAA,YAAY,kBAAkBU,EAAa,CAC5D,QAAAV,CAAA,CACD,CAEyB,CAAA,CAqBvB,kBAAkBF,EAAiC,CAClD,KAAA,CACJ,QAAAE,EACA,aAAAW,EACA,cAAAC,EACA,YAAAV,EACA,SAAAO,EACA,EAAAD,EACA,EAAAF,EACA,EAAAC,CAAA,EACET,EAkBG,MAAA,CAAE,SAhBQ,IACf,KAAK,cAAc,MAAM,kBACvB,CAACa,EAAcC,EAAeV,EAAaO,EAAUD,EAAGF,EAAGC,CAAC,EAC5D,CACE,QAAAP,EACA,MAAO,KAAK,SAAA,CAEhB,EASiB,SARF,IACf,KAAK,cAAc,YAAY,kBAC7B,CAACW,EAAcC,EAAeV,EAAaO,EAAUD,EAAGF,EAAGC,CAAC,EAC5D,CACE,QAAAP,CAAA,CAEJ,CAE0B,CAAA,CAEhC"}
1
+ {"version":3,"file":"nucleus-teller-handler.cjs","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":"geAgCO,MAAMA,CAAqB,CAchC,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,2BACAA,EAAA,cAYE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAEH,KAAA,UAAYE,cAAYJ,CAAK,EAClC,KAAK,mBAAqB,IAAIK,EAAA,mBAC5BL,EACAC,EACAC,CACF,EACA,KAAK,MAAQI,EAAAA,WAAW,QAAA,CAUnB,UAAUC,EAAmB,CAClC,YAAK,MAAQA,EACN,IAAA,CASF,aAAc,CACnB,MAAMC,EAAUC,EAAAA,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK,EACpD,cACGC,EAAMC,EAAA,OACNC,EAAS,CAAE,OAAQ,KAAK,aAAc,OAAQ,KAAK,YAAa,EAEtE,OAAOC,EAAY,YAAA,CAAE,QAAAL,EAAS,IAAAE,EAAK,OAAAE,EAAQ,CAAA,CAYtC,YAAa,CAClB,OAAO,KAAK,cAAc,KAAK,WAAW,CAAA,CAQrC,OAAQ,CACb,OAAO,KAAK,cAAc,KAAK,MAAM,CAAA,CAQhC,iBAAkB,CACvB,OAAO,KAAK,cAAc,KAAK,gBAAgB,CAAA,CAS1C,gBAAgBE,EAAwB,CAC7C,OAAO,KAAK,YAAY,EAAE,KAAK,gBAAgB,CAACA,CAAa,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AAAP,EACA,MAAO,KAAK,SAAA,CAEhB,EASiB,SARF,IACf,KAAK,cAAc,YAAY,kBAC7B,CAACW,EAAcV,EAAQC,EAAaO,EAAUD,EAAGF,EAAGC,CAAC,EACrD,CACE,QAAAP,CAAA,CAEJ,CAE0B,CAAA,CAEhC"}
@@ -1,6 +1,7 @@
1
1
  import { WalletClient, PublicClient, Address, GetContractReturnType } from 'viem';
2
2
  import { Chain, ViemChain } from '../../chains/constants';
3
3
  import { Token, UnifiToken } from '../tokens';
4
+ import { PermitData } from '../common/lib/types';
4
5
  export type DepositParams = {
5
6
  account: Address;
6
7
  token: Token;
@@ -9,15 +10,10 @@ export type DepositParams = {
9
10
  minimumMint: bigint;
10
11
  isPreapproved?: boolean;
11
12
  };
12
- export type DepositWithPermitParams = {
13
+ export type DepositWithPermitParams = PermitData & {
13
14
  account: Address;
14
15
  depositAsset: Address;
15
- depositAmount: bigint;
16
16
  minimumMint: bigint;
17
- deadline: bigint;
18
- v: number;
19
- r: Address;
20
- s: Address;
21
17
  };
22
18
  /**
23
19
  * Handler for the `Teller` contract from nucleus.
@@ -3,10 +3,10 @@ var P = (n, t, e) => t in n ? g(n, t, { enumerable: !0, configurable: !0, writab
3
3
  var m = (n, t, e) => P(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { V as k } from "../../constants-C9YZ6Ewc.js";
5
5
  import { VAULTS_ADDRESSES as T } from "../vaults-addresses.js";
6
- import { UnifiToken as f, TOKENS_ADDRESSES as p } from "../tokens.js";
6
+ import { UnifiToken as f, TOKENS_ADDRESSES as C } from "../tokens.js";
7
7
  import { ERC20PermitHandler as v } from "./erc20-permit-handler.js";
8
- import { Teller as S } from "../abis/mainnet/Teller.js";
9
- import { g as w } from "../../getContract-DEPNMZxg.js";
8
+ import { Teller as w } from "../abis/mainnet/Teller.js";
9
+ import { g as S } from "../../getContract-DEPNMZxg.js";
10
10
  class L {
11
11
  /**
12
12
  * Create the handler for processing tokens.
@@ -44,8 +44,8 @@ class L {
44
44
  * @returns The viem contract.
45
45
  */
46
46
  getContract() {
47
- const t = T[this.token][this.chain].NucleusTeller, e = S, i = { public: this.publicClient, wallet: this.walletClient };
48
- return w({ address: t, abi: e, client: i });
47
+ const t = T[this.token][this.chain].NucleusTeller, e = w, i = { public: this.publicClient, wallet: this.walletClient };
48
+ return S({ address: t, abi: e, client: i });
49
49
  }
50
50
  /**
51
51
  * Get the address of the `Accountant` contract.
@@ -114,7 +114,7 @@ class L {
114
114
  amount: s,
115
115
  minimumMint: a,
116
116
  isPreapproved: c = !1
117
- } = t, o = p[e][this.chain];
117
+ } = t, o = C[e][this.chain];
118
118
  if (c)
119
119
  return {
120
120
  transact: () => this.getContract().write.deposit(
@@ -129,17 +129,17 @@ class L {
129
129
  { account: r }
130
130
  )
131
131
  };
132
- const { r: h, s: d, v: u, deadline: C } = await this.erc20PermitHandler.withToken(e).getPermitSignature(
132
+ const { r: h, s: d, v: u, deadline: p } = await this.erc20PermitHandler.withToken(e).getPermitData(
133
133
  r,
134
134
  // The UniFi token contract is the spender.
135
- p[i][this.chain],
135
+ C[i][this.chain],
136
136
  s
137
137
  ), l = [
138
138
  o,
139
139
  s,
140
140
  a,
141
- C,
142
- Number(u),
141
+ p,
142
+ u,
143
143
  h,
144
144
  d
145
145
  ];
@@ -169,16 +169,7 @@ class L {
169
169
  * transaction.
170
170
  */
171
171
  depositWithPermit(t) {
172
- const {
173
- account: e,
174
- depositAsset: i,
175
- depositAmount: r,
176
- minimumMint: s,
177
- deadline: a,
178
- v: c,
179
- r: o,
180
- s: h
181
- } = t;
172
+ const { account: e, depositAsset: i, amount: r, minimumMint: s, deadline: a, v: c, r: o, s: h } = t;
182
173
  return { transact: () => this.getContract().write.depositWithPermit(
183
174
  [i, r, s, a, c, o, h],
184
175
  {