Skip to content

Commit

Permalink
migrate to assetId on the vault interface; (#20)
Browse files Browse the repository at this point in the history
DRAFT PR: show how we're going to modify the vault interface to support multiple assets 
within the vaults
  • Loading branch information
jake-nyquist authored May 19, 2022
1 parent 8248a5e commit 923a972
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
62 changes: 39 additions & 23 deletions src/interfaces/IHookVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,31 +25,44 @@ 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,
uint256 expiry,
address beneficialOwner
);

event EntitlementCleared(address beneficialOwner);

event BeneficialOwnerSet(address beneficialOwner, address setBy);
/// @notice emitted when an entitlment is cleared from an asset
event EntitlementCleared(uint256 assetId, address beneficialOwner);

event AssetWithdrawn(address caller, address assetReceiver);
/// @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,
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
/// @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(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
Expand All @@ -63,35 +79,35 @@ 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() 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()
/// @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
returns (bool isActive, address operator);

/// @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);
}
4 changes: 4 additions & 0 deletions src/lib/Entitlements.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ library Entitlements {
"address beneficialOwner,",
"address operator,",
"address vaultAddress,",
"uint256 assetId,",
"uint256 expiry",
")"
)
Expand All @@ -27,6 +28,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;
}
Expand All @@ -44,6 +47,7 @@ library Entitlements {
entitlement.beneficialOwner,
entitlement.operator,
entitlement.vaultAddress,
entitlement.assetId,
entitlement.expiry
)
);
Expand Down

0 comments on commit 923a972

Please sign in to comment.