Deposit/Withdraw Collateral
Before users can borrow any assets, they must first deposit assets as collateral into their Obligation Account.
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?