From cbbf546258469ac90100f1e553f800b4d31e88de Mon Sep 17 00:00:00 2001 From: "Jacob R. Nyquist" Date: Tue, 17 May 2022 16:26:25 -0400 Subject: [PATCH 1/2] migrate to assetId on the vault interface; --- src/interfaces/IHookVault.sol | 37 +++++++++++++++++++++++------------ src/lib/Entitlements.sol | 2 ++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/interfaces/IHookVault.sol b/src/interfaces/IHookVault.sol index bdca79f..b54e0af 100644 --- a/src/interfaces/IHookVault.sol +++ b/src/interfaces/IHookVault.sol @@ -13,6 +13,9 @@ import "../lib/Entitlements.sol"; /// the utility of the asset. Specifically, that means this structure should not be used in order to /// hold assets in escrow away from owner to benefit an owner for a short period of time. /// +/// The vault can work with multiple assets via the assetId, where the asset or set of assets covered by +/// each segment is granted an individual id. +/// /// ENTITLEMENTS - /// (1) only one entitlement can be placed at a time. /// (2) entitlements must expire, but can also be cleared by the entitled party @@ -23,30 +26,35 @@ import "../lib/Entitlements.sol"; /// interface IHookVault { event EntitlementImposed( + uint256 assetId, address entitledAccout, uint256 expiry, address beneficialOwner ); - event EntitlementCleared(address beneficialOwner); - - event BeneficialOwnerSet(address beneficialOwner, address setBy); + event EntitlementCleared(uint256 assetId, address beneficialOwner); - event AssetWithdrawn(address caller, address assetReceiver); + event BeneficialOwnerSet( + uint256 assetId, + address beneficialOwner, + address setBy + ); event AssetReceived( address owner, address sender, address contractAddress, - uint256 tokenId + uint256 tokenId, + uint256 assetId ); - /// @notice Withdrawl an unencumbered asset from this vault - function withdrawalAsset() external; + /// @notice Withdrawal an unencumbered asset from this vault + function withdrawalAsset(uint256 assetId) external; /// @notice setBeneficialOwner updates the current address that can claim the asset when it is free of entitlements. /// @param newBeneficialOwner the account of the person who is able to withdrawl when there are no entitlements. - function setBeneficialOwner(address newBeneficialOwner) external; + function setBeneficialOwner(uint256 assetId, address newBeneficialOwner) + external; /// @notice Add an entitlement claim to the asset held within the contract /// @param entitlement The entitlement to impose onto the contract @@ -78,14 +86,14 @@ interface IHookVault { returns (bool success); /// @notice looks up the current beneficial owner of the underlying asset - function getBeneficialOwner() external view returns (address); + function getBeneficialOwner(uint256 assetId) external view returns (address); /// @notice checks if the asset is currently stored in the vault - function getHoldsAsset() external view returns (bool); + function getHoldsAsset(uint256 assetId) external view returns (bool); - function assetAddress() external view returns (address); + function assetAddress(uint256 assetId) external view returns (address); - function getCurrentEntitlementOperator() + function getCurrentEntitlementOperator(uint256 assetId) external view returns (bool isActive, address operator); @@ -93,5 +101,8 @@ interface IHookVault { /// @notice Looks up the expiration timestamp of the current entitlement /// @dev returns the 0 if no entitlement is set /// @return expiry the block timestamp after which the entitlement expires - function entitlementExpiration() external view returns (uint256 expiry); + function entitlementExpiration(uint256 assetId) + external + view + returns (uint256 expiry); } diff --git a/src/lib/Entitlements.sol b/src/lib/Entitlements.sol index e6906fa..dc07e43 100644 --- a/src/lib/Entitlements.sol +++ b/src/lib/Entitlements.sol @@ -27,6 +27,8 @@ library Entitlements { address operator; /// @notice the contract address for the vault that contains the underlying assets address vaultAddress; + /// @notice the assetId of the asset or assets within the vault + uint256 assetId; /// @notice the block timestamp after which the asset is free of the entitlement uint256 expiry; } From 6afd33d788db15bf54ef0afb1f986f0f04f7d5b7 Mon Sep 17 00:00:00 2001 From: "Jacob R. Nyquist" Date: Tue, 17 May 2022 16:38:30 -0400 Subject: [PATCH 2/2] update additional fields on the entitlement --- src/interfaces/IHookVault.sol | 25 +++++++++++++++---------- src/lib/Entitlements.sol | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/interfaces/IHookVault.sol b/src/interfaces/IHookVault.sol index b54e0af..0751920 100644 --- a/src/interfaces/IHookVault.sol +++ b/src/interfaces/IHookVault.sol @@ -25,6 +25,7 @@ import "../lib/Entitlements.sol"; /// (5) the beneficial owner cannot modify the beneficial owner while an entitlement is in place /// interface IHookVault { + /// @notice emitted when an entitlement is placed on an asset event EntitlementImposed( uint256 assetId, address entitledAccout, @@ -32,14 +33,19 @@ interface IHookVault { address beneficialOwner ); + /// @notice emitted when an entitlment is cleared from an asset event EntitlementCleared(uint256 assetId, address beneficialOwner); + /// @notice emitted when the beneficial owner of an asset changes + /// @dev it is not required that this event is emitted when an entitlement is + /// imposed that also modifies the beneficial owner. event BeneficialOwnerSet( uint256 assetId, address beneficialOwner, address setBy ); + /// @notice emitted when an asset is added into the vault event AssetReceived( address owner, address sender, @@ -49,9 +55,11 @@ interface IHookVault { ); /// @notice Withdrawal an unencumbered asset from this vault + /// @param assetId the asset to remove from the vault function withdrawalAsset(uint256 assetId) external; /// @notice setBeneficialOwner updates the current address that can claim the asset when it is free of entitlements. + /// @param assetId the id of the subject asset to impose the entitlement /// @param newBeneficialOwner the account of the person who is able to withdrawl when there are no entitlements. function setBeneficialOwner(uint256 assetId, address newBeneficialOwner) external; @@ -71,19 +79,14 @@ interface IHookVault { external; /// @notice Allowes the entitled address to release their claim on the asset - function clearEntitlement() external; + /// @param assetId the id of the asset to clear + function clearEntitlement(uint256 assetId) external; /// @notice Removes the active entitlement from a vault and returns the asset to the beneficial owner /// @param reciever the intended reciever of the asset - function clearEntitlementAndDistribute(address reciever) external; - - /// @param to Destination address of transaction. - /// @param data Data payload of transaction. - /// @return success if the call was successful. - function execTransaction(address to, bytes memory data) - external - payable - returns (bool success); + /// @param assetId the Id of the asset to clear + function clearEntitlementAndDistribute(uint256 assetId, address reciever) + external; /// @notice looks up the current beneficial owner of the underlying asset function getBeneficialOwner(uint256 assetId) external view returns (address); @@ -93,6 +96,8 @@ interface IHookVault { function assetAddress(uint256 assetId) external view returns (address); + /// @notice looks up the current operator of an entitlemnt on an asset + /// @param assetId the id of the underlying asset function getCurrentEntitlementOperator(uint256 assetId) external view diff --git a/src/lib/Entitlements.sol b/src/lib/Entitlements.sol index dc07e43..684648c 100644 --- a/src/lib/Entitlements.sol +++ b/src/lib/Entitlements.sol @@ -13,6 +13,7 @@ library Entitlements { "address beneficialOwner,", "address operator,", "address vaultAddress,", + "uint256 assetId,", "uint256 expiry", ")" ) @@ -46,6 +47,7 @@ library Entitlements { entitlement.beneficialOwner, entitlement.operator, entitlement.vaultAddress, + entitlement.assetId, entitlement.expiry ) );