CustodyBridge
Last updated
Was this helpful?
Last updated
Was this helpful?
A helper (bridge) contract that coordinates moving securities between a broker's net balance in BrokerNetSettlement and a user's DRS lot in Token. Example usage:
moveToDRS(broker, user, amount, costBasis, acquisitionDate)
Subtracts amount
from broker's netBalance in BrokerNetSettlement.
Creates a new lot in Token for user
.
moveFromDRS(user, broker, tokenId, rawQuantity)
Invalidates or partially sells from the user's lot in Token.
Adds rawQuantity
back to broker's netBalance in BrokerNetSettlement.
Moves amount
securities from broker
's net balance into a new DRS lot for user
. This effectively reduces the broker's netBalance by amount
and calls createLot
in CapitalAsset
.
Parameters
broker
address
The broker address in BrokerNetSettlement.
user
address
The end user who will own the new DRS lot.
amount
uint256
The quantity to move from netBalance to the new lot.
costBasis
uint96
The raw cost basis per share (if relevant).
acquisitionDate
uint64
A timestamp or date representing the original purchase date.
uri
string
The URI of the lot.
data
bytes
Additional data associated with the lot.
Moves rawQuantity
securities from a user's DRS lot back to a broker's netBalance. We call sellFromToken
on the CapitalAsset to partially or fully remove from the lot, then increment the broker's netBalance in BrokerNetSettlement.
Parameters
user
address
The user whose DRS lot is being reduced.
broker
address
The broker that regains these securities in netBalance.
tokenId
bytes32
The user's lot ID in CapitalAsset.
rawQuantity
uint96
The raw quantity to remove from the lot (not the real post-split quantity).
uri
string
The URI of the lot.
data
bytes
Additional data associated with the lot.
*The underlying step to reduce a broker's netBalance by amount
. We can do this by calling brokerNetSettlement's existing functions:
brokerNetSettlement.transfer(...) from broker to address(0) if allowed
or brokerNetSettlement.burn(...) if broker calls it For simplicity, we do a "batch" approach with negative deltas if the function is public. We illustrate a direct approach here, but it might need broker's signature in a real scenario.*
Internal function to increase a broker's netBalance in BrokerNetSettlement. Utilizes the BrokerNetSettlement's createLot
function to add securities.
Parameters
broker
address
The broker whose netBalance is to be increased.
amount
uint256
The amount to increase.
Allows the owner to update the BrokerNetSettlement address.
Parameters
_clearingLedger
address
The new BrokerNetSettlement address.
Allows the owner to update the Token address.
Parameters
_baseAsset
address
The new Token address.
(Optional) convenience function for advanced bridging, e.g. user -> user direct or multiple brokers in one go, etc. Kept minimal in this example.