UNPKG

@rainfi/sdk

Version:

This package is used to interact with Rain.fi protocol on Solana

210 lines 8.79 kB
"use strict"; /** * This code was GENERATED using the solita package. * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. * * See: https://github.com/metaplex-foundation/solita */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.liquidityProvisionOrderBeet = exports.LiquidityProvisionOrder = void 0; const beet = __importStar(require("@metaplex-foundation/beet")); const beetSolana = __importStar(require("@metaplex-foundation/beet-solana")); const LpOrderState_1 = require("../types/LpOrderState"); const liquidityProvisionOrderDiscriminator = [ 166, 41, 189, 108, 247, 187, 64, 186, ]; /** * Holds the data for the {@link LiquidityProvisionOrder} Account and provides de/serialization * functionality for that data * * @category Accounts * @category generated */ class LiquidityProvisionOrder { constructor(nftSwapPair, lpOrderState, orderACounter, orderBCounter, accumulatedFee, lpTokenMint, liquidityFeeBump, createdAt) { this.nftSwapPair = nftSwapPair; this.lpOrderState = lpOrderState; this.orderACounter = orderACounter; this.orderBCounter = orderBCounter; this.accumulatedFee = accumulatedFee; this.lpTokenMint = lpTokenMint; this.liquidityFeeBump = liquidityFeeBump; this.createdAt = createdAt; } /** * Creates a {@link LiquidityProvisionOrder} instance from the provided args. */ static fromArgs(args) { return new LiquidityProvisionOrder(args.nftSwapPair, args.lpOrderState, args.orderACounter, args.orderBCounter, args.accumulatedFee, args.lpTokenMint, args.liquidityFeeBump, args.createdAt); } /** * Deserializes the {@link LiquidityProvisionOrder} from the data of the provided {@link web3.AccountInfo}. * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it. */ static fromAccountInfo(accountInfo, offset = 0) { return LiquidityProvisionOrder.deserialize(accountInfo.data, offset); } /** * Retrieves the account info from the provided address and deserializes * the {@link LiquidityProvisionOrder} from its data. * * @throws Error if no account info is found at the address or if deserialization fails */ static fromAccountAddress(connection, address) { return __awaiter(this, void 0, void 0, function* () { const accountInfo = yield connection.getAccountInfo(address); if (accountInfo == null) { throw new Error(`Unable to find LiquidityProvisionOrder account at ${address}`); } return LiquidityProvisionOrder.fromAccountInfo(accountInfo, 0)[0]; }); } /** * Deserializes the {@link LiquidityProvisionOrder} from the provided data Buffer. * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it. */ static deserialize(buf, offset = 0) { return exports.liquidityProvisionOrderBeet.deserialize(buf, offset); } /** * Serializes the {@link LiquidityProvisionOrder} into a Buffer. * @returns a tuple of the created Buffer and the offset up to which the buffer was written to store it. */ serialize() { return exports.liquidityProvisionOrderBeet.serialize(Object.assign({ accountDiscriminator: liquidityProvisionOrderDiscriminator }, this)); } /** * Returns the byteSize of a {@link Buffer} holding the serialized data of * {@link LiquidityProvisionOrder} */ static get byteSize() { return exports.liquidityProvisionOrderBeet.byteSize; } /** * Fetches the minimum balance needed to exempt an account holding * {@link LiquidityProvisionOrder} data from rent * * @param connection used to retrieve the rent exemption information */ static getMinimumBalanceForRentExemption(connection, commitment) { return __awaiter(this, void 0, void 0, function* () { return connection.getMinimumBalanceForRentExemption(LiquidityProvisionOrder.byteSize, commitment); }); } /** * Determines if the provided {@link Buffer} has the correct byte size to * hold {@link LiquidityProvisionOrder} data. */ static hasCorrectByteSize(buf, offset = 0) { return buf.byteLength - offset === LiquidityProvisionOrder.byteSize; } /** * Returns a readable version of {@link LiquidityProvisionOrder} properties * and can be used to convert to JSON and/or logging */ pretty() { return { nftSwapPair: this.nftSwapPair.toBase58(), lpOrderState: 'LpOrderState.' + LpOrderState_1.LpOrderState[this.lpOrderState], orderACounter: (() => { const x = this.orderACounter; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), orderBCounter: (() => { const x = this.orderBCounter; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), accumulatedFee: (() => { const x = this.accumulatedFee; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), lpTokenMint: this.lpTokenMint.toBase58(), liquidityFeeBump: this.liquidityFeeBump, createdAt: (() => { const x = this.createdAt; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), }; } } exports.LiquidityProvisionOrder = LiquidityProvisionOrder; /** * @category Accounts * @category generated */ exports.liquidityProvisionOrderBeet = new beet.BeetStruct([ ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], ['nftSwapPair', beetSolana.publicKey], ['lpOrderState', LpOrderState_1.lpOrderStateBeet], ['orderACounter', beet.i64], ['orderBCounter', beet.i64], ['accumulatedFee', beet.u64], ['lpTokenMint', beetSolana.publicKey], ['liquidityFeeBump', beet.u8], ['createdAt', beet.u64], ], LiquidityProvisionOrder.fromArgs, 'LiquidityProvisionOrder'); //# sourceMappingURL=liquidityProvisionOrder.js.map