-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcadence-transactions.ts
More file actions
693 lines (581 loc) · 20.8 KB
/
Copy pathcadence-transactions.ts
File metadata and controls
693 lines (581 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
/**
* Cadence Transaction Templates for EVM DCA System
*
* Uses DCAServiceEVM for pure EVM-native DCA.
* Users interact via ERC-20 approve in their EVM wallet (Metamask).
*/
// =============================================================================
// SCRIPTS - Query DCA plans and state
// =============================================================================
/**
* Get all DCA plans for an EVM user address
*/
export const GET_USER_PLANS_SCRIPT = `
import EVM from 0xEVM
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(userEVMAddressHex: String): [DCAServiceEVM.PlanData] {
let userEVMAddress = EVM.addressFromString(userEVMAddressHex)
return DCAServiceEVM.getUserPlans(userEVMAddress: userEVMAddress)
}
`;
/**
* Get a specific DCA plan by ID
*/
export const GET_PLAN_SCRIPT = `
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(planId: UInt64): DCAServiceEVM.PlanData? {
return DCAServiceEVM.getPlan(planId: planId)
}
`;
/**
* Get total number of DCA plans
*/
export const GET_TOTAL_PLANS_SCRIPT = `
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(): Int {
return DCAServiceEVM.getTotalPlans()
}
`;
/**
* Get the shared COA address that users need to approve
*/
export const GET_COA_ADDRESS_SCRIPT = `
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(): String {
return DCAServiceEVM.getCOAAddress().toString()
}
`;
/**
* Check ERC-20 allowance for a user
*/
export const CHECK_ALLOWANCE_SCRIPT = `
import EVM from 0xEVM
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(userEVMAddressHex: String, tokenAddressHex: String): UInt256 {
let userEVMAddress = EVM.addressFromString(userEVMAddressHex)
let tokenAddress = EVM.addressFromString(tokenAddressHex)
return DCAServiceEVM.checkAllowance(userEVMAddress: userEVMAddress, tokenAddress: tokenAddress)
}
`;
/**
* Get ERC-20 token balance for an EVM address
* Uses the shared COA to make the call (read-only)
*/
export const GET_EVM_TOKEN_BALANCE_SCRIPT = `
import EVM from 0xEVM
import DCAServiceEVM from 0xDCAServiceEVM
access(all) fun main(userEVMAddressHex: String, tokenAddressHex: String): UInt256 {
let userAddress = EVM.addressFromString(userEVMAddressHex)
let tokenAddress = EVM.addressFromString(tokenAddressHex)
// balanceOf(address) function selector: 0x70a08231
let functionSelector: [UInt8] = [0x70, 0xa0, 0x82, 0x31]
// Encode the address parameter (32 bytes, left-padded)
var addressBytes: [UInt8] = []
// 12 bytes of padding
var i = 0
while i < 12 {
addressBytes.append(0)
i = i + 1
}
// 20 bytes of address
for byte in userAddress.bytes {
addressBytes.append(byte)
}
// Combine function selector + encoded address
var calldata: [UInt8] = functionSelector
for byte in addressBytes {
calldata.append(byte)
}
// Use the shared COA to make a static call (read-only)
let result = DCAServiceEVM.sharedCOA.call(
to: tokenAddress,
data: calldata,
gasLimit: 100000,
value: EVM.Balance(attoflow: 0)
)
if result.status != EVM.Status.successful {
return 0
}
// Decode the result (32 bytes representing a UInt256)
if result.data.length < 32 {
return 0
}
var balance: UInt256 = 0
var j = 0
while j < 32 {
balance = balance << 8
balance = balance + UInt256(result.data[j])
j = j + 1
}
return balance
}
`;
/**
* Get FLOW balance (native Cadence)
*/
export const GET_FLOW_BALANCE_SCRIPT = `
import FlowToken from 0xFlowToken
import FungibleToken from 0xFungibleToken
access(all) fun main(address: Address): UFix64 {
let account = getAccount(address)
let vaultRef = account.capabilities.borrow<&{FungibleToken.Balance}>(/public/flowTokenBalance)
return vaultRef?.balance ?? 0.0
}
`;
// =============================================================================
// CADENCE USER TRANSACTIONS - For Flow wallet users
// =============================================================================
/**
* Setup COA (Cadence Owned Account) for Cadence users
* Creates an EVM account that can hold ERC-20 tokens
*/
export const SETUP_COA_TX = `
import EVM from 0xEVM
import FungibleToken from 0xFungibleToken
import FlowToken from 0xFlowToken
transaction(initialFunding: UFix64?) {
let coa: auth(EVM.Call) &EVM.CadenceOwnedAccount
prepare(signer: auth(Storage, Capabilities, BorrowValue) &Account) {
let coaPath = /storage/evm
if signer.storage.type(at: coaPath) == nil {
let newCOA <- EVM.createCadenceOwnedAccount()
signer.storage.save(<-newCOA, to: coaPath)
log("Created new COA")
let cap = signer.capabilities.storage.issue<&EVM.CadenceOwnedAccount>(coaPath)
signer.capabilities.publish(cap, at: /public/evm)
log("Published COA capability")
} else {
log("COA already exists")
}
self.coa = signer.storage.borrow<auth(EVM.Call) &EVM.CadenceOwnedAccount>(from: coaPath)
?? panic("Could not borrow COA")
if initialFunding != nil && initialFunding! > 0.0 {
let flowVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(
from: /storage/flowTokenVault
) ?? panic("Could not borrow FlowToken vault")
let funding <- flowVault.withdraw(amount: initialFunding!) as! @FlowToken.Vault
self.coa.deposit(from: <-funding)
log("Funded COA with ".concat(initialFunding!.toString()).concat(" FLOW"))
}
}
execute {
let evmAddress = self.coa.address()
log("COA Setup Complete!")
log("EVM Address: ".concat(evmAddress.toString()))
}
}
`;
/**
* Wrap FLOW to WFLOW for Cadence users (standalone - kept for backwards compatibility)
*/
export const WRAP_FLOW_TX = `
import EVM from 0xEVM
import FungibleToken from 0xFungibleToken
import FlowToken from 0xFlowToken
transaction(amount: UFix64) {
let coa: auth(EVM.Call) &EVM.CadenceOwnedAccount
let flowVault: auth(FungibleToken.Withdraw) &FlowToken.Vault
prepare(signer: auth(Storage, BorrowValue) &Account) {
self.coa = signer.storage.borrow<auth(EVM.Call) &EVM.CadenceOwnedAccount>(
from: /storage/evm
) ?? panic("COA not found. Run setup_coa first.")
self.flowVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(
from: /storage/flowTokenVault
) ?? panic("FlowToken vault not found")
}
execute {
// WFLOW contract address (same on mainnet and testnet)
let wflowAddress = EVM.EVMAddress(
bytes: [0xd3, 0xbF, 0x53, 0xDA, 0xC1, 0x06, 0xA0, 0x29, 0x0B, 0x04,
0x83, 0xEc, 0xBC, 0x89, 0xd4, 0x0F, 0xCC, 0x96, 0x1f, 0x3e]
)
// Step 1: Deposit FLOW into COA
let funding <- self.flowVault.withdraw(amount: amount) as! @FlowToken.Vault
self.coa.deposit(from: <-funding)
log("Deposited ".concat(amount.toString()).concat(" FLOW to COA"))
// Step 2: Call WFLOW.deposit() to wrap
let depositCalldata: [UInt8] = [0xd0, 0xe3, 0x0d, 0xb0]
let amountInWei = EVM.Balance(attoflow: 0)
amountInWei.setFLOW(flow: amount)
let result = self.coa.call(
to: wflowAddress,
data: depositCalldata,
gasLimit: 100000,
value: amountInWei
)
if result.status != EVM.Status.successful {
panic("WFLOW wrap failed with error code: ".concat(result.errorCode.toString()))
}
log("Wrapped ".concat(amount.toString()).concat(" FLOW to WFLOW"))
}
}
`;
/**
* Combined: Wrap FLOW to WFLOW AND Approve DCA service in one transaction
* This simplifies the UX by reducing two transactions to one
*/
export const WRAP_AND_APPROVE_TX = `
import EVM from 0xEVM
import FungibleToken from 0xFungibleToken
import FlowToken from 0xFlowToken
transaction(amount: UFix64, spenderAddress: String, approvalAmount: UInt256) {
let coa: auth(EVM.Call) &EVM.CadenceOwnedAccount
let flowVault: auth(FungibleToken.Withdraw) &FlowToken.Vault
prepare(signer: auth(Storage, BorrowValue) &Account) {
self.coa = signer.storage.borrow<auth(EVM.Call) &EVM.CadenceOwnedAccount>(
from: /storage/evm
) ?? panic("COA not found. Run setup_coa first.")
self.flowVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(
from: /storage/flowTokenVault
) ?? panic("FlowToken vault not found")
}
execute {
// WFLOW contract address (same on mainnet and testnet)
let wflowAddress = EVM.EVMAddress(
bytes: [0xd3, 0xbF, 0x53, 0xDA, 0xC1, 0x06, 0xA0, 0x29, 0x0B, 0x04,
0x83, 0xEc, 0xBC, 0x89, 0xd4, 0x0F, 0xCC, 0x96, 0x1f, 0x3e]
)
// === Step 1: Deposit FLOW into COA and wrap to WFLOW ===
let funding <- self.flowVault.withdraw(amount: amount) as! @FlowToken.Vault
self.coa.deposit(from: <-funding)
let depositCalldata: [UInt8] = [0xd0, 0xe3, 0x0d, 0xb0]
let amountInWei = EVM.Balance(attoflow: 0)
amountInWei.setFLOW(flow: amount)
let wrapResult = self.coa.call(
to: wflowAddress,
data: depositCalldata,
gasLimit: 100000,
value: amountInWei
)
if wrapResult.status != EVM.Status.successful {
panic("WFLOW wrap failed with error code: ".concat(wrapResult.errorCode.toString()))
}
log("Wrapped ".concat(amount.toString()).concat(" FLOW to WFLOW"))
// === Step 2: Approve DCA service to spend WFLOW ===
// Parse spender address
let spenderBytes = spenderAddress.decodeHex()
var spenderAddressBytes: [UInt8; 20] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var s = 0
while s < 20 && s < spenderBytes.length {
spenderAddressBytes[s] = spenderBytes[s]
s = s + 1
}
// Build approve(address spender, uint256 amount) calldata
var calldata: [UInt8] = [0x09, 0x5e, 0xa7, 0xb3]
// Pad spender address to 32 bytes
var j = 0
while j < 12 {
calldata.append(0x00)
j = j + 1
}
for byte in spenderAddressBytes {
calldata.append(byte)
}
// Encode approval amount as 32 bytes
let amountBytes = approvalAmount.toBigEndianBytes()
var k = 0
while k < (32 - amountBytes.length) {
calldata.append(0x00)
k = k + 1
}
for byte in amountBytes {
calldata.append(byte)
}
// Call approve on WFLOW contract
let approveResult = self.coa.call(
to: wflowAddress,
data: calldata,
gasLimit: 100000,
value: EVM.Balance(attoflow: 0)
)
if approveResult.status != EVM.Status.successful {
panic("Approve failed with error code: ".concat(approveResult.errorCode.toString()))
}
log("Approved DCA service to spend WFLOW")
}
}
`;
/**
* Approve DCA service to spend tokens from user's COA
* Spender address is passed as parameter for network compatibility
*/
export const APPROVE_DCA_TX = `
import EVM from 0xEVM
transaction(tokenAddress: String, spenderAddress: String, amount: UInt256) {
let coa: auth(EVM.Call) &EVM.CadenceOwnedAccount
prepare(signer: auth(Storage, BorrowValue) &Account) {
self.coa = signer.storage.borrow<auth(EVM.Call) &EVM.CadenceOwnedAccount>(
from: /storage/evm
) ?? panic("COA not found. Run setup_coa first.")
}
execute {
// Parse DCA COA spender address from hex string
let spenderBytes = spenderAddress.decodeHex()
var spenderAddressBytes: [UInt8; 20] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var s = 0
while s < 20 && s < spenderBytes.length {
spenderAddressBytes[s] = spenderBytes[s]
s = s + 1
}
// Parse token address from hex string
let tokenBytes = tokenAddress.decodeHex()
var tokenAddressBytes: [UInt8; 20] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var i = 0
while i < 20 && i < tokenBytes.length {
tokenAddressBytes[i] = tokenBytes[i]
i = i + 1
}
let tokenEVMAddress = EVM.EVMAddress(bytes: tokenAddressBytes)
// Build approve(address spender, uint256 amount) calldata
var calldata: [UInt8] = [0x09, 0x5e, 0xa7, 0xb3]
// Pad spender address to 32 bytes (12 zero bytes + 20 address bytes)
var j = 0
while j < 12 {
calldata.append(0x00)
j = j + 1
}
// Append spender address bytes
for byte in spenderAddressBytes {
calldata.append(byte)
}
// Encode amount as 32 bytes (big-endian)
let amountBytes = amount.toBigEndianBytes()
var k = 0
while k < (32 - amountBytes.length) {
calldata.append(0x00)
k = k + 1
}
for byte in amountBytes {
calldata.append(byte)
}
// Call approve on the token contract
let result = self.coa.call(
to: tokenEVMAddress,
data: calldata,
gasLimit: 100000,
value: EVM.Balance(attoflow: 0)
)
if result.status != EVM.Status.successful {
panic("Approve failed with error code: ".concat(result.errorCode.toString()))
}
log("Approved DCA service to spend tokens")
log("Token: ".concat(tokenAddress))
log("Spender: ".concat(spenderAddress))
log("Amount: ".concat(amount.toString()))
}
}
`;
/**
* Get user's COA EVM address
*/
export const GET_USER_COA_SCRIPT = `
import EVM from 0xEVM
access(all) fun main(address: Address): String? {
let account = getAccount(address)
let coaCap = account.capabilities.get<&EVM.CadenceOwnedAccount>(/public/evm)
if !coaCap.check() {
return nil
}
let coa = coaCap.borrow()
if coa == nil {
return nil
}
return coa!.address().toString()
}
`;
// =============================================================================
// ADMIN TRANSACTIONS - Called by backend with deployer key
// =============================================================================
/**
* Create a DCA plan (admin only)
* Users don't call this directly - they approve tokens and backend creates plan
*/
export const CREATE_PLAN_TX = `
import EVM from 0xEVM
import DCAServiceEVM from 0xDCAServiceEVM
transaction(
userEVMAddressHex: String,
sourceTokenHex: String,
targetTokenHex: String,
amountPerInterval: UInt256,
intervalSeconds: UInt64,
maxSlippageBps: UInt64,
maxExecutions: UInt64?,
feeTier: UInt32,
firstExecutionDelay: UFix64
) {
prepare(signer: auth(Storage) &Account) {
// Only admin should call this
}
execute {
let userEVMAddress = EVM.addressFromString(userEVMAddressHex)
let sourceToken = EVM.addressFromString(sourceTokenHex)
let targetToken = EVM.addressFromString(targetTokenHex)
let firstExecutionTime = getCurrentBlock().timestamp + firstExecutionDelay
let planId = DCAServiceEVM.createPlan(
userEVMAddress: userEVMAddress,
sourceToken: sourceToken,
targetToken: targetToken,
amountPerInterval: amountPerInterval,
intervalSeconds: intervalSeconds,
maxSlippageBps: maxSlippageBps,
maxExecutions: maxExecutions,
feeTier: feeTier,
firstExecutionTime: firstExecutionTime
)
log("Created DCA plan #".concat(planId.toString()))
}
}
`;
/**
* Pause a DCA plan (admin only)
*/
export const PAUSE_PLAN_TX = `
import DCAServiceEVM from 0xDCAServiceEVM
transaction(planId: UInt64) {
prepare(signer: auth(Storage) &Account) {}
execute {
DCAServiceEVM.pausePlan(planId: planId)
log("Paused plan ".concat(planId.toString()))
}
}
`;
/**
* Resume a DCA plan (admin only)
*/
export const RESUME_PLAN_TX = `
import DCAServiceEVM from 0xDCAServiceEVM
transaction(planId: UInt64, delaySeconds: UFix64?) {
prepare(signer: auth(Storage) &Account) {}
execute {
let nextExecutionTime: UFix64? = delaySeconds != nil
? getCurrentBlock().timestamp + delaySeconds!
: nil
DCAServiceEVM.resumePlan(planId: planId, nextExecutionTime: nextExecutionTime)
log("Resumed plan ".concat(planId.toString()))
}
}
`;
/**
* Cancel a DCA plan (admin only)
*/
export const CANCEL_PLAN_TX = `
import DCAServiceEVM from 0xDCAServiceEVM
transaction(planId: UInt64) {
prepare(signer: auth(Storage) &Account) {}
execute {
DCAServiceEVM.cancelPlan(planId: planId)
log("Cancelled plan ".concat(planId.toString()))
}
}
`;
// =============================================================================
// TOKEN UTILITIES
// =============================================================================
/**
* Get FLOW token balance for token balance display
*/
export const GET_TOKEN_BALANCE_SCRIPT = `
import FungibleToken from 0xFungibleToken
import FlowToken from 0xFlowToken
access(all) fun main(address: Address, tokenSymbol: String): UFix64 {
let account = getAccount(address)
if tokenSymbol == "FLOW" {
let vaultRef = account.capabilities.borrow<&{FungibleToken.Balance}>(/public/flowTokenBalance)
return vaultRef?.balance ?? 0.0
}
// For EVM tokens (USDC, USDF, WFLOW), user needs to check via their EVM wallet
return 0.0
}
`;
/**
* Get swappable tokens from IncrementFi (for token selector)
*/
export const GET_FLOW_SWAPPABLE_TOKENS_SCRIPT = `
import SwapFactory from 0xb063c16cac85dbd1
import SwapInterfaces from 0xb78ef7afa52ff906
access(all) struct TokenInfo {
access(all) let symbol: String
access(all) let tokenAddress: String
access(all) let tokenContract: String
access(all) let tokenIdentifier: String
access(all) let pairAddress: String
access(all) let flowReserve: String
access(all) let tokenReserve: String
access(all) let isStable: Bool
init(
symbol: String,
tokenAddress: String,
tokenContract: String,
tokenIdentifier: String,
pairAddress: String,
flowReserve: String,
tokenReserve: String,
isStable: Bool
) {
self.symbol = symbol
self.tokenAddress = tokenAddress
self.tokenContract = tokenContract
self.tokenIdentifier = tokenIdentifier
self.pairAddress = pairAddress
self.flowReserve = flowReserve
self.tokenReserve = tokenReserve
self.isStable = isStable
}
}
access(all) fun main(): [TokenInfo] {
let tokens: [TokenInfo] = []
let flowTokenAddress = Address(0x1654653399040a61)
let flowTokenType = Type<@FlowToken.Vault>()
let flowTokenIdentifier = flowTokenType.identifier
let pairAddresses = SwapFactory.getAllPairAddresses()
for pairAddress in pairAddresses {
let pairAccount = getAccount(pairAddress)
let pairRef = pairAccount.capabilities.borrow<&{SwapInterfaces.PairPublic}>(/public/IncrementSwapPair)
if pairRef == nil {
continue
}
let pairInfo = pairRef!.getPairInfo()
let token0Type = pairInfo[0] as! Type
let token1Type = pairInfo[1] as! Type
let reserve0 = pairInfo[2] as! UFix64
let reserve1 = pairInfo[3] as! UFix64
let isStable = pairInfo.length > 6 ? (pairInfo[6] as? Bool ?? false) : false
// Check if this pair includes FLOW
var otherTokenType: Type? = nil
var flowReserve: UFix64 = 0.0
var tokenReserve: UFix64 = 0.0
if token0Type.identifier == flowTokenIdentifier {
otherTokenType = token1Type
flowReserve = reserve0
tokenReserve = reserve1
} else if token1Type.identifier == flowTokenIdentifier {
otherTokenType = token0Type
flowReserve = reserve1
tokenReserve = reserve0
}
if otherTokenType == nil {
continue
}
// Extract token info from type identifier
let parts = otherTokenType!.identifier.split(separator: ".")
if parts.length < 3 {
continue
}
let tokenAddress = "0x".concat(parts[1])
let tokenContract = parts[2]
let symbol = tokenContract
tokens.append(TokenInfo(
symbol: symbol,
tokenAddress: tokenAddress,
tokenContract: tokenContract,
tokenIdentifier: otherTokenType!.identifier,
pairAddress: pairAddress.toString(),
flowReserve: flowReserve.toString(),
tokenReserve: tokenReserve.toString(),
isStable: isStable
))
}
return tokens
}
`;