clawkr-cli 1.1.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.
@@ -0,0 +1,817 @@
1
+ "use strict";
2
+ /**
3
+ * Flattened ClawkrToken contract source code for Etherscan verification
4
+ *
5
+ * This file contains the complete flattened source of ClawkrToken.sol including
6
+ * all dependencies (Solady ERC20). Generated using forge flatten.
7
+ *
8
+ * DO NOT EDIT MANUALLY - Regenerate using:
9
+ * cd contracts && forge flatten src/ClawkrToken.sol
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.STANDARD_JSON_INPUT = exports.CONTRACT_NAME = exports.EVM_VERSION = exports.OPTIMIZATION_RUNS = exports.COMPILER_VERSION = exports.CLAWKR_TOKEN_SOURCE = void 0;
13
+ exports.CLAWKR_TOKEN_SOURCE = `// SPDX-License-Identifier: MIT
14
+ pragma solidity ^0.8.4;
15
+
16
+ // lib/solady/src/tokens/ERC20.sol
17
+
18
+ /// @notice Simple ERC20 + EIP-2612 implementation.
19
+ /// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC20.sol)
20
+ /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
21
+ /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol)
22
+ ///
23
+ /// @dev Note:
24
+ /// - The ERC20 standard allows minting and transferring to and from the zero address,
25
+ /// minting and transferring zero tokens, as well as self-approvals.
26
+ /// For performance, this implementation WILL NOT revert for such actions.
27
+ /// Please add any checks with overrides if desired.
28
+ /// - The \`permit\` function uses the ecrecover precompile (0x1).
29
+ ///
30
+ /// If you are overriding:
31
+ /// - NEVER violate the ERC20 invariant:
32
+ /// the total sum of all balances must be equal to \`totalSupply()\`.
33
+ /// - Check that the overridden function is actually used in the function you want to
34
+ /// change the behavior of. Much of the code has been manually inlined for performance.
35
+ abstract contract ERC20 {
36
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
37
+ /* CUSTOM ERRORS */
38
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
39
+
40
+ /// @dev The total supply has overflowed.
41
+ error TotalSupplyOverflow();
42
+
43
+ /// @dev The allowance has overflowed.
44
+ error AllowanceOverflow();
45
+
46
+ /// @dev The allowance has underflowed.
47
+ error AllowanceUnderflow();
48
+
49
+ /// @dev Insufficient balance.
50
+ error InsufficientBalance();
51
+
52
+ /// @dev Insufficient allowance.
53
+ error InsufficientAllowance();
54
+
55
+ /// @dev The permit is invalid.
56
+ error InvalidPermit();
57
+
58
+ /// @dev The permit has expired.
59
+ error PermitExpired();
60
+
61
+ /// @dev The allowance of Permit2 is fixed at infinity.
62
+ error Permit2AllowanceIsFixedAtInfinity();
63
+
64
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
65
+ /* EVENTS */
66
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
67
+
68
+ /// @dev Emitted when \`amount\` tokens is transferred from \`from\` to \`to\`.
69
+ event Transfer(address indexed from, address indexed to, uint256 amount);
70
+
71
+ /// @dev Emitted when \`amount\` tokens is approved by \`owner\` to be used by \`spender\`.
72
+ event Approval(address indexed owner, address indexed spender, uint256 amount);
73
+
74
+ /// @dev \`keccak256(bytes("Transfer(address,address,uint256)"))\`.
75
+ uint256 private constant _TRANSFER_EVENT_SIGNATURE =
76
+ 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
77
+
78
+ /// @dev \`keccak256(bytes("Approval(address,address,uint256)"))\`.
79
+ uint256 private constant _APPROVAL_EVENT_SIGNATURE =
80
+ 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;
81
+
82
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
83
+ /* STORAGE */
84
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
85
+
86
+ /// @dev The storage slot for the total supply.
87
+ uint256 private constant _TOTAL_SUPPLY_SLOT = 0x05345cdf77eb68f44c;
88
+
89
+ /// @dev The balance slot of \`owner\` is given by:
90
+ /// \`\`\`
91
+ /// mstore(0x0c, _BALANCE_SLOT_SEED)
92
+ /// mstore(0x00, owner)
93
+ /// let balanceSlot := keccak256(0x0c, 0x20)
94
+ /// \`\`\`
95
+ uint256 private constant _BALANCE_SLOT_SEED = 0x87a211a2;
96
+
97
+ /// @dev The allowance slot of (\`owner\`, \`spender\`) is given by:
98
+ /// \`\`\`
99
+ /// mstore(0x20, spender)
100
+ /// mstore(0x0c, _ALLOWANCE_SLOT_SEED)
101
+ /// mstore(0x00, owner)
102
+ /// let allowanceSlot := keccak256(0x0c, 0x34)
103
+ /// \`\`\`
104
+ uint256 private constant _ALLOWANCE_SLOT_SEED = 0x7f5e9f20;
105
+
106
+ /// @dev The nonce slot of \`owner\` is given by:
107
+ /// \`\`\`
108
+ /// mstore(0x0c, _NONCES_SLOT_SEED)
109
+ /// mstore(0x00, owner)
110
+ /// let nonceSlot := keccak256(0x0c, 0x20)
111
+ /// \`\`\`
112
+ uint256 private constant _NONCES_SLOT_SEED = 0x38377508;
113
+
114
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
115
+ /* CONSTANTS */
116
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
117
+
118
+ /// @dev \`(_NONCES_SLOT_SEED << 16) | 0x1901\`.
119
+ uint256 private constant _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX = 0x383775081901;
120
+
121
+ /// @dev \`keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")\`.
122
+ bytes32 private constant _DOMAIN_TYPEHASH =
123
+ 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
124
+
125
+ /// @dev \`keccak256("1")\`.
126
+ /// If you need to use a different version, override \`_versionHash\`.
127
+ bytes32 private constant _DEFAULT_VERSION_HASH =
128
+ 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6;
129
+
130
+ /// @dev \`keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")\`.
131
+ bytes32 private constant _PERMIT_TYPEHASH =
132
+ 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
133
+
134
+ /// @dev The canonical Permit2 address.
135
+ /// For signature-based allowance granting for single transaction ERC20 \`transferFrom\`.
136
+ /// Enabled by default. To disable, override \`_givePermit2InfiniteAllowance()\`.
137
+ /// [Github](https://github.com/Uniswap/permit2)
138
+ /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
139
+ address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
140
+
141
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
142
+ /* ERC20 METADATA */
143
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
144
+
145
+ /// @dev Returns the name of the token.
146
+ function name() public view virtual returns (string memory);
147
+
148
+ /// @dev Returns the symbol of the token.
149
+ function symbol() public view virtual returns (string memory);
150
+
151
+ /// @dev Returns the decimals places of the token.
152
+ function decimals() public view virtual returns (uint8) {
153
+ return 18;
154
+ }
155
+
156
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
157
+ /* ERC20 */
158
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
159
+
160
+ /// @dev Returns the amount of tokens in existence.
161
+ function totalSupply() public view virtual returns (uint256 result) {
162
+ /// @solidity memory-safe-assembly
163
+ assembly {
164
+ result := sload(_TOTAL_SUPPLY_SLOT)
165
+ }
166
+ }
167
+
168
+ /// @dev Returns the amount of tokens owned by \`owner\`.
169
+ function balanceOf(address owner) public view virtual returns (uint256 result) {
170
+ /// @solidity memory-safe-assembly
171
+ assembly {
172
+ mstore(0x0c, _BALANCE_SLOT_SEED)
173
+ mstore(0x00, owner)
174
+ result := sload(keccak256(0x0c, 0x20))
175
+ }
176
+ }
177
+
178
+ /// @dev Returns the amount of tokens that \`spender\` can spend on behalf of \`owner\`.
179
+ function allowance(address owner, address spender)
180
+ public
181
+ view
182
+ virtual
183
+ returns (uint256 result)
184
+ {
185
+ if (_givePermit2InfiniteAllowance()) {
186
+ if (spender == _PERMIT2) return type(uint256).max;
187
+ }
188
+ /// @solidity memory-safe-assembly
189
+ assembly {
190
+ mstore(0x20, spender)
191
+ mstore(0x0c, _ALLOWANCE_SLOT_SEED)
192
+ mstore(0x00, owner)
193
+ result := sload(keccak256(0x0c, 0x34))
194
+ }
195
+ }
196
+
197
+ /// @dev Sets \`amount\` as the allowance of \`spender\` over the caller's tokens.
198
+ ///
199
+ /// Emits a {Approval} event.
200
+ function approve(address spender, uint256 amount) public virtual returns (bool) {
201
+ if (_givePermit2InfiniteAllowance()) {
202
+ /// @solidity memory-safe-assembly
203
+ assembly {
204
+ // If \`spender == _PERMIT2 && amount != type(uint256).max\`.
205
+ if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(amount)))) {
206
+ mstore(0x00, 0x3f68539a) // \`Permit2AllowanceIsFixedAtInfinity()\`.
207
+ revert(0x1c, 0x04)
208
+ }
209
+ }
210
+ }
211
+ /// @solidity memory-safe-assembly
212
+ assembly {
213
+ // Compute the allowance slot and store the amount.
214
+ mstore(0x20, spender)
215
+ mstore(0x0c, _ALLOWANCE_SLOT_SEED)
216
+ mstore(0x00, caller())
217
+ sstore(keccak256(0x0c, 0x34), amount)
218
+ // Emit the {Approval} event.
219
+ mstore(0x00, amount)
220
+ log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, caller(), shr(96, mload(0x2c)))
221
+ }
222
+ return true;
223
+ }
224
+
225
+ /// @dev Transfer \`amount\` tokens from the caller to \`to\`.
226
+ ///
227
+ /// Requirements:
228
+ /// - \`from\` must at least have \`amount\`.
229
+ ///
230
+ /// Emits a {Transfer} event.
231
+ function transfer(address to, uint256 amount) public virtual returns (bool) {
232
+ _beforeTokenTransfer(msg.sender, to, amount);
233
+ /// @solidity memory-safe-assembly
234
+ assembly {
235
+ // Compute the balance slot and load its value.
236
+ mstore(0x0c, _BALANCE_SLOT_SEED)
237
+ mstore(0x00, caller())
238
+ let fromBalanceSlot := keccak256(0x0c, 0x20)
239
+ let fromBalance := sload(fromBalanceSlot)
240
+ // Revert if insufficient balance.
241
+ if gt(amount, fromBalance) {
242
+ mstore(0x00, 0xf4d678b8) // \`InsufficientBalance()\`.
243
+ revert(0x1c, 0x04)
244
+ }
245
+ // Subtract and store the updated balance.
246
+ sstore(fromBalanceSlot, sub(fromBalance, amount))
247
+ // Compute the balance slot of \`to\`.
248
+ mstore(0x00, to)
249
+ let toBalanceSlot := keccak256(0x0c, 0x20)
250
+ // Add and store the updated balance of \`to\`.
251
+ // Will not overflow because the sum of all user balances
252
+ // cannot exceed the maximum uint256 value.
253
+ sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
254
+ // Emit the {Transfer} event.
255
+ mstore(0x20, amount)
256
+ log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c)))
257
+ }
258
+ _afterTokenTransfer(msg.sender, to, amount);
259
+ return true;
260
+ }
261
+
262
+ /// @dev Transfers \`amount\` tokens from \`from\` to \`to\`.
263
+ ///
264
+ /// Note: Does not update the allowance if it is the maximum uint256 value.
265
+ ///
266
+ /// Requirements:
267
+ /// - \`from\` must at least have \`amount\`.
268
+ /// - The caller must have at least \`amount\` of allowance to transfer the tokens of \`from\`.
269
+ ///
270
+ /// Emits a {Transfer} event.
271
+ function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {
272
+ _beforeTokenTransfer(from, to, amount);
273
+ // Code duplication is for zero-cost abstraction if possible.
274
+ if (_givePermit2InfiniteAllowance()) {
275
+ /// @solidity memory-safe-assembly
276
+ assembly {
277
+ let from_ := shl(96, from)
278
+ if iszero(eq(caller(), _PERMIT2)) {
279
+ // Compute the allowance slot and load its value.
280
+ mstore(0x20, caller())
281
+ mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED))
282
+ let allowanceSlot := keccak256(0x0c, 0x34)
283
+ let allowance_ := sload(allowanceSlot)
284
+ // If the allowance is not the maximum uint256 value.
285
+ if not(allowance_) {
286
+ // Revert if the amount to be transferred exceeds the allowance.
287
+ if gt(amount, allowance_) {
288
+ mstore(0x00, 0x13be252b) // \`InsufficientAllowance()\`.
289
+ revert(0x1c, 0x04)
290
+ }
291
+ // Subtract and store the updated allowance.
292
+ sstore(allowanceSlot, sub(allowance_, amount))
293
+ }
294
+ }
295
+ // Compute the balance slot and load its value.
296
+ mstore(0x0c, or(from_, _BALANCE_SLOT_SEED))
297
+ let fromBalanceSlot := keccak256(0x0c, 0x20)
298
+ let fromBalance := sload(fromBalanceSlot)
299
+ // Revert if insufficient balance.
300
+ if gt(amount, fromBalance) {
301
+ mstore(0x00, 0xf4d678b8) // \`InsufficientBalance()\`.
302
+ revert(0x1c, 0x04)
303
+ }
304
+ // Subtract and store the updated balance.
305
+ sstore(fromBalanceSlot, sub(fromBalance, amount))
306
+ // Compute the balance slot of \`to\`.
307
+ mstore(0x00, to)
308
+ let toBalanceSlot := keccak256(0x0c, 0x20)
309
+ // Add and store the updated balance of \`to\`.
310
+ // Will not overflow because the sum of all user balances
311
+ // cannot exceed the maximum uint256 value.
312
+ sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
313
+ // Emit the {Transfer} event.
314
+ mstore(0x20, amount)
315
+ log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c)))
316
+ }
317
+ } else {
318
+ /// @solidity memory-safe-assembly
319
+ assembly {
320
+ let from_ := shl(96, from)
321
+ // Compute the allowance slot and load its value.
322
+ mstore(0x20, caller())
323
+ mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED))
324
+ let allowanceSlot := keccak256(0x0c, 0x34)
325
+ let allowance_ := sload(allowanceSlot)
326
+ // If the allowance is not the maximum uint256 value.
327
+ if not(allowance_) {
328
+ // Revert if the amount to be transferred exceeds the allowance.
329
+ if gt(amount, allowance_) {
330
+ mstore(0x00, 0x13be252b) // \`InsufficientAllowance()\`.
331
+ revert(0x1c, 0x04)
332
+ }
333
+ // Subtract and store the updated allowance.
334
+ sstore(allowanceSlot, sub(allowance_, amount))
335
+ }
336
+ // Compute the balance slot and load its value.
337
+ mstore(0x0c, or(from_, _BALANCE_SLOT_SEED))
338
+ let fromBalanceSlot := keccak256(0x0c, 0x20)
339
+ let fromBalance := sload(fromBalanceSlot)
340
+ // Revert if insufficient balance.
341
+ if gt(amount, fromBalance) {
342
+ mstore(0x00, 0xf4d678b8) // \`InsufficientBalance()\`.
343
+ revert(0x1c, 0x04)
344
+ }
345
+ // Subtract and store the updated balance.
346
+ sstore(fromBalanceSlot, sub(fromBalance, amount))
347
+ // Compute the balance slot of \`to\`.
348
+ mstore(0x00, to)
349
+ let toBalanceSlot := keccak256(0x0c, 0x20)
350
+ // Add and store the updated balance of \`to\`.
351
+ // Will not overflow because the sum of all user balances
352
+ // cannot exceed the maximum uint256 value.
353
+ sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
354
+ // Emit the {Transfer} event.
355
+ mstore(0x20, amount)
356
+ log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c)))
357
+ }
358
+ }
359
+ _afterTokenTransfer(from, to, amount);
360
+ return true;
361
+ }
362
+
363
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
364
+ /* EIP-2612 */
365
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
366
+
367
+ /// @dev For more performance, override to return the constant value
368
+ /// of \`keccak256(bytes(name()))\` if \`name()\` will never change.
369
+ function _constantNameHash() internal view virtual returns (bytes32 result) {}
370
+
371
+ /// @dev If you need a different value, override this function.
372
+ function _versionHash() internal view virtual returns (bytes32 result) {
373
+ result = _DEFAULT_VERSION_HASH;
374
+ }
375
+
376
+ /// @dev For inheriting contracts to increment the nonce.
377
+ function _incrementNonce(address owner) internal virtual {
378
+ /// @solidity memory-safe-assembly
379
+ assembly {
380
+ mstore(0x0c, _NONCES_SLOT_SEED)
381
+ mstore(0x00, owner)
382
+ let nonceSlot := keccak256(0x0c, 0x20)
383
+ sstore(nonceSlot, add(1, sload(nonceSlot)))
384
+ }
385
+ }
386
+
387
+ /// @dev Returns the current nonce for \`owner\`.
388
+ /// This value is used to compute the signature for EIP-2612 permit.
389
+ function nonces(address owner) public view virtual returns (uint256 result) {
390
+ /// @solidity memory-safe-assembly
391
+ assembly {
392
+ // Compute the nonce slot and load its value.
393
+ mstore(0x0c, _NONCES_SLOT_SEED)
394
+ mstore(0x00, owner)
395
+ result := sload(keccak256(0x0c, 0x20))
396
+ }
397
+ }
398
+
399
+ /// @dev Sets \`value\` as the allowance of \`spender\` over the tokens of \`owner\`,
400
+ /// authorized by a signed approval by \`owner\`.
401
+ ///
402
+ /// Emits a {Approval} event.
403
+ function permit(
404
+ address owner,
405
+ address spender,
406
+ uint256 value,
407
+ uint256 deadline,
408
+ uint8 v,
409
+ bytes32 r,
410
+ bytes32 s
411
+ ) public virtual {
412
+ if (_givePermit2InfiniteAllowance()) {
413
+ /// @solidity memory-safe-assembly
414
+ assembly {
415
+ // If \`spender == _PERMIT2 && value != type(uint256).max\`.
416
+ if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(value)))) {
417
+ mstore(0x00, 0x3f68539a) // \`Permit2AllowanceIsFixedAtInfinity()\`.
418
+ revert(0x1c, 0x04)
419
+ }
420
+ }
421
+ }
422
+ bytes32 nameHash = _constantNameHash();
423
+ // We simply calculate it on-the-fly to allow for cases where the \`name\` may change.
424
+ if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name()));
425
+ bytes32 versionHash = _versionHash();
426
+ /// @solidity memory-safe-assembly
427
+ assembly {
428
+ // Revert if the block timestamp is greater than \`deadline\`.
429
+ if gt(timestamp(), deadline) {
430
+ mstore(0x00, 0x1a15a3cc) // \`PermitExpired()\`.
431
+ revert(0x1c, 0x04)
432
+ }
433
+ let m := mload(0x40) // Grab the free memory pointer.
434
+ // Clean the upper 96 bits.
435
+ owner := shr(96, shl(96, owner))
436
+ spender := shr(96, shl(96, spender))
437
+ // Compute the nonce slot and load its value.
438
+ mstore(0x0e, _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX)
439
+ mstore(0x00, owner)
440
+ let nonceSlot := keccak256(0x0c, 0x20)
441
+ let nonceValue := sload(nonceSlot)
442
+ // Prepare the domain separator.
443
+ mstore(m, _DOMAIN_TYPEHASH)
444
+ mstore(add(m, 0x20), nameHash)
445
+ mstore(add(m, 0x40), versionHash)
446
+ mstore(add(m, 0x60), chainid())
447
+ mstore(add(m, 0x80), address())
448
+ mstore(0x2e, keccak256(m, 0xa0))
449
+ // Prepare the struct hash.
450
+ mstore(m, _PERMIT_TYPEHASH)
451
+ mstore(add(m, 0x20), owner)
452
+ mstore(add(m, 0x40), spender)
453
+ mstore(add(m, 0x60), value)
454
+ mstore(add(m, 0x80), nonceValue)
455
+ mstore(add(m, 0xa0), deadline)
456
+ mstore(0x4e, keccak256(m, 0xc0))
457
+ // Prepare the ecrecover calldata.
458
+ mstore(0x00, keccak256(0x2c, 0x42))
459
+ mstore(0x20, and(0xff, v))
460
+ mstore(0x40, r)
461
+ mstore(0x60, s)
462
+ let t := staticcall(gas(), 1, 0x00, 0x80, 0x20, 0x20)
463
+ // If the ecrecover fails, the returndatasize will be 0x00,
464
+ // \`owner\` will be checked if it equals the hash at 0x00,
465
+ // which evaluates to false (i.e. 0), and we will revert.
466
+ // If the ecrecover succeeds, the returndatasize will be 0x20,
467
+ // \`owner\` will be compared against the returned address at 0x20.
468
+ if iszero(eq(mload(returndatasize()), owner)) {
469
+ mstore(0x00, 0xddafbaef) // \`InvalidPermit()\`.
470
+ revert(0x1c, 0x04)
471
+ }
472
+ // Increment and store the updated nonce.
473
+ sstore(nonceSlot, add(nonceValue, t)) // \`t\` is 1 if ecrecover succeeds.
474
+ // Compute the allowance slot and store the value.
475
+ // The \`owner\` is already at slot 0x20.
476
+ mstore(0x40, or(shl(160, _ALLOWANCE_SLOT_SEED), spender))
477
+ sstore(keccak256(0x2c, 0x34), value)
478
+ // Emit the {Approval} event.
479
+ log3(add(m, 0x60), 0x20, _APPROVAL_EVENT_SIGNATURE, owner, spender)
480
+ mstore(0x40, m) // Restore the free memory pointer.
481
+ mstore(0x60, 0) // Restore the zero pointer.
482
+ }
483
+ }
484
+
485
+ /// @dev Returns the EIP-712 domain separator for the EIP-2612 permit.
486
+ function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) {
487
+ bytes32 nameHash = _constantNameHash();
488
+ // We simply calculate it on-the-fly to allow for cases where the \`name\` may change.
489
+ if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name()));
490
+ bytes32 versionHash = _versionHash();
491
+ /// @solidity memory-safe-assembly
492
+ assembly {
493
+ let m := mload(0x40) // Grab the free memory pointer.
494
+ mstore(m, _DOMAIN_TYPEHASH)
495
+ mstore(add(m, 0x20), nameHash)
496
+ mstore(add(m, 0x40), versionHash)
497
+ mstore(add(m, 0x60), chainid())
498
+ mstore(add(m, 0x80), address())
499
+ result := keccak256(m, 0xa0)
500
+ }
501
+ }
502
+
503
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
504
+ /* INTERNAL MINT FUNCTIONS */
505
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
506
+
507
+ /// @dev Mints \`amount\` tokens to \`to\`, increasing the total supply.
508
+ ///
509
+ /// Emits a {Transfer} event.
510
+ function _mint(address to, uint256 amount) internal virtual {
511
+ _beforeTokenTransfer(address(0), to, amount);
512
+ /// @solidity memory-safe-assembly
513
+ assembly {
514
+ let totalSupplyBefore := sload(_TOTAL_SUPPLY_SLOT)
515
+ let totalSupplyAfter := add(totalSupplyBefore, amount)
516
+ // Revert if the total supply overflows.
517
+ if lt(totalSupplyAfter, totalSupplyBefore) {
518
+ mstore(0x00, 0xe5cfe957) // \`TotalSupplyOverflow()\`.
519
+ revert(0x1c, 0x04)
520
+ }
521
+ // Store the updated total supply.
522
+ sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter)
523
+ // Compute the balance slot and load its value.
524
+ mstore(0x0c, _BALANCE_SLOT_SEED)
525
+ mstore(0x00, to)
526
+ let toBalanceSlot := keccak256(0x0c, 0x20)
527
+ // Add and store the updated balance.
528
+ sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
529
+ // Emit the {Transfer} event.
530
+ mstore(0x20, amount)
531
+ log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, mload(0x0c)))
532
+ }
533
+ _afterTokenTransfer(address(0), to, amount);
534
+ }
535
+
536
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
537
+ /* INTERNAL BURN FUNCTIONS */
538
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
539
+
540
+ /// @dev Burns \`amount\` tokens from \`from\`, reducing the total supply.
541
+ ///
542
+ /// Emits a {Transfer} event.
543
+ function _burn(address from, uint256 amount) internal virtual {
544
+ _beforeTokenTransfer(from, address(0), amount);
545
+ /// @solidity memory-safe-assembly
546
+ assembly {
547
+ // Compute the balance slot and load its value.
548
+ mstore(0x0c, _BALANCE_SLOT_SEED)
549
+ mstore(0x00, from)
550
+ let fromBalanceSlot := keccak256(0x0c, 0x20)
551
+ let fromBalance := sload(fromBalanceSlot)
552
+ // Revert if insufficient balance.
553
+ if gt(amount, fromBalance) {
554
+ mstore(0x00, 0xf4d678b8) // \`InsufficientBalance()\`.
555
+ revert(0x1c, 0x04)
556
+ }
557
+ // Subtract and store the updated balance.
558
+ sstore(fromBalanceSlot, sub(fromBalance, amount))
559
+ // Subtract and store the updated total supply.
560
+ sstore(_TOTAL_SUPPLY_SLOT, sub(sload(_TOTAL_SUPPLY_SLOT), amount))
561
+ // Emit the {Transfer} event.
562
+ mstore(0x00, amount)
563
+ log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)
564
+ }
565
+ _afterTokenTransfer(from, address(0), amount);
566
+ }
567
+
568
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
569
+ /* INTERNAL TRANSFER FUNCTIONS */
570
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
571
+
572
+ /// @dev Moves \`amount\` of tokens from \`from\` to \`to\`.
573
+ function _transfer(address from, address to, uint256 amount) internal virtual {
574
+ _beforeTokenTransfer(from, to, amount);
575
+ /// @solidity memory-safe-assembly
576
+ assembly {
577
+ let from_ := shl(96, from)
578
+ // Compute the balance slot and load its value.
579
+ mstore(0x0c, or(from_, _BALANCE_SLOT_SEED))
580
+ let fromBalanceSlot := keccak256(0x0c, 0x20)
581
+ let fromBalance := sload(fromBalanceSlot)
582
+ // Revert if insufficient balance.
583
+ if gt(amount, fromBalance) {
584
+ mstore(0x00, 0xf4d678b8) // \`InsufficientBalance()\`.
585
+ revert(0x1c, 0x04)
586
+ }
587
+ // Subtract and store the updated balance.
588
+ sstore(fromBalanceSlot, sub(fromBalance, amount))
589
+ // Compute the balance slot of \`to\`.
590
+ mstore(0x00, to)
591
+ let toBalanceSlot := keccak256(0x0c, 0x20)
592
+ // Add and store the updated balance of \`to\`.
593
+ // Will not overflow because the sum of all user balances
594
+ // cannot exceed the maximum uint256 value.
595
+ sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
596
+ // Emit the {Transfer} event.
597
+ mstore(0x20, amount)
598
+ log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c)))
599
+ }
600
+ _afterTokenTransfer(from, to, amount);
601
+ }
602
+
603
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
604
+ /* INTERNAL ALLOWANCE FUNCTIONS */
605
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
606
+
607
+ /// @dev Updates the allowance of \`owner\` for \`spender\` based on spent \`amount\`.
608
+ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
609
+ if (_givePermit2InfiniteAllowance()) {
610
+ if (spender == _PERMIT2) return; // Do nothing, as allowance is infinite.
611
+ }
612
+ /// @solidity memory-safe-assembly
613
+ assembly {
614
+ // Compute the allowance slot and load its value.
615
+ mstore(0x20, spender)
616
+ mstore(0x0c, _ALLOWANCE_SLOT_SEED)
617
+ mstore(0x00, owner)
618
+ let allowanceSlot := keccak256(0x0c, 0x34)
619
+ let allowance_ := sload(allowanceSlot)
620
+ // If the allowance is not the maximum uint256 value.
621
+ if not(allowance_) {
622
+ // Revert if the amount to be transferred exceeds the allowance.
623
+ if gt(amount, allowance_) {
624
+ mstore(0x00, 0x13be252b) // \`InsufficientAllowance()\`.
625
+ revert(0x1c, 0x04)
626
+ }
627
+ // Subtract and store the updated allowance.
628
+ sstore(allowanceSlot, sub(allowance_, amount))
629
+ }
630
+ }
631
+ }
632
+
633
+ /// @dev Sets \`amount\` as the allowance of \`spender\` over the tokens of \`owner\`.
634
+ ///
635
+ /// Emits a {Approval} event.
636
+ function _approve(address owner, address spender, uint256 amount) internal virtual {
637
+ if (_givePermit2InfiniteAllowance()) {
638
+ /// @solidity memory-safe-assembly
639
+ assembly {
640
+ // If \`spender == _PERMIT2 && amount != type(uint256).max\`.
641
+ if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(amount)))) {
642
+ mstore(0x00, 0x3f68539a) // \`Permit2AllowanceIsFixedAtInfinity()\`.
643
+ revert(0x1c, 0x04)
644
+ }
645
+ }
646
+ }
647
+ /// @solidity memory-safe-assembly
648
+ assembly {
649
+ let owner_ := shl(96, owner)
650
+ // Compute the allowance slot and store the amount.
651
+ mstore(0x20, spender)
652
+ mstore(0x0c, or(owner_, _ALLOWANCE_SLOT_SEED))
653
+ sstore(keccak256(0x0c, 0x34), amount)
654
+ // Emit the {Approval} event.
655
+ mstore(0x00, amount)
656
+ log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, owner_), shr(96, mload(0x2c)))
657
+ }
658
+ }
659
+
660
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
661
+ /* HOOKS TO OVERRIDE */
662
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
663
+
664
+ /// @dev Hook that is called before any transfer of tokens.
665
+ /// This includes minting and burning.
666
+ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
667
+
668
+ /// @dev Hook that is called after any transfer of tokens.
669
+ /// This includes minting and burning.
670
+ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
671
+
672
+ /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
673
+ /* PERMIT2 */
674
+ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
675
+
676
+ /// @dev Returns whether to fix the Permit2 contract's allowance at infinity.
677
+ ///
678
+ /// This value should be kept constant after contract initialization,
679
+ /// or else the actual allowance values may not match with the {Approval} events.
680
+ /// For best performance, return a compile-time constant for zero-cost abstraction.
681
+ function _givePermit2InfiniteAllowance() internal view virtual returns (bool) {
682
+ return true;
683
+ }
684
+ }
685
+
686
+ // src/ClawkrToken.sol
687
+
688
+ /// @title ClawkrToken
689
+ /// @notice ERC20 token launched by AI agents through Clawkr
690
+ /// @dev Uses Solady's gas-efficient ERC20 implementation
691
+ contract ClawkrToken is ERC20 {
692
+ /// @notice The agent that launched this token
693
+ address public immutable agent;
694
+
695
+ /// @notice The Clawkr hook that manages this token
696
+ address public immutable clawkrHook;
697
+
698
+ /// @notice Token name (stored for ERC20)
699
+ string private _name;
700
+
701
+ /// @notice Token symbol (stored for ERC20)
702
+ string private _symbol;
703
+
704
+ /// @notice Token metadata URI (IPFS/Arweave URL containing image and metadata)
705
+ /// @dev Following flaunch.gg pattern - stored as public variable with auto-generated getter
706
+ string public tokenURI;
707
+
708
+ /// @notice Permit2 address for gasless approvals
709
+ address public constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
710
+
711
+ /// @notice Error when caller is not authorized
712
+ error Unauthorized();
713
+
714
+ /// @notice Error when token is already initialized
715
+ error AlreadyInitialized();
716
+
717
+ /// @param _agent The agent launching this token
718
+ /// @param _clawkrHook The Clawkr hook address
719
+ constructor(address _agent, address _clawkrHook) {
720
+ agent = _agent;
721
+ clawkrHook = _clawkrHook;
722
+ }
723
+
724
+ /// @notice Initialize the token with name, symbol, tokenURI, and mint to recipient
725
+ /// @param name_ Token name
726
+ /// @param symbol_ Token symbol
727
+ /// @param tokenUri_ Token metadata URI (IPFS/Arweave URL)
728
+ /// @param supply Total supply to mint
729
+ /// @param recipient Address to receive the minted tokens
730
+ function initialize(
731
+ string calldata name_,
732
+ string calldata symbol_,
733
+ string calldata tokenUri_,
734
+ uint256 supply,
735
+ address recipient
736
+ ) external {
737
+ if (msg.sender != clawkrHook) revert Unauthorized();
738
+ if (bytes(_name).length > 0) revert AlreadyInitialized();
739
+
740
+ _name = name_;
741
+ _symbol = symbol_;
742
+ tokenURI = tokenUri_;
743
+ _mint(recipient, supply);
744
+ }
745
+
746
+ /// @notice Returns the name of the token
747
+ function name() public view override returns (string memory) {
748
+ return _name;
749
+ }
750
+
751
+ /// @notice Returns the symbol of the token
752
+ function symbol() public view override returns (string memory) {
753
+ return _symbol;
754
+ }
755
+
756
+ /// @notice Returns the number of decimals (always 18)
757
+ function decimals() public pure override returns (uint8) {
758
+ return 18;
759
+ }
760
+
761
+ /// @notice Override allowance to give Permit2 infinite approval
762
+ /// @dev This enables single-transaction approvals via Permit2
763
+ function allowance(address owner, address spender) public view override returns (uint256) {
764
+ if (spender == PERMIT2) {
765
+ return type(uint256).max;
766
+ }
767
+ return super.allowance(owner, spender);
768
+ }
769
+ }
770
+
771
+ `;
772
+ /**
773
+ * Compiler version used to compile ClawkrToken
774
+ * Must match exactly for Etherscan verification
775
+ *
776
+ * From: contracts/out/ClawkrToken.sol/ClawkrToken.json metadata.compiler.version
777
+ */
778
+ exports.COMPILER_VERSION = 'v0.8.26+commit.8a97fa7a';
779
+ /**
780
+ * Optimization runs from foundry.toml
781
+ */
782
+ exports.OPTIMIZATION_RUNS = 200;
783
+ /**
784
+ * EVM version target from foundry.toml
785
+ */
786
+ exports.EVM_VERSION = 'cancun';
787
+ /**
788
+ * Contract name for verification
789
+ */
790
+ exports.CONTRACT_NAME = 'ClawkrToken';
791
+ /**
792
+ * Standard JSON Input for verification (supports via-ir compilation)
793
+ * Required for contracts compiled with via-ir=true
794
+ */
795
+ exports.STANDARD_JSON_INPUT = JSON.stringify({
796
+ language: 'Solidity',
797
+ sources: {
798
+ 'ClawkrToken.sol': {
799
+ content: exports.CLAWKR_TOKEN_SOURCE
800
+ }
801
+ },
802
+ settings: {
803
+ optimizer: {
804
+ enabled: true,
805
+ runs: exports.OPTIMIZATION_RUNS
806
+ },
807
+ viaIR: true,
808
+ evmVersion: exports.EVM_VERSION,
809
+ outputSelection: {
810
+ '*': {
811
+ '*': ['abi', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers'],
812
+ '': ['ast']
813
+ }
814
+ }
815
+ }
816
+ });
817
+ //# sourceMappingURL=contract-sources.js.map