Borrowing Asset
After depositing any collateral assets, users can borrow any asset using their Obligation Account. Borrowed assets accrue interest, and must be repaid to unlock the collateral.
Borrow Asset
Using ScallopClient
borrow requires the obligation id and the obligation key. Both can be read with getObligations.
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 poolName = 'usdc';
const amount = 1e6; // 1 USDC
const obligations = await scallopClient.query.getObligations();
const { id: obligationId, keyId: obligationKey } = obligations[0];
const { effects, digest } = await scallopClient.borrow(
poolName,
amount,
true, // sign and send the transaction
obligationId,
obligationKey
);
console.log(`${effects?.status.status}: ${digest}`);Using ScallopBuilder
Quick Method for Automatic Price Updates
borrowQuick updates the X-Oracle prices internally, and returns the borrowed coin.
Normal Method for More Composability
Repay Asset
Using ScallopClient
Using ScallopBuilder
Quick Method for Automatic Coin Selection
Normal Method for More Composability
Last updated
Was this helpful?