@bananapus/suckers-v6 0.0.76 → 0.0.78

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.
@@ -5,6 +5,7 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
  import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
6
6
  import {IJBProjects} from "@bananapus/core-v6/src/interfaces/IJBProjects.sol";
7
7
  import {IJBTokens} from "@bananapus/core-v6/src/interfaces/IJBTokens.sol";
8
+ import {JBAccountingSnapshot} from "../structs/JBAccountingSnapshot.sol";
8
9
  import {JBClaim} from "../structs/JBClaim.sol";
9
10
  import {JBInboxTreeRoot} from "../structs/JBInboxTreeRoot.sol";
10
11
  import {JBOutboxTree} from "../structs/JBOutboxTree.sol";
@@ -18,6 +19,11 @@ import {JBTokenMapping} from "../structs/JBTokenMapping.sol";
18
19
  interface IJBSucker is IERC165 {
19
20
  // Events
20
21
 
22
+ /// @notice Emitted when peer-chain accounting data is sent without a merkle-root update.
23
+ /// @param sourceTimestamp The source freshness key assigned to the snapshot.
24
+ /// @param caller The address that initiated the send.
25
+ event AccountingDataSynced(uint256 sourceTimestamp, address caller);
26
+
21
27
  /// @notice Emitted when a beneficiary claims bridged tokens from the inbox tree.
22
28
  /// @param beneficiary The beneficiary receiving the tokens.
23
29
  /// @param token The terminal token address.
@@ -207,6 +213,10 @@ interface IJBSucker is IERC165 {
207
213
  /// @param claimData The claim data including token, leaf, and proof.
208
214
  function claim(JBClaim calldata claimData) external;
209
215
 
216
+ /// @notice Receive peer-chain accounting data from the remote sucker without a merkle-root update.
217
+ /// @param snapshot The accounting snapshot to store.
218
+ function fromRemoteAccounting(JBAccountingSnapshot calldata snapshot) external;
219
+
210
220
  /// @notice Map a local token to a remote token for bridging.
211
221
  /// @param map The token mapping to add.
212
222
  function mapToken(JBTokenMapping calldata map) external payable;
@@ -232,6 +242,10 @@ interface IJBSucker is IERC165 {
232
242
  )
233
243
  external;
234
244
 
245
+ /// @notice Send peer-chain accounting data without sending an outbox root or paying the registry `toRemoteFee`.
246
+ /// @dev The caller still provides bridge transport payment through `msg.value` when the bridge requires it.
247
+ function syncAccountingData() external payable;
248
+
235
249
  /// @notice Send the outbox tree root and bridged assets to the remote peer.
236
250
  /// @param token The terminal token to bridge.
237
251
  function toRemote(address token) external payable;
@@ -13,6 +13,7 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
13
13
 
14
14
  import {IJBPeerChainAdjustedAccounts} from "../interfaces/IJBPeerChainAdjustedAccounts.sol";
15
15
  import {JBPeerChainAdjustedAccountsLib} from "./JBPeerChainAdjustedAccountsLib.sol";
16
+ import {JBAccountingSnapshot} from "../structs/JBAccountingSnapshot.sol";
16
17
  import {JBInboxTreeRoot} from "../structs/JBInboxTreeRoot.sol";
17
18
  import {JBMessageRoot} from "../structs/JBMessageRoot.sol";
18
19
  import {JBSourceContext} from "../structs/JBSourceContext.sol";
@@ -36,6 +37,37 @@ library JBSuckerLib {
36
37
  // ---------------------- external transactions ---------------------- //
37
38
  //*********************************************************************//
38
39
 
40
+ /// @notice Build the cross-chain accounting snapshot (total supply plus per-context surplus and balance).
41
+ /// @dev Extracted from `JBSucker.syncAccountingData` to reduce child contract bytecode. Called via DELEGATECALL.
42
+ /// The snapshot carries each context's surplus and balance in its own currency, without price-feed valuation.
43
+ /// @param directory The JB directory to look up controllers and terminals.
44
+ /// @param projectId The project ID.
45
+ /// @param messageVersion The message format version.
46
+ /// @param sourceTimestamp The monotonic source freshness key for this snapshot.
47
+ /// @return snapshot The constructed accounting snapshot.
48
+ function buildAccountingSnapshot(
49
+ IJBDirectory directory,
50
+ uint256 projectId,
51
+ uint8 messageVersion,
52
+ uint256 sourceTimestamp
53
+ )
54
+ external
55
+ view
56
+ returns (JBAccountingSnapshot memory snapshot)
57
+ {
58
+ // Snapshot the project's per-context surplus and balance, un-valued. No price oracle is consulted on send.
59
+ (uint256 localTotalSupply, JBSourceContext[] memory sourceContexts) =
60
+ _snapshotAccountsOf({directory: directory, projectId: projectId});
61
+
62
+ // Construct the accounting-only message without any token-local merkle root.
63
+ snapshot = JBAccountingSnapshot({
64
+ version: messageVersion,
65
+ sourceTotalSupply: localTotalSupply,
66
+ sourceContexts: sourceContexts,
67
+ sourceTimestamp: sourceTimestamp
68
+ });
69
+ }
70
+
39
71
  /// @notice Build the cross-chain snapshot message (total supply plus per-context surplus and balance).
40
72
  /// @dev Extracted from `JBSucker._buildSnapshotAndSend` to reduce child contract bytecode. Called via DELEGATECALL.
41
73
  /// The snapshot carries each context's surplus and balance in its own currency, without price-feed valuation.
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {JBSourceContext} from "./JBSourceContext.sol";
5
+
6
+ /// @notice A peer-chain accounting snapshot, without any token-local merkle root or transported value.
7
+ /// @custom:member version The message format version. Used to reject incompatible messages.
8
+ /// @custom:member sourceTotalSupply The total token supply (including reserved tokens) on the source chain at the
9
+ /// time the message was sent. Used by the receiving chain to track cross-chain supply for cash out tax calculations.
10
+ /// @custom:member sourceContexts The source chain's surplus and balance per accounting context, each in the context's
11
+ /// own currency and decimals, un-valued.
12
+ /// @custom:member sourceTimestamp A monotonic source-chain freshness key for the snapshot. Used by the receiving
13
+ /// chain to reject stale surplus/balance/supply updates.
14
+ struct JBAccountingSnapshot {
15
+ uint8 version;
16
+ uint256 sourceTotalSupply;
17
+ JBSourceContext[] sourceContexts;
18
+ uint256 sourceTimestamp;
19
+ }