UNPKG

blub-sdk

Version:

A modular SDK for interacting with the BLUB ecosystem on the Sui blockchain.

59 lines (58 loc) 3.12 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _VaultModule_config; Object.defineProperty(exports, "__esModule", { value: true }); exports.VaultModule = void 0; /** * VaultModule class for managing vault operations in BlubStaking. */ class VaultModule { /** * @param {StakingConfig} config Configuration for BlubStaking */ constructor(config) { _VaultModule_config.set(this, void 0); __classPrivateFieldSet(this, _VaultModule_config, config, "f"); } /** * @description Deposit a reward coin into the vault * @param {DepositRewardCoinParams} params Parameters for depositing a reward coin * @param {Transaction} tx Transaction object */ depositRewardCoin(params, tx) { const vault = params.vault ?? __classPrivateFieldGet(this, _VaultModule_config, "f").VAULT_ID; tx.moveCall({ target: `${__classPrivateFieldGet(this, _VaultModule_config, "f").BLUB_STAKING_PACKAGE_ID}::vault::deposit_reward_coin`, arguments: [tx.object(vault), params.rewardCoin], }); } /** * @description Unstake from the pool * @param {string} poolKey The key to identify the pool * @param {string} balanceManagerKey The key to identify the BalanceManager * @returns A function that takes a Transaction object */ withdrawRewardCoin(params, recipient, tx) { const vault = params.vault ?? __classPrivateFieldGet(this, _VaultModule_config, "f").VAULT_ID; const adminCap = params.adminCap ?? __classPrivateFieldGet(this, _VaultModule_config, "f").ADMIN_CAP_ID; const amount = params.amount; const [coin] = tx.moveCall({ target: `${__classPrivateFieldGet(this, _VaultModule_config, "f").BLUB_STAKING_PACKAGE_ID}::vault::withdraw_reward_coin`, arguments: [tx.object(vault), tx.object(adminCap), tx.pure.u64(amount)], typeArguments: [params.coinType], }); tx.transferObjects([coin], recipient); } } exports.VaultModule = VaultModule; _VaultModule_config = new WeakMap();