Skip to content

GenericDepositor

Git Source

Helper contract to automate deposits into the GUSD vault system

Users must approve this contract to spend their assets before calling deposit/mint functions The contract automatically resolves the correct vault for each asset type and handles all necessary approvals and transfers on behalf of users.

State Variables

unitToken

The Generic unit token that represents shares across all vaults

IGenericShare public immutable unitToken

bridgeCoordinator

The bridge coordinator for cross-chain operations

IBridgeCoordinatorL1Outbound public immutable bridgeCoordinator

Functions

constructor

Initializes the GenericDepositor with required contract references

constructor(IGenericShare _unitToken, IBridgeCoordinatorL1Outbound _bridgeCoordinator) ;
Parameters
NameTypeDescription
_unitTokenIGenericShareThe Generic unit token contract
_bridgeCoordinatorIBridgeCoordinatorL1OutboundThe bridge coordinator for cross-chain operations

deposit

Deposits assets into the appropriate vault and mints shares to the caller

Automatically resolves the correct vault for the given asset

function deposit(IERC20 asset, address whitelabel, uint256 assets) external returns (uint256 shares);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
whitelabeladdressThe whitelabeled unit token address, or address(0) for standard units
assetsuint256The amount of assets to deposit
Returns
NameTypeDescription
sharesuint256The number of shares minted to the caller

mint

Mints a specific amount of shares by depositing the required assets

Calculates the required asset amount using previewMint and deposits that amount

function mint(IERC20 asset, address whitelabel, uint256 shares) external returns (uint256 assets);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
whitelabeladdressThe whitelabeled unit token address, or address(0) for standard units
sharesuint256The exact number of shares to mint
Returns
NameTypeDescription
assetsuint256The amount of assets that were deposited

depositAndBridge

Deposits assets and immediately bridges the resulting shares to another chain

Combines deposit and bridge operations in a single transaction

function depositAndBridge(
    IERC20 asset,
    uint256 assets,
    uint16 bridgeType,
    uint256 chainId,
    bytes32 remoteRecipient,
    bytes32 whitelabel,
    bytes calldata bridgeParams
)
    external
    payable
    returns (uint256 shares, bytes32 messageId);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
assetsuint256The amount of assets to deposit
bridgeTypeuint16The type of bridge to use
chainIduint256The destination chain ID
remoteRecipientbytes32The recipient address on the destination chain (as bytes32)
whitelabelbytes32
bridgeParamsbytesAdditional parameters required by the bridge
Returns
NameTypeDescription
sharesuint256The number of shares minted
messageIdbytes32The bridge message ID for tracking

mintAndBridge

Mints a specific amount of shares and immediately bridges them to another chain

Combines mint and bridge operations in a single transaction

function mintAndBridge(
    IERC20 asset,
    uint256 shares,
    uint16 bridgeType,
    uint256 chainId,
    bytes32 remoteRecipient,
    bytes32 whitelabel,
    bytes calldata bridgeParams
)
    external
    payable
    returns (uint256 assets, bytes32 messageId);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
sharesuint256The exact number of shares to mint
bridgeTypeuint16The type of bridge to use
chainIduint256The destination chain ID
remoteRecipientbytes32The recipient address on the destination chain (as bytes32)
whitelabelbytes32The whitelabeled unit token address on the destination chain
bridgeParamsbytesAdditional parameters required by the bridge
Returns
NameTypeDescription
assetsuint256The amount of assets that were deposited
messageIdbytes32The bridge message ID for tracking

depositAndPredeposit

Deposits assets and predeposits the resulting shares for later bridging

Predeposited shares can be bridged later via the bridge coordinator

function depositAndPredeposit(
    IERC20 asset,
    uint256 assets,
    bytes32 chainNickname,
    bytes32 remoteRecipient
)
    external
    returns (uint256 shares);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
assetsuint256The amount of assets to deposit
chainNicknamebytes32A human-readable identifier for the destination chain
remoteRecipientbytes32The recipient address on the destination chain (as bytes32)
Returns
NameTypeDescription
sharesuint256The number of shares minted and predeposited

mintAndPredeposit

Mints a specific amount of shares and predeposits them for later bridging

Predeposited shares can be bridged later via the bridge coordinator

function mintAndPredeposit(
    IERC20 asset,
    uint256 shares,
    bytes32 chainNickname,
    bytes32 remoteRecipient
)
    external
    returns (uint256 assets);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit (USDC, USDT, or USDS)
sharesuint256The exact number of shares to mint
chainNicknamebytes32A human-readable identifier for the destination chain
remoteRecipientbytes32The recipient address on the destination chain (as bytes32)
Returns
NameTypeDescription
assetsuint256The amount of assets that were deposited

_deposit

Internal function to handle asset deposits into the appropriate vault

function _deposit(
    IERC20 asset,
    address whitelabel,
    uint256 assets,
    address receiver
)
    internal
    returns (uint256 shares);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit
whitelabeladdressThe whitelabeled unit token address, or address(0) for standard units
assetsuint256The amount of assets to deposit
receiveraddressThe address that will receive the minted shares
Returns
NameTypeDescription
sharesuint256The number of shares minted

_mint

Internal function to mint a specific amount of shares by depositing assets

function _mint(
    IERC20 asset,
    address whitelabel,
    uint256 shares,
    address receiver
)
    internal
    returns (uint256 assets);
Parameters
NameTypeDescription
assetIERC20The ERC20 token to deposit
whitelabeladdressThe whitelabeled unit token address, or address(0) for standard units
sharesuint256The exact number of shares to mint
receiveraddressThe address that will receive the minted shares
Returns
NameTypeDescription
assetsuint256The amount of assets that were deposited

_bridge

Internal function to bridge Generic units to another chain

function _bridge(
    uint16 bridgeType,
    uint256 chainId,
    address onBehalf,
    bytes32 remoteRecipient,
    bytes32 whitelabel,
    uint256 units,
    bytes calldata bridgeParams
)
    internal
    returns (bytes32 messageId);
Parameters
NameTypeDescription
bridgeTypeuint16The type of bridge to use
chainIduint256The destination chain ID
onBehalfaddressThe address initiating the bridge operation
remoteRecipientbytes32The recipient address on the destination chain
whitelabelbytes32The whitelabeled unit token address on the destination chain
unitsuint256The number of units to bridge
bridgeParamsbytesAdditional parameters required by the bridge
Returns
NameTypeDescription
messageIdbytes32The bridge message ID for tracking

_predeposit

Internal function to predeposit Generic units for later bridging

function _predeposit(
    bytes32 chainNickname,
    address onBehalf,
    bytes32 remoteRecipient,
    uint256 units
)
    internal;
Parameters
NameTypeDescription
chainNicknamebytes32A human-readable identifier for the destination chain
onBehalfaddressThe address initiating the predeposit operation
remoteRecipientbytes32The recipient address on the destination chain
unitsuint256The number of units to predeposit

Errors

NoVaultForAsset

Thrown when no vault exists for the specified asset

error NoVaultForAsset();

AssetMismatch

Thrown when the vault's asset doesn't match the provided asset

error AssetMismatch();

ZeroAssets

Thrown when zero assets are specified for deposit

error ZeroAssets();

ZeroShares

Thrown when zero shares are specified for minting

error ZeroShares();

ZeroReceiver

Thrown when the receiver address is zero

error ZeroReceiver();

MintAmountMismatch

Thrown when the actual mint amount doesn't match the expected amount

error MintAmountMismatch();