@vsc.eco/crosschain-core
v0.0.3
Published
Magi (VSC) L2 operation builders + swap math — pure functions, no framework dependencies
Downloads
462
Readme
@vsc.eco/crosschain-core
Pure swap math and operation builders for the Magi (VSC) L2 DEX. Zero runtime dependencies, no network calls.
Ports the CLP swap formula from the Altera app and emits the exact L1 ops (transfer + custom_json) that the router expects, so callers can preview, build, and broadcast swaps without any framework.
Install
pnpm add @vsc.eco/crosschain-coreUsage
import {
calculateSwap,
getHiveDepositOp,
getHiveSwapOp,
CoinAmount,
MAINNET_CONFIG
} from '@vsc.eco/crosschain-core';
const amount = CoinAmount.fromDecimal('10', 'HBD');
const { expectedOutput, minAmountOut } = calculateSwap(
amount.raw,
reserveIn,
reserveOut,
100 // 1% slippage, in bps
);
const depositOp = getHiveDepositOp({
from: 'alice',
toDid: 'hive:alice',
amount,
config: MAINNET_CONFIG
});See also
@vsc.eco/crosschain-sdk— higher-level client with pool/price/balance providers andquickSwap().@vsc.eco/crosschain-widget— drop-in React + web component UI.- Repository README — full architecture, routing rules, swap paths.
