DelegationTokensManager
Contract Name | GitHub | Deployed Contract Address | Contract Implemented | Initialization Data |
DelegatioTokensManager | Coming soon | Coming soon | IDelegatioTokensManager , LazyInitCapableElement |
The DelegationTokensManager is the dedicated Component of a Delegation that allows the token supported by an Organization to be wrapped as Delegation tokens, which can be used to vote in the Delegation's internal proposals such as
TransferManagerProposal
and VoteProposal
.The Organization can set as its supported token to be wrapped an:
- ERC20 or Item using the Interoperable Interface
- ERC1155 or Items using the Main Interface
- ETH
The
DelegationTokensManager
must be initialized with the following data, as per the initialization pattern that is valid for a LazyInitCapableElement
contract:function _lazyInit(bytes memory lazyInitData) internal override returns (bytes memory) {
ticker = abi.decode(lazyInitData, (string));
itemMainInterfaceAddress = IItemProjectionFactory(projectionAddress = initializer).mainInterface();
collectionId = IItemProjection(projectionAddress).collectionId();
return "";
}
ticker
-> this is the ticker used to generatename
andsymbol
of the Delegation tokens.
Upon initialization of the
DelegationTokensManager
, the Delegations Item Collection is retrieved and saved in the DelegationTokensManager
contract. The Delegations Items Collection is created and hosted by the Delegations Factory.When a token is sent to be wrapped in the
DelegationTokensManager
, it interacts with the Factory asking it to mint the Delegation token. So all the Delegations share the same Items Collection.Regardless of its standard, the token you're wrapping must be the supported token defined by the Organization's
DelegationsManager
.To wrap an ERC1155 (or an Item using the Main Interface), the
safeTransferFrom
function is used (or safeBatchTransferFrom
, if wrapping multiple ERC1155s for multiple Organizations) to send the amount of tokens to the DelegationTokensManager
contract, which implements the onERC1155Received
and onERC1155BatchReceived
methods. When wrapping a single ERC1155, the following encoded parameters must be passed as data in the
safeTransferFrom
function:(address delegationsManagerAddress, address receiver, bytes memory response) = abi.decode(data, (address, address, bytes));
delegationsManagerAddress
-> this is the address of the Organization'sDelegationsManager
.receiver
-> this is the address that will receive the delegation Items. Pass asaddress(0)
to set the receiver asmsg.sender
.response
-> pass this as empty.
When wrapping multiple ERC1155s, an encoded array of bytes containing the following parameters for each ERC1155 (i.e, for each id) must be passed as data in the
safeBatchTransferFrom
function: bytes[] memory datas = abi.decode(data, (bytes[]));
(address delegationsManagerAddress, address receiver, bytes memory response) = abi.decode(data, (address, address, bytes));
delegationsManagerAddress
-> this is the address of the Organization'sDelegationsManager
.receiver
-> this is the address that will receive the delegation Items. Pass asaddress(0)
to set the receiver asmsg.sender
.response
-> pass this as empty.
To wrap an ERC20 (or an Item using the Interoperable Interface) or ETH, the
wrap
function is used to send the amount of tokens to the DelegationTokensManager
contract.function wrap(address sourceDelegationsManagerAddress, bytes memory permitSignature, uint256 amount, address receiver) payable external returns(uint256 wrappedObjectId);
The
wrap
function takes as input:sourceDelegationsManagerAddress
-> this is the address of the Organization'sDelegationsManager
.permitSignature
-> bytes parameter containing the encodedv
,r
,s
anddeadline
parameters to perform apermit
approval. IfpermitSignature
is passed empty, the classicapprove
will be required.amount
-> amount of tokens to be wrapped.receiver
-> this is the address that will receive the delegation Items. Pass asaddress(0)
to set the receiver asmsg.sender
.
In the case of wrapping ETH, the
amount
parameter must be equal to the msg.value
amount sent in the transaction.The
wrap
function internally retrieves the supported Organization token address using the sourceDelegationsManagerAddress
parameter.To unwrap a delegation token, and thereby retrieve the original token, transfer the delegation token to the
DelegationTokensManager
contract using the safeTransferFrom
function (or, for multi-unwraps, the safeBatchTransferFrom
one). You must unwrap via the Main Interface, not the Item's Interoperable Interface.
The delegation token is burned, and the original token is transferred from the general Delegation's
treasuryManager
to the receiver address.When unwrapping tokens of a single id, the following encoded parameters must be passed as data the
safeTransferFrom
function:(address delegationsManagerAddress, address receiver, bytes memory response) = abi.decode(data, (address, address, bytes));
delegationsManagerAddress
-> pass this asaddress(0)
.receiver
-> this is the address that will receive the original tokens. To set the receiver asmsg.sender
, pass it asaddress(0)
.response
-> this can be passed as empty or, if the original token is an ERC1155, with data to be executed along inside theTreasuryManager
transfer.
When unwrapping multiple tokens, an encoded array of bytes containing the following parameters must be passed as data in the
safeBatchTransferFrom
function:bytes[] memory datas = abi.decode(data, (bytes[]));
(address delegationsManagerAddress, address receiver, bytes memory response) = abi.decode(data, (address, address, bytes));
delegationsManagerAddress
-> pass this as address(0).receiver
-> this is the address that will receive the original tokens. To set the receiver asmsg.sender
, pass it asaddress(0)
.response
-> this can be passed as empty or, if the original token is an ERC1155, with data to be executed inside theTreasuryManager
transfer.
If you're unwrapping an ERC20/Item Interoperable Interface or ETH, you can unwrap any quantity.
If you're unwrapping an 1155 Item using the Main Interface you can unwrap any quantity since both the Delegation Item and the original Item have 18 decimals.
If you're unwrapping a classic ERC1155 with 0 decimals, you can unwrap only 1e18 to give back 1 1155 token, 2e18 to give back 2 1155 tokens, 3e18 to give back 3 1155 tokens, and so on of a Delegation Item.
Last modified 1yr ago