Skip to content

Commit 11e33f9

Browse files
authored
feat: automatic protocol fee payout (#293)
* feat: code that compiles * fix: use internal functions for fee payout lib * fix: existing tests * test: new behavior * chore: update abis + bindings * test: add setter tests * fix: init fee tracker correctly * fix: test names * feat: introduce manual withdrawal mechanism for edge case * chore: update abi + bindings after rebase * fix: address PR comments * chore: update abi + bindings after adding events * feat: index fee transfer recipient in event * fix: tests expect indexed fee transfer receipient * feat: update abi + bindings again
1 parent d6d48d3 commit 11e33f9

16 files changed

Lines changed: 1709 additions & 710 deletions

contracts-abi/abi/BidderRegistry.abi

Lines changed: 91 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,7 @@
173173
},
174174
{
175175
"type": "function",
176-
"name": "feeRecipient",
177-
"inputs": [],
178-
"outputs": [
179-
{
180-
"name": "",
181-
"type": "address",
182-
"internalType": "address"
183-
}
184-
],
185-
"stateMutability": "view"
186-
},
187-
{
188-
"type": "function",
189-
"name": "feeRecipientAmount",
176+
"name": "getAccumulatedProtocolFee",
190177
"inputs": [],
191178
"outputs": [
192179
{
@@ -221,19 +208,6 @@
221208
],
222209
"stateMutability": "view"
223210
},
224-
{
225-
"type": "function",
226-
"name": "getFeeRecipientAmount",
227-
"inputs": [],
228-
"outputs": [
229-
{
230-
"name": "",
231-
"type": "uint256",
232-
"internalType": "uint256"
233-
}
234-
],
235-
"stateMutability": "view"
236-
},
237211
{
238212
"type": "function",
239213
"name": "getProviderAmount",
@@ -258,7 +232,7 @@
258232
"name": "initialize",
259233
"inputs": [
260234
{
261-
"name": "_feeRecipient",
235+
"name": "_protocolFeeRecipient",
262236
"type": "address",
263237
"internalType": "address"
264238
},
@@ -281,6 +255,11 @@
281255
"name": "_blocksPerWindow",
282256
"type": "uint256",
283257
"internalType": "uint256"
258+
},
259+
{
260+
"name": "_feePayoutPeriodBlocks",
261+
"type": "uint256",
262+
"internalType": "uint256"
284263
}
285264
],
286265
"outputs": [],
@@ -310,6 +289,13 @@
310289
],
311290
"stateMutability": "view"
312291
},
292+
{
293+
"type": "function",
294+
"name": "manuallyWithdrawProtocolFee",
295+
"inputs": [],
296+
"outputs": [],
297+
"stateMutability": "nonpayable"
298+
},
313299
{
314300
"type": "function",
315301
"name": "maxBidPerBlock",
@@ -403,11 +389,26 @@
403389
},
404390
{
405391
"type": "function",
406-
"name": "protocolFeeAmount",
392+
"name": "protocolFeeTracker",
407393
"inputs": [],
408394
"outputs": [
409395
{
410-
"name": "",
396+
"name": "recipient",
397+
"type": "address",
398+
"internalType": "address"
399+
},
400+
{
401+
"name": "accumulatedAmount",
402+
"type": "uint256",
403+
"internalType": "uint256"
404+
},
405+
{
406+
"name": "lastPayoutBlock",
407+
"type": "uint256",
408+
"internalType": "uint256"
409+
},
410+
{
411+
"name": "payoutPeriodBlocks",
411412
"type": "uint256",
412413
"internalType": "uint256"
413414
}
@@ -481,6 +482,19 @@
481482
"outputs": [],
482483
"stateMutability": "nonpayable"
483484
},
485+
{
486+
"type": "function",
487+
"name": "setNewFeePayoutPeriodBlocks",
488+
"inputs": [
489+
{
490+
"name": "newFeePayoutPeriodBlocks",
491+
"type": "uint256",
492+
"internalType": "uint256"
493+
}
494+
],
495+
"outputs": [],
496+
"stateMutability": "nonpayable"
497+
},
484498
{
485499
"type": "function",
486500
"name": "setNewFeePercent",
@@ -496,10 +510,10 @@
496510
},
497511
{
498512
"type": "function",
499-
"name": "setNewFeeRecipient",
513+
"name": "setNewProtocolFeeRecipient",
500514
"inputs": [
501515
{
502-
"name": "newFeeRecipient",
516+
"name": "newProtocolFeeRecipient",
503517
"type": "address",
504518
"internalType": "address"
505519
}
@@ -611,13 +625,6 @@
611625
"outputs": [],
612626
"stateMutability": "nonpayable"
613627
},
614-
{
615-
"type": "function",
616-
"name": "withdrawFeeRecipientAmount",
617-
"inputs": [],
618-
"outputs": [],
619-
"stateMutability": "nonpayable"
620-
},
621628
{
622629
"type": "function",
623630
"name": "withdrawFromWindows",
@@ -631,19 +638,6 @@
631638
"outputs": [],
632639
"stateMutability": "nonpayable"
633640
},
634-
{
635-
"type": "function",
636-
"name": "withdrawProtocolFee",
637-
"inputs": [
638-
{
639-
"name": "treasuryAddress",
640-
"type": "address",
641-
"internalType": "address payable"
642-
}
643-
],
644-
"outputs": [],
645-
"stateMutability": "nonpayable"
646-
},
647641
{
648642
"type": "function",
649643
"name": "withdrawProviderAmount",
@@ -707,6 +701,38 @@
707701
],
708702
"anonymous": false
709703
},
704+
{
705+
"type": "event",
706+
"name": "FeePayoutPeriodBlocksUpdated",
707+
"inputs": [
708+
{
709+
"name": "newFeePayoutPeriodBlocks",
710+
"type": "uint256",
711+
"indexed": true,
712+
"internalType": "uint256"
713+
}
714+
],
715+
"anonymous": false
716+
},
717+
{
718+
"type": "event",
719+
"name": "FeeTransfer",
720+
"inputs": [
721+
{
722+
"name": "amount",
723+
"type": "uint256",
724+
"indexed": false,
725+
"internalType": "uint256"
726+
},
727+
{
728+
"name": "recipient",
729+
"type": "address",
730+
"indexed": true,
731+
"internalType": "address"
732+
}
733+
],
734+
"anonymous": false
735+
},
710736
{
711737
"type": "event",
712738
"name": "FundsRetrieved",
@@ -826,6 +852,19 @@
826852
],
827853
"anonymous": false
828854
},
855+
{
856+
"type": "event",
857+
"name": "ProtocolFeeRecipientUpdated",
858+
"inputs": [
859+
{
860+
"name": "newProtocolFeeRecipient",
861+
"type": "address",
862+
"indexed": true,
863+
"internalType": "address"
864+
}
865+
],
866+
"anonymous": false
867+
},
829868
{
830869
"type": "event",
831870
"name": "Upgraded",

contracts-abi/abi/PreConfCommitmentStore.abi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@
717717
"internalType": "address"
718718
},
719719
{
720-
"name": "_oracle",
720+
"name": "_oracleContract",
721721
"type": "address",
722722
"internalType": "address"
723723
},
@@ -847,7 +847,7 @@
847847
},
848848
{
849849
"type": "function",
850-
"name": "oracle",
850+
"name": "oracleContract",
851851
"inputs": [],
852852
"outputs": [
853853
{
@@ -987,10 +987,10 @@
987987
},
988988
{
989989
"type": "function",
990-
"name": "updateOracle",
990+
"name": "updateOracleContract",
991991
"inputs": [
992992
{
993-
"name": "newOracle",
993+
"name": "newOracleContract",
994994
"type": "address",
995995
"internalType": "address"
996996
}

0 commit comments

Comments
 (0)