TREX Gateway

Methods

addDeployer

function addDeployer(address deployer) external nonpayable

Adds an address to the list of approved deployers.

Only the owner can call this method. If the provided deployer address is already an approved deployer, the function will revert. Emits a DeployerAdded event upon successful addition.

Parameters

NameTypeDescription
deployeraddressAddress to be added to the list of approved deployers. emits DeployerAdded Indicates that a new deployer address has been successfully added.

batchAddDeployer

function batchAddDeployer(address[] deployers) external nonpayable

Adds multiple addresses to the list of approved deployers in a single transaction.

This function allows batch addition of deployers. It can only be called by an admin (owner or agent). The function will revert if the length of the deployers array is more than 500 to prevent excessive gas consumption. It will also revert if any address in the deployers array is already an approved deployer. Emits a DeployerAdded event for each successfully added deployer.

Parameters

NameTypeDescription
deployersaddress[]An array of addresses to be added to the list of approved deployers.

applyFeeDiscount

function applyFeeDiscount(address deployer, uint16 discount) external nonpayable

Applies a fee discount to a specific deployer's address.

Only the owner can call this method. The fee discount is expressed per 10,000 (10000 = 100%, 1000 = 10%, etc.). If the discount exceeds 10000, the function will revert. Emits a FeeDiscountApplied event upon successful application.

Parameters

NameTypeDescription
deployeraddressAddress of the deployer to which the discount will be applied.
discountuint16The discount rate, expressed per 10,000. emits FeeDiscountApplied Indicates that a fee discount has been successfully applied to a deployer.

calculateFee

function calculateFee(address deployer) external view returns (uint256)

Calculates the deployment fee for a given deployer after accounting for any discounts.

The fee discount, if any, is expressed per 10,000 (e.g., 10000 = 100%, 1000 = 10%, etc.). The final fee is derived by subtracting the discount amount from the original fee.

Parameters

NameTypeDescription
deployeraddressAddress of the deployer for which the fee will be calculated.

Returns

NameTypeDescription
_0uint256The calculated fee after accounting for potential discounts.

deployTREXSuite

function deployTREXSuite(ITREXFactory.TokenDetails _tokenDetails, ITREXFactory.ClaimDetails _claimDetails) external nonpayable

Deploys a TREX suite of contracts using provided token and claim details.

This function performs multiple checks before deploying:

  1. If public deployments are disabled, only approved deployers can execute this function.
  2. If public deployments are enabled, an external entity can deploy only on its behalf and not for other addresses unless it's an approved deployer.

If deployment fees are enabled and applicable (after considering any discounts for the deployer), the fee is collected from the deployer's address.

The actual TREX suite deployment is then triggered via the factory contract, and a unique salt is derived from the token owner's address and the token name for the deployment.

Parameters

NameTypeDescription
_tokenDetailsITREXFactory.TokenDetailsTokenDetails struct containing: owner: The contract owner's address; name: The token's name; symbol: Token's symbol or ticker; decimals: Token's decimal places, between 0 and 18; irs: Address for identity registry storage, use ZERO address for new deployments (ensure factory owns the contract if an address is given); ONCHAINID: The token's ONCHAINID; irAgents: List of identity registry agents (can be an AgentManager contract); tokenAgents: List of token-specific agents; complianceModules: Addresses of compliance modules bound to the token (indexes correspond to settings callData); complianceSettings: Configuration settings for the attached compliance modules.
_claimDetailsITREXFactory.ClaimDetailsClaimDetails struct comprising: claimTopics: Required claim topics; issuers: Addresses of trusted claim issuers; issuerClaims: Claims the issuers are allowed to emit, where index alignment corresponds to the issuers array.

enableDeploymentFee

function enableDeploymentFee(bool _isEnabled) external nonpayable

Toggles the deployment fee status for TREX contracts.

Enables or disables the deployment fees. If the function call doesn't change the current status, it will revert. Only the owner can call this method. Emits a DeploymentFeeEnabled event upon successful execution. Reverts with DeploymentFeesAlreadyEnabled if trying to enable when already enabled. Reverts with DeploymentFeesAlreadyDisabled if trying to disable when already disabled.

Parameters

NameTypeDescription
_isEnabledboolDetermines if deployment fees are enabled (true) or disabled (false). emits DeploymentFeeEnabled When the new deployment fee status is set.

getDeploymentFee

function getDeploymentFee() external view returns (struct ITREXGateway.Fee)

Retrieves the current deployment fee details.

This function provides details about the deployment fee, including the amount, token type, and the collector address.

Returns

NameTypeDescription
_0ITREXGateway.FeeFee struct containing: - fee: The amount to be paid as the deployment fee. - feeToken: Address of the token used for the deployment fee. - feeCollector: Address that collects the deployment fees.

getFactory

function getFactory() external view returns (address)

Retrieves the address of the current Factory contract.

The Factory contract is responsible for deploying TREX contracts. This function allows querying its address.

Returns

NameTypeDescription
_0addressAddress of the current Factory contract.

getPublicDeploymentStatus

function getPublicDeploymentStatus() external view returns (bool)

Retrieves the current public deployment status.

Indicates whether public deployments of TREX contracts are currently allowed.

Returns

NameTypeDescription
_0boolA boolean value representing the public deployment status: true if public deployments are allowed, false otherwise.

isDeployer

function isDeployer(address deployer) external view returns (bool)

Checks if the provided address is an approved deployer.

Determines if a specific address has permissions to deploy TREX contracts.

Parameters

NameTypeDescription
deployeraddressAddress to be checked for deployer permissions.

Returns

NameTypeDescription
_0boolA boolean value indicating whether the provided address is an approved deployer (true) or not (false).

isDeploymentFeeEnabled

function isDeploymentFeeEnabled() external view returns (bool)

Checks if the deployment fee is currently enabled.

Provides a way to determine if deployers are currently required to pay a fee when deploying TREX contracts.

Returns

NameTypeDescription
_0boolA boolean value indicating whether the deployment fee is enabled (true) or disabled (false).

removeDeployer

function removeDeployer(address deployer) external nonpayable

Removes an address from the list of approved deployers.

Only the owner can call this method. If the provided deployer address is not an approved deployer, the function will revert. Emits a DeployerRemoved event upon successful removal.

Parameters

NameTypeDescription
deployeraddressAddress to be removed from the list of approved deployers. emits DeployerRemoved Indicates that a deployer address has been successfully removed.

setDeploymentFee

function setDeploymentFee(uint256 _fee, address _feeToken, address _feeCollector) external nonpayable

Sets the deployment fee details for TREX contracts.

Only the owner can call this method. The function establishes the amount, token type, and collector address for the deployment fee. Reverts if either the provided _feeToken or _feeCollector address is zero. Emits a DeploymentFeeSet event upon successful execution.

Parameters

NameTypeDescription
_feeuint256The amount to be set as the deployment fee.
_feeTokenaddressAddress of the token used for the deployment fee.
_feeCollectoraddressAddress that will collect the deployment fees. emits DeploymentFeeSet Indicates that the deployment fee details have been successfully set.

setFactory

function setFactory(address factory) external nonpayable

Sets the factory contract address used for deploying TREX smart contracts.

Only the owner can call this method. Emits a FactorySet event upon successful execution. Reverts if the provided factory address is zero.

Parameters

NameTypeDescription
factoryaddressThe address of the new factory contract. emits FactorySet When the new factory address is set.

setPublicDeploymentStatus

function setPublicDeploymentStatus(bool _isEnabled) external nonpayable

Sets the status for public deployments of TREX contracts.

Enables or disables public deployments. If the function call doesn't change the current status, it will revert. Only the owner can call this method. Emits a PublicDeploymentStatusSet event upon successful execution. Reverts with PublicDeploymentAlreadyEnabled if trying to enable when already enabled. Reverts with PublicDeploymentAlreadyDisabled if trying to disable when already disabled.

Parameters

NameTypeDescription
_isEnabledboolDetermines if public deployments are enabled (true) or disabled (false). emits PublicDeploymentStatusSet When the new public deployment status is set.

transferFactoryOwnership

function transferFactoryOwnership(address _newOwner) external nonpayable

Transfers the ownership of the Factory contract.

Only the owner can call this method. Utilizes the transferOwnership function of the Ownable pattern.

Parameters

NameTypeDescription
_newOwneraddressAddress of the new owner for the Factory contract.

Events

DeployerAdded

event DeployerAdded(address indexed deployer)

event emitted when an address is flagged as a deployer

Parameters

NameTypeDescription
deployer indexedaddressAddress added to the list of approved deployers.

DeployerRemoved

event DeployerRemoved(address indexed deployer)

event emitted when a deployer address loses deployment privileges

Parameters

NameTypeDescription
deployer indexedaddressAddress removed from the list of approved deployers.

DeploymentFeeEnabled

event DeploymentFeeEnabled(bool indexed isEnabled)

event emitted when the deployment fees are enabled/disabled

Parameters

NameTypeDescription
isEnabled indexedboolBool value determining if deployment fees are enabled (true) or disabled (false).

DeploymentFeeSet

event DeploymentFeeSet(uint256 indexed fee, address indexed feeToken, address indexed feeCollector)

event emitted when the deployment fees details are set/modified

Parameters

NameTypeDescription
fee indexeduint256The amount to be paid as the deployment fee.
feeToken indexedaddressAddress of the token used for the deployment fee
feeCollector indexedaddressAddress that collects the deployment fees

FactorySet

event FactorySet(address indexed factory)

event emitted when the _factory variable is set/modified

Parameters

NameTypeDescription
factory indexedaddressAddress of the current Factory contract.

FeeDiscountApplied

event FeeDiscountApplied(address indexed deployer, uint16 discount)

event emitted when a discount on deployment fees is granted for an address

Parameters

NameTypeDescription
deployer indexedaddressAddress of the deployer to which the discount is applied.
discountuint16The discount rate, expressed per 10,000

GatewaySuiteDeploymentProcessed

event GatewaySuiteDeploymentProcessed(address indexed requester, address intendedOwner, uint256 feeApplied)

event emitted whenever a TREX token has been deployed by the TREX factory through the use of the Gateway

Parameters

NameTypeDescription
requester indexedaddressaddress of the deployer that called the TREX deployment function
intendedOwneraddressOwner address for the deployed token
feeApplieduint256fee paid to process the deployment, expressed in tokens (decimals are not displayed here)

PublicDeploymentStatusSet

event PublicDeploymentStatusSet(bool indexed publicDeploymentStatus)

event emitted when the public deployment status is set/modified

Parameters

NameTypeDescription
publicDeploymentStatus indexedboolA boolean value representing the public deployment status: true if public deployments are allowed, false otherwise.