Purchases & Redemptions
How to enable users to purchase and redeem bonds
Purchases
Our Teller contract's purchase function takes the following parameters:
recipient- the address which will receive the vesting tokens (i.e. the purchaser)referrer- the address to which frontend referral fees (currently disabled) will be sent if enabled (or0x0000000000000000000000000000000000000000if not providing an address)id- the id of the market from which the bond is being purchasedamount- the amount being purchasedminAmountOut- the minimum number of payout tokens the user will receive. This protects the user against excessive slippageoverrides- standard override parameters,gasLimit,gasPriceetc
The values for amount and minAmountOut should be formatted taking into account their decimals:
amount = ethers.utils.parseUnits(amount.toString(), quoteDecimals)
.toString();
minAmountOut = ethers.utils.parseUnits(minAmountOut.toString(), payoutDecimals)
.toString()So an example call would be:
tellerContract.purchase(
recipientAddress,
referrer,
id,
amount,
minAmountOut,
overrides
);Redemptions
Our Teller's redeem function takes the following parameters:
token- the address of the vesting tokenamount- the amount to redeemoverrides- standard override parameters,gasLimit,gasPriceetc
For amount we recommend using the user's full balance by default.
So an example call would be:
tellerContract.redeem(
tokenAddress,
amount,
overrides
);Last updated

