UNPKG

@bluefin-exchange/bluefin7k-aggregator-sdk

Version:
30 lines (29 loc) 947 B
import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils"; import { SuiUtils } from "../../utils/sui"; export class BaseContract { swapInfo; inputCoinObject; currentAccount; config; pythMap; constructor({ swapInfo, inputCoinObject, currentAccount, config, pythMap, }) { this.swapInfo = swapInfo; this.inputCoinObject = inputCoinObject; this.currentAccount = currentAccount; this.config = config; this.pythMap = pythMap; } getInputCoinValue(tx) { return SuiUtils.getCoinValue(this.swapInfo.assetIn, this.inputCoinObject, tx); } getTypeParams() { return parseStructTag(this.swapInfo.extra?.poolStructTag || "").typeParams.map(normalizeStructTag); } get extra() { const extra = this.swapInfo.extra; if (!extra) { throw new Error(`Invalid extra info for getExtra`); } return extra; } }