@okxweb3/coin-stellar
Version:
@ok/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers
39 lines • 1.77 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.liquidityPoolDeposit = void 0;
const xdr_1 = __importDefault(require("../xdr"));
function liquidityPoolDeposit(opts = {}) {
const { liquidityPoolId, maxAmountA, maxAmountB, minPrice, maxPrice } = opts;
const attributes = {};
if (!liquidityPoolId) {
throw new TypeError('liquidityPoolId argument is required');
}
attributes.liquidityPoolId = xdr_1.default.PoolId.fromXDR(liquidityPoolId, 'hex');
if (!this.isValidAmount(maxAmountA, true)) {
throw new TypeError(this.constructAmountRequirementsError('maxAmountA'));
}
attributes.maxAmountA = this._toXDRAmount(maxAmountA);
if (!this.isValidAmount(maxAmountB, true)) {
throw new TypeError(this.constructAmountRequirementsError('maxAmountB'));
}
attributes.maxAmountB = this._toXDRAmount(maxAmountB);
if (minPrice === undefined) {
throw new TypeError('minPrice argument is required');
}
attributes.minPrice = this._toXDRPrice(minPrice);
if (maxPrice === undefined) {
throw new TypeError('maxPrice argument is required');
}
attributes.maxPrice = this._toXDRPrice(maxPrice);
const liquidityPoolDepositOp = new xdr_1.default.LiquidityPoolDepositOp(attributes);
const opAttributes = {
body: xdr_1.default.OperationBody.liquidityPoolDeposit(liquidityPoolDepositOp)
};
this.setSourceAccount(opAttributes, opts);
return new xdr_1.default.Operation(opAttributes);
}
exports.liquidityPoolDeposit = liquidityPoolDeposit;
//# sourceMappingURL=liquidity_pool_deposit.js.map