For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Deposit/Withdraw Collateral

Before users can borrow any assets, they must first deposit assets as collateral into their Obligation Account.

ScallopClient.depositCollateral creates an Obligation Account automatically if the user has none. The ScallopBuilder quick methods do not; they throw an error if no obligation is found. See Obligation Account Management to create one manually.

Deposit Collateral

Using ScallopClient

import { ScallopClient } from '@scallop-io/sui-scallop-sdk';

const scallopClient = new ScallopClient({
  addressId: '695fcdc084f790c04eb068dc',
  fullnodeUrl: 'https://fullnode.mainnet.sui.io:443',
  secretKey: '...', // or mnemonics: '...'
});

await scallopClient.init();

const coinName = 'sca';
const amount = 1e9; // 1 SCA

const { effects, digest } = await scallopClient.depositCollateral(
  coinName,
  amount
);
console.log(`${effects?.status.status}: ${digest}`);

To deposit into a specific obligation, pass the obligation id as the fourth argument: depositCollateral(coinName, amount, true, obligationId).

Using ScallopBuilder

Quick Method for Automatic Coin Selection

Normal Method for More Composability

Withdraw Collateral

Withdrawing collateral requires the latest asset prices, so that the protocol can verify the obligation stays healthy.

Using ScallopClient

Using ScallopBuilder

Quick Method for Automatic Price Updates

Normal Method for More Composability

Last updated

Was this helpful?