# IFrictionlessTreasuryManager

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/interface/IFrictionlessTreasuryManager.sol)

**Author:** DEFYCA Labs S.à.r.l

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The IFrictionlessTreasuryManager is responsible for all token operations, minting, transferring and burning in the Frictionless protocol. The tokens and their lifecycles are defined in the public README for the Frictionless protocol at <https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/tree/main?ref\\_type=heads#tokens-overview>

## Functions

### setTokensInitData

*Sets and associates the implementation authority with the associated token type*

```solidity
function setTokensInitData(FrictionlessTokenInitData[] calldata initDataArr_) external;
```

**Parameters**

| Name           | Type                          | Description                                                                                                            |
| -------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `initDataArr_` | `FrictionlessTokenInitData[]` | the `FrictionlessTokenInitData` configuration associating the implementation authority with the associated token type. |

### mintFundDepositForTreasury

*Mints a Fund Deposit Token in the specified currency/IBAN pair. This function is invoked to create the genesis mint of the deposit token in the PROTOCOL\_TREASURY.*

```solidity
function mintFundDepositForTreasury(
    IFrictionlessFundDepositToken.FFDImmutableData calldata depositData,
    address treasuryAddress,
    uint256 amount
) external returns (address);
```

**Parameters**

| Name              | Type                                             | Description                                                    |
| ----------------- | ------------------------------------------------ | -------------------------------------------------------------- |
| `depositData`     | `IFrictionlessFundDepositToken.FFDImmutableData` | the immutable deposit data for the token                       |
| `treasuryAddress` | `address`                                        | the address of the treasury, which receives the deposit tokens |
| `amount`          | `uint256`                                        | the amount of tokens                                           |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                                                                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `address` | address of the token minted emits `FrictionlessTokenMinted` event throws error `FrictionlessTreasuryManagerInvalidDepositData` if the deposit data is invalid. requires the depositData.currency to be a 3 letter currency code requires the depositData.description to be not empty requires the depositData.IBAN to be not empty |

### mintDigitalSecurity

*Mints a FrictionlessDigitalSecurityToken as the future dated cash distribution from the underlying FrictionlessOnChainAssetToken. This function is invoked to create the genesis mint of the deposit token in the PROTOCOL\_TREASURY.*

```solidity
function mintDigitalSecurity(
    IFrictionlessDigitalSecurityToken.FDSImmutableData memory initData,
    IFrictionlessDigitalSecurityToken.FDSMutableData memory updateData,
    uint256 amount,
    address userAddress
) external returns (address);
```

**Parameters**

| Name          | Type                                                 | Description                                                                  |
| ------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------- |
| `initData`    | `IFrictionlessDigitalSecurityToken.FDSImmutableData` | the immutable data for the token                                             |
| `updateData`  | `IFrictionlessDigitalSecurityToken.FDSMutableData`   | the mutable data for the token                                               |
| `amount`      | `uint256`                                            | the amount of tokens                                                         |
| `userAddress` | `address`                                            | the address of the protocol user, which receives the digital security tokens |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                                                                                 |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `address` | address of the token minted emits `FrictionlessTokenMinted` event throws error `FrictionlessTreasuryManagerInvalidFDSImmutableData` if the initData is invalid. requires the initData.currency to be a 3 letter currency code requires the initData.onChainAssetAddress to be non 0 address |

### mintOnChainAsset

*Mints a FrictionlessOnChainAssetToken as the representation of the asset to be securitized, fractionalized & sold. This function is invoked to create the genesis mint of the deposit token to the PERMISSIONED\_CUSTODIAN.*

```solidity
function mintOnChainAsset(
    IFrictionlessOnChainAssetToken.FOCASpecData memory specData,
    IFrictionlessOnChainAssetToken.FOCAIssuanceData memory issuanceData,
    IFrictionlessOnChainAssetToken.FOCAUpdateData memory updateData,
    address custodianAddress
) external returns (address);
```

**Parameters**

| Name               | Type                                              | Description                                                                               |
| ------------------ | ------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `specData`         | `IFrictionlessOnChainAssetToken.FOCASpecData`     | the immutable data for the token                                                          |
| `issuanceData`     | `IFrictionlessOnChainAssetToken.FOCAIssuanceData` | the issuance data for the token                                                           |
| `updateData`       | `IFrictionlessOnChainAssetToken.FOCAUpdateData`   | the update data for the token                                                             |
| `custodianAddress` | `address`                                         | the address of the protocol custodian, which receives the `FrictionlessOnChainAssetToken` |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                         |
| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `address` | address of the token minted emits `FrictionlessTokenMinted` event throws error `FrictionlessTreasuryManagerInvalidFOCASpecData` or `FrictionlessTreasuryManagerInvalidFOCAIssuanceData` if the specData or issuanceData is invalid. |

### mintTokenForUser

*Used to increase the mint of a Frictionless token which already exists.*

```solidity
function mintTokenForUser(address token, address userAddress, uint256 amount) external;
```

**Parameters**

| Name          | Type      | Description                                                        |
| ------------- | --------- | ------------------------------------------------------------------ |
| `token`       | `address` | the address of the token                                           |
| `userAddress` | `address` | the address to min the token to                                    |
| `amount`      | `uint256` | the amount of tokens to mint emits `FrictionlessTokenMinted` event |

### transferToken

*Used to increase the mint of a Frictionless token which already exists.*

```solidity
function transferToken(address token, address userAddressFrom, address userAddressTo, uint256 amount) external;
```

**Parameters**

| Name              | Type      | Description                                                             |
| ----------------- | --------- | ----------------------------------------------------------------------- |
| `token`           | `address` | the address of the token                                                |
| `userAddressFrom` | `address` | the address to transfer the tokens from                                 |
| `userAddressTo`   | `address` | the address to transfer the tokens to                                   |
| `amount`          | `uint256` | the amount of tokens to mint emits `FrictionlessTokenTransferred` event |

### burnToken

*Used to burn an amount of Frictionless token which already exists.*

```solidity
function burnToken(address token, address userAddress, uint256 amount) external;
```

**Parameters**

| Name          | Type      | Description                                                        |
| ------------- | --------- | ------------------------------------------------------------------ |
| `token`       | `address` | the address of the token                                           |
| `userAddress` | `address` | the address to burn the tokens from                                |
| `amount`      | `uint256` | the amount of tokens to burn emits `FrictionlessTokenBurned` event |

### getFundDepositToken

*returns the address of the fund deposit token by currency and fundIBAN*

```solidity
function getFundDepositToken(string calldata currency_, string calldata fundIBAN_) external view returns (address);
```

**Parameters**

| Name        | Type     | Description                            |
| ----------- | -------- | -------------------------------------- |
| `currency_` | `string` | the currency of the fund deposit token |
| `fundIBAN_` | `string` | the fundIBAN of the fund deposit token |

**Returns**

| Name     | Type      | Description                                                               |
| -------- | --------- | ------------------------------------------------------------------------- |
| `<none>` | `address` | the address of the fund deposit token for specified currency and fundIBAN |

### getFundDepositTokenKey

*returns fund deposit token key by currency and fundIBAN*

```solidity
function getFundDepositTokenKey(string memory currency_, string memory fundIBAN_) external pure returns (bytes32);
```

**Parameters**

| Name        | Type     | Description                                     |
| ----------- | -------- | ----------------------------------------------- |
| `currency_` | `string` | the currency of the fund deposit token you need |
| `fundIBAN_` | `string` | the fundIBAN of the fund deposit token you need |

**Returns**

| Name     | Type      | Description                |
| -------- | --------- | -------------------------- |
| `<none>` | `bytes32` | the fund deposit token key |

## Events

### FrictionlessTokenMinted

*Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is minted.*

```solidity
event FrictionlessTokenMinted(
    IBasicFrictionlessToken.FrictionlessTokenTypes tokenType,
    address token,
    string tokenName,
    string tokenSymbol,
    uint256 amount,
    address toAddress
);
```

### FrictionlessTokenTransferred

*Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is transferred.*

```solidity
event FrictionlessTokenTransferred(
    IBasicFrictionlessToken.FrictionlessTokenTypes tokenType,
    address token,
    uint256 amount,
    address fromAddress,
    address toAddress
);
```

### FrictionlessTokenBurned

*Event emitted when a `FrictionlessFundDeposit`, `FrictionlessDigitalSecurity` or `FrictionlessOnChainAsset` is burned.*

```solidity
event FrictionlessTokenBurned(
    IBasicFrictionlessToken.FrictionlessTokenTypes tokenType, address token, uint256 amount, address fromAddress
);
```

## Errors

### FrictionlessIsZeroAddress

*throws if specific address is zero.*

```solidity
error FrictionlessIsZeroAddress(string);
```

### FrictionlessTreasuryManagerNotAProtocolTreasury

*error throw if the function caller is not a PROTOCOL\_TREASURY address. Thrown during the `mintFundDepositForTreasury`*

```solidity
error FrictionlessTreasuryManagerNotAProtocolTreasury(address);
```

### FrictionlessTreasuryManagerFundDepositTokenAlreadyExists

*error throw if the FundDepositToken for specified currency and fundIBAN already exists*

```solidity
error FrictionlessTreasuryManagerFundDepositTokenAlreadyExists(string currency, string fundIBAN);
```

### FrictionlessTreasuryManagerInvalidTokenInitData

*error throw if the data for the token init data `FrictionlessTokenInitData` is invalid. Thrown during the `_setTokensInitData`*

```solidity
error FrictionlessTreasuryManagerInvalidTokenInitData(FrictionlessTokenInitData);
```

### FrictionlessTreasuryManagerUnableToUpdateTokenInitData

*error throw if the data for the token init data `FrictionlessTokenInitData` is already set. Thrown during the `_setTokensInitData`*

```solidity
error FrictionlessTreasuryManagerUnableToUpdateTokenInitData(IBasicFrictionlessToken.FrictionlessTokenTypes);
```

### FrictionlessTreasuryManagerInvalidDepositData

*error throw if the data for the IFrictionlessFundDepositToken is invalid. Thrown during the `mintFundDepositForTreasury`*

```solidity
error FrictionlessTreasuryManagerInvalidDepositData(IFrictionlessFundDepositToken.FFDImmutableData);
```

### FrictionlessTreasuryManagerInvalidFDSImmutableData

*error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintDigitalSecurity`*

```solidity
error FrictionlessTreasuryManagerInvalidFDSImmutableData(IFrictionlessDigitalSecurityToken.FDSImmutableData);
```

### FrictionlessTreasuryManagerInvalidFOCASpecData

*error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintOnChainAsset`*

```solidity
error FrictionlessTreasuryManagerInvalidFOCASpecData(IFrictionlessOnChainAssetToken.FOCASpecData);
```

### FrictionlessTreasuryManagerInvalidFOCAIssuanceData

*error throw if the data for the IFrictionlessDigitalSecurityToken is invalid. Thrown during the `mintOnChainAsset`*

```solidity
error FrictionlessTreasuryManagerInvalidFOCAIssuanceData(IFrictionlessOnChainAssetToken.FOCAIssuanceData);
```

## Structs

### FrictionlessTokenInitData

*Structure that encapsulates both the implAuthority and the compliance for the specific token.*

```solidity
struct FrictionlessTokenInitData {
    address implAuthority;
    IBasicFrictionlessToken.FrictionlessTokenTypes tokenType;
}
```
