@enclave-e3/contracts 0.1.4 → 0.1.6
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.
- package/README.md +46 -2
- package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +135 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/artifacts.d.ts +27 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json +77 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +126 -0
- package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/artifacts.d.ts +43 -0
- package/artifacts/build-info/solc-0_8_28-5150b9e6b6cf4df4986fccba97bea37a16fdfebc.json +311 -0
- package/artifacts/build-info/solc-0_8_28-5150b9e6b6cf4df4986fccba97bea37a16fdfebc.output.json +1 -0
- package/artifacts/contracts/Enclave.sol/Enclave.json +239 -147
- package/artifacts/contracts/Enclave.sol/artifacts.d.ts +6 -6
- package/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json +881 -0
- package/artifacts/contracts/interfaces/IBondingRegistry.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json +326 -10
- package/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/artifacts.d.ts +2 -2
- package/artifacts/contracts/interfaces/IComputeProvider.sol/IComputeProvider.json +1 -1
- package/artifacts/contracts/interfaces/IComputeProvider.sol/artifacts.d.ts +1 -1
- package/artifacts/contracts/interfaces/IDecryptionVerifier.sol/IDecryptionVerifier.json +1 -1
- package/artifacts/contracts/interfaces/IDecryptionVerifier.sol/artifacts.d.ts +1 -1
- package/artifacts/contracts/interfaces/IE3Program.sol/IE3Program.json +21 -3
- package/artifacts/contracts/interfaces/IE3Program.sol/artifacts.d.ts +2 -2
- package/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json +247 -27
- package/artifacts/contracts/interfaces/IEnclave.sol/artifacts.d.ts +2 -2
- package/artifacts/contracts/interfaces/{IRegistryFilter.sol/IRegistryFilter.json → ISlashVerifier.sol/ISlashVerifier.json} +10 -10
- package/artifacts/contracts/interfaces/ISlashVerifier.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/interfaces/ISlashingManager.sol/ISlashingManager.json +759 -0
- package/artifacts/contracts/interfaces/ISlashingManager.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/lib/ExitQueueLib.sol/ExitQueueLib.json +116 -0
- package/artifacts/contracts/lib/ExitQueueLib.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/registry/BondingRegistry.sol/BondingRegistry.json +1217 -0
- package/artifacts/contracts/registry/BondingRegistry.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/CiphernodeRegistryOwnable.json +351 -57
- package/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/artifacts.d.ts +6 -6
- package/artifacts/contracts/slashing/SlashingManager.sol/SlashingManager.json +1107 -0
- package/artifacts/contracts/slashing/SlashingManager.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.json +328 -12
- package/artifacts/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.json +328 -12
- package/artifacts/contracts/test/MockCiphernodeRegistry.sol/artifacts.d.ts +8 -8
- package/artifacts/contracts/test/MockComputeProvider.sol/MockComputeProvider.json +4 -4
- package/artifacts/contracts/test/MockComputeProvider.sol/artifacts.d.ts +4 -4
- package/artifacts/contracts/test/MockDecryptionVerifier.sol/MockDecryptionVerifier.json +3 -3
- package/artifacts/contracts/test/MockDecryptionVerifier.sol/artifacts.d.ts +3 -3
- package/artifacts/contracts/test/MockE3Program.sol/MockE3Program.json +26 -32
- package/artifacts/contracts/test/MockE3Program.sol/artifacts.d.ts +4 -4
- package/artifacts/contracts/test/MockSlashingVerifier.sol/MockSlashingVerifier.json +38 -0
- package/artifacts/contracts/test/MockSlashingVerifier.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/test/MockStableToken.sol/MockUSDC.json +425 -0
- package/artifacts/contracts/test/MockStableToken.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/token/EnclaveTicketToken.sol/EnclaveTicketToken.json +1222 -0
- package/artifacts/contracts/token/EnclaveTicketToken.sol/artifacts.d.ts +27 -0
- package/artifacts/contracts/token/EnclaveToken.sol/EnclaveToken.json +1460 -0
- package/artifacts/contracts/token/EnclaveToken.sol/artifacts.d.ts +27 -0
- package/artifacts/poseidon-solidity/PoseidonT3.sol/PoseidonT3.json +3 -3
- package/artifacts/poseidon-solidity/PoseidonT3.sol/artifacts.d.ts +3 -3
- package/contracts/Enclave.sol +230 -81
- package/contracts/interfaces/IBondingRegistry.sol +446 -0
- package/contracts/interfaces/ICiphernodeRegistry.sol +153 -9
- package/contracts/interfaces/IComputeProvider.sol +12 -2
- package/contracts/interfaces/IDecryptionVerifier.sol +11 -6
- package/contracts/interfaces/IE3.sol +21 -17
- package/contracts/interfaces/IE3Program.sol +30 -17
- package/contracts/interfaces/IEnclave.sol +95 -21
- package/contracts/interfaces/ISlashVerifier.sol +23 -0
- package/contracts/interfaces/ISlashingManager.sol +426 -0
- package/contracts/lib/ExitQueueLib.sol +490 -0
- package/contracts/registry/BondingRegistry.sol +737 -0
- package/contracts/registry/CiphernodeRegistryOwnable.sol +393 -26
- package/contracts/slashing/SlashingManager.sol +367 -0
- package/contracts/test/MockCiphernodeRegistry.sol +118 -24
- package/contracts/test/MockComputeProvider.sol +2 -2
- package/contracts/test/MockE3Program.sol +17 -14
- package/contracts/test/MockSlashingVerifier.sol +19 -0
- package/contracts/test/MockStableToken.sol +28 -0
- package/contracts/token/EnclaveTicketToken.sol +243 -0
- package/contracts/token/EnclaveToken.sol +267 -0
- package/dist/hardhat.config.d.ts.map +1 -1
- package/dist/hardhat.config.js +35 -16
- package/dist/ignition/modules/{mockInputValidator.d.ts → bondingRegistry.d.ts} +1 -1
- package/dist/ignition/modules/bondingRegistry.d.ts.map +1 -0
- package/dist/ignition/modules/bondingRegistry.js +35 -0
- package/dist/ignition/modules/ciphernodeRegistry.d.ts.map +1 -1
- package/dist/ignition/modules/ciphernodeRegistry.js +12 -2
- package/dist/ignition/modules/enclave.d.ts.map +1 -1
- package/dist/ignition/modules/enclave.js +16 -7
- package/dist/ignition/modules/{naiveRegistryFilter.d.ts → enclaveTicketToken.d.ts} +1 -1
- package/dist/ignition/modules/enclaveTicketToken.d.ts.map +1 -0
- package/dist/ignition/modules/enclaveTicketToken.js +17 -0
- package/dist/ignition/modules/enclaveToken.d.ts +3 -0
- package/dist/ignition/modules/enclaveToken.d.ts.map +1 -0
- package/dist/ignition/modules/{mockInputValidator.js → enclaveToken.js} +4 -4
- package/dist/ignition/modules/mockCiphernodeRegistry.d.ts.map +1 -1
- package/dist/ignition/modules/mockCiphernodeRegistry.js +0 -1
- package/dist/ignition/modules/mockCiphernodeRegistryEmptyKey.d.ts.map +1 -1
- package/dist/ignition/modules/mockCiphernodeRegistryEmptyKey.js +0 -1
- package/dist/ignition/modules/mockComputeProvider.d.ts.map +1 -1
- package/dist/ignition/modules/mockComputeProvider.js +0 -1
- package/dist/ignition/modules/mockDecryptionVerifier.d.ts.map +1 -1
- package/dist/ignition/modules/mockDecryptionVerifier.js +0 -1
- package/dist/ignition/modules/mockE3Program.d.ts.map +1 -1
- package/dist/ignition/modules/mockE3Program.js +1 -3
- package/dist/ignition/modules/mockSlashingVerifier.d.ts +3 -0
- package/dist/ignition/modules/mockSlashingVerifier.d.ts.map +1 -0
- package/dist/ignition/modules/mockSlashingVerifier.js +10 -0
- package/dist/ignition/modules/mockStableToken.d.ts +3 -0
- package/dist/ignition/modules/mockStableToken.d.ts.map +1 -0
- package/dist/ignition/modules/mockStableToken.js +11 -0
- package/dist/ignition/modules/poseidonT3.d.ts.map +1 -1
- package/dist/ignition/modules/poseidonT3.js +0 -1
- package/dist/ignition/modules/slashingManager.d.ts +3 -0
- package/dist/ignition/modules/slashingManager.d.ts.map +1 -0
- package/dist/ignition/modules/slashingManager.js +16 -0
- package/dist/scripts/cleanIgnitionState.d.ts +12 -0
- package/dist/scripts/cleanIgnitionState.d.ts.map +1 -0
- package/dist/scripts/cleanIgnitionState.js +41 -0
- package/dist/scripts/deployAndSave/bondingRegistry.d.ts +38 -0
- package/dist/scripts/deployAndSave/bondingRegistry.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/bondingRegistry.js +133 -0
- package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.d.ts +11 -1
- package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.d.ts.map +1 -1
- package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.js +76 -19
- package/dist/scripts/deployAndSave/enclave.d.ts +16 -2
- package/dist/scripts/deployAndSave/enclave.d.ts.map +1 -1
- package/dist/scripts/deployAndSave/enclave.js +89 -22
- package/dist/scripts/deployAndSave/enclaveTicketToken.d.ts +20 -0
- package/dist/scripts/deployAndSave/enclaveTicketToken.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/enclaveTicketToken.js +41 -0
- package/dist/scripts/deployAndSave/enclaveToken.d.ts +18 -0
- package/dist/scripts/deployAndSave/enclaveToken.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/enclaveToken.js +57 -0
- package/dist/scripts/deployAndSave/mockComputeProvider.d.ts.map +1 -1
- package/dist/scripts/deployAndSave/mockComputeProvider.js +5 -5
- package/dist/scripts/deployAndSave/mockDecryptionVerifier.d.ts.map +1 -1
- package/dist/scripts/deployAndSave/mockDecryptionVerifier.js +5 -5
- package/dist/scripts/deployAndSave/mockProgram.d.ts +1 -2
- package/dist/scripts/deployAndSave/mockProgram.d.ts.map +1 -1
- package/dist/scripts/deployAndSave/mockProgram.js +7 -19
- package/dist/scripts/deployAndSave/mockStableToken.d.ts +18 -0
- package/dist/scripts/deployAndSave/mockStableToken.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/mockStableToken.js +36 -0
- package/dist/scripts/deployAndSave/poseidonT3.d.ts +11 -0
- package/dist/scripts/deployAndSave/poseidonT3.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/poseidonT3.js +41 -0
- package/dist/scripts/deployAndSave/slashingManager.d.ts +19 -0
- package/dist/scripts/deployAndSave/slashingManager.d.ts.map +1 -0
- package/dist/scripts/deployAndSave/slashingManager.js +38 -0
- package/dist/scripts/deployEnclave.d.ts.map +1 -1
- package/dist/scripts/deployEnclave.js +109 -23
- package/dist/scripts/deployMocks.d.ts +0 -1
- package/dist/scripts/deployMocks.d.ts.map +1 -1
- package/dist/scripts/deployMocks.js +3 -6
- package/dist/scripts/index.d.ts +7 -2
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +7 -2
- package/dist/scripts/proxy.d.ts +22 -0
- package/dist/scripts/proxy.d.ts.map +1 -0
- package/dist/scripts/proxy.js +36 -0
- package/dist/scripts/runVerification.d.ts +2 -0
- package/dist/scripts/runVerification.d.ts.map +1 -0
- package/dist/scripts/runVerification.js +16 -0
- package/dist/scripts/upgrade/bondingRegistry.d.ts +6 -0
- package/dist/scripts/upgrade/bondingRegistry.d.ts.map +1 -0
- package/dist/scripts/upgrade/bondingRegistry.js +49 -0
- package/dist/scripts/upgrade/ciphernodeRegistryOwnable.d.ts +6 -0
- package/dist/scripts/upgrade/ciphernodeRegistryOwnable.d.ts.map +1 -0
- package/dist/scripts/upgrade/ciphernodeRegistryOwnable.js +52 -0
- package/dist/scripts/upgrade/enclave.d.ts +6 -0
- package/dist/scripts/upgrade/enclave.d.ts.map +1 -0
- package/dist/scripts/upgrade/enclave.js +49 -0
- package/dist/scripts/utils.d.ts +51 -2
- package/dist/scripts/utils.d.ts.map +1 -1
- package/dist/scripts/utils.js +67 -4
- package/dist/scripts/verify.d.ts +6 -0
- package/dist/scripts/verify.d.ts.map +1 -0
- package/dist/scripts/verify.js +142 -0
- package/dist/tasks/ciphernode.d.ts +2 -0
- package/dist/tasks/ciphernode.d.ts.map +1 -1
- package/dist/tasks/ciphernode.js +290 -19
- package/dist/tasks/enclave.d.ts.map +1 -1
- package/dist/tasks/enclave.js +76 -31
- package/dist/test/Enclave.spec.js +377 -370
- package/dist/test/Registry/BondingRegistry.spec.d.ts +2 -0
- package/dist/test/Registry/BondingRegistry.spec.d.ts.map +1 -0
- package/dist/test/Registry/BondingRegistry.spec.js +684 -0
- package/dist/test/Registry/CiphernodeRegistryOwnable.spec.d.ts.map +1 -0
- package/dist/test/Registry/CiphernodeRegistryOwnable.spec.js +374 -0
- package/dist/test/Slashing/SlashingManager.spec.d.ts +2 -0
- package/dist/test/Slashing/SlashingManager.spec.d.ts.map +1 -0
- package/dist/test/Slashing/SlashingManager.spec.js +672 -0
- package/dist/types/@openzeppelin/contracts/index.d.ts +3 -0
- package/dist/types/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/types/@openzeppelin/contracts/proxy/index.d.ts +3 -0
- package/dist/types/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.d.ts +97 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.d.ts.map +1 -0
- package/dist/types/{contracts/registry/NaiveRegistryFilter.js → @openzeppelin/contracts/proxy/transparent/ProxyAdmin.js} +0 -4
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.d.ts +81 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.d.ts.map +1 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.js +12 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.d.ts +52 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.d.ts.map +1 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.js +8 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts +3 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts.map +1 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/index.d.ts +4 -0
- package/dist/types/@openzeppelin/contracts/proxy/transparent/index.d.ts.map +1 -0
- package/dist/types/@openzeppelin/index.d.ts +3 -0
- package/dist/types/@openzeppelin/index.d.ts.map +1 -0
- package/dist/types/contracts/Enclave.d.ts +126 -53
- package/dist/types/contracts/Enclave.d.ts.map +1 -1
- package/dist/types/contracts/Enclave.js +12 -0
- package/dist/types/contracts/index.d.ts +6 -0
- package/dist/types/contracts/index.d.ts.map +1 -1
- package/dist/types/contracts/interfaces/IBondingRegistry.d.ts +622 -0
- package/dist/types/contracts/interfaces/IBondingRegistry.d.ts.map +1 -0
- package/dist/types/contracts/interfaces/IBondingRegistry.js +24 -0
- package/dist/types/contracts/interfaces/ICiphernodeRegistry.d.ts +245 -15
- package/dist/types/contracts/interfaces/ICiphernodeRegistry.d.ts.map +1 -1
- package/dist/types/contracts/interfaces/ICiphernodeRegistry.js +16 -0
- package/dist/types/contracts/interfaces/IE3Program.d.ts +20 -10
- package/dist/types/contracts/interfaces/IE3Program.d.ts.map +1 -1
- package/dist/types/contracts/interfaces/IEnclave.d.ts +149 -20
- package/dist/types/contracts/interfaces/IEnclave.d.ts.map +1 -1
- package/dist/types/contracts/interfaces/IEnclave.js +12 -0
- package/dist/types/contracts/interfaces/{IRegistryFilter.d.ts → ISlashVerifier.d.ts} +16 -16
- package/dist/types/contracts/interfaces/ISlashVerifier.d.ts.map +1 -0
- package/dist/types/contracts/interfaces/ISlashVerifier.js +1 -0
- package/dist/types/contracts/interfaces/ISlashingManager.d.ts +384 -0
- package/dist/types/contracts/interfaces/ISlashingManager.d.ts.map +1 -0
- package/dist/types/contracts/interfaces/ISlashingManager.js +24 -0
- package/dist/types/contracts/interfaces/index.d.ts +3 -2
- package/dist/types/contracts/interfaces/index.d.ts.map +1 -1
- package/dist/types/contracts/lib/ExitQueueLib.d.ts +73 -0
- package/dist/types/contracts/lib/ExitQueueLib.d.ts.map +1 -0
- package/dist/types/contracts/lib/ExitQueueLib.js +12 -0
- package/dist/types/contracts/lib/index.d.ts +2 -0
- package/dist/types/contracts/lib/index.d.ts.map +1 -0
- package/dist/types/contracts/lib/index.js +1 -0
- package/dist/types/contracts/registry/BondingRegistry.d.ts +821 -0
- package/dist/types/contracts/registry/BondingRegistry.d.ts.map +1 -0
- package/dist/types/contracts/registry/BondingRegistry.js +44 -0
- package/dist/types/contracts/registry/CiphernodeRegistryOwnable.d.ts +194 -34
- package/dist/types/contracts/registry/CiphernodeRegistryOwnable.d.ts.map +1 -1
- package/dist/types/contracts/registry/CiphernodeRegistryOwnable.js +20 -0
- package/dist/types/contracts/registry/index.d.ts +1 -1
- package/dist/types/contracts/registry/index.d.ts.map +1 -1
- package/dist/types/contracts/slashing/SlashingManager.d.ts +592 -0
- package/dist/types/contracts/slashing/SlashingManager.d.ts.map +1 -0
- package/dist/types/contracts/slashing/SlashingManager.js +36 -0
- package/dist/types/contracts/slashing/index.d.ts +2 -0
- package/dist/types/contracts/slashing/index.d.ts.map +1 -0
- package/dist/types/contracts/slashing/index.js +1 -0
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.d.ts +247 -17
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.d.ts.map +1 -1
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.js +16 -0
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.d.ts +247 -17
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.d.ts.map +1 -1
- package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.js +16 -0
- package/dist/types/contracts/test/MockE3Program.d.ts +20 -14
- package/dist/types/contracts/test/MockE3Program.d.ts.map +1 -1
- package/dist/types/contracts/test/{MockInputValidator.d.ts → MockSlashingVerifier.d.ts} +15 -15
- package/dist/types/contracts/test/MockSlashingVerifier.d.ts.map +1 -0
- package/dist/types/contracts/test/MockSlashingVerifier.js +1 -0
- package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.d.ts +227 -0
- package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.d.ts.map +1 -0
- package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.js +12 -0
- package/dist/types/contracts/test/MockStableToken.sol/index.d.ts +2 -0
- package/dist/types/contracts/test/MockStableToken.sol/index.d.ts.map +1 -0
- package/dist/types/contracts/test/MockStableToken.sol/index.js +1 -0
- package/dist/types/contracts/test/index.d.ts +3 -3
- package/dist/types/contracts/test/index.d.ts.map +1 -1
- package/dist/types/contracts/token/EnclaveTicketToken.d.ts +574 -0
- package/dist/types/contracts/token/EnclaveTicketToken.d.ts.map +1 -0
- package/dist/types/contracts/token/EnclaveTicketToken.js +24 -0
- package/dist/types/contracts/token/EnclaveToken.d.ts +775 -0
- package/dist/types/contracts/token/EnclaveToken.d.ts.map +1 -0
- package/dist/types/contracts/token/EnclaveToken.js +48 -0
- package/dist/types/contracts/token/index.d.ts +3 -0
- package/dist/types/contracts/token/index.d.ts.map +1 -0
- package/dist/types/contracts/token/index.js +1 -0
- package/dist/types/factories/@openzeppelin/contracts/index.d.ts +2 -0
- package/dist/types/factories/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/index.js +4 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/index.d.ts +2 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/index.js +4 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.d.ts +118 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.js +157 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.d.ts +57 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.js +78 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.d.ts +105 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.js +141 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts +3 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.js +5 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.d.ts +3 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.js +5 -0
- package/dist/types/factories/@openzeppelin/index.d.ts +2 -0
- package/dist/types/factories/@openzeppelin/index.d.ts.map +1 -0
- package/dist/types/factories/@openzeppelin/index.js +4 -0
- package/dist/types/factories/contracts/Enclave__factory.d.ts +190 -104
- package/dist/types/factories/contracts/Enclave__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/Enclave__factory.js +241 -134
- package/dist/types/factories/contracts/index.d.ts +3 -0
- package/dist/types/factories/contracts/index.d.ts.map +1 -1
- package/dist/types/factories/contracts/index.js +3 -0
- package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.d.ts +678 -0
- package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.js +882 -0
- package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.d.ts +253 -9
- package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.js +325 -9
- package/dist/types/factories/contracts/interfaces/IE3Program__factory.d.ts +16 -2
- package/dist/types/factories/contracts/interfaces/IE3Program__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/interfaces/IE3Program__factory.js +20 -2
- package/dist/types/factories/contracts/interfaces/IEnclave__factory.d.ts +190 -24
- package/dist/types/factories/contracts/interfaces/IEnclave__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/interfaces/IEnclave__factory.js +246 -26
- package/dist/types/factories/contracts/interfaces/ISlashVerifier__factory.d.ts +26 -0
- package/dist/types/factories/contracts/interfaces/ISlashVerifier__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/interfaces/{IRegistryFilter__factory.js → ISlashVerifier__factory.js} +7 -7
- package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.d.ts +594 -0
- package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.js +760 -0
- package/dist/types/factories/contracts/interfaces/index.d.ts +3 -2
- package/dist/types/factories/contracts/interfaces/index.d.ts.map +1 -1
- package/dist/types/factories/contracts/interfaces/index.js +3 -2
- package/dist/types/factories/contracts/lib/ExitQueueLib__factory.d.ts +107 -0
- package/dist/types/factories/contracts/lib/ExitQueueLib__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/lib/ExitQueueLib__factory.js +138 -0
- package/dist/types/factories/contracts/lib/index.d.ts +2 -0
- package/dist/types/factories/contracts/lib/index.d.ts.map +1 -0
- package/dist/types/factories/contracts/lib/index.js +4 -0
- package/dist/types/factories/contracts/registry/BondingRegistry__factory.d.ts +958 -0
- package/dist/types/factories/contracts/registry/BondingRegistry__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/registry/BondingRegistry__factory.js +1239 -0
- package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.d.ts +272 -40
- package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.js +343 -49
- package/dist/types/factories/contracts/registry/index.d.ts +1 -1
- package/dist/types/factories/contracts/registry/index.d.ts.map +1 -1
- package/dist/types/factories/contracts/registry/index.js +1 -1
- package/dist/types/factories/contracts/slashing/SlashingManager__factory.d.ts +879 -0
- package/dist/types/factories/contracts/slashing/SlashingManager__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/slashing/SlashingManager__factory.js +1129 -0
- package/dist/types/factories/contracts/slashing/index.d.ts +2 -0
- package/dist/types/factories/contracts/slashing/index.d.ts.map +1 -0
- package/dist/types/factories/contracts/slashing/index.js +4 -0
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.d.ts +254 -10
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.js +326 -10
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.d.ts +254 -10
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.js +326 -10
- package/dist/types/factories/contracts/test/MockComputeProvider__factory.d.ts +2 -2
- package/dist/types/factories/contracts/test/MockComputeProvider__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/MockComputeProvider__factory.js +2 -2
- package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.d.ts +1 -1
- package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.js +1 -1
- package/dist/types/factories/contracts/test/MockE3Program__factory.d.ts +23 -27
- package/dist/types/factories/contracts/test/MockE3Program__factory.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/MockE3Program__factory.js +28 -34
- package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.d.ts +43 -0
- package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.js +60 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.d.ts +338 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.js +447 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/index.d.ts +2 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/index.d.ts.map +1 -0
- package/dist/types/factories/contracts/test/MockStableToken.sol/index.js +4 -0
- package/dist/types/factories/contracts/test/index.d.ts +2 -2
- package/dist/types/factories/contracts/test/index.d.ts.map +1 -1
- package/dist/types/factories/contracts/test/index.js +2 -2
- package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.d.ts +894 -0
- package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.js +1175 -0
- package/dist/types/factories/contracts/token/EnclaveToken__factory.d.ts +1101 -0
- package/dist/types/factories/contracts/token/EnclaveToken__factory.d.ts.map +1 -0
- package/dist/types/factories/contracts/token/EnclaveToken__factory.js +1439 -0
- package/dist/types/factories/contracts/token/index.d.ts +3 -0
- package/dist/types/factories/contracts/token/index.d.ts.map +1 -0
- package/dist/types/factories/contracts/token/index.js +5 -0
- package/dist/types/factories/index.d.ts +1 -0
- package/dist/types/factories/index.d.ts.map +1 -1
- package/dist/types/factories/index.js +1 -0
- package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.d.ts +1 -1
- package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.d.ts.map +1 -1
- package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.js +1 -1
- package/dist/types/index.d.ts +28 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +13 -6
- package/package.json +30 -21
- package/LICENSE.md +0 -165
- package/artifacts/build-info/solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5.json +0 -130
- package/artifacts/build-info/solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5.output.json +0 -1
- package/artifacts/contracts/interfaces/IInputValidator.sol/IInputValidator.json +0 -38
- package/artifacts/contracts/interfaces/IInputValidator.sol/artifacts.d.ts +0 -27
- package/artifacts/contracts/interfaces/IRegistryFilter.sol/artifacts.d.ts +0 -27
- package/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json +0 -309
- package/artifacts/contracts/registry/NaiveRegistryFilter.sol/artifacts.d.ts +0 -27
- package/artifacts/contracts/test/MockInputValidator.sol/MockInputValidator.json +0 -43
- package/artifacts/contracts/test/MockInputValidator.sol/artifacts.d.ts +0 -27
- package/artifacts/contracts/test/MockRegistryFilter.sol/IRegistry.json +0 -37
- package/artifacts/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.json +0 -262
- package/artifacts/contracts/test/MockRegistryFilter.sol/artifacts.d.ts +0 -43
- package/contracts/interfaces/IInputValidator.sol +0 -18
- package/contracts/interfaces/IRegistryFilter.sol +0 -13
- package/contracts/registry/NaiveRegistryFilter.sol +0 -124
- package/contracts/test/MockInputValidator.sol +0 -29
- package/contracts/test/MockRegistryFilter.sol +0 -117
- package/dist/ignition/modules/mockInputValidator.d.ts.map +0 -1
- package/dist/ignition/modules/naiveRegistryFilter.d.ts.map +0 -1
- package/dist/ignition/modules/naiveRegistryFilter.js +0 -16
- package/dist/scripts/deployAndSave/mockInputValidator.d.ts +0 -6
- package/dist/scripts/deployAndSave/mockInputValidator.d.ts.map +0 -1
- package/dist/scripts/deployAndSave/mockInputValidator.js +0 -18
- package/dist/scripts/deployAndSave/naiveRegistryFilter.d.ts +0 -11
- package/dist/scripts/deployAndSave/naiveRegistryFilter.d.ts.map +0 -1
- package/dist/scripts/deployAndSave/naiveRegistryFilter.js +0 -41
- package/dist/test/CiphernodeRegistry/CiphernodeRegistryOwnable.spec.d.ts.map +0 -1
- package/dist/test/CiphernodeRegistry/CiphernodeRegistryOwnable.spec.js +0 -279
- package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.d.ts +0 -2
- package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.d.ts.map +0 -1
- package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.js +0 -160
- package/dist/types/contracts/interfaces/IInputValidator.d.ts +0 -36
- package/dist/types/contracts/interfaces/IInputValidator.d.ts.map +0 -1
- package/dist/types/contracts/interfaces/IRegistryFilter.d.ts.map +0 -1
- package/dist/types/contracts/registry/NaiveRegistryFilter.d.ts +0 -187
- package/dist/types/contracts/registry/NaiveRegistryFilter.d.ts.map +0 -1
- package/dist/types/contracts/test/MockInputValidator.d.ts.map +0 -1
- package/dist/types/contracts/test/MockRegistryFilter.sol/IRegistry.d.ts +0 -38
- package/dist/types/contracts/test/MockRegistryFilter.sol/IRegistry.d.ts.map +0 -1
- package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.d.ts +0 -163
- package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.d.ts.map +0 -1
- package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.js +0 -8
- package/dist/types/contracts/test/MockRegistryFilter.sol/index.d.ts +0 -3
- package/dist/types/contracts/test/MockRegistryFilter.sol/index.d.ts.map +0 -1
- package/dist/types/factories/contracts/interfaces/IInputValidator__factory.d.ts +0 -26
- package/dist/types/factories/contracts/interfaces/IInputValidator__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/interfaces/IInputValidator__factory.js +0 -39
- package/dist/types/factories/contracts/interfaces/IRegistryFilter__factory.d.ts +0 -26
- package/dist/types/factories/contracts/interfaces/IRegistryFilter__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.d.ts +0 -251
- package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.js +0 -331
- package/dist/types/factories/contracts/test/MockInputValidator__factory.d.ts +0 -47
- package/dist/types/factories/contracts/test/MockInputValidator__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/test/MockInputValidator__factory.js +0 -65
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.d.ts +0 -26
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.js +0 -38
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.d.ts +0 -216
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.d.ts.map +0 -1
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.js +0 -284
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.d.ts +0 -3
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.d.ts.map +0 -1
- package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.js +0 -5
- /package/dist/test/{CiphernodeRegistry → Registry}/CiphernodeRegistryOwnable.spec.d.ts +0 -0
- /package/dist/types/{contracts/test/MockRegistryFilter.sol → @openzeppelin/contracts}/index.js +0 -0
- /package/dist/types/{contracts/interfaces/IInputValidator.js → @openzeppelin/contracts/proxy/index.js} +0 -0
- /package/dist/types/{contracts/interfaces/IRegistryFilter.js → @openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.js} +0 -0
- /package/dist/types/{contracts/test/MockInputValidator.js → @openzeppelin/contracts/proxy/transparent/index.js} +0 -0
- /package/dist/types/{contracts/test/MockRegistryFilter.sol/IRegistry.js → @openzeppelin/index.js} +0 -0
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
//
|
|
3
|
+
// This file is provided WITHOUT ANY WARRANTY;
|
|
4
|
+
// without even the implied warranty of MERCHANTABILITY
|
|
5
|
+
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
6
|
+
|
|
7
|
+
pragma solidity >=0.8.27;
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
OwnableUpgradeable
|
|
11
|
+
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
12
|
+
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
13
|
+
import {
|
|
14
|
+
SafeERC20
|
|
15
|
+
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
16
|
+
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
|
|
17
|
+
import { ExitQueueLib } from "../lib/ExitQueueLib.sol";
|
|
18
|
+
|
|
19
|
+
import { IBondingRegistry } from "../interfaces/IBondingRegistry.sol";
|
|
20
|
+
import { ICiphernodeRegistry } from "../interfaces/ICiphernodeRegistry.sol";
|
|
21
|
+
import { ISlashingManager } from "../interfaces/ISlashingManager.sol";
|
|
22
|
+
import { EnclaveTicketToken } from "../token/EnclaveTicketToken.sol";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @title BondingRegistry
|
|
26
|
+
* @notice Implementation of the bonding registry managing operator ticket balances and license bonds
|
|
27
|
+
* @dev Handles deposits, withdrawals, slashing, exits, and integrates with registry and slashing manager
|
|
28
|
+
*/
|
|
29
|
+
contract BondingRegistry is IBondingRegistry, OwnableUpgradeable {
|
|
30
|
+
using SafeERC20 for IERC20;
|
|
31
|
+
using ExitQueueLib for ExitQueueLib.ExitQueueState;
|
|
32
|
+
|
|
33
|
+
// ======================
|
|
34
|
+
// Constants
|
|
35
|
+
// ======================
|
|
36
|
+
|
|
37
|
+
/// @dev Reason code for ticket balance deposits
|
|
38
|
+
bytes32 private constant REASON_DEPOSIT = bytes32("DEPOSIT");
|
|
39
|
+
|
|
40
|
+
/// @dev Reason code for ticket balance withdrawals
|
|
41
|
+
bytes32 private constant REASON_WITHDRAW = bytes32("WITHDRAW");
|
|
42
|
+
|
|
43
|
+
/// @dev Reason code for license bond operations
|
|
44
|
+
bytes32 private constant REASON_BOND = bytes32("BOND");
|
|
45
|
+
|
|
46
|
+
/// @dev Reason code for license unbond operations
|
|
47
|
+
bytes32 private constant REASON_UNBOND = bytes32("UNBOND");
|
|
48
|
+
|
|
49
|
+
// ======================
|
|
50
|
+
// Storage
|
|
51
|
+
// ======================
|
|
52
|
+
|
|
53
|
+
/// @notice Ticket token (ETK with underlying USDC) used for collateral
|
|
54
|
+
EnclaveTicketToken public ticketToken;
|
|
55
|
+
|
|
56
|
+
/// @notice License token (ENCL) required for operator registration
|
|
57
|
+
IERC20 public licenseToken;
|
|
58
|
+
|
|
59
|
+
/// @notice Registry contract for managing committee membership
|
|
60
|
+
ICiphernodeRegistry public registry;
|
|
61
|
+
|
|
62
|
+
/// @notice Address authorized to perform slashing operations
|
|
63
|
+
address public slashingManager;
|
|
64
|
+
|
|
65
|
+
/// @notice Address authorized to distribute rewards to operators
|
|
66
|
+
address public rewardDistributor;
|
|
67
|
+
|
|
68
|
+
/// @notice Treasury address that receives slashed funds
|
|
69
|
+
address public slashedFundsTreasury;
|
|
70
|
+
|
|
71
|
+
/// @notice Price per ticket in ticket token units
|
|
72
|
+
uint256 public ticketPrice;
|
|
73
|
+
|
|
74
|
+
/// @notice Minimum license bond required for initial registration
|
|
75
|
+
uint256 public licenseRequiredBond;
|
|
76
|
+
|
|
77
|
+
/// @notice Minimum number of tickets required to maintain active status
|
|
78
|
+
uint256 public minTicketBalance;
|
|
79
|
+
|
|
80
|
+
/// @notice Time delay in seconds before exits can be claimed
|
|
81
|
+
uint64 public exitDelay;
|
|
82
|
+
|
|
83
|
+
/// @notice Percentage (in basis points) of license bond that must remain bonded to stay active
|
|
84
|
+
/// @dev Default 8000 = 80%. Allows operators to unbond up to 20% while remaining active
|
|
85
|
+
uint256 public licenseActiveBps;
|
|
86
|
+
|
|
87
|
+
/// @notice Operator state data structure
|
|
88
|
+
/// @param licenseBond Amount of license tokens currently bonded
|
|
89
|
+
/// @param exitUnlocksAt Timestamp when pending exit can be claimed
|
|
90
|
+
/// @param registered Whether operator is registered in the protocol
|
|
91
|
+
/// @param exitRequested Whether operator has requested to exit
|
|
92
|
+
/// @param active Whether operator meets all requirements for active status
|
|
93
|
+
struct Operator {
|
|
94
|
+
uint256 licenseBond;
|
|
95
|
+
uint64 exitUnlocksAt;
|
|
96
|
+
bool registered;
|
|
97
|
+
bool exitRequested;
|
|
98
|
+
bool active;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// @notice Maps operator address to their state data
|
|
102
|
+
mapping(address operator => Operator data) internal operators;
|
|
103
|
+
|
|
104
|
+
/// @notice Total slashed ticket balance available for treasury withdrawal
|
|
105
|
+
uint256 public slashedTicketBalance;
|
|
106
|
+
|
|
107
|
+
/// @notice Total slashed license bond available for treasury withdrawal
|
|
108
|
+
uint256 public slashedLicenseBond;
|
|
109
|
+
|
|
110
|
+
// ======================
|
|
111
|
+
// Exit Queue library state
|
|
112
|
+
// ======================
|
|
113
|
+
|
|
114
|
+
/// @dev Internal state for managing exit queue of tickets and licenses
|
|
115
|
+
ExitQueueLib.ExitQueueState private _exits;
|
|
116
|
+
|
|
117
|
+
// ======================
|
|
118
|
+
// Modifiers
|
|
119
|
+
// ======================
|
|
120
|
+
|
|
121
|
+
/// @dev Restricts function access to only the slashing manager
|
|
122
|
+
modifier onlySlashingManager() {
|
|
123
|
+
if (msg.sender != slashingManager) revert Unauthorized();
|
|
124
|
+
_;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// @dev Reverts if operator has an exit in progress that hasn't unlocked yet
|
|
128
|
+
/// @param operator Address of the operator to check
|
|
129
|
+
modifier noExitInProgress(address operator) {
|
|
130
|
+
Operator memory op = operators[operator];
|
|
131
|
+
if (op.exitRequested && block.timestamp < op.exitUnlocksAt) {
|
|
132
|
+
revert ExitInProgress();
|
|
133
|
+
}
|
|
134
|
+
_;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
////////////////////////////////////////////////////////////
|
|
138
|
+
// //
|
|
139
|
+
// Initialization //
|
|
140
|
+
// //
|
|
141
|
+
////////////////////////////////////////////////////////////
|
|
142
|
+
|
|
143
|
+
/// @notice Constructor that disables initializers.
|
|
144
|
+
/// @dev Prevents the implementation contract from being initialized. Initialization is performed
|
|
145
|
+
/// via the initialize() function when deployed behind a proxy.
|
|
146
|
+
constructor() {
|
|
147
|
+
_disableInitializers();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// @notice Initializes the bonding registry contract
|
|
151
|
+
/// @dev Can only be called once due to initializer modifier
|
|
152
|
+
/// @param _owner Address that will own the contract
|
|
153
|
+
/// @param _ticketToken Ticket token contract for collateral
|
|
154
|
+
/// @param _licenseToken License token contract for bonding
|
|
155
|
+
/// @param _registry Ciphernode registry contract
|
|
156
|
+
/// @param _slashedFundsTreasury Address to receive slashed funds
|
|
157
|
+
/// @param _ticketPrice Initial price per ticket
|
|
158
|
+
/// @param _licenseRequiredBond Initial required license bond for registration
|
|
159
|
+
/// @param _minTicketBalance Initial minimum ticket balance for activation
|
|
160
|
+
/// @param _exitDelay Initial exit delay period in seconds
|
|
161
|
+
function initialize(
|
|
162
|
+
address _owner,
|
|
163
|
+
EnclaveTicketToken _ticketToken,
|
|
164
|
+
IERC20 _licenseToken,
|
|
165
|
+
ICiphernodeRegistry _registry,
|
|
166
|
+
address _slashedFundsTreasury,
|
|
167
|
+
uint256 _ticketPrice,
|
|
168
|
+
uint256 _licenseRequiredBond,
|
|
169
|
+
uint256 _minTicketBalance,
|
|
170
|
+
uint64 _exitDelay
|
|
171
|
+
) public initializer {
|
|
172
|
+
__Ownable_init(msg.sender);
|
|
173
|
+
setTicketToken(_ticketToken);
|
|
174
|
+
setLicenseToken(_licenseToken);
|
|
175
|
+
setRegistry(_registry);
|
|
176
|
+
setSlashedFundsTreasury(_slashedFundsTreasury);
|
|
177
|
+
setTicketPrice(_ticketPrice);
|
|
178
|
+
setLicenseRequiredBond(_licenseRequiredBond);
|
|
179
|
+
setMinTicketBalance(_minTicketBalance);
|
|
180
|
+
setExitDelay(_exitDelay);
|
|
181
|
+
setLicenseActiveBps(8_000);
|
|
182
|
+
if (_owner != owner()) transferOwnership(_owner);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ======================
|
|
186
|
+
// View Functions
|
|
187
|
+
// ======================
|
|
188
|
+
|
|
189
|
+
/// @inheritdoc IBondingRegistry
|
|
190
|
+
function getLicenseToken() external view returns (address) {
|
|
191
|
+
return address(licenseToken);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// @inheritdoc IBondingRegistry
|
|
195
|
+
function getTicketToken() external view returns (address) {
|
|
196
|
+
return address(ticketToken);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/// @inheritdoc IBondingRegistry
|
|
200
|
+
function getTicketBalance(
|
|
201
|
+
address operator
|
|
202
|
+
) external view returns (uint256) {
|
|
203
|
+
return ticketToken.balanceOf(operator);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/// @inheritdoc IBondingRegistry
|
|
207
|
+
function getLicenseBond(address operator) external view returns (uint256) {
|
|
208
|
+
return operators[operator].licenseBond;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// @inheritdoc IBondingRegistry
|
|
212
|
+
function availableTickets(
|
|
213
|
+
address operator
|
|
214
|
+
) external view returns (uint256) {
|
|
215
|
+
return ticketToken.balanceOf(operator) / ticketPrice;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/// @notice Get operator's ticket balance at a specific block
|
|
219
|
+
/// @dev Uses checkpoint mechanism from ticket token
|
|
220
|
+
/// @param operator Address of the operator
|
|
221
|
+
/// @param blockNumber Block number to query
|
|
222
|
+
/// @return Ticket balance at the specified block
|
|
223
|
+
function getTicketBalanceAtBlock(
|
|
224
|
+
address operator,
|
|
225
|
+
uint256 blockNumber
|
|
226
|
+
) external view returns (uint256) {
|
|
227
|
+
return ticketToken.getPastVotes(operator, blockNumber);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/// @notice Get operator's total pending exit amounts
|
|
231
|
+
/// @param operator Address of the operator
|
|
232
|
+
/// @return ticket Total pending ticket balance in exit queue
|
|
233
|
+
/// @return license Total pending license bond in exit queue
|
|
234
|
+
function pendingExits(
|
|
235
|
+
address operator
|
|
236
|
+
) external view returns (uint256 ticket, uint256 license) {
|
|
237
|
+
return _exits.getPendingAmounts(operator);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// @notice Preview how much an operator can currently claim
|
|
241
|
+
/// @param operator Address of the operator
|
|
242
|
+
/// @return ticket Claimable ticket balance
|
|
243
|
+
/// @return license Claimable license bond
|
|
244
|
+
function previewClaimable(
|
|
245
|
+
address operator
|
|
246
|
+
) external view returns (uint256 ticket, uint256 license) {
|
|
247
|
+
return _exits.previewClaimableAmounts(operator);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/// @inheritdoc IBondingRegistry
|
|
251
|
+
function isLicensed(address operator) external view returns (bool) {
|
|
252
|
+
return operators[operator].licenseBond >= _minLicenseBond();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// @inheritdoc IBondingRegistry
|
|
256
|
+
function isRegistered(address operator) external view returns (bool) {
|
|
257
|
+
return operators[operator].registered;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/// @inheritdoc IBondingRegistry
|
|
261
|
+
function isActive(address operator) external view returns (bool) {
|
|
262
|
+
return operators[operator].active;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/// @inheritdoc IBondingRegistry
|
|
266
|
+
function hasExitInProgress(address operator) external view returns (bool) {
|
|
267
|
+
Operator memory op = operators[operator];
|
|
268
|
+
return op.exitRequested && block.timestamp < op.exitUnlocksAt;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ======================
|
|
272
|
+
// Operator Functions
|
|
273
|
+
// ======================
|
|
274
|
+
|
|
275
|
+
/// @inheritdoc IBondingRegistry
|
|
276
|
+
function registerOperator() external noExitInProgress(msg.sender) {
|
|
277
|
+
// Clear previous exit request
|
|
278
|
+
if (operators[msg.sender].exitRequested) {
|
|
279
|
+
operators[msg.sender].exitRequested = false;
|
|
280
|
+
operators[msg.sender].exitUnlocksAt = 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
require(
|
|
284
|
+
!ISlashingManager(slashingManager).isBanned(msg.sender),
|
|
285
|
+
CiphernodeBanned()
|
|
286
|
+
);
|
|
287
|
+
require(!operators[msg.sender].registered, AlreadyRegistered());
|
|
288
|
+
require(
|
|
289
|
+
operators[msg.sender].licenseBond >= licenseRequiredBond,
|
|
290
|
+
NotLicensed()
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
operators[msg.sender].registered = true;
|
|
294
|
+
|
|
295
|
+
// CiphernodeRegistry already emits an event when a ciphernode is added
|
|
296
|
+
registry.addCiphernode(msg.sender);
|
|
297
|
+
|
|
298
|
+
_updateOperatorStatus(msg.sender);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/// @inheritdoc IBondingRegistry
|
|
302
|
+
function deregisterOperator(
|
|
303
|
+
uint256[] calldata siblingNodes
|
|
304
|
+
) external noExitInProgress(msg.sender) {
|
|
305
|
+
Operator storage op = operators[msg.sender];
|
|
306
|
+
require(op.registered, NotRegistered());
|
|
307
|
+
|
|
308
|
+
op.registered = false;
|
|
309
|
+
op.exitRequested = true;
|
|
310
|
+
op.exitUnlocksAt = uint64(block.timestamp) + exitDelay;
|
|
311
|
+
|
|
312
|
+
uint256 ticketOut = ticketToken.balanceOf(msg.sender);
|
|
313
|
+
uint256 licenseOut = op.licenseBond;
|
|
314
|
+
if (ticketOut != 0) {
|
|
315
|
+
ticketToken.burnTickets(msg.sender, ticketOut);
|
|
316
|
+
emit TicketBalanceUpdated(
|
|
317
|
+
msg.sender,
|
|
318
|
+
-int256(ticketOut),
|
|
319
|
+
0,
|
|
320
|
+
REASON_WITHDRAW
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
if (licenseOut != 0) {
|
|
324
|
+
op.licenseBond = 0;
|
|
325
|
+
emit LicenseBondUpdated(
|
|
326
|
+
msg.sender,
|
|
327
|
+
-int256(licenseOut),
|
|
328
|
+
0,
|
|
329
|
+
REASON_UNBOND
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (ticketOut != 0 || licenseOut != 0) {
|
|
334
|
+
_exits.queueAssetsForExit(
|
|
335
|
+
msg.sender,
|
|
336
|
+
exitDelay,
|
|
337
|
+
ticketOut,
|
|
338
|
+
licenseOut
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// CiphernodeRegistry already emits an event when a ciphernode is removed
|
|
343
|
+
registry.removeCiphernode(msg.sender, siblingNodes);
|
|
344
|
+
|
|
345
|
+
emit CiphernodeDeregistrationRequested(msg.sender, op.exitUnlocksAt);
|
|
346
|
+
_updateOperatorStatus(msg.sender);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/// @inheritdoc IBondingRegistry
|
|
350
|
+
function addTicketBalance(
|
|
351
|
+
uint256 amount
|
|
352
|
+
) external noExitInProgress(msg.sender) {
|
|
353
|
+
require(amount != 0, ZeroAmount());
|
|
354
|
+
require(operators[msg.sender].registered, NotRegistered());
|
|
355
|
+
|
|
356
|
+
ticketToken.depositFrom(msg.sender, msg.sender, amount);
|
|
357
|
+
|
|
358
|
+
emit TicketBalanceUpdated(
|
|
359
|
+
msg.sender,
|
|
360
|
+
int256(amount),
|
|
361
|
+
ticketToken.balanceOf(msg.sender),
|
|
362
|
+
REASON_DEPOSIT
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
_updateOperatorStatus(msg.sender);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/// @inheritdoc IBondingRegistry
|
|
369
|
+
function removeTicketBalance(
|
|
370
|
+
uint256 amount
|
|
371
|
+
) external noExitInProgress(msg.sender) {
|
|
372
|
+
require(amount != 0, ZeroAmount());
|
|
373
|
+
require(operators[msg.sender].registered, NotRegistered());
|
|
374
|
+
require(
|
|
375
|
+
ticketToken.balanceOf(msg.sender) >= amount,
|
|
376
|
+
InsufficientBalance()
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
ticketToken.burnTickets(msg.sender, amount);
|
|
380
|
+
_exits.queueTicketsForExit(msg.sender, exitDelay, amount);
|
|
381
|
+
|
|
382
|
+
emit TicketBalanceUpdated(
|
|
383
|
+
msg.sender,
|
|
384
|
+
-int256(amount),
|
|
385
|
+
ticketToken.balanceOf(msg.sender),
|
|
386
|
+
REASON_WITHDRAW
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
_updateOperatorStatus(msg.sender);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/// @inheritdoc IBondingRegistry
|
|
393
|
+
function bondLicense(uint256 amount) external noExitInProgress(msg.sender) {
|
|
394
|
+
require(amount != 0, ZeroAmount());
|
|
395
|
+
|
|
396
|
+
uint256 balanceBefore = licenseToken.balanceOf(address(this));
|
|
397
|
+
licenseToken.safeTransferFrom(msg.sender, address(this), amount);
|
|
398
|
+
uint256 actualReceived = licenseToken.balanceOf(address(this)) -
|
|
399
|
+
balanceBefore;
|
|
400
|
+
|
|
401
|
+
operators[msg.sender].licenseBond += actualReceived;
|
|
402
|
+
|
|
403
|
+
emit LicenseBondUpdated(
|
|
404
|
+
msg.sender,
|
|
405
|
+
int256(actualReceived),
|
|
406
|
+
operators[msg.sender].licenseBond,
|
|
407
|
+
REASON_BOND
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
_updateOperatorStatus(msg.sender);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/// @inheritdoc IBondingRegistry
|
|
414
|
+
function unbondLicense(
|
|
415
|
+
uint256 amount
|
|
416
|
+
) external noExitInProgress(msg.sender) {
|
|
417
|
+
require(amount != 0, ZeroAmount());
|
|
418
|
+
require(
|
|
419
|
+
operators[msg.sender].licenseBond >= amount,
|
|
420
|
+
InsufficientBalance()
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
operators[msg.sender].licenseBond -= amount;
|
|
424
|
+
_exits.queueLicensesForExit(msg.sender, exitDelay, amount);
|
|
425
|
+
|
|
426
|
+
emit LicenseBondUpdated(
|
|
427
|
+
msg.sender,
|
|
428
|
+
-int256(amount),
|
|
429
|
+
operators[msg.sender].licenseBond,
|
|
430
|
+
REASON_UNBOND
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
_updateOperatorStatus(msg.sender);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ======================
|
|
437
|
+
// Claim Functions
|
|
438
|
+
// ======================
|
|
439
|
+
|
|
440
|
+
/// @inheritdoc IBondingRegistry
|
|
441
|
+
function claimExits(
|
|
442
|
+
uint256 maxTicketAmount,
|
|
443
|
+
uint256 maxLicenseAmount
|
|
444
|
+
) external {
|
|
445
|
+
(uint256 ticketClaim, uint256 licenseClaim) = _exits.claimAssets(
|
|
446
|
+
msg.sender,
|
|
447
|
+
maxTicketAmount,
|
|
448
|
+
maxLicenseAmount
|
|
449
|
+
);
|
|
450
|
+
require(ticketClaim > 0 || licenseClaim > 0, ExitNotReady());
|
|
451
|
+
|
|
452
|
+
if (ticketClaim > 0) ticketToken.payout(msg.sender, ticketClaim);
|
|
453
|
+
if (licenseClaim > 0) {
|
|
454
|
+
licenseToken.safeTransfer(msg.sender, licenseClaim);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ======================
|
|
459
|
+
// Slashing Functions
|
|
460
|
+
// ======================
|
|
461
|
+
|
|
462
|
+
/// @inheritdoc IBondingRegistry
|
|
463
|
+
function slashTicketBalance(
|
|
464
|
+
address operator,
|
|
465
|
+
uint256 requestedSlashAmount,
|
|
466
|
+
bytes32 slashReason
|
|
467
|
+
) external onlySlashingManager {
|
|
468
|
+
require(requestedSlashAmount != 0, ZeroAmount());
|
|
469
|
+
|
|
470
|
+
(uint256 pendingTicketBalance, ) = _exits.getPendingAmounts(operator);
|
|
471
|
+
uint256 activeBalance = ticketToken.balanceOf(operator);
|
|
472
|
+
uint256 totalAvailableBalance = activeBalance + pendingTicketBalance;
|
|
473
|
+
|
|
474
|
+
uint256 actualSlashAmount = Math.min(
|
|
475
|
+
requestedSlashAmount,
|
|
476
|
+
totalAvailableBalance
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
if (actualSlashAmount == 0) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Slash from active balance first
|
|
484
|
+
uint256 slashedFromActiveBalance = Math.min(
|
|
485
|
+
actualSlashAmount,
|
|
486
|
+
activeBalance
|
|
487
|
+
);
|
|
488
|
+
if (slashedFromActiveBalance > 0) {
|
|
489
|
+
ticketToken.burnTickets(operator, slashedFromActiveBalance);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Slash remaining amount from pending queue
|
|
493
|
+
uint256 remainingToSlash = actualSlashAmount - slashedFromActiveBalance;
|
|
494
|
+
if (remainingToSlash > 0) {
|
|
495
|
+
_exits.slashPendingAssets(
|
|
496
|
+
operator,
|
|
497
|
+
remainingToSlash,
|
|
498
|
+
0, // licenseAmount
|
|
499
|
+
true
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
slashedTicketBalance += actualSlashAmount;
|
|
504
|
+
emit TicketBalanceUpdated(
|
|
505
|
+
operator,
|
|
506
|
+
-int256(actualSlashAmount),
|
|
507
|
+
ticketToken.balanceOf(operator),
|
|
508
|
+
slashReason
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
_updateOperatorStatus(operator);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/// @inheritdoc IBondingRegistry
|
|
515
|
+
function slashLicenseBond(
|
|
516
|
+
address operator,
|
|
517
|
+
uint256 requestedSlashAmount,
|
|
518
|
+
bytes32 slashReason
|
|
519
|
+
) external onlySlashingManager {
|
|
520
|
+
require(requestedSlashAmount != 0, ZeroAmount());
|
|
521
|
+
|
|
522
|
+
Operator storage operatorData = operators[operator];
|
|
523
|
+
(, uint256 pendingLicenseBalance) = _exits.getPendingAmounts(operator);
|
|
524
|
+
uint256 totalAvailableBalance = operatorData.licenseBond +
|
|
525
|
+
pendingLicenseBalance;
|
|
526
|
+
uint256 actualSlashAmount = Math.min(
|
|
527
|
+
requestedSlashAmount,
|
|
528
|
+
totalAvailableBalance
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
if (actualSlashAmount == 0) return;
|
|
532
|
+
|
|
533
|
+
// Slash from active balance first
|
|
534
|
+
uint256 slashedFromActiveBalance = Math.min(
|
|
535
|
+
actualSlashAmount,
|
|
536
|
+
operatorData.licenseBond
|
|
537
|
+
);
|
|
538
|
+
if (slashedFromActiveBalance > 0) {
|
|
539
|
+
operatorData.licenseBond -= slashedFromActiveBalance;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// Slash remaining amount from pending queue
|
|
543
|
+
uint256 remainingToSlash = actualSlashAmount - slashedFromActiveBalance;
|
|
544
|
+
if (remainingToSlash > 0) {
|
|
545
|
+
_exits.slashPendingAssets(
|
|
546
|
+
operator,
|
|
547
|
+
0, // ticketAmount
|
|
548
|
+
remainingToSlash,
|
|
549
|
+
true
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
slashedLicenseBond += actualSlashAmount;
|
|
554
|
+
emit LicenseBondUpdated(
|
|
555
|
+
operator,
|
|
556
|
+
-int256(actualSlashAmount),
|
|
557
|
+
operatorData.licenseBond,
|
|
558
|
+
slashReason
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
_updateOperatorStatus(operator);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// ======================
|
|
565
|
+
// Reward Distribution Functions
|
|
566
|
+
// ======================
|
|
567
|
+
|
|
568
|
+
/// @inheritdoc IBondingRegistry
|
|
569
|
+
function distributeRewards(
|
|
570
|
+
IERC20 rewardToken,
|
|
571
|
+
address[] calldata recipients,
|
|
572
|
+
uint256[] calldata amounts
|
|
573
|
+
) external {
|
|
574
|
+
require(msg.sender == rewardDistributor, OnlyRewardDistributor());
|
|
575
|
+
require(recipients.length == amounts.length, ArrayLengthMismatch());
|
|
576
|
+
|
|
577
|
+
uint256 len = recipients.length;
|
|
578
|
+
for (uint256 i = 0; i < len; i++) {
|
|
579
|
+
if (amounts[i] > 0 && operators[recipients[i]].registered) {
|
|
580
|
+
rewardToken.safeTransferFrom(
|
|
581
|
+
rewardDistributor,
|
|
582
|
+
recipients[i],
|
|
583
|
+
amounts[i]
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// ======================
|
|
590
|
+
// Admin Functions
|
|
591
|
+
// ======================
|
|
592
|
+
|
|
593
|
+
/// @inheritdoc IBondingRegistry
|
|
594
|
+
function setTicketPrice(uint256 newTicketPrice) public onlyOwner {
|
|
595
|
+
require(newTicketPrice != 0, InvalidConfiguration());
|
|
596
|
+
|
|
597
|
+
uint256 oldValue = ticketPrice;
|
|
598
|
+
ticketPrice = newTicketPrice;
|
|
599
|
+
|
|
600
|
+
emit ConfigurationUpdated("ticketPrice", oldValue, newTicketPrice);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/// @inheritdoc IBondingRegistry
|
|
604
|
+
function setLicenseRequiredBond(
|
|
605
|
+
uint256 newLicenseRequiredBond
|
|
606
|
+
) public onlyOwner {
|
|
607
|
+
require(newLicenseRequiredBond != 0, InvalidConfiguration());
|
|
608
|
+
|
|
609
|
+
uint256 oldValue = licenseRequiredBond;
|
|
610
|
+
licenseRequiredBond = newLicenseRequiredBond;
|
|
611
|
+
|
|
612
|
+
emit ConfigurationUpdated(
|
|
613
|
+
"licenseRequiredBond",
|
|
614
|
+
oldValue,
|
|
615
|
+
newLicenseRequiredBond
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/// @inheritdoc IBondingRegistry
|
|
620
|
+
function setLicenseActiveBps(uint256 newBps) public onlyOwner {
|
|
621
|
+
require(newBps > 0 && newBps <= 10_000, InvalidConfiguration());
|
|
622
|
+
|
|
623
|
+
uint256 oldValue = licenseActiveBps;
|
|
624
|
+
licenseActiveBps = newBps;
|
|
625
|
+
|
|
626
|
+
emit ConfigurationUpdated("licenseActiveBps", oldValue, newBps);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/// @inheritdoc IBondingRegistry
|
|
630
|
+
function setMinTicketBalance(uint256 newMinTicketBalance) public onlyOwner {
|
|
631
|
+
uint256 oldValue = minTicketBalance;
|
|
632
|
+
minTicketBalance = newMinTicketBalance;
|
|
633
|
+
|
|
634
|
+
emit ConfigurationUpdated(
|
|
635
|
+
"minTicketBalance",
|
|
636
|
+
oldValue,
|
|
637
|
+
newMinTicketBalance
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/// @inheritdoc IBondingRegistry
|
|
642
|
+
function setExitDelay(uint64 newExitDelay) public onlyOwner {
|
|
643
|
+
uint256 oldValue = uint256(exitDelay);
|
|
644
|
+
exitDelay = newExitDelay;
|
|
645
|
+
|
|
646
|
+
emit ConfigurationUpdated("exitDelay", oldValue, uint256(newExitDelay));
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/// @inheritdoc IBondingRegistry
|
|
650
|
+
function setSlashedFundsTreasury(
|
|
651
|
+
address newSlashedFundsTreasury
|
|
652
|
+
) public onlyOwner {
|
|
653
|
+
require(newSlashedFundsTreasury != address(0), ZeroAddress());
|
|
654
|
+
slashedFundsTreasury = newSlashedFundsTreasury;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/// @inheritdoc IBondingRegistry
|
|
658
|
+
function setTicketToken(
|
|
659
|
+
EnclaveTicketToken newTicketToken
|
|
660
|
+
) public onlyOwner {
|
|
661
|
+
ticketToken = newTicketToken;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/// @inheritdoc IBondingRegistry
|
|
665
|
+
function setLicenseToken(IERC20 newLicenseToken) public onlyOwner {
|
|
666
|
+
licenseToken = newLicenseToken;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/// @inheritdoc IBondingRegistry
|
|
670
|
+
function setRegistry(ICiphernodeRegistry newRegistry) public onlyOwner {
|
|
671
|
+
registry = newRegistry;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/// @inheritdoc IBondingRegistry
|
|
675
|
+
function setSlashingManager(address newSlashingManager) public onlyOwner {
|
|
676
|
+
slashingManager = newSlashingManager;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/// @notice Sets the reward distributor address
|
|
680
|
+
/// @dev Only callable by owner
|
|
681
|
+
/// @param newRewardDistributor Address of the reward distributor
|
|
682
|
+
function setRewardDistributor(
|
|
683
|
+
address newRewardDistributor
|
|
684
|
+
) public onlyOwner {
|
|
685
|
+
rewardDistributor = newRewardDistributor;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/// @inheritdoc IBondingRegistry
|
|
689
|
+
function withdrawSlashedFunds(
|
|
690
|
+
uint256 ticketAmount,
|
|
691
|
+
uint256 licenseAmount
|
|
692
|
+
) public onlyOwner {
|
|
693
|
+
require(ticketAmount <= slashedTicketBalance, InsufficientBalance());
|
|
694
|
+
require(licenseAmount <= slashedLicenseBond, InsufficientBalance());
|
|
695
|
+
|
|
696
|
+
if (ticketAmount > 0) {
|
|
697
|
+
slashedTicketBalance -= ticketAmount;
|
|
698
|
+
ticketToken.payout(slashedFundsTreasury, ticketAmount);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (licenseAmount > 0) {
|
|
702
|
+
slashedLicenseBond -= licenseAmount;
|
|
703
|
+
licenseToken.safeTransfer(slashedFundsTreasury, licenseAmount);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
emit SlashedFundsWithdrawn(
|
|
707
|
+
slashedFundsTreasury,
|
|
708
|
+
ticketAmount,
|
|
709
|
+
licenseAmount
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// ======================
|
|
714
|
+
// Internal Functions
|
|
715
|
+
// ======================
|
|
716
|
+
|
|
717
|
+
/// @dev Updates operator's active status based on current conditions
|
|
718
|
+
/// @dev Operator is active if: registered, has minimum license bond, and has minimum tickets
|
|
719
|
+
/// @param operator Address of the operator to update
|
|
720
|
+
function _updateOperatorStatus(address operator) internal {
|
|
721
|
+
Operator storage op = operators[operator];
|
|
722
|
+
bool newActiveStatus = op.registered &&
|
|
723
|
+
op.licenseBond >= _minLicenseBond() &&
|
|
724
|
+
(ticketToken.balanceOf(operator) / ticketPrice >= minTicketBalance);
|
|
725
|
+
|
|
726
|
+
if (op.active != newActiveStatus) {
|
|
727
|
+
op.active = newActiveStatus;
|
|
728
|
+
emit OperatorActivationChanged(operator, newActiveStatus);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/// @dev Calculates the minimum license bond required to maintain active status
|
|
733
|
+
/// @return Minimum license bond (licenseRequiredBond * licenseActiveBps / 10000)
|
|
734
|
+
function _minLicenseBond() internal view returns (uint256) {
|
|
735
|
+
return (licenseRequiredBond * licenseActiveBps) / 10_000;
|
|
736
|
+
}
|
|
737
|
+
}
|