UNPKG

aftermath-ts-sdk

Version:
903 lines 97.3 kB
"use strict"; 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.FarmsApi = void 0; const utils_1 = require("../../../general/utils"); const eventsApiHelpers_1 = require("../../../general/apiHelpers/eventsApiHelpers"); const sui_1 = require("../../sui"); const transactions_1 = require("@mysten/sui/transactions"); const __1 = require("../.."); class FarmsApi { // ========================================================================= // Constructor // ========================================================================= /** * Constructor for FarmsApi * @param Provider The AftermathApi provider instance * @throws Error if not all required addresses have been set in provider */ constructor(Provider) { this.Provider = Provider; // ========================================================================= // Public Methods // ========================================================================= // ========================================================================= // Objects // ========================================================================= // ========================================================================= // Staking Pool Objects // ========================================================================= /** * Fetches the owner caps for staking pools owned by a specific wallet address * @param inputs Object containing wallet address * @returns Array of StakingPoolOwnerCapObject */ this.fetchOwnedStakingPoolOwnerCaps = (inputs) => __awaiter(this, void 0, void 0, function* () { const { walletAddress } = inputs; const [capsV1, capsV2] = yield Promise.all([ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakingPoolOwnerCapV1, objectFromSuiObjectResponse: utils_1.Casting.farms .stakingPoolOwnerCapObjectFromSuiObjectResponseV1, }), this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakingPoolOwnerCapV2, objectFromSuiObjectResponse: utils_1.Casting.farms .stakingPoolOwnerCapObjectFromSuiObjectResponseV2, }), ]); return [...capsV1, ...capsV2]; }); /** * Fetches the one-time admin caps for staking pools owned by a specific wallet address * @param inputs Object containing wallet address * @returns Array of StakingPoolOneTimeAdminCapObject */ this.fetchOwnedStakingPoolOneTimeAdminCaps = (inputs) => __awaiter(this, void 0, void 0, function* () { const { walletAddress } = inputs; const [capsV1, capsV2] = yield Promise.all([ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakingPoolOneTimeAdminCapV1, objectFromSuiObjectResponse: utils_1.Casting.farms .stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV1, }), this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakingPoolOneTimeAdminCapV2, objectFromSuiObjectResponse: utils_1.Casting.farms .stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV2, }), ]); return [...capsV1, ...capsV2]; }); // ========================================================================= // Staked Position Objects // ========================================================================= /** * Fetches partial staked positions owned by a specific wallet address * @param inputs Object containing wallet address * @returns Array of PartialFarmsStakedPositionObject */ this.fetchOwnedPartialStakedPositions = (inputs) => __awaiter(this, void 0, void 0, function* () { const { walletAddress } = inputs; const [positionsV1, positionsV2] = yield Promise.all([ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakedPositionV1, objectFromSuiObjectResponse: utils_1.Casting.farms .partialStakedPositionObjectFromSuiObjectResponseV1, }), this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({ walletAddress, objectType: this.objectTypes.stakedPositionV2, objectFromSuiObjectResponse: utils_1.Casting.farms .partialStakedPositionObjectFromSuiObjectResponseV2, }), ]); return [...positionsV1, ...positionsV2]; }); // ========================================================================= // Transaction Commands // ========================================================================= // ========================================================================= // Staking Transaction Commands // ========================================================================= /** * @deprecated use stakeTxV2 instead * Creates a transaction to stake coins in a staking pool (original version) * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, and coin type * @returns Transaction object argument for StakedPosition */ this.stakeTxV1 = (inputs) => { const { tx, stakeCoinId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "stake"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof stakeCoinId === "string" ? tx.object(stakeCoinId) : stakeCoinId, // Coin tx.pure.u64(inputs.lockDurationMs), ], }); }; /** * Creates a transaction to stake coins in a staking pool * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, lock enforcement, and coin type * @returns Transaction object argument for StakedPosition */ this.stakeTxV2 = (inputs) => { const { tx, stakeCoinId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "stake"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof stakeCoinId === "string" ? tx.object(stakeCoinId) : stakeCoinId, // Coin tx.pure.u8(inputs.lockEnforcement === "Strict" ? 0 : 1), // lock_enforcement tx.pure.u64(inputs.lockDurationMs), // lock_duration_ms ], }); }; /** * @deprecated use depositPrincipalTxV2 instead * Creates a transaction to deposit additional principal to a staked position (original version) * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type * @returns Transaction command to deposit principal */ this.depositPrincipalTxV1 = (inputs) => { const { tx, stakeCoinId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof stakeCoinId === "string" ? tx.object(stakeCoinId) : stakeCoinId, // Coin ], }); }; /** * Creates a transaction to deposit additional principal to a staked position * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type * @returns Transaction command to deposit principal */ this.depositPrincipalTxV2 = (inputs) => { const { tx, stakeCoinId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof stakeCoinId === "string" ? tx.object(stakeCoinId) : stakeCoinId, // Coin ], }); }; /** * @deprecated use withdrawPrincipalTxV2 instead * Creates a transaction to withdraw principal from a staked position (original version) * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type * @returns Transaction object argument for the withdrawn Coin */ this.withdrawPrincipalTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.withdrawAmount), ], }); }; /** * Creates a transaction to withdraw principal from a staked position * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type * @returns Transaction object argument for the withdrawn Coin */ this.withdrawPrincipalTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.withdrawAmount), ], }); }; /** * @deprecated use destroyStakedPositionTxV2 instead * Creates a transaction to destroy a staked position (original version) * @param inputs Destroy parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to destroy the position */ this.destroyStakedPositionTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "destroy"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * Creates a transaction to destroy a staked position * @param inputs Destroy parameters including transaction, position ID, and coin type * @returns Transaction command to destroy the position */ this.destroyStakedPositionTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "destroy"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(this.addresses.objects.version), // Version ], }); }; /** * @deprecated use updatePositionTxV2 instead * Creates a transaction to update a staked position, recalculating rewards (original version) * @param inputs Update parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to update the position */ this.updatePositionTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "update_position"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * Creates a transaction to update a staked position, recalculating rewards * @param inputs Update parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to update the position */ this.updatePositionTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "update_position"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; // ========================================================================= // Locking Transaction Commands // ========================================================================= /** * @deprecated use lockTxV2 instead * Creates a transaction to lock a staked position for a specific duration (original version) * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type * @returns Transaction command to lock the position */ this.lockTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "lock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.lockDurationMs), ], }); }; /** * Creates a transaction to lock a staked position for a specific duration * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type * @returns Transaction command to lock the position */ this.lockTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "lock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.lockDurationMs), ], }); }; /** * @deprecated use renewLockTxV2 instead * Creates a transaction to renew the lock on a staked position (original version) * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to renew the lock */ this.renewLockTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * Creates a transaction to renew the lock on a staked position * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to renew the lock */ this.renewLockTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.object(this.addresses.objects.version), // Version ], }); }; /** * @deprecated use unlockTxV2 instead * Creates a transaction to unlock a staked position (original version) * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to unlock the position */ this.unlockTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "unlock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * Creates a transaction to unlock a staked position * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type * @returns Transaction command to unlock the position */ this.unlockTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "unlock"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; // ========================================================================= // Reward Harvesting Transaction Commands // ========================================================================= /** * @deprecated use beginHarvestTxV2 instead * Creates a transaction to begin the reward harvesting process (original version) * @param inputs Begin harvest parameters including transaction, pool ID, and coin type * @returns Transaction object argument for the harvest metadata */ this.beginHarvestTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakingPoolId), // AfterburnerVault ], }); }; /** * Creates a transaction to begin the reward harvesting process * @param inputs Begin harvest parameters including transaction, position ID, pool ID, and coin type * @returns Transaction object argument for the harvest cap */ this.beginHarvestTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest_tx"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version ], }); }; /** * @deprecated use harvestRewardsTxV2 instead * Creates a transaction to harvest rewards from a staked position (original version) * @param inputs Harvest parameters including transaction, position ID, pool ID, harvest metadata, stake coin type, and reward coin type * @returns Transaction object argument for the harvested rewards */ this.harvestRewardsTxV1 = (inputs) => { const { tx, harvestedRewardsEventMetadataId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault typeof harvestedRewardsEventMetadataId === "string" ? tx.object(harvestedRewardsEventMetadataId) : harvestedRewardsEventMetadataId, // HarvestedRewardsEventMetadata tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * Creates a transaction to harvest rewards from a staked position * @param inputs Harvest parameters including transaction, harvest cap, position ID, pool ID, stake coin type, and reward coin type * @returns Transaction object argument for the harvested rewards */ this.harvestRewardsTxV2 = (inputs) => { const { tx, harvestRewardsCap } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ typeof harvestRewardsCap === "string" ? tx.object(harvestRewardsCap) : harvestRewardsCap, // HarvestRewardsCap tx.object(inputs.stakedPositionId), // StakedPosition tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock ], }); }; /** * @deprecated use endHarvestTxV2 instead * Creates a transaction to end the reward harvesting process (original version) * @param inputs End harvest parameters including transaction and harvest metadata * @returns Transaction command to end the harvest */ this.endHarvestTxV1 = (inputs) => { const { tx, harvestedRewardsEventMetadataId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest"), typeArguments: [], arguments: [ typeof harvestedRewardsEventMetadataId === "string" ? tx.object(harvestedRewardsEventMetadataId) : harvestedRewardsEventMetadataId, // HarvestedRewardsEventMetadata ], }); }; /** * Creates a transaction to end the reward harvesting process * @param inputs End harvest parameters including transaction and harvest cap * @returns Transaction command to end the harvest */ this.endHarvestTxV2 = (inputs) => { const { tx, harvestRewardsCap } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest_tx"), typeArguments: [], arguments: [ typeof harvestRewardsCap === "string" ? tx.object(harvestRewardsCap) : harvestRewardsCap, // HarvestRewardsCap tx.object(this.addresses.objects.version), // Version ], }); }; // ========================================================================= // Staking Pool Creation Transaction Commands // ========================================================================= /** * @deprecated use newStakingPoolTxV2 instead * Creates a transaction for the deprecated version of staking pool creation * @param inputs Pool creation parameters including transaction, lock enforcement, durations, multiplier, stake amount, and coin type * @returns Transaction objects for the vault and owner cap */ this.newStakingPoolTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "new"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.pure.u64(inputs.lockEnforcement === "Strict" ? 0 : 1), tx.pure.u64(inputs.minLockDurationMs), tx.pure.u64(inputs.maxLockDurationMs), tx.pure.u64(inputs.maxLockMultiplier), tx.pure.u64(inputs.minStakeAmount), ], }); }; /** * Creates a transaction for the current version of staking pool creation * @param inputs Pool creation parameters including transaction, lock enforcements array, durations, multiplier, stake amount, and coin type * @returns Transaction objects for the vault and authority cap */ this.newStakingPoolTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "new"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(this.addresses.objects.version), tx.pure.vector("u8", inputs.lockEnforcements.map((lockEnforcement) => lockEnforcement === "Strict" ? 0 : 1)), tx.pure.u64(inputs.minLockDurationMs), tx.pure.u64(inputs.maxLockDurationMs), tx.pure.u64(inputs.maxLockMultiplier), tx.pure.u64(inputs.minStakeAmount), ], }); }; /** * @deprecated use shareStakingPoolTxV2 instead * Creates a transaction to share a staking pool, making it public * @param inputs Share pool parameters including transaction, pool ID, and coin type * @returns Transaction command to share the pool */ this.shareStakingPoolTxV1 = (inputs) => { const { tx, stakingPoolId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "share_vault"), typeArguments: [inputs.stakeCoinType], arguments: [ typeof stakingPoolId === "string" ? tx.object(stakingPoolId) : stakingPoolId, // AfterburnerVault ], }); }; /** * Creates a transaction to share a staking pool, making it public * @param inputs Share pool parameters including transaction, pool ID, and coin type * @returns Transaction command to share the pool */ this.shareStakingPoolTxV2 = (inputs) => { const { tx, stakingPoolId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "share"), typeArguments: [inputs.stakeCoinType], arguments: [ typeof stakingPoolId === "string" ? tx.object(stakingPoolId) : stakingPoolId, // AfterburnerVault ], }); }; /** * @deprecated use transferOwnerCapTxV2 instead * Creates a transaction to transfer ownership of a staking pool * @param inputs Transfer parameters including transaction, owner cap ID, and recipient address * @returns Transaction command to transfer the owner cap */ this.transferOwnerCapTxV1 = (inputs) => { const { tx, ownerCapId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "transfer_owner_cap"), typeArguments: [], arguments: [ typeof ownerCapId === "string" ? tx.object(ownerCapId) : ownerCapId, // OwnerCap tx.pure.address(inputs.recipientAddress), ], }); }; /** * @deprecated use grantOneTimeAdminCapTxV2 instead * Creates a transaction to grant a one-time admin capability for a staking pool (original version) * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type * @returns Transaction command to grant the one-time admin cap */ this.grantOneTimeAdminCapTxV1 = (inputs) => { const { tx, ownerCapId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "grant_one_time_admin_cap"), typeArguments: [inputs.rewardCoinType], arguments: [ typeof ownerCapId === "string" ? tx.object(ownerCapId) : ownerCapId, // OwnerCap tx.pure.address(inputs.recipientAddress), ], }); }; /** * Creates a transaction to grant a one-time admin capability for a staking pool * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type * @returns Transaction command to grant the one-time admin cap */ this.grantOneTimeAdminCapTxV2 = (inputs) => { const { tx, ownerCapId } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "grant_one_time_admin_cap"), typeArguments: [inputs.rewardCoinType], arguments: [ typeof ownerCapId === "string" ? tx.object(ownerCapId) : ownerCapId, // OwnerCap tx.object(this.addresses.objects.version), // Version tx.pure.address(inputs.recipientAddress), ], }); }; // ========================================================================= // Staking Pool Mutation Transaction Commands // ========================================================================= /** * @deprecated use initializeStakingPoolRewardTxV2 instead * Creates a transaction to initialize rewards for a staking pool (original version) * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type * @returns Transaction command to initialize the reward */ this.initializeStakingPoolRewardTxV1 = (inputs) => { const { tx, rewardCoinId } = inputs; const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs); const capId = FarmsApi.farmCapId(inputs); return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap ? "initialize_reward_and_consume_admin_cap" : "initialize_reward"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(capId), // OwnerCap / OneTimeAdminCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof rewardCoinId === "string" ? tx.object(rewardCoinId) : rewardCoinId, // Coin tx.pure.u64(inputs.emissionScheduleMs), tx.pure.u64(inputs.emissionRate), tx.pure.u64(inputs.emissionDelayTimestampMs), ], }); }; /** * Creates a transaction to initialize rewards for a staking pool * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type * @returns Transaction command to initialize the reward */ this.initializeStakingPoolRewardTxV2 = (inputs) => { const { tx, rewardCoinId } = inputs; const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs); const capId = FarmsApi.farmCapId(inputs); return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap ? "initialize_reward_and_consume_admin_cap" : "initialize_reward"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(capId), // OwnerCap / OneTimeAdminCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock typeof rewardCoinId === "string" ? tx.object(rewardCoinId) : rewardCoinId, // Coin tx.pure.u64(inputs.emissionScheduleMs), tx.pure.u64(inputs.emissionRate), tx.pure.u64(inputs.emissionDelayTimestampMs), ], }); }; /** * @deprecated use topUpStakingPoolRewardTxV2 instead * Creates a transaction to add more rewards to a staking pool (original version) * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type * @returns Transaction command to add rewards */ this.topUpStakingPoolRewardTxV1 = (inputs) => { const { tx, rewardCoinId } = inputs; const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs); const capId = FarmsApi.farmCapId(inputs); return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap ? "add_reward_and_consume_admin_cap" : "add_reward"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(capId), // OwnerCap / OneTimeAdminCap tx.object(inputs.stakingPoolId), // AfterburnerVault typeof rewardCoinId === "string" ? tx.object(rewardCoinId) : rewardCoinId, // Coin ], }); }; /** * Creates a transaction to add more rewards to a staking pool * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type * @returns Transaction command to add rewards */ this.topUpStakingPoolRewardTxV2 = (inputs) => { const { tx, rewardCoinId } = inputs; const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs); const capId = FarmsApi.farmCapId(inputs); return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap ? "add_reward_and_consume_admin_cap" : "add_reward"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(capId), // OwnerCap / OneTimeAdminCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version typeof rewardCoinId === "string" ? tx.object(rewardCoinId) : rewardCoinId, // Coin ], }); }; /** * @deprecated use increaseStakingPoolRewardEmissionsTxV2 instead * Creates a transaction to increase the emission rate for a staking pool reward (original version) * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type * @returns Transaction command to update emissions */ this.increaseStakingPoolRewardEmissionsTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "update_emissions_for"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(inputs.ownerCapId), // OwnerCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.emissionScheduleMs), tx.pure.u64(inputs.emissionRate), ], }); }; /** * Creates a transaction to increase the emission rate for a staking pool reward * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type * @returns Transaction command to update emissions */ this.increaseStakingPoolRewardEmissionsTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "update_emission_schedule"), typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType], arguments: [ tx.object(inputs.ownerCapId), // OwnerCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock tx.pure.u64(inputs.emissionScheduleMs), tx.pure.u64(inputs.emissionRate), ], }); }; /** * @deprecated use setStakingPoolMinStakeAmountTxV2 instead * Creates a transaction to set the minimum stake amount for a staking pool (original version) * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type * @returns Transaction command to set the minimum stake amount */ this.setStakingPoolMinStakeAmountTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "set_min_stake_amount"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.ownerCapId), // OwnerCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.pure.u64(inputs.minStakeAmount), ], }); }; /** * Creates a transaction to set the minimum stake amount for a staking pool * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type * @returns Transaction command to set the minimum stake amount */ this.setStakingPoolMinStakeAmountTxV2 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "set_min_stake_amount"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.ownerCapId), // OwnerCap tx.object(inputs.stakingPoolId), // AfterburnerVault tx.object(this.addresses.objects.version), // Version tx.pure.u64(inputs.minStakeAmount), ], }); }; // ========================================================================= // Staking Pool Inspection Transaction Commands // ========================================================================= /** * Creates a transaction to check if a staking pool is unlocked * @param inputs Check parameters including transaction, pool ID, and coin type * @returns Transaction object argument for the boolean result */ this.isVaultUnlockedTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "is_vault_unlocked"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakingPoolId), // AfterburnerVault ], }); }; /** * Creates a transaction to get the remaining rewards for a staking pool * @param inputs Remaining rewards parameters including transaction, pool ID, and coin type * @returns Transaction object argument for the vector of remaining rewards */ this.remainingRewardsTxV1 = (inputs) => { const { tx } = inputs; return tx.moveCall({ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "remaining_rewards"), typeArguments: [inputs.stakeCoinType], arguments: [ tx.object(inputs.stakingPoolId), // AfterburnerVault ], }); }; // ========================================================================= // Transactions // ========================================================================= // ========================================================================= // Staking Transactions // ========================================================================= /** * @deprecated use fetchBuildStakeTxV2 instead * Builds a complete transaction for staking coins * @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type * @returns Complete transaction ready for signing and execution */ this.fetchBuildStakeTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () { const { walletAddress, isSponsoredTx } = inputs; const tx = new transactions_1.Transaction(); tx.setSender(walletAddress); const stakeCoinId = yield thi