@pufferfinance/puffer-sdk 1.4.2 → 1.5.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 (202) hide show
  1. package/dist/api/puffer-client-helpers.cjs +2 -0
  2. package/dist/api/puffer-client-helpers.cjs.map +1 -0
  3. package/dist/api/puffer-client-helpers.d.ts +0 -1
  4. package/dist/api/puffer-client-helpers.js +142 -0
  5. package/dist/api/puffer-client-helpers.js.map +1 -0
  6. package/dist/api/puffer-client.cjs +2 -0
  7. package/dist/api/puffer-client.cjs.map +1 -0
  8. package/dist/api/puffer-client.d.ts +6 -1
  9. package/dist/api/puffer-client.js +97 -0
  10. package/dist/api/puffer-client.js.map +1 -0
  11. package/dist/{ccip-ZoYOXsGl.js → ccip-D4klNwCt.js} +28 -27
  12. package/dist/{ccip-ZoYOXsGl.js.map → ccip-D4klNwCt.js.map} +1 -1
  13. package/dist/ccip-DLDqFodf.cjs +2 -0
  14. package/dist/{ccip-Dv116NSL.cjs.map → ccip-DLDqFodf.cjs.map} +1 -1
  15. package/dist/chains/constants.cjs +2 -0
  16. package/dist/chains/constants.cjs.map +1 -0
  17. package/dist/chains/constants.d.ts +3 -2
  18. package/dist/chains/constants.js +6 -0
  19. package/dist/chains/constants.js.map +1 -0
  20. package/dist/constants-BvU-JhfL.cjs +9 -0
  21. package/dist/constants-BvU-JhfL.cjs.map +1 -0
  22. package/dist/constants-rWWWhxR_.js +2099 -0
  23. package/dist/constants-rWWWhxR_.js.map +1 -0
  24. package/dist/contracts/abis/holesky/PufferDepositor.cjs +2 -0
  25. package/dist/contracts/abis/holesky/PufferDepositor.cjs.map +1 -0
  26. package/dist/contracts/abis/holesky/PufferDepositor.js +377 -0
  27. package/dist/contracts/abis/holesky/PufferDepositor.js.map +1 -0
  28. package/dist/contracts/abis/holesky/PufferVaultV2.cjs +2 -0
  29. package/dist/contracts/abis/holesky/PufferVaultV2.cjs.map +1 -0
  30. package/dist/contracts/abis/holesky/PufferVaultV2.js +1787 -0
  31. package/dist/contracts/abis/holesky/PufferVaultV2.js.map +1 -0
  32. package/dist/contracts/abis/l1-reward-manager-abis.cjs +2 -0
  33. package/dist/contracts/abis/l1-reward-manager-abis.cjs.map +1 -0
  34. package/dist/contracts/abis/l1-reward-manager-abis.d.ts +527 -0
  35. package/dist/contracts/abis/l1-reward-manager-abis.js +9 -0
  36. package/dist/contracts/abis/l1-reward-manager-abis.js.map +1 -0
  37. package/dist/contracts/abis/l2-reward-manager-abis.cjs +2 -0
  38. package/dist/contracts/abis/l2-reward-manager-abis.cjs.map +1 -0
  39. package/dist/contracts/abis/l2-reward-manager-abis.d.ts +685 -0
  40. package/dist/contracts/abis/l2-reward-manager-abis.js +9 -0
  41. package/dist/contracts/abis/l2-reward-manager-abis.js.map +1 -0
  42. package/dist/contracts/abis/mainnet/ERC20Permit.cjs +2 -0
  43. package/dist/contracts/abis/mainnet/ERC20Permit.cjs.map +1 -0
  44. package/dist/contracts/abis/mainnet/ERC20Permit.js +524 -0
  45. package/dist/contracts/abis/mainnet/ERC20Permit.js.map +1 -0
  46. package/dist/contracts/abis/mainnet/L1RewardManager.cjs +2 -0
  47. package/dist/contracts/abis/mainnet/L1RewardManager.cjs.map +1 -0
  48. package/dist/contracts/abis/mainnet/L1RewardManager.d.ts +523 -0
  49. package/dist/contracts/abis/mainnet/L1RewardManager.js +447 -0
  50. package/dist/contracts/abis/mainnet/L1RewardManager.js.map +1 -0
  51. package/dist/contracts/abis/mainnet/L2RewardManager.cjs +2 -0
  52. package/dist/contracts/abis/mainnet/L2RewardManager.cjs.map +1 -0
  53. package/dist/contracts/abis/mainnet/L2RewardManager.d.ts +681 -0
  54. package/dist/contracts/abis/mainnet/L2RewardManager.js +538 -0
  55. package/dist/contracts/abis/mainnet/L2RewardManager.js.map +1 -0
  56. package/dist/contracts/abis/mainnet/PufLocker.cjs +2 -0
  57. package/dist/contracts/abis/mainnet/PufLocker.cjs.map +1 -0
  58. package/dist/contracts/abis/mainnet/PufLocker.js +362 -0
  59. package/dist/contracts/abis/mainnet/PufLocker.js.map +1 -0
  60. package/dist/contracts/abis/mainnet/PufToken.cjs +2 -0
  61. package/dist/contracts/abis/mainnet/PufToken.cjs.map +1 -0
  62. package/dist/contracts/abis/mainnet/PufToken.js +883 -0
  63. package/dist/contracts/abis/mainnet/PufToken.js.map +1 -0
  64. package/dist/contracts/abis/mainnet/PufferDepositor.cjs +2 -0
  65. package/dist/contracts/abis/mainnet/PufferDepositor.cjs.map +1 -0
  66. package/dist/contracts/abis/mainnet/PufferDepositor.js +377 -0
  67. package/dist/contracts/abis/mainnet/PufferDepositor.js.map +1 -0
  68. package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs +2 -0
  69. package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs.map +1 -0
  70. package/dist/contracts/abis/mainnet/PufferL2Depositor.js +300 -0
  71. package/dist/contracts/abis/mainnet/PufferL2Depositor.js.map +1 -0
  72. package/dist/contracts/abis/mainnet/PufferVaultV2.cjs +2 -0
  73. package/dist/contracts/abis/mainnet/PufferVaultV2.cjs.map +1 -0
  74. package/dist/contracts/abis/mainnet/PufferVaultV2.js +1864 -0
  75. package/dist/contracts/abis/mainnet/PufferVaultV2.js.map +1 -0
  76. package/dist/contracts/abis/puf-locker-abis.cjs +2 -0
  77. package/dist/contracts/abis/puf-locker-abis.cjs.map +1 -0
  78. package/dist/contracts/abis/puf-locker-abis.js +10 -0
  79. package/dist/contracts/abis/puf-locker-abis.js.map +1 -0
  80. package/dist/contracts/abis/puf-token-abis.cjs +2 -0
  81. package/dist/contracts/abis/puf-token-abis.cjs.map +1 -0
  82. package/dist/contracts/abis/puf-token-abis.js +10 -0
  83. package/dist/contracts/abis/puf-token-abis.js.map +1 -0
  84. package/dist/contracts/abis/puffer-depositor-abis.cjs +2 -0
  85. package/dist/contracts/abis/puffer-depositor-abis.cjs.map +1 -0
  86. package/dist/contracts/abis/puffer-depositor-abis.js +20 -0
  87. package/dist/contracts/abis/puffer-depositor-abis.js.map +1 -0
  88. package/dist/contracts/abis/puffer-vault-abis.cjs +2 -0
  89. package/dist/contracts/abis/puffer-vault-abis.cjs.map +1 -0
  90. package/dist/contracts/abis/puffer-vault-abis.js +15 -0
  91. package/dist/contracts/abis/puffer-vault-abis.js.map +1 -0
  92. package/dist/contracts/abis/tokens-abis.cjs +2 -0
  93. package/dist/contracts/abis/tokens-abis.cjs.map +1 -0
  94. package/dist/contracts/abis/tokens-abis.js +6 -0
  95. package/dist/contracts/abis/tokens-abis.js.map +1 -0
  96. package/dist/contracts/addresses.cjs +2 -0
  97. package/dist/contracts/addresses.cjs.map +1 -0
  98. package/dist/contracts/addresses.d.ts +23 -0
  99. package/dist/contracts/addresses.js +27 -0
  100. package/dist/contracts/addresses.js.map +1 -0
  101. package/dist/contracts/handlers/erc20-permit-handler.cjs +2 -0
  102. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -0
  103. package/dist/contracts/handlers/erc20-permit-handler.d.ts +579 -579
  104. package/dist/contracts/handlers/erc20-permit-handler.js +124 -0
  105. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -0
  106. package/dist/contracts/handlers/l1-reward-manager-handler.cjs +2 -0
  107. package/dist/contracts/handlers/l1-reward-manager-handler.cjs.map +1 -0
  108. package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +6693 -0
  109. package/dist/contracts/handlers/l1-reward-manager-handler.js +68 -0
  110. package/dist/contracts/handlers/l1-reward-manager-handler.js.map +1 -0
  111. package/dist/contracts/handlers/l2-reward-manager-handler.cjs +2 -0
  112. package/dist/contracts/handlers/l2-reward-manager-handler.cjs.map +1 -0
  113. package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +6912 -0
  114. package/dist/contracts/handlers/l2-reward-manager-handler.js +137 -0
  115. package/dist/contracts/handlers/l2-reward-manager-handler.js.map +1 -0
  116. package/dist/contracts/handlers/puf-locker-handler.cjs +2 -0
  117. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -0
  118. package/dist/contracts/handlers/puf-locker-handler.d.ts +579 -579
  119. package/dist/contracts/handlers/puf-locker-handler.js +168 -0
  120. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -0
  121. package/dist/contracts/handlers/puf-token-handler.cjs +2 -0
  122. package/dist/contracts/handlers/puf-token-handler.cjs.map +1 -0
  123. package/dist/contracts/handlers/puf-token-handler.d.ts +579 -579
  124. package/dist/contracts/handlers/puf-token-handler.js +174 -0
  125. package/dist/contracts/handlers/puf-token-handler.js.map +1 -0
  126. package/dist/contracts/handlers/puffer-depositor-handler.cjs +2 -0
  127. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -0
  128. package/dist/contracts/handlers/puffer-depositor-handler.d.ts +579 -579
  129. package/dist/contracts/handlers/puffer-depositor-handler.js +113 -0
  130. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -0
  131. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +2 -0
  132. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -0
  133. package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +579 -579
  134. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +112 -0
  135. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -0
  136. package/dist/contracts/handlers/puffer-vault-handler.cjs +2 -0
  137. package/dist/contracts/handlers/puffer-vault-handler.cjs.map +1 -0
  138. package/dist/contracts/handlers/puffer-vault-handler.d.ts +579 -579
  139. package/dist/contracts/handlers/puffer-vault-handler.js +185 -0
  140. package/dist/contracts/handlers/puffer-vault-handler.js.map +1 -0
  141. package/dist/contracts/tokens.cjs +2 -0
  142. package/dist/contracts/tokens.cjs.map +1 -0
  143. package/dist/contracts/tokens.d.ts +0 -1
  144. package/dist/contracts/tokens.js +134 -0
  145. package/dist/contracts/tokens.js.map +1 -0
  146. package/dist/createWalletClient-Bmopj8MM.cjs +4 -0
  147. package/dist/createWalletClient-Bmopj8MM.cjs.map +1 -0
  148. package/dist/createWalletClient-DKcpswHR.js +2007 -0
  149. package/dist/createWalletClient-DKcpswHR.js.map +1 -0
  150. package/dist/errors/base-error.cjs +3 -0
  151. package/dist/errors/base-error.cjs.map +1 -0
  152. package/dist/errors/base-error.d.ts +0 -1
  153. package/dist/errors/base-error.js +23 -0
  154. package/dist/errors/base-error.js.map +1 -0
  155. package/dist/errors/types.cjs +2 -0
  156. package/dist/errors/types.cjs.map +1 -0
  157. package/dist/errors/types.js +2 -0
  158. package/dist/errors/types.js.map +1 -0
  159. package/dist/errors/validation-errors.cjs +2 -0
  160. package/dist/errors/validation-errors.cjs.map +1 -0
  161. package/dist/errors/validation-errors.d.ts +2 -1
  162. package/dist/errors/validation-errors.js +10 -0
  163. package/dist/errors/validation-errors.js.map +1 -0
  164. package/dist/getContract-B3Spz0SO.js +115 -0
  165. package/dist/getContract-B3Spz0SO.js.map +1 -0
  166. package/dist/getContract-MrPLx6gp.cjs +2 -0
  167. package/dist/getContract-MrPLx6gp.cjs.map +1 -0
  168. package/dist/main.cjs +1 -1
  169. package/dist/main.js +14 -10
  170. package/dist/main.js.map +1 -1
  171. package/dist/secp256k1-BLbXMlpX.js +1172 -0
  172. package/dist/secp256k1-BLbXMlpX.js.map +1 -0
  173. package/dist/secp256k1-CFnFaJ0H.cjs +2 -0
  174. package/dist/secp256k1-CFnFaJ0H.cjs.map +1 -0
  175. package/dist/utils/time.cjs +2 -0
  176. package/dist/utils/time.cjs.map +1 -0
  177. package/dist/utils/time.js +5 -0
  178. package/dist/utils/time.js.map +1 -0
  179. package/dist/utils/types.cjs +2 -0
  180. package/dist/utils/types.cjs.map +1 -0
  181. package/dist/utils/types.js +2 -0
  182. package/dist/utils/types.js.map +1 -0
  183. package/dist/utils/version.cjs +2 -0
  184. package/dist/utils/version.cjs.map +1 -0
  185. package/dist/utils/version.js +5 -0
  186. package/dist/utils/version.js.map +1 -0
  187. package/dist/writeContract-BBHpAss8.cjs +32 -0
  188. package/dist/writeContract-BBHpAss8.cjs.map +1 -0
  189. package/dist/writeContract-RluxM31W.js +3833 -0
  190. package/dist/writeContract-RluxM31W.js.map +1 -0
  191. package/package.json +22 -11
  192. package/dist/ccip-Dv116NSL.cjs +0 -2
  193. package/dist/contracts/handlers/erc20-permit-handler.test.d.ts +0 -1
  194. package/dist/contracts/handlers/puf-locker-handler.test.d.ts +0 -1
  195. package/dist/contracts/handlers/puf-token-handler.test.d.ts +0 -1
  196. package/dist/contracts/handlers/puffer-depositor-handler.test.d.ts +0 -1
  197. package/dist/contracts/handlers/puffer-l2-depositor-handler.test.d.ts +0 -1
  198. package/dist/contracts/handlers/puffer-vault-handler.test.d.ts +0 -1
  199. package/dist/main-69HiNG3t.js +0 -16001
  200. package/dist/main-69HiNG3t.js.map +0 -1
  201. package/dist/main-IyjWcdJ1.cjs +0 -41
  202. package/dist/main-IyjWcdJ1.cjs.map +0 -1
@@ -0,0 +1,168 @@
1
+ var f = Object.defineProperty;
2
+ var S = (r, t, e) => t in r ? f(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var o = (r, t, e) => S(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { V as k, p as l } from "../../constants-rWWWhxR_.js";
5
+ import { PUF_LOCKER_ABIS as v } from "../abis/puf-locker-abis.js";
6
+ import { CONTRACT_ADDRESSES as p } from "../addresses.js";
7
+ import { TOKENS_ADDRESSES as n } from "../tokens.js";
8
+ import { ERC20PermitHandler as D } from "./erc20-permit-handler.js";
9
+ import { g as A } from "../../getContract-B3Spz0SO.js";
10
+ class y {
11
+ /**
12
+ * Create the handler for the `PufLocker` contract exposing methods to
13
+ * interact with the contract.
14
+ *
15
+ * @param chain Chain to use for the client.
16
+ * @param walletClient The wallet client to use for wallet
17
+ * interactions.
18
+ * @param publicClient The public client to use for public
19
+ * interactions.
20
+ */
21
+ constructor(t, e, i) {
22
+ o(this, "viemChain");
23
+ o(this, "erc20PermitHandler");
24
+ this.chain = t, this.walletClient = e, this.publicClient = i, this.viemChain = k[t], this.erc20PermitHandler = new D(
25
+ t,
26
+ e,
27
+ i
28
+ );
29
+ }
30
+ /**
31
+ * Get the contract. This is a method because the typings are complex
32
+ * and lost when trying to make it a member.
33
+ *
34
+ * @returns The viem contract.
35
+ */
36
+ getContract() {
37
+ const t = p[this.chain].PufLocker, e = v[this.chain].PufLocker, i = { public: this.publicClient, wallet: this.walletClient };
38
+ return A({ address: t, abi: e, client: i });
39
+ }
40
+ /**
41
+ * Get all deposits of the given account address.
42
+ *
43
+ * @param pufToken The PufToken to get the deposits for.
44
+ * @param walletAddress The wallet address to get the deposits for.
45
+ * @returns The amount and deposits of the given account address.
46
+ */
47
+ getAllDeposits(t, e) {
48
+ return this.getContract().read.getAllDeposits([
49
+ n[t][this.chain],
50
+ e
51
+ ]);
52
+ }
53
+ /**
54
+ * Get the user's deposits for the given token and deposit index.
55
+ *
56
+ * @param pufToken PufToken to get the deposits of.
57
+ * @param userAddress User address to get the deposits for.
58
+ * @param start The starting index of the deposits.
59
+ * @param limit The maximum number of deposits to retrieve.
60
+ * @returns The amount and release time of the deposits.
61
+ */
62
+ getDeposits(t, e, i, a) {
63
+ return this.getContract().read.getDeposits([
64
+ e,
65
+ n[t][this.chain],
66
+ i,
67
+ a
68
+ ]);
69
+ }
70
+ /**
71
+ * Get the minimum and maximum lock periods allowed for deposits.
72
+ *
73
+ * @returns The minimum and maximum lock period in seconds.
74
+ * (`[minLock, maxLock]`)
75
+ */
76
+ getLockPeriods() {
77
+ return this.getContract().read.getLockPeriods();
78
+ }
79
+ /**
80
+ * Deposit the given PufToken into the locker. This doesn't make the
81
+ * transaction but returns two methods namely `transact` and
82
+ * `estimate`.
83
+ *
84
+ * @param depositParams.pufToken PufToken to deposit.
85
+ * @param depositParams.account Wallet address of the depositor.
86
+ * @param depositParams.recipient Recipient of the deposit.
87
+ * @param depositParams.value Amount of the deposit.
88
+ * @param depositParams.lockPeriod The period for the deposit in
89
+ * seconds.
90
+ * @param depositParams.isPreapproved Whether the token is
91
+ * pre-approved or needs a permit.
92
+ * @returns `transact: () => Promise<Address>` - Used to make the
93
+ * transaction.
94
+ *
95
+ * `estimate: () => Promise<bigint>` - Gas estimate of the
96
+ * transaction.
97
+ */
98
+ async deposit(t) {
99
+ const {
100
+ token: e,
101
+ account: i,
102
+ recipient: a,
103
+ value: s,
104
+ lockPeriod: c,
105
+ isPreapproved: h = !1
106
+ } = t;
107
+ let m = {
108
+ r: l("0x", { size: 32 }),
109
+ s: l("0x", { size: 32 }),
110
+ v: 0,
111
+ deadline: 0n,
112
+ amount: s
113
+ };
114
+ if (!h) {
115
+ const { r: u, s: g, v: C, yParity: P, deadline: w } = await this.erc20PermitHandler.withToken(e).getPermitSignature(
116
+ i,
117
+ p[this.chain].PufLocker,
118
+ s
119
+ );
120
+ m = {
121
+ r: u,
122
+ s: g,
123
+ v: Number(C ?? P),
124
+ deadline: w,
125
+ amount: s
126
+ };
127
+ }
128
+ const d = [
129
+ n[e][this.chain],
130
+ a,
131
+ c,
132
+ m
133
+ ];
134
+ return { transact: () => this.getContract().write.deposit(d, {
135
+ account: i,
136
+ chain: this.viemChain
137
+ }), estimate: () => this.getContract().estimateGas.deposit(d, {
138
+ account: i
139
+ }) };
140
+ }
141
+ /**
142
+ * Withdraw the deposits identified by the deposit indexes from the
143
+ * locker.
144
+ *
145
+ * @param pufToken PufToken to withdraw.
146
+ * @param walletAddress Address of the account making the transaction.
147
+ * @param recipient Recipient of the withdrawal.
148
+ * @param depositIndexes Deposit indexes to withdraw.
149
+ * @returns Hash of the withdrawal transaction.
150
+ */
151
+ withdraw(t, e, i, a) {
152
+ const s = [
153
+ n[t][this.chain],
154
+ a,
155
+ i
156
+ ];
157
+ return { transact: () => this.getContract().write.withdraw(s, {
158
+ account: e,
159
+ chain: this.viemChain
160
+ }), estimate: () => this.getContract().estimateGas.withdraw(s, {
161
+ account: e
162
+ }) };
163
+ }
164
+ }
165
+ export {
166
+ y as PufLockerHandler
167
+ };
168
+ //# sourceMappingURL=puf-locker-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puf-locker-handler.js","sources":["../../../lib/contracts/handlers/puf-locker-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n Address,\n padHex,\n GetContractReturnType,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { PUF_LOCKER_ABIS } from '../abis/puf-locker-abis';\nimport { CONTRACT_ADDRESSES } from '../addresses';\nimport { PufToken, TOKENS_ADDRESSES } from '../tokens';\nimport { ERC20PermitHandler } from './erc20-permit-handler';\n\nexport type LockerDepositParams = {\n token: PufToken;\n account: Address;\n recipient: Address;\n value: bigint;\n lockPeriod: bigint;\n isPreapproved?: boolean;\n};\n\n/**\n * Handler for the `PufLocker` contract exposing methods to interact\n * with the contract.\n */\nexport class PufLockerHandler {\n private viemChain: ViemChain;\n private erc20PermitHandler: ERC20PermitHandler;\n\n /**\n * Create the handler for the `PufLocker` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n this.erc20PermitHandler = new ERC20PermitHandler(\n chain,\n walletClient,\n publicClient,\n );\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = CONTRACT_ADDRESSES[this.chain].PufLocker as Address;\n const abi = PUF_LOCKER_ABIS[this.chain].PufLocker;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({ address, abi, client }) as GetContractReturnType<\n typeof abi,\n typeof client,\n Address\n >;\n }\n\n /**\n * Get all deposits of the given account address.\n *\n * @param pufToken The PufToken to get the deposits for.\n * @param walletAddress The wallet address to get the deposits for.\n * @returns The amount and deposits of the given account address.\n */\n public getAllDeposits(pufToken: PufToken, walletAddress: Address) {\n return this.getContract().read.getAllDeposits([\n TOKENS_ADDRESSES[pufToken][this.chain],\n walletAddress,\n ]);\n }\n\n /**\n * Get the user's deposits for the given token and deposit index.\n *\n * @param pufToken PufToken to get the deposits of.\n * @param userAddress User address to get the deposits for.\n * @param start The starting index of the deposits.\n * @param limit The maximum number of deposits to retrieve.\n * @returns The amount and release time of the deposits.\n */\n public getDeposits(\n pufToken: PufToken,\n userAddress: Address,\n start: bigint,\n limit: bigint,\n ) {\n return this.getContract().read.getDeposits([\n userAddress,\n TOKENS_ADDRESSES[pufToken][this.chain],\n start,\n limit,\n ]);\n }\n\n /**\n * Get the minimum and maximum lock periods allowed for deposits.\n *\n * @returns The minimum and maximum lock period in seconds.\n * (`[minLock, maxLock]`)\n */\n public getLockPeriods() {\n return this.getContract().read.getLockPeriods();\n }\n\n /**\n * Deposit the given PufToken into the locker. This doesn't make the\n * transaction but returns two methods namely `transact` and\n * `estimate`.\n *\n * @param depositParams.pufToken PufToken to deposit.\n * @param depositParams.account Wallet address of the depositor.\n * @param depositParams.recipient Recipient of the deposit.\n * @param depositParams.value Amount of the deposit.\n * @param depositParams.lockPeriod The period for the deposit in\n * seconds.\n * @param depositParams.isPreapproved Whether the token is\n * pre-approved or needs a permit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public async deposit(depositParams: LockerDepositParams) {\n const {\n token,\n account,\n recipient,\n value,\n lockPeriod,\n isPreapproved = false,\n } = depositParams;\n\n // Only `amount` is needed if `Token.approve()` is already called.\n // So using mock values for other properties.\n let permitData = {\n r: padHex('0x', { size: 32 }),\n s: padHex('0x', { size: 32 }),\n v: 0,\n deadline: 0n,\n amount: value,\n };\n\n if (!isPreapproved) {\n const { r, s, v, yParity, deadline } = await this.erc20PermitHandler\n .withToken(token)\n .getPermitSignature(\n account,\n CONTRACT_ADDRESSES[this.chain].PufLocker as Address,\n value,\n );\n /* istanbul ignore next */\n permitData = {\n r,\n s,\n v: Number(v ?? yParity),\n deadline,\n amount: value,\n };\n }\n\n const depositArgs = <const>[\n TOKENS_ADDRESSES[token][this.chain],\n recipient,\n lockPeriod,\n permitData,\n ];\n\n const transact = () =>\n this.getContract().write.deposit(depositArgs, {\n account,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.deposit(depositArgs, {\n account,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Withdraw the deposits identified by the deposit indexes from the\n * locker.\n *\n * @param pufToken PufToken to withdraw.\n * @param walletAddress Address of the account making the transaction.\n * @param recipient Recipient of the withdrawal.\n * @param depositIndexes Deposit indexes to withdraw.\n * @returns Hash of the withdrawal transaction.\n */\n public withdraw(\n pufToken: PufToken,\n walletAddress: Address,\n recipient: Address,\n depositIndexes: bigint[],\n ) {\n const withdrawArgs = <const>[\n TOKENS_ADDRESSES[pufToken][this.chain],\n depositIndexes,\n recipient,\n ];\n\n const transact = () =>\n this.getContract().write.withdraw(withdrawArgs, {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.withdraw(withdrawArgs, {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n}\n"],"names":["PufLockerHandler","chain","walletClient","publicClient","__publicField","VIEM_CHAINS","ERC20PermitHandler","address","CONTRACT_ADDRESSES","abi","PUF_LOCKER_ABIS","client","getContract","pufToken","walletAddress","TOKENS_ADDRESSES","userAddress","start","limit","depositParams","token","account","recipient","value","lockPeriod","isPreapproved","permitData","padHex","r","s","v","yParity","deadline","depositArgs","depositIndexes","withdrawArgs"],"mappings":";;;;;;;;;AA2BO,MAAMA,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc5B,YACUC,GACAC,GACAC,GACR;AAjBM,IAAAC,EAAA;AACA,IAAAA,EAAA;AAaE,SAAA,QAAAH,GACA,KAAA,eAAAC,GACA,KAAA,e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AAA,MACT,OAAO,KAAK;AAAA,IAAA,CACb,GAMgB,UALF,MACf,KAAK,YAAc,EAAA,YAAY,SAASqB,GAAc;AAAA,MACpD,SAASrB;AAAA,IAAA,CACV;EAGL;AACF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var h=(i,t,n)=>t in i?s(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var a=(i,t,n)=>h(i,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants-BvU-JhfL.cjs"),C=require("../abis/puf-token-abis.cjs"),o=require("../tokens.cjs"),p=require("../../getContract-MrPLx6gp.cjs");class g{constructor(t,n,e){a(this,"viemChain");a(this,"pufToken");this.chain=t,this.walletClient=n,this.publicClient=e,this.pufToken=o.PufToken.pufWETH,this.viemChain=u.VIEM_CHAINS[t]}withPufToken(t){return this.pufToken=t,this}getContract(){const t=o.TOKENS_ADDRESSES[this.pufToken][this.chain],n=C.PUF_TOKEN_ABIS[this.chain].PufToken,e={public:this.publicClient,wallet:this.walletClient};return p.getContract({address:t,abi:n,client:e})}balanceOf(t){return this.getContract().read.balanceOf([t])}getAllowance(t,n){return this.getContract().read.allowance([t,n])}getTotalDepositCap(){return this.getContract().read.totalDepositCap()}getTotalSupply(){return this.getContract().read.totalSupply()}withdraw(t,n){return{transact:()=>this.getContract().write.withdraw([t,n],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.withdraw([t,n],{account:t})}}deposit(t,n,e){return{transact:()=>this.getContract().write.deposit([t,n,e],{account:n,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.deposit([t,n,e],{account:n})}}migrate(t,n,e){return{transact:()=>this.getContract().write.migrate([e,n,t],{account:t,chain:this.viemChain}),estimate:()=>this.getContract().estimateGas.migrate([e,n,t],{account:t})}}approve(t,n,e){return this.getContract().write.approve([n,e],{account:t,chain:this.viemChain})}}exports.PufTokenHandler=g;
2
+ //# sourceMappingURL=puf-token-handler.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puf-token-handler.cjs","sources":["../../../lib/contracts/handlers/puf-token-handler.ts"],"sourcesContent":["import {\n WalletClient,\n PublicClient,\n getContract,\n GetContractReturnType,\n Address,\n} from 'viem';\nimport { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';\nimport { PUF_TOKEN_ABIS } from '../abis/puf-token-abis';\nimport { PufToken, TOKENS_ADDRESSES } from '../tokens';\n\n/**\n * Handler for the `PufToken` contract exposing methods to interact with\n * the contract for each of the wrapped PufTokens (like pufWETH,\n * pufstETH, pufwstETH etc.).\n */\nexport class PufTokenHandler {\n private viemChain: ViemChain;\n private pufToken: PufToken;\n\n /**\n * Create the handler for the `PufToken` contract exposing methods to\n * interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n private chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.pufToken = PufToken.pufWETH;\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Set the PufToken to use for executing transactions on the contract.\n *\n * @param pufToken The PufToken to use for the handler.\n * @returns The handler.\n */\n public withPufToken(pufToken: PufToken) {\n this.pufToken = pufToken;\n return this;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n const address = TOKENS_ADDRESSES[this.pufToken][this.chain];\n const abi = PUF_TOKEN_ABIS[this.chain].PufToken;\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 * Check the wrapped token (PufToken) balance of the wallet.\n *\n * @param walletAddress Wallet address to check the balance of.\n * @returns The wrapped token's (PufToken) balance in wei.\n */\n public balanceOf(walletAddress: Address) {\n return this.getContract().read.balanceOf([walletAddress]);\n }\n\n /**\n * Get the allowance for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the owner.\n * @param spenderAddress Address of the spender.\n * @returns Allowance that can be used by the spender.\n */\n public getAllowance(ownerAddress: Address, spenderAddress: Address) {\n return this.getContract().read.allowance([ownerAddress, spenderAddress]);\n }\n\n /**\n * Get the total cap of the PufToken that can be deposited.\n *\n * @returns Total cap of the PufToken that can be deposited.\n */\n public getTotalDepositCap() {\n return this.getContract().read.totalDepositCap();\n }\n\n /**\n * Get the total supply of the PufToken.\n *\n * @returns Total supply of the PufToken.\n */\n public getTotalSupply() {\n return this.getContract().read.totalSupply();\n }\n\n /**\n * Withdraws the PufToken and returns the underlying token to the\n * given wallet. This doesn't make the transaction but returns two\n * methods namely `transact` and `estimate`.\n *\n * @param walletAddress Wallet address to withdraw the PufToken from.\n * @param value Value of the withdrawal.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public withdraw(walletAddress: Address, value: bigint) {\n const transact = () =>\n this.getContract().write.withdraw([walletAddress, value], {\n account: walletAddress,\n chain: this.viemChain,\n });\n const estimate = () =>\n this.getContract().estimateGas.withdraw([walletAddress, value], {\n account: walletAddress,\n });\n\n return { transact, estimate };\n }\n\n /**\n * Deposits the underlying token in exchange for the wrapped PufToken.\n * This doesn't make the transaction but returns two methods namely\n * `transact` and `estimate`.\n *\n * @param depositorAddress Depositor of the underlying token.\n * @param walletAddress Wallet address of the recipient of the\n * deposit.\n * @param value Value of the deposit.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public deposit(\n depositorAddress: Address,\n walletAddress: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.deposit(\n [depositorAddress, walletAddress, value],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n const estimate = () =>\n this.getContract().estimateGas.deposit(\n [depositorAddress, walletAddress, value],\n {\n account: walletAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Migrate tokens using an allowed `migratorContract` to the given\n * wallet address. This doesn't make the transaction but returns two\n * methods namely `transact` and `estimate`.\n *\n * @param walletAddress Address to migrate the tokens to.\n * @param migratorContract Address of the migrator contract.\n * @param value Value of the tokens to migrate.\n * @returns `transact: () => Promise<Address>` - Used to make the\n * transaction.\n *\n * `estimate: () => Promise<bigint>` - Gas estimate of the\n * transaction.\n */\n public migrate(\n walletAddress: Address,\n migratorContract: Address,\n value: bigint,\n ) {\n const transact = () =>\n this.getContract().write.migrate(\n [value, migratorContract, walletAddress],\n {\n account: walletAddress,\n chain: this.viemChain,\n },\n );\n const estimate = () =>\n this.getContract().estimateGas.migrate(\n [value, migratorContract, walletAddress],\n {\n account: walletAddress,\n },\n );\n\n return { transact, estimate };\n }\n\n /**\n * Approve transaction for the spender to spend the owner's tokens.\n *\n * @param ownerAddress Address of the caller of the transaction.\n * @param spenderAddress Address of the spender.\n * @param value Value to approve for the spender.\n * @returns Hash of the transaction.\n */\n public approve(\n ownerAddress: Address,\n spenderAddress: Address,\n value: bigint,\n ) {\n return this.getContract().write.approve([spenderAddress, value], {\n account: ownerAddress,\n chain: this.viemChain,\n });\n }\n}\n"],"names":["PufTokenHandler","chain","walletClient","publicClient","__publicField","PufToken","VIEM_CHAINS","pufToken","address","TOKENS_ADDRESSES","abi","PUF_TOKEN_ABIS","client","getContract","walletAddress","ownerAddress","spenderAddress","value","depositorAddress","migratorContract"],"mappings":"mZAgBO,MAAMA,CAAgB,CAc3B,YACUC,EACAC,EACAC,EACR,CAjBMC,EAAA,kBACAA,EAAA,iBAaE,KAAA,MAAAH,EACA,KAAA,aAAAC,EACA,KAAA,aAAAC,EAER,KAAK,SAAWE,EAAS,SAAA,QACpB,KAAA,UAAYC,cAAYL,CAAK,CACpC,CAQO,aAAaM,EAAoB,CACtC,YAAK,SAAWA,EACT,IACT,CAQO,aAAc,CACnB,MAAMC,E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