Overview

1Hive's Token Request app allows users to create requests for Organization's tokens in exchange for payment. For example a user may request minting 100 organization tokens in exchange for 100 DAI. The request would require a vote to approve, if the vote is rejected the user would be able to withdraw the request and recieve their payment back and if it is approved, the payment would be deposited in the organization's vault and Organization's tokens minted.

When a user makes a request they should transfer the payment to the Token Request app which will hold them in escrow while the vote is created and executed. If the vote duration passes and the payment is still in the Token Request app, the user should be able to claim their tokens. If the vote passes then executing the vote should transfer the user's payment from the token request app to the organization's vault, and mint tokens from the tokens app for the user.

Hard Coded Global Parameters

We have this hard maximum to prevent OOG issues. Since we iterate over an array, there is risk that if it reachs a size that is too big to iterate over within the gas limit, however unlikely, the contract could become locked.

uint256 public constant MAX_ACCEPTED_DEPOSIT_TOKENS = 100;

Token Request Struct

This is the format of token requests.

enum Status { Pending, Refunded, Finalised }

struct TokenRequest {
	address requesterAddress;
	address depositToken;
	uint256 depositAmount;
	uint256 requestAmount;
	Status status;
}

User Defined Global Variables

These variables are available in the global scope of the contract, but can be changed via the contract's functions.

TokenManager public tokenManager;
address public vault;

address[] public acceptedDepositTokens;

uint256 public nextTokenRequestId;
mapping(uint256 => TokenRequest) public tokenRequests; // ID => TokenRequest

Initialization

The token request app is initialized by passing the address of a _tokenManager instance, the address of a _vault instance, and an array of addresses _acceptedDepositTokens. The _acceptedDepositTokens array must be less than the MAX_ACCEPTED_DEPOSIT_TOKENS variable which is set to 100.