Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "fToken"

Index

Functions

borrow

  • borrow(asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise<TrxResponse>
  • Borrows an Binance Smart Chain asset from the Fortress Protocol for the user. The user's address must first have supplied collateral and entered a corresponding market.

    example
    const fortress = new Fortress(window.ethereum);
    
    (async function() {
    
      const daiScaledUp = '32000000000000000000';
      const trxOptions = { mantissa: true };
    
      console.log('Borrowing 32 DAI...');
      const trx = await fortress.borrow(Fortress.DAI, daiScaledUp, trxOptions);
    
      console.log('Ethers.js transaction object', trx);
    
    })().catch(console.error);

    Parameters

    • asset: string

      A string of the asset to borrow (must be a supported underlying asset).

    • amount: string | number | BigNumber

      A string, number, or BigNumber object of the amount of an asset to borrow. Use the mantissa boolean in the options parameter to indicate if this value is scaled up (so there are no decimals) or in its natural scale.

    • Default value options: CallOptions = {}

    Returns Promise<TrxResponse>

    Returns an Ethers.js transaction object of the borrow transaction.

redeem

  • redeem(asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise<TrxResponse>
  • Redeems the user's Binance Smart Chain asset from the Fortress Protocol.

    example
    const fortress = new Fortress(window.ethereum);
    
    (async function() {
    
      console.log('Redeeming DAI...');
      const trx = await fortress.redeem(Fortress.DAI, 1); // also accepts fToken args
      console.log('Ethers.js transaction object', trx);
    
    })().catch(console.error);

    Parameters

    • asset: string

      A string of the asset to redeem, or its fToken name.

    • amount: string | number | BigNumber

      A string, number, or BigNumber object of the amount of an asset to redeem. Use the mantissa boolean in the options parameter to indicate if this value is scaled up (so there are no decimals) or in its natural scale. This can be an amount of fTokens or underlying asset (use the asset parameter to specify).

    • Default value options: CallOptions = {}

    Returns Promise<TrxResponse>

    Returns an Ethers.js transaction object of the redeem transaction.

repayBorrow

  • repayBorrow(asset: string, amount: string | number | BigNumber, borrower: string, noApprove?: boolean, options?: CallOptions): Promise<TrxResponse>
  • Repays a borrowed Binance Smart Chain asset for the user or on behalf of another Binance Smart Chain address.

    example
    const fortress = new Fortress(window.ethereum);
    
    (async function() {
    
      console.log('Repaying DAI borrow...');
      const address = null; // set this to any address to repayBorrowBehalf
      const trx = await fortress.repayBorrow(Fortress.DAI, 32, address);
    
      console.log('Ethers.js transaction object', trx);
    
    })().catch(console.error);

    Parameters

    • asset: string

      A string of the asset that was borrowed (must be a supported underlying asset).

    • amount: string | number | BigNumber

      A string, number, or BigNumber object of the amount of an asset to borrow. Use the mantissa boolean in the options parameter to indicate if this value is scaled up (so there are no decimals) or in its natural scale.

    • borrower: string
    • Default value noApprove: boolean = false

      Explicitly prevent this method from attempting an ERC-20 approve transaction prior to sending the subsequent repayment transaction.

    • Default value options: CallOptions = {}

    Returns Promise<TrxResponse>

    Returns an Ethers.js transaction object of the repayBorrow or repayBorrowBehalf transaction.

supply

  • supply(asset: string, amount: string | number | BigNumber, noApprove?: boolean, options?: CallOptions): Promise<TrxResponse>
  • Supplies the user's Binance Smart Chain asset to the Fortress Protocol.

    example
    const fortress = new Fortress(window.ethereum);
    
    // Ethers.js overrides are an optional 3rd parameter for `supply`
    // const trxOptions = { gasLimit: 250000, mantissa: false };
    
    (async function() {
    
      console.log('Supplying DAI to the Fortress Protocol...');
      const trx = await fortress.supply(Fortress.DAI, 1);
      console.log('Ethers.js transaction object', trx);
    
    })().catch(console.error);

    Parameters

    • asset: string

      A string of the asset to supply.

    • amount: string | number | BigNumber

      A string, number, or BigNumber object of the amount of an asset to supply. Use the mantissa boolean in the options parameter to indicate if this value is scaled up (so there are no decimals) or in its natural scale.

    • Default value noApprove: boolean = false

      Explicitly prevent this method from attempting an BEP-20 approve transaction prior to sending the mint transaction.

    • Default value options: CallOptions = {}

    Returns Promise<TrxResponse>

    Returns an Ethers.js transaction object of the supply transaction.