@rootzero/contracts 0.9.7 → 0.9.8
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/Core.sol +2 -2
- package/Events.sol +3 -3
- package/Utils.sol +2 -1
- package/core/Access.sol +2 -2
- package/core/Host.sol +4 -2
- package/core/{Context.sol → Runtime.sol} +3 -3
- package/events/Locked.sol +21 -0
- package/events/Position.sol +4 -2
- package/events/Received.sol +4 -3
- package/events/Spent.sol +4 -3
- package/events/Unlocked.sol +21 -0
- package/package.json +1 -1
- package/queries/Base.sol +2 -2
- package/utils/Actions.sol +16 -0
- package/events/Collateral.sol +0 -24
- package/events/Contexts.sol +0 -12
- package/events/Debt.sol +0 -25
package/Core.sol
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
|
-
// Aggregator: re-exports the core host,
|
|
4
|
+
// Aggregator: re-exports the core host, runtime, access, node-call, and validation layer.
|
|
5
5
|
// Import this file to bring the full rootzero host base layer into scope.
|
|
6
6
|
|
|
7
7
|
import { AccessControl } from "./core/Access.sol";
|
|
8
8
|
import { Balances } from "./core/Balances.sol";
|
|
9
|
-
import {
|
|
9
|
+
import { Runtime } from "./core/Runtime.sol";
|
|
10
10
|
import { Host, IHostIntroduction } from "./core/Host.sol";
|
|
11
11
|
import { FailedCall, NodeCalls } from "./core/Calls.sol";
|
|
12
12
|
import { Payable } from "./core/Payable.sol";
|
package/Events.sol
CHANGED
|
@@ -6,22 +6,22 @@ pragma solidity ^0.8.33;
|
|
|
6
6
|
|
|
7
7
|
import { AdminEvent } from "./events/Admin.sol";
|
|
8
8
|
import { AssetStatusEvent } from "./events/Asset.sol";
|
|
9
|
+
import { Actions } from "./utils/Actions.sol";
|
|
9
10
|
import { BalanceEvent } from "./events/Balance.sol";
|
|
10
|
-
import { CollateralEvent } from "./events/Collateral.sol";
|
|
11
11
|
import { CommandEvent } from "./events/Command.sol";
|
|
12
|
-
import { Contexts } from "./events/Contexts.sol";
|
|
13
|
-
import { DebtEvent } from "./events/Debt.sol";
|
|
14
12
|
import { PositionEvent } from "./events/Position.sol";
|
|
15
13
|
import { ReceivedEvent } from "./events/Received.sol";
|
|
16
14
|
import { EventEmitter } from "./events/Emitter.sol";
|
|
17
15
|
import { GuardEvent } from "./events/Guard.sol";
|
|
18
16
|
import { GuardianEvent } from "./events/Guardian.sol";
|
|
19
17
|
import { IntroductionEvent } from "./events/Introduction.sol";
|
|
18
|
+
import { LockedEvent } from "./events/Locked.sol";
|
|
20
19
|
import { NodeEvent } from "./events/Node.sol";
|
|
21
20
|
import { PeerEvent } from "./events/Peer.sol";
|
|
22
21
|
import { QueryEvent } from "./events/Query.sol";
|
|
23
22
|
import { RootedEvent } from "./events/Rooted.sol";
|
|
24
23
|
import { SpentEvent } from "./events/Spent.sol";
|
|
24
|
+
import { UnlockedEvent } from "./events/Unlocked.sol";
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
package/Utils.sol
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
|
-
// Aggregator: re-exports all utility libraries (Keys, Accounts, Assets, ECDSA, Ids, Layout, Utils, Value).
|
|
4
|
+
// Aggregator: re-exports all utility libraries (Keys, Accounts, Actions, Assets, ECDSA, Ids, Layout, Utils, Value).
|
|
5
5
|
// Import this file to access the full utility surface without managing individual paths.
|
|
6
6
|
|
|
7
7
|
import { Keys } from "./blocks/Keys.sol";
|
|
8
8
|
import { Accounts } from "./utils/Accounts.sol";
|
|
9
|
+
import { Actions } from "./utils/Actions.sol";
|
|
9
10
|
import { Amounts, Assets } from "./utils/Assets.sol";
|
|
10
11
|
import { ECDSA } from "./utils/ECDSA.sol";
|
|
11
12
|
import { Ids, Selectors } from "./utils/Ids.sol";
|
package/core/Access.sol
CHANGED
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.33;
|
|
|
3
3
|
|
|
4
4
|
import {NodeEvent} from "../events/Node.sol";
|
|
5
5
|
import {GuardianEvent} from "../events/Guardian.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {Runtime} from "./Runtime.sol";
|
|
7
7
|
import {Accounts} from "../utils/Accounts.sol";
|
|
8
8
|
import {Ids} from "../utils/Ids.sol";
|
|
9
9
|
import {addrOr} from "../utils/Utils.sol";
|
|
@@ -14,7 +14,7 @@ import {addrOr} from "../utils/Utils.sol";
|
|
|
14
14
|
/// mapping of externally trusted node IDs. Inbound trust is host-based:
|
|
15
15
|
/// trusted hosts, the commander, and this contract itself may interact
|
|
16
16
|
/// with the host through the guarded command and peer entrypoints.
|
|
17
|
-
abstract contract AccessControl is
|
|
17
|
+
abstract contract AccessControl is Runtime, NodeEvent, GuardianEvent {
|
|
18
18
|
/// @dev Trusted commander address. All calls from this address are implicitly trusted.
|
|
19
19
|
/// Defaults to `address(this)` when no external commander is provided.
|
|
20
20
|
address internal immutable commander;
|
package/core/Host.sol
CHANGED
|
@@ -7,6 +7,7 @@ import {Authorize} from "../commands/admin/Authorize.sol";
|
|
|
7
7
|
import {Dismiss} from "../commands/admin/Dismiss.sol";
|
|
8
8
|
import {Unauthorize} from "../commands/admin/Unauthorize.sol";
|
|
9
9
|
import {ExecutePayable} from "../commands/admin/Execute.sol";
|
|
10
|
+
import {Revoke} from "../guards/Revoke.sol";
|
|
10
11
|
import {IntroductionEvent} from "../events/Introduction.sol";
|
|
11
12
|
import {Ids} from "../utils/Ids.sol";
|
|
12
13
|
|
|
@@ -23,10 +24,11 @@ interface IHostIntroduction {
|
|
|
23
24
|
|
|
24
25
|
/// @title Host
|
|
25
26
|
/// @notice Abstract base contract for rootzero host implementations.
|
|
26
|
-
/// Inherits admin command support (authorize, unauthorize, executePayable)
|
|
27
|
+
/// Inherits admin command support (authorize, unauthorize, executePayable),
|
|
28
|
+
/// guardian management, the default guardian revoke action, and
|
|
27
29
|
/// optionally introduces itself to a commander host at deployment.
|
|
28
30
|
/// Accepts native ETH payments via the `receive` function.
|
|
29
|
-
abstract contract Host is Authorize, Unauthorize, Appoint, Dismiss, ExecutePayable, IntroductionEvent, IHostIntroduction {
|
|
31
|
+
abstract contract Host is Authorize, Unauthorize, Revoke, Appoint, Dismiss, ExecutePayable, IntroductionEvent, IHostIntroduction {
|
|
30
32
|
/// @param cmdr Commander address; passed to `AccessControl`.
|
|
31
33
|
/// If `cmdr` is a deployed contract, the host calls `introduce`
|
|
32
34
|
/// on it during construction.
|
|
@@ -7,9 +7,9 @@ import {Ids} from "../utils/Ids.sol";
|
|
|
7
7
|
|
|
8
8
|
using Cursors for Cur;
|
|
9
9
|
|
|
10
|
-
/// @title
|
|
11
|
-
/// @notice Shared
|
|
12
|
-
abstract contract
|
|
10
|
+
/// @title Runtime
|
|
11
|
+
/// @notice Shared runtime for host identity, native value identity, and block-stream cursors.
|
|
12
|
+
abstract contract Runtime {
|
|
13
13
|
/// @dev This contract's host node ID, set to `Ids.toHost(address(this))` at construction.
|
|
14
14
|
uint public immutable host = Ids.toHost(address(this));
|
|
15
15
|
/// @dev Asset ID for the native chain value (ETH), bound to the current chain at deployment.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.33;
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
+
|
|
6
|
+
/// @notice Emitted when an account locks an asset in a protocol operation.
|
|
7
|
+
abstract contract LockedEvent is EventEmitter {
|
|
8
|
+
string private constant ABI = "event Locked(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context)";
|
|
9
|
+
|
|
10
|
+
/// @param account Account identifier that locked the asset.
|
|
11
|
+
/// @param asset Asset identifier.
|
|
12
|
+
/// @param meta Asset metadata slot.
|
|
13
|
+
/// @param amount Amount locked.
|
|
14
|
+
/// @param action Primary operation hint from `Actions`.
|
|
15
|
+
/// @param context Reserved context value for future use.
|
|
16
|
+
event Locked(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context);
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
emit EventAbi(ABI);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/events/Position.sol
CHANGED
|
@@ -6,14 +6,16 @@ import {EventEmitter} from "./Emitter.sol";
|
|
|
6
6
|
/// @notice Emitted when the reported value of an asset-backed position changes or is observed.
|
|
7
7
|
/// A value of 0 should be interpreted as a closed position.
|
|
8
8
|
abstract contract PositionEvent is EventEmitter {
|
|
9
|
-
string private constant ABI = "event Position(bytes32 indexed account, bytes32 asset, bytes32 meta, uint value, uint queryId)";
|
|
9
|
+
string private constant ABI = "event Position(bytes32 indexed account, bytes32 asset, bytes32 meta, uint value, uint32 action, uint context, uint queryId)";
|
|
10
10
|
|
|
11
11
|
/// @param account Account identifier that owns or is associated with the position.
|
|
12
12
|
/// @param asset Asset identifier for the asset class.
|
|
13
13
|
/// @param meta Asset metadata slot carrying the position context.
|
|
14
14
|
/// @param value Context-specific position value; 0 indicates a closed position.
|
|
15
|
+
/// @param action Primary operation hint from `Actions`.
|
|
16
|
+
/// @param context Reserved context value for future use.
|
|
15
17
|
/// @param queryId Query ID associated with the position lookup or reporting context.
|
|
16
|
-
event Position(bytes32 indexed account, bytes32 asset, bytes32 meta, uint value, uint queryId);
|
|
18
|
+
event Position(bytes32 indexed account, bytes32 asset, bytes32 meta, uint value, uint32 action, uint context, uint queryId);
|
|
17
19
|
|
|
18
20
|
constructor() {
|
|
19
21
|
emit EventAbi(ABI);
|
package/events/Received.sol
CHANGED
|
@@ -5,14 +5,15 @@ import { EventEmitter } from "./Emitter.sol";
|
|
|
5
5
|
|
|
6
6
|
/// @notice Emitted when an account receives an asset in a protocol operation.
|
|
7
7
|
abstract contract ReceivedEvent is EventEmitter {
|
|
8
|
-
string private constant ABI = "event Received(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint context)";
|
|
8
|
+
string private constant ABI = "event Received(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context)";
|
|
9
9
|
|
|
10
10
|
/// @param account Account identifier that received the asset.
|
|
11
11
|
/// @param asset Asset identifier.
|
|
12
12
|
/// @param meta Asset metadata slot.
|
|
13
13
|
/// @param amount Amount received.
|
|
14
|
-
/// @param
|
|
15
|
-
|
|
14
|
+
/// @param action Primary operation hint from `Actions`.
|
|
15
|
+
/// @param context Reserved context value for future use.
|
|
16
|
+
event Received(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context);
|
|
16
17
|
|
|
17
18
|
constructor() {
|
|
18
19
|
emit EventAbi(ABI);
|
package/events/Spent.sol
CHANGED
|
@@ -5,14 +5,15 @@ import { EventEmitter } from "./Emitter.sol";
|
|
|
5
5
|
|
|
6
6
|
/// @notice Emitted when an account spends an asset in a protocol operation.
|
|
7
7
|
abstract contract SpentEvent is EventEmitter {
|
|
8
|
-
string private constant ABI = "event Spent(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint context)";
|
|
8
|
+
string private constant ABI = "event Spent(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context)";
|
|
9
9
|
|
|
10
10
|
/// @param account Account identifier that spent the asset.
|
|
11
11
|
/// @param asset Asset identifier.
|
|
12
12
|
/// @param meta Asset metadata slot.
|
|
13
13
|
/// @param amount Amount spent.
|
|
14
|
-
/// @param
|
|
15
|
-
|
|
14
|
+
/// @param action Primary operation hint from `Actions`.
|
|
15
|
+
/// @param context Reserved context value for future use.
|
|
16
|
+
event Spent(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context);
|
|
16
17
|
|
|
17
18
|
constructor() {
|
|
18
19
|
emit EventAbi(ABI);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.33;
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
+
|
|
6
|
+
/// @notice Emitted when an account unlocks an asset in a protocol operation.
|
|
7
|
+
abstract contract UnlockedEvent is EventEmitter {
|
|
8
|
+
string private constant ABI = "event Unlocked(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context)";
|
|
9
|
+
|
|
10
|
+
/// @param account Account identifier that unlocked the asset.
|
|
11
|
+
/// @param asset Asset identifier.
|
|
12
|
+
/// @param meta Asset metadata slot.
|
|
13
|
+
/// @param amount Amount unlocked.
|
|
14
|
+
/// @param action Primary operation hint from `Actions`.
|
|
15
|
+
/// @param context Reserved context value for future use.
|
|
16
|
+
event Unlocked(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint32 action, uint context);
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
emit EventAbi(ABI);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
package/queries/Base.sol
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
pragma solidity ^0.8.33;
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Runtime } from "../core/Runtime.sol";
|
|
5
5
|
import { QueryEvent } from "../events/Query.sol";
|
|
6
6
|
import { Ids, Selectors } from "../utils/Ids.sol";
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ function encodeQueryCall(uint target, bytes calldata request) pure returns (byte
|
|
|
20
20
|
/// @notice Abstract base for rootzero query contracts.
|
|
21
21
|
/// Queries are view-only entry points that consume a block-stream request and
|
|
22
22
|
/// return a block-stream response.
|
|
23
|
-
abstract contract QueryBase is
|
|
23
|
+
abstract contract QueryBase is Runtime, QueryEvent {
|
|
24
24
|
|
|
25
25
|
/// @notice Derive the deterministic node ID for a named query on this contract.
|
|
26
26
|
/// The ID encodes the ABI selector of `name(bytes)` and `address(this)`,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.33;
|
|
3
|
+
|
|
4
|
+
library Actions {
|
|
5
|
+
uint32 constant None = 0;
|
|
6
|
+
uint32 constant Transfer = 1;
|
|
7
|
+
uint32 constant Deposit = 2;
|
|
8
|
+
uint32 constant Withdraw = 3;
|
|
9
|
+
uint32 constant Fee = 4;
|
|
10
|
+
uint32 constant Mint = 5;
|
|
11
|
+
uint32 constant Burn = 6;
|
|
12
|
+
uint32 constant Swap = 7;
|
|
13
|
+
uint32 constant Borrow = 8;
|
|
14
|
+
uint32 constant Repay = 9;
|
|
15
|
+
uint32 constant Liquidate = 10;
|
|
16
|
+
}
|
package/events/Collateral.sol
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
-
|
|
6
|
-
/// @notice Emitted when an account's collateral position changes.
|
|
7
|
-
/// Off-chain indexers should query the access command to retrieve the precise collateral details.
|
|
8
|
-
abstract contract CollateralEvent is EventEmitter {
|
|
9
|
-
string private constant ABI = "event Collateral(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint access)";
|
|
10
|
-
|
|
11
|
-
/// @param account Account identifier that holds the collateral.
|
|
12
|
-
/// @param asset Asset identifier of the collateral.
|
|
13
|
-
/// @param meta Asset metadata slot.
|
|
14
|
-
/// @param amount Current collateral amount.
|
|
15
|
-
/// @param access Command ID or context identifier associated with this change.
|
|
16
|
-
event Collateral(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint access);
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
emit EventAbi(ABI);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
package/events/Contexts.sol
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
/// @notice Standard context codes for generic asset activity events.
|
|
5
|
-
library Contexts {
|
|
6
|
-
uint constant Deposit = 1;
|
|
7
|
-
uint constant Withdraw = 2;
|
|
8
|
-
uint constant Fee = 3;
|
|
9
|
-
uint constant Mint = 4;
|
|
10
|
-
uint constant Burn = 5;
|
|
11
|
-
uint constant Swap = 6;
|
|
12
|
-
}
|
package/events/Debt.sol
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
-
|
|
6
|
-
/// @notice Emitted when an account's debt position changes.
|
|
7
|
-
/// Off-chain indexers should query the access command to retrieve precise debt details.
|
|
8
|
-
abstract contract DebtEvent is EventEmitter {
|
|
9
|
-
string private constant ABI = "event Debt(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint mode, uint access)";
|
|
10
|
-
|
|
11
|
-
/// @param account Account identifier that holds the debt.
|
|
12
|
-
/// @param asset Asset identifier of the debt.
|
|
13
|
-
/// @param meta Asset metadata slot.
|
|
14
|
-
/// @param amount Current debt amount.
|
|
15
|
-
/// @param mode Debt mode or type discriminant (implementation-defined).
|
|
16
|
-
/// @param access Command ID or context identifier associated with this change.
|
|
17
|
-
event Debt(bytes32 indexed account, bytes32 asset, bytes32 meta, uint amount, uint mode, uint access);
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
emit EventAbi(ABI);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|