Skip to content

Commit

Permalink
feat: automatic protocol fee payout (#293)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
shaspitz authored Jul 31, 2024
1 parent d6d48d3 commit 11e33f9
Show file tree
Hide file tree
Showing 16 changed files with 1,709 additions and 710 deletions.
143 changes: 91 additions & 52 deletions contracts-abi/abi/BidderRegistry.abi
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,7 @@
},
{
"type": "function",
"name": "feeRecipient",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "feeRecipientAmount",
"name": "getAccumulatedProtocolFee",
"inputs": [],
"outputs": [
{
Expand Down Expand Up @@ -221,19 +208,6 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getFeeRecipientAmount",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getProviderAmount",
Expand All @@ -258,7 +232,7 @@
"name": "initialize",
"inputs": [
{
"name": "_feeRecipient",
"name": "_protocolFeeRecipient",
"type": "address",
"internalType": "address"
},
Expand All @@ -281,6 +255,11 @@
"name": "_blocksPerWindow",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_feePayoutPeriodBlocks",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
Expand Down Expand Up @@ -310,6 +289,13 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "manuallyWithdrawProtocolFee",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "maxBidPerBlock",
Expand Down Expand Up @@ -403,11 +389,26 @@
},
{
"type": "function",
"name": "protocolFeeAmount",
"name": "protocolFeeTracker",
"inputs": [],
"outputs": [
{
"name": "",
"name": "recipient",
"type": "address",
"internalType": "address"
},
{
"name": "accumulatedAmount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "lastPayoutBlock",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "payoutPeriodBlocks",
"type": "uint256",
"internalType": "uint256"
}
Expand Down Expand Up @@ -481,6 +482,19 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setNewFeePayoutPeriodBlocks",
"inputs": [
{
"name": "newFeePayoutPeriodBlocks",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setNewFeePercent",
Expand All @@ -496,10 +510,10 @@
},
{
"type": "function",
"name": "setNewFeeRecipient",
"name": "setNewProtocolFeeRecipient",
"inputs": [
{
"name": "newFeeRecipient",
"name": "newProtocolFeeRecipient",
"type": "address",
"internalType": "address"
}
Expand Down Expand Up @@ -611,13 +625,6 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "withdrawFeeRecipientAmount",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "withdrawFromWindows",
Expand All @@ -631,19 +638,6 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "withdrawProtocolFee",
"inputs": [
{
"name": "treasuryAddress",
"type": "address",
"internalType": "address payable"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "withdrawProviderAmount",
Expand Down Expand Up @@ -707,6 +701,38 @@
],
"anonymous": false
},
{
"type": "event",
"name": "FeePayoutPeriodBlocksUpdated",
"inputs": [
{
"name": "newFeePayoutPeriodBlocks",
"type": "uint256",
"indexed": true,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "FeeTransfer",
"inputs": [
{
"name": "amount",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "recipient",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"type": "event",
"name": "FundsRetrieved",
Expand Down Expand Up @@ -826,6 +852,19 @@
],
"anonymous": false
},
{
"type": "event",
"name": "ProtocolFeeRecipientUpdated",
"inputs": [
{
"name": "newProtocolFeeRecipient",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Upgraded",
Expand Down
8 changes: 4 additions & 4 deletions contracts-abi/abi/PreConfCommitmentStore.abi
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@
"internalType": "address"
},
{
"name": "_oracle",
"name": "_oracleContract",
"type": "address",
"internalType": "address"
},
Expand Down Expand Up @@ -847,7 +847,7 @@
},
{
"type": "function",
"name": "oracle",
"name": "oracleContract",
"inputs": [],
"outputs": [
{
Expand Down Expand Up @@ -987,10 +987,10 @@
},
{
"type": "function",
"name": "updateOracle",
"name": "updateOracleContract",
"inputs": [
{
"name": "newOracle",
"name": "newOracleContract",
"type": "address",
"internalType": "address"
}
Expand Down
Loading

0 comments on commit 11e33f9

Please sign in to comment.