-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathrevenue_pool.json
More file actions
511 lines (484 loc) · 18.4 KB
/
Copy pathrevenue_pool.json
File metadata and controls
511 lines (484 loc) · 18.4 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
{
"contract": "callora-revenue-pool",
"version": "0.0.1",
"description": "Simple revenue distribution contract. Receives USDC when the vault forwards deducted funds and lets the admin distribute those funds to developer wallets individually or in batch.",
"crate": "callora-revenue-pool",
"source": "contracts/revenue_pool/src/lib.rs",
"types": {},
"functions": [
{
"name": "init",
"description": "Initialize the revenue pool with an admin and the USDC token address. Can only be called once. The admin must authorize the call.",
"access": "admin (must sign)",
"params": [
{
"name": "admin",
"type": "Address",
"optional": false,
"description": "Address that may call distribute, batch_distribute, receive_payment, and set_admin."
},
{
"name": "usdc_token",
"type": "Address",
"optional": false,
"description": "Stellar USDC (or wrapped USDC) token contract address."
}
],
"returns": "void",
"panics": [
"\"revenue pool already initialized\" — called more than once."
],
"events": [
{ "topics": ["\"init\"", "admin"], "data": "usdc_token (Address)" }
]
},
{
"name": "pause",
"description": "Activate the circuit-breaker. Blocks distribute and batch_distribute until unpause is called. Admin rotation (set_admin / claim_admin) remains available while paused.",
"access": "admin or pause guardian",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the current admin or configured pause guardian; must authorize." }
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin or pause guardian\" — caller is neither current admin nor configured pause guardian.",
"\"revenue pool already paused\" — pool is already paused."
],
"events": [
{ "topics": ["\"pause_set\"", "caller"], "data": "true (bool)" }
]
},
{
"name": "unpause",
"description": "Deactivate the circuit-breaker, restoring distribute and batch_distribute.",
"access": "admin",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"revenue pool not paused\" — pool is not currently paused."
],
"events": [
{ "topics": ["\"pause_set\"", "caller"], "data": "false (bool)" }
]
},
{
"name": "is_paused",
"description": "Return true if the revenue pool is currently paused, false otherwise. Defaults to false before any pause call.",
"access": "any",
"params": [],
"returns": "bool",
"panics": [],
"events": []
},
{
"name": "set_pause_guardian",
"description": "Set or replace the emergency pause guardian. The guardian can pause the pool but cannot unpause, distribute, rotate admin, change caps, or upgrade.",
"access": "admin",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the current admin; must authorize." },
{ "name": "guardian", "type": "Address", "optional": false, "description": "Address that may call pause." }
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin."
],
"events": [
{ "topics": ["\"pause_guardian_set\"", "caller"], "data": "guardian (Address)" }
]
},
{
"name": "clear_pause_guardian",
"description": "Remove the configured emergency pause guardian. After clearing, only the admin can pause.",
"access": "admin",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the current admin; must authorize." }
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"no pause guardian set\" — no guardian is configured."
],
"events": [
{ "topics": ["\"pause_guardian_cleared\"", "caller"], "data": "previous guardian (Address)" }
]
},
{
"name": "get_pause_guardian",
"description": "Return the configured emergency pause guardian, or None if no guardian is set.",
"access": "any",
"params": [],
"returns": "Option<Address>",
"panics": [],
"events": []
},
{
"name": "distribute",
"description": "Transfer USDC from this contract to a developer wallet. Admin only. Blocked while paused.",
"access": "admin",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
},
{
"name": "to",
"type": "Address",
"optional": false,
"description": "Developer address to receive USDC."
},
{
"name": "amount",
"type": "i128",
"optional": false,
"description": "Amount in USDC base units; must be > 0."
}
],
"returns": "void",
"panics": [
"\"revenue pool is paused\" — pool is paused.",
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"amount must be positive\" — amount <= 0.",
"\"revenue pool not initialized\" — called before init.",
"\"insufficient USDC balance\" — contract holds less than amount."
],
"events": [
{ "topics": ["\"distribute\"", "to"], "data": "amount (i128)" }
]
},
{
"name": "batch_distribute",
"description": "Atomically distribute USDC to multiple developer wallets. Validates the total against the available balance before any transfer. One event is emitted per payment. Admin only. Blocked while paused.",
"access": "admin",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
},
{
"name": "payments",
"type": "Vec<(Address, i128)>",
"optional": false,
"description": "Ordered list of (developer_address, amount) pairs. All amounts must be > 0."
}
],
"returns": "void",
"panics": [
"\"revenue pool is paused\" — pool is paused.",
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"amount must be positive\" — any individual amount <= 0.",
"\"total overflow\" — extremely unlikely sum overflow.",
"\"revenue pool not initialized\" — called before init.",
"\"insufficient USDC balance\" — total amount exceeds contract balance."
],
"events": [
{
"note": "One event per payment entry.",
"topics": ["\"batch_distribute\"", "to"],
"data": "amount (i128)"
}
]
},
{
"name": "receive_payment",
"description": "Event-only helper — does NOT move tokens. Emits a receive_payment event for indexer alignment when the backend wants to log a payment credited from the vault. USDC is received passively when any address transfers tokens to this contract; no explicit call is required for token receipt.",
"access": "admin",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
},
{
"name": "amount",
"type": "i128",
"optional": false,
"description": "Amount received (for event logging only; no tokens are moved)."
},
{
"name": "from_vault",
"type": "bool",
"optional": false,
"description": "True if the source was the vault contract."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin."
],
"events": [
{
"topics": ["\"receive_payment\"", "caller"],
"data": "(amount, from_vault) tuple"
}
]
},
{
"name": "balance",
"description": "Return the contract's current USDC balance.",
"access": "any",
"params": [],
"returns": "i128",
"panics": ["\"revenue pool not initialized\" — called before init."],
"events": []
},
{
"name": "get_admin",
"description": "Return the current admin address.",
"access": "any",
"params": [],
"returns": "Address",
"panics": ["\"revenue pool not initialized\" — called before init."],
"events": []
},
{
"name": "get_pending_admin",
"description": "Return the pending admin address, or null if no two-step transfer is in progress. Integrators can poll this to detect an in-flight admin handover before accept_admin or claim_admin is called.",
"access": "any",
"params": [],
"returns": "Address | null",
"panics": [],
"events": []
},
{
"name": "set_admin",
"description": "Initiate replacement of the current admin. The proposed new admin must call claim_admin to complete the transfer.",
"access": "admin",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
},
{
"name": "new_admin",
"type": "Address",
"optional": false,
"description": "Address of the proposed new admin."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin."
],
"events": [
{
"topics": ["\"admin_transfer_started\"", "current_admin"],
"data": "new_admin (Address)"
}
]
},
{
"name": "get_treasury",
"description": "Return the current treasury address authorized to call deposit_yield. Deployments without a dedicated treasury key fall back to the admin address.",
"access": "any",
"params": [],
"returns": "Address",
"panics": ["\"revenue pool not initialized\" — called before init and no treasury fallback exists."],
"events": []
},
{
"name": "get_pending_treasury",
"description": "Return the pending treasury address, or null if no two-step treasury transfer is in progress.",
"access": "any",
"params": [],
"returns": "Address | null",
"panics": [],
"events": []
},
{
"name": "set_treasury",
"description": "Nominate a new treasury. The current admin must authorize, and the nominee must call accept_treasury before deposit_yield authority changes.",
"access": "admin",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the current admin; must authorize." },
{ "name": "new_treasury", "type": "Address", "optional": false, "description": "Address of the proposed treasury." }
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"new treasury is already current treasury\" — nominee is already active."
],
"events": [
{ "topics": ["\"treasury_transfer_started\"", "caller"], "data": "(old_treasury, new_treasury)" }
]
},
{
"name": "accept_treasury",
"description": "Complete a pending treasury transfer. Must be called by the pending treasury.",
"access": "pending treasury (must sign)",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the pending treasury; must authorize." }
],
"returns": "void",
"panics": [
"\"no pending treasury\" — set_treasury was not called first.",
"\"unauthorized: caller is not pending treasury\" — caller is not the pending treasury."
],
"events": [
{ "topics": ["\"treasury_transfer_completed\"", "new_treasury"], "data": "old_treasury (Address)" }
]
},
{
"name": "cancel_treasury_transfer",
"description": "Cancel a pending treasury transfer. Only the current admin may call this.",
"access": "admin",
"params": [
{ "name": "caller", "type": "Address", "optional": false, "description": "Must be the current admin; must authorize." }
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"no treasury transfer pending\" — no pending treasury is configured."
],
"events": [
{ "topics": ["\"treasury_cancelled\"", "caller"], "data": "pending_treasury (Address)" }
]
},
{
"name": "claim_admin",
"description": "Complete the admin transfer. Must be called by the pending admin set via set_admin.",
"access": "pending admin (must sign)",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the pending admin; must authorize."
}
],
"returns": "void",
"panics": [
"\"no pending admin\" — set_admin was not called first.",
"\"unauthorized: caller is not pending admin\" — caller is not the pending admin."
],
"events": [
{
"topics": ["\"admin_transfer_completed\"", "new_admin"],
"data": "void"
}
]
},
{
"name": "propose_emergency_drain",
"description": "Propose a timelocked USDC emergency drain to a treasury address. Stores a PendingEmergencyDrain snapshot; execution is only possible after EMERGENCY_DRAIN_TIMELOCK_SECONDS (86 400 s = 24 h) have elapsed. A new proposal replaces any existing one, resetting the clock. When the admin is a Stellar multisig account, require_auth enforces the native multi-signature threshold automatically, providing Multisig + timelock protection.",
"access": "admin (must sign; multisig threshold enforced by Soroban host when admin is a multisig account)",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
},
{
"name": "treasury",
"type": "Address",
"optional": false,
"description": "Destination address for drained USDC. Cannot be the contract itself."
},
{
"name": "amount",
"type": "i128",
"optional": false,
"description": "USDC amount in base units. Must be positive."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"amount must be positive\" — amount <= 0.",
"\"invalid recipient: cannot drain to the contract itself\" — treasury == contract address.",
"\"timelock overflow\" — proposed_at + 86400 would overflow u64."
],
"events": [
{
"topics": ["\"emergency_drain_proposed\"", "caller"],
"data": "PendingEmergencyDrain { to, amount, proposed_at, execute_after }"
}
]
},
{
"name": "execute_emergency_drain",
"description": "Execute a pending emergency drain after the 24-hour timelock has expired. Transfers the proposed USDC amount to the destination address and removes the pending snapshot (replay protection).",
"access": "admin (must sign)",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"no pending emergency drain\" — propose_emergency_drain was not called first.",
"\"emergency drain timelock has not expired\" — current timestamp < execute_after.",
"\"insufficient USDC balance\" — contract holds less than the proposed amount."
],
"events": [
{
"topics": ["\"emergency_drain_executed\"", "caller"],
"data": "(to, amount, proposed_at, executed_at) tuple"
}
]
},
{
"name": "cancel_emergency_drain",
"description": "Cancel a pending emergency drain. May be called at any time before execution, including before the timelock expires. Removes the snapshot and emits an audit event.",
"access": "admin (must sign)",
"params": [
{
"name": "caller",
"type": "Address",
"optional": false,
"description": "Must be the current admin; must authorize."
}
],
"returns": "void",
"panics": [
"\"unauthorized: caller is not admin\" — caller != current admin.",
"\"no pending emergency drain\" — no proposal exists to cancel."
],
"events": [
{
"topics": ["\"emergency_drain_cancelled\"", "caller"],
"data": "PendingEmergencyDrain { to, amount, proposed_at, execute_after }"
}
]
},
{
"name": "get_pending_emergency_drain",
"description": "Return the pending emergency drain proposal snapshot, or null if none exists. Off-chain monitors and the admin can poll this to verify or cancel a pending drain before the timelock expires.",
"access": "any",
"params": [],
"returns": "Option<PendingEmergencyDrain>",
"panics": [],
"events": []
}
],
"types_detail": {
"PendingEmergencyDrain": {
"description": "Immutable snapshot of a pending emergency drain proposal.",
"fields": {
"to": { "type": "Address", "description": "Destination address for the drained USDC." },
"amount": { "type": "i128", "description": "USDC amount in base units to drain." },
"proposed_at": { "type": "u64", "description": "Ledger timestamp (seconds) when the proposal was created." },
"execute_after": { "type": "u64", "description": "Earliest ledger timestamp at which execute_emergency_drain may succeed. Equals proposed_at + 86400." }
}
}
}
}