Lending Function

Mint


Supplying asset to lending pool and enable user to interest earning from supplied liquidity.

public fun mint<T>(
    version: &Version,
    market: &mut Market,
    coin: Coin<T>,
    clock: &Clock,
    ctx: &mut TxContext,
  ): Coin<MarketCoin<T>> { }

Parameters

Name

Type

Description

version

Version

The version control object, contract version must match with this

market

Market

The Scallop market object, it contains base assets, and related protocol configs

coin

Coin

The base asset to be supplied to the market

clock

Clock

The SUI system Clock object

Return Values

Name
Type
Description

MarketCoin

Coin

The yield bearing coin also an coin that proof user has supplied asset on Scallop.

Note: If the yield-bearing coin is transferred to another address, it means that you have moved your supplied asset to that address, and the current address can no longer withdraw the assets. Only the receiving address can withdraw the assets.

Events

  • MintEvent is emited when the supply tx success

Errors

  • 73729: Currently market not active.

  • 81922: Asset supply already reach limit cap.

Example:

module protocol::foo {

  use sui::clock::{Self, Clock};
  use sui::tx_context::{Self ,TxContext};
  use sui::coin::{Self, Coin};

  use scallop_protocol::mint::mint;
  use scallop_protocol::Market as ScallopMarket;
  use scallop_protocol::Version as ScallopVersion;

  public fun doFoo<T>(
    scallop_version: &ScallopVersion,
    scallop_market: &mut ScallopMarket,
    coin: Coin<T>,
    clock: &Clock,
    ctx: &mut TxContext
  ): Coin<MarketCoin<T>> {
     scallop_protocol::mint::mint<T>(
	scallop_version,
	scallop_market,
	coin,
	clock,
	ctx,
      )
  }
}

Redeem


Withdraw assets from Scallop on Lending Pools, but there’s one thing to remember here is you need your sCoin object to withdraw assets from pool.

public fun redeem<T>(
  version: &Version,
  market: &mut Market,
  coin: Coin<MarketCoin<T>>,
  clock: &Clock,
  ctx: &mut TxContext,
): Coin<T> { }

Paremeters:

Name

Type

Description

version

Version

The version control object, contract version must match with this

market

Market

The Scallop market object, it contains base assets, and related protocol configs

coin

Coin<MarketCoin>

The sCoin object to exchange for underlying base asset

clock

Clock

The SUI system Clock object

Return Value:

Name
Type
Description

Coin

Coin

The redeemed underlying asset

Events

  • RedeemEvent is emited when the withdraw tx success

Errors

  • 2050: The marketcoin used to redeem the assets is to small.

  • 81924: Reserve not enough.

  • 81921: Pool liquidity not enough to redeemed underlying assets.

Example:

module protocol::foo {

  use sui::tx_context::{Self ,TxContext};
  use sui::coin::{Self, Coin};
  use sui::coin::{Self, Coin};

  use scallop_protocol::mint::mint;
  use scallop_protocol::Market as ScallopMarket;
  use scallop_protocol::Version as ScallopVersion;

  public fun doFoo<T>(
    scallop_version: &ScallopVersion,
    scallop_market: &mut ScallopMarket,
    s_coin: Coin<MarketCoin<T>>,
    clock: &Clock,
    ctx: &mut TxContext
  ): Coin<MarketCoin<T>> {
     scallop_protocol::redeem::redeem<T>(
	scallop_version,
	scallop_market,
	s_coin,
	clock,
	ctx,
     )
  }
}

Last updated