@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
706 lines • 34.9 kB
JavaScript
"use strict";
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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WhirlpoolStrategy = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars */
const kit_1 = require("@solana/kit");
/* eslint-enable @typescript-eslint/no-unused-vars */
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
const utils_1 = require("../utils"); // eslint-disable-line @typescript-eslint/no-unused-vars
const types = __importStar(require("../types")); // eslint-disable-line @typescript-eslint/no-unused-vars
const programId_1 = require("../programId");
class WhirlpoolStrategy {
adminAuthority;
globalConfig;
baseVaultAuthority;
baseVaultAuthorityBump;
pool;
poolTokenVaultA;
poolTokenVaultB;
tickArrayLower;
tickArrayUpper;
position;
positionMint;
positionMetadata;
positionTokenAccount;
tokenAVault;
tokenBVault;
deprecated0;
deprecated1;
tokenAMint;
tokenBMint;
tokenAMintDecimals;
tokenBMintDecimals;
tokenAAmounts;
tokenBAmounts;
tokenACollateralId;
tokenBCollateralId;
scopePrices;
deprecated2;
sharesMint;
sharesMintDecimals;
sharesMintAuthority;
sharesMintAuthorityBump;
sharesIssued;
status;
reward0Amount;
reward0Vault;
reward0CollateralId;
reward0Decimals;
reward1Amount;
reward1Vault;
reward1CollateralId;
reward1Decimals;
reward2Amount;
reward2Vault;
reward2CollateralId;
reward2Decimals;
depositCapUsd;
feesACumulative;
feesBCumulative;
reward0AmountCumulative;
reward1AmountCumulative;
reward2AmountCumulative;
depositCapUsdPerIxn;
withdrawalCapA;
withdrawalCapB;
maxPriceDeviationBps;
swapVaultMaxSlippageBps;
swapVaultMaxSlippageFromReferenceBps;
strategyType;
padding0;
withdrawFee;
feesFee;
reward0Fee;
reward1Fee;
reward2Fee;
positionTimestamp;
kaminoRewards;
strategyDex;
raydiumProtocolPositionOrBaseVaultAuthority;
allowDepositWithoutInvest;
raydiumPoolConfigOrBaseVaultAuthority;
depositBlocked;
creationStatus;
investBlocked;
/** share_calculation_method can be either DOLAR_BASED=0 or PROPORTION_BASED=1 */
shareCalculationMethod;
withdrawBlocked;
reservedFlag2;
localAdminBlocked;
flashVaultSwapAllowed;
referenceSwapPriceA;
referenceSwapPriceB;
isCommunity;
rebalanceType;
padding1;
rebalanceRaw;
padding2;
tokenAFeesFromRewardsCumulative;
tokenBFeesFromRewardsCumulative;
strategyLookupTable;
lastSwapUnevenStepTimestamp;
farm;
rebalancesCap;
swapUnevenAuthority;
tokenATokenProgram;
tokenBTokenProgram;
pendingAdmin;
padding3;
padding4;
padding5;
padding6;
padding7;
static discriminator = Buffer.from([
190, 178, 231, 184, 49, 186, 103, 13,
]);
static layout = borsh.struct([
(0, utils_1.borshAddress)("adminAuthority"),
(0, utils_1.borshAddress)("globalConfig"),
(0, utils_1.borshAddress)("baseVaultAuthority"),
borsh.u64("baseVaultAuthorityBump"),
(0, utils_1.borshAddress)("pool"),
(0, utils_1.borshAddress)("poolTokenVaultA"),
(0, utils_1.borshAddress)("poolTokenVaultB"),
(0, utils_1.borshAddress)("tickArrayLower"),
(0, utils_1.borshAddress)("tickArrayUpper"),
(0, utils_1.borshAddress)("position"),
(0, utils_1.borshAddress)("positionMint"),
(0, utils_1.borshAddress)("positionMetadata"),
(0, utils_1.borshAddress)("positionTokenAccount"),
(0, utils_1.borshAddress)("tokenAVault"),
(0, utils_1.borshAddress)("tokenBVault"),
borsh.array((0, utils_1.borshAddress)(), 2, "deprecated0"),
borsh.array(borsh.u64(), 2, "deprecated1"),
(0, utils_1.borshAddress)("tokenAMint"),
(0, utils_1.borshAddress)("tokenBMint"),
borsh.u64("tokenAMintDecimals"),
borsh.u64("tokenBMintDecimals"),
borsh.u64("tokenAAmounts"),
borsh.u64("tokenBAmounts"),
borsh.u64("tokenACollateralId"),
borsh.u64("tokenBCollateralId"),
(0, utils_1.borshAddress)("scopePrices"),
(0, utils_1.borshAddress)("deprecated2"),
(0, utils_1.borshAddress)("sharesMint"),
borsh.u64("sharesMintDecimals"),
(0, utils_1.borshAddress)("sharesMintAuthority"),
borsh.u64("sharesMintAuthorityBump"),
borsh.u64("sharesIssued"),
borsh.u64("status"),
borsh.u64("reward0Amount"),
(0, utils_1.borshAddress)("reward0Vault"),
borsh.u64("reward0CollateralId"),
borsh.u64("reward0Decimals"),
borsh.u64("reward1Amount"),
(0, utils_1.borshAddress)("reward1Vault"),
borsh.u64("reward1CollateralId"),
borsh.u64("reward1Decimals"),
borsh.u64("reward2Amount"),
(0, utils_1.borshAddress)("reward2Vault"),
borsh.u64("reward2CollateralId"),
borsh.u64("reward2Decimals"),
borsh.u64("depositCapUsd"),
borsh.u64("feesACumulative"),
borsh.u64("feesBCumulative"),
borsh.u64("reward0AmountCumulative"),
borsh.u64("reward1AmountCumulative"),
borsh.u64("reward2AmountCumulative"),
borsh.u64("depositCapUsdPerIxn"),
types.WithdrawalCaps.layout("withdrawalCapA"),
types.WithdrawalCaps.layout("withdrawalCapB"),
borsh.u64("maxPriceDeviationBps"),
borsh.u32("swapVaultMaxSlippageBps"),
borsh.u32("swapVaultMaxSlippageFromReferenceBps"),
borsh.u64("strategyType"),
borsh.u64("padding0"),
borsh.u64("withdrawFee"),
borsh.u64("feesFee"),
borsh.u64("reward0Fee"),
borsh.u64("reward1Fee"),
borsh.u64("reward2Fee"),
borsh.u64("positionTimestamp"),
borsh.array(types.KaminoRewardInfo.layout(), 3, "kaminoRewards"),
borsh.u64("strategyDex"),
(0, utils_1.borshAddress)("raydiumProtocolPositionOrBaseVaultAuthority"),
borsh.u64("allowDepositWithoutInvest"),
(0, utils_1.borshAddress)("raydiumPoolConfigOrBaseVaultAuthority"),
borsh.u8("depositBlocked"),
borsh.u8("creationStatus"),
borsh.u8("investBlocked"),
borsh.u8("shareCalculationMethod"),
borsh.u8("withdrawBlocked"),
borsh.u8("reservedFlag2"),
borsh.u8("localAdminBlocked"),
borsh.u8("flashVaultSwapAllowed"),
types.Price.layout("referenceSwapPriceA"),
types.Price.layout("referenceSwapPriceB"),
borsh.u8("isCommunity"),
borsh.u8("rebalanceType"),
borsh.array(borsh.u8(), 6, "padding1"),
types.RebalanceRaw.layout("rebalanceRaw"),
borsh.array(borsh.u8(), 7, "padding2"),
borsh.u64("tokenAFeesFromRewardsCumulative"),
borsh.u64("tokenBFeesFromRewardsCumulative"),
(0, utils_1.borshAddress)("strategyLookupTable"),
borsh.u64("lastSwapUnevenStepTimestamp"),
(0, utils_1.borshAddress)("farm"),
types.WithdrawalCaps.layout("rebalancesCap"),
(0, utils_1.borshAddress)("swapUnevenAuthority"),
(0, utils_1.borshAddress)("tokenATokenProgram"),
(0, utils_1.borshAddress)("tokenBTokenProgram"),
(0, utils_1.borshAddress)("pendingAdmin"),
borsh.u64("padding3"),
borsh.array(borsh.u128(), 13, "padding4"),
borsh.array(borsh.u128(), 32, "padding5"),
borsh.array(borsh.u128(), 32, "padding6"),
borsh.array(borsh.u128(), 32, "padding7"),
]);
constructor(fields) {
this.adminAuthority = fields.adminAuthority;
this.globalConfig = fields.globalConfig;
this.baseVaultAuthority = fields.baseVaultAuthority;
this.baseVaultAuthorityBump = fields.baseVaultAuthorityBump;
this.pool = fields.pool;
this.poolTokenVaultA = fields.poolTokenVaultA;
this.poolTokenVaultB = fields.poolTokenVaultB;
this.tickArrayLower = fields.tickArrayLower;
this.tickArrayUpper = fields.tickArrayUpper;
this.position = fields.position;
this.positionMint = fields.positionMint;
this.positionMetadata = fields.positionMetadata;
this.positionTokenAccount = fields.positionTokenAccount;
this.tokenAVault = fields.tokenAVault;
this.tokenBVault = fields.tokenBVault;
this.deprecated0 = fields.deprecated0;
this.deprecated1 = fields.deprecated1;
this.tokenAMint = fields.tokenAMint;
this.tokenBMint = fields.tokenBMint;
this.tokenAMintDecimals = fields.tokenAMintDecimals;
this.tokenBMintDecimals = fields.tokenBMintDecimals;
this.tokenAAmounts = fields.tokenAAmounts;
this.tokenBAmounts = fields.tokenBAmounts;
this.tokenACollateralId = fields.tokenACollateralId;
this.tokenBCollateralId = fields.tokenBCollateralId;
this.scopePrices = fields.scopePrices;
this.deprecated2 = fields.deprecated2;
this.sharesMint = fields.sharesMint;
this.sharesMintDecimals = fields.sharesMintDecimals;
this.sharesMintAuthority = fields.sharesMintAuthority;
this.sharesMintAuthorityBump = fields.sharesMintAuthorityBump;
this.sharesIssued = fields.sharesIssued;
this.status = fields.status;
this.reward0Amount = fields.reward0Amount;
this.reward0Vault = fields.reward0Vault;
this.reward0CollateralId = fields.reward0CollateralId;
this.reward0Decimals = fields.reward0Decimals;
this.reward1Amount = fields.reward1Amount;
this.reward1Vault = fields.reward1Vault;
this.reward1CollateralId = fields.reward1CollateralId;
this.reward1Decimals = fields.reward1Decimals;
this.reward2Amount = fields.reward2Amount;
this.reward2Vault = fields.reward2Vault;
this.reward2CollateralId = fields.reward2CollateralId;
this.reward2Decimals = fields.reward2Decimals;
this.depositCapUsd = fields.depositCapUsd;
this.feesACumulative = fields.feesACumulative;
this.feesBCumulative = fields.feesBCumulative;
this.reward0AmountCumulative = fields.reward0AmountCumulative;
this.reward1AmountCumulative = fields.reward1AmountCumulative;
this.reward2AmountCumulative = fields.reward2AmountCumulative;
this.depositCapUsdPerIxn = fields.depositCapUsdPerIxn;
this.withdrawalCapA = new types.WithdrawalCaps({ ...fields.withdrawalCapA });
this.withdrawalCapB = new types.WithdrawalCaps({ ...fields.withdrawalCapB });
this.maxPriceDeviationBps = fields.maxPriceDeviationBps;
this.swapVaultMaxSlippageBps = fields.swapVaultMaxSlippageBps;
this.swapVaultMaxSlippageFromReferenceBps =
fields.swapVaultMaxSlippageFromReferenceBps;
this.strategyType = fields.strategyType;
this.padding0 = fields.padding0;
this.withdrawFee = fields.withdrawFee;
this.feesFee = fields.feesFee;
this.reward0Fee = fields.reward0Fee;
this.reward1Fee = fields.reward1Fee;
this.reward2Fee = fields.reward2Fee;
this.positionTimestamp = fields.positionTimestamp;
this.kaminoRewards = fields.kaminoRewards.map((item) => new types.KaminoRewardInfo({ ...item }));
this.strategyDex = fields.strategyDex;
this.raydiumProtocolPositionOrBaseVaultAuthority =
fields.raydiumProtocolPositionOrBaseVaultAuthority;
this.allowDepositWithoutInvest = fields.allowDepositWithoutInvest;
this.raydiumPoolConfigOrBaseVaultAuthority =
fields.raydiumPoolConfigOrBaseVaultAuthority;
this.depositBlocked = fields.depositBlocked;
this.creationStatus = fields.creationStatus;
this.investBlocked = fields.investBlocked;
this.shareCalculationMethod = fields.shareCalculationMethod;
this.withdrawBlocked = fields.withdrawBlocked;
this.reservedFlag2 = fields.reservedFlag2;
this.localAdminBlocked = fields.localAdminBlocked;
this.flashVaultSwapAllowed = fields.flashVaultSwapAllowed;
this.referenceSwapPriceA = new types.Price({
...fields.referenceSwapPriceA,
});
this.referenceSwapPriceB = new types.Price({
...fields.referenceSwapPriceB,
});
this.isCommunity = fields.isCommunity;
this.rebalanceType = fields.rebalanceType;
this.padding1 = fields.padding1;
this.rebalanceRaw = new types.RebalanceRaw({ ...fields.rebalanceRaw });
this.padding2 = fields.padding2;
this.tokenAFeesFromRewardsCumulative =
fields.tokenAFeesFromRewardsCumulative;
this.tokenBFeesFromRewardsCumulative =
fields.tokenBFeesFromRewardsCumulative;
this.strategyLookupTable = fields.strategyLookupTable;
this.lastSwapUnevenStepTimestamp = fields.lastSwapUnevenStepTimestamp;
this.farm = fields.farm;
this.rebalancesCap = new types.WithdrawalCaps({ ...fields.rebalancesCap });
this.swapUnevenAuthority = fields.swapUnevenAuthority;
this.tokenATokenProgram = fields.tokenATokenProgram;
this.tokenBTokenProgram = fields.tokenBTokenProgram;
this.pendingAdmin = fields.pendingAdmin;
this.padding3 = fields.padding3;
this.padding4 = fields.padding4;
this.padding5 = fields.padding5;
this.padding6 = fields.padding6;
this.padding7 = fields.padding7;
}
static async fetch(rpc, address, programId = programId_1.PROGRAM_ID) {
const info = await (0, kit_1.fetchEncodedAccount)(rpc, address);
if (!info.exists) {
return null;
}
if (info.programAddress !== programId) {
throw new Error("account doesn't belong to this program");
}
return this.decode(Buffer.from(info.data));
}
static async fetchMultiple(rpc, addresses, programId = programId_1.PROGRAM_ID) {
const infos = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses);
return infos.map((info) => {
if (!info.exists) {
return null;
}
if (info.programAddress !== programId) {
throw new Error("account doesn't belong to this program");
}
return this.decode(Buffer.from(info.data));
});
}
static decode(data) {
if (!data.slice(0, 8).equals(WhirlpoolStrategy.discriminator)) {
throw new Error("invalid account discriminator");
}
const dec = WhirlpoolStrategy.layout.decode(data.slice(8));
return new WhirlpoolStrategy({
adminAuthority: dec.adminAuthority,
globalConfig: dec.globalConfig,
baseVaultAuthority: dec.baseVaultAuthority,
baseVaultAuthorityBump: dec.baseVaultAuthorityBump,
pool: dec.pool,
poolTokenVaultA: dec.poolTokenVaultA,
poolTokenVaultB: dec.poolTokenVaultB,
tickArrayLower: dec.tickArrayLower,
tickArrayUpper: dec.tickArrayUpper,
position: dec.position,
positionMint: dec.positionMint,
positionMetadata: dec.positionMetadata,
positionTokenAccount: dec.positionTokenAccount,
tokenAVault: dec.tokenAVault,
tokenBVault: dec.tokenBVault,
deprecated0: dec.deprecated0,
deprecated1: dec.deprecated1,
tokenAMint: dec.tokenAMint,
tokenBMint: dec.tokenBMint,
tokenAMintDecimals: dec.tokenAMintDecimals,
tokenBMintDecimals: dec.tokenBMintDecimals,
tokenAAmounts: dec.tokenAAmounts,
tokenBAmounts: dec.tokenBAmounts,
tokenACollateralId: dec.tokenACollateralId,
tokenBCollateralId: dec.tokenBCollateralId,
scopePrices: dec.scopePrices,
deprecated2: dec.deprecated2,
sharesMint: dec.sharesMint,
sharesMintDecimals: dec.sharesMintDecimals,
sharesMintAuthority: dec.sharesMintAuthority,
sharesMintAuthorityBump: dec.sharesMintAuthorityBump,
sharesIssued: dec.sharesIssued,
status: dec.status,
reward0Amount: dec.reward0Amount,
reward0Vault: dec.reward0Vault,
reward0CollateralId: dec.reward0CollateralId,
reward0Decimals: dec.reward0Decimals,
reward1Amount: dec.reward1Amount,
reward1Vault: dec.reward1Vault,
reward1CollateralId: dec.reward1CollateralId,
reward1Decimals: dec.reward1Decimals,
reward2Amount: dec.reward2Amount,
reward2Vault: dec.reward2Vault,
reward2CollateralId: dec.reward2CollateralId,
reward2Decimals: dec.reward2Decimals,
depositCapUsd: dec.depositCapUsd,
feesACumulative: dec.feesACumulative,
feesBCumulative: dec.feesBCumulative,
reward0AmountCumulative: dec.reward0AmountCumulative,
reward1AmountCumulative: dec.reward1AmountCumulative,
reward2AmountCumulative: dec.reward2AmountCumulative,
depositCapUsdPerIxn: dec.depositCapUsdPerIxn,
withdrawalCapA: types.WithdrawalCaps.fromDecoded(dec.withdrawalCapA),
withdrawalCapB: types.WithdrawalCaps.fromDecoded(dec.withdrawalCapB),
maxPriceDeviationBps: dec.maxPriceDeviationBps,
swapVaultMaxSlippageBps: dec.swapVaultMaxSlippageBps,
swapVaultMaxSlippageFromReferenceBps: dec.swapVaultMaxSlippageFromReferenceBps,
strategyType: dec.strategyType,
padding0: dec.padding0,
withdrawFee: dec.withdrawFee,
feesFee: dec.feesFee,
reward0Fee: dec.reward0Fee,
reward1Fee: dec.reward1Fee,
reward2Fee: dec.reward2Fee,
positionTimestamp: dec.positionTimestamp,
kaminoRewards: dec.kaminoRewards.map((item /* eslint-disable-line @typescript-eslint/no-explicit-any */) => types.KaminoRewardInfo.fromDecoded(item)),
strategyDex: dec.strategyDex,
raydiumProtocolPositionOrBaseVaultAuthority: dec.raydiumProtocolPositionOrBaseVaultAuthority,
allowDepositWithoutInvest: dec.allowDepositWithoutInvest,
raydiumPoolConfigOrBaseVaultAuthority: dec.raydiumPoolConfigOrBaseVaultAuthority,
depositBlocked: dec.depositBlocked,
creationStatus: dec.creationStatus,
investBlocked: dec.investBlocked,
shareCalculationMethod: dec.shareCalculationMethod,
withdrawBlocked: dec.withdrawBlocked,
reservedFlag2: dec.reservedFlag2,
localAdminBlocked: dec.localAdminBlocked,
flashVaultSwapAllowed: dec.flashVaultSwapAllowed,
referenceSwapPriceA: types.Price.fromDecoded(dec.referenceSwapPriceA),
referenceSwapPriceB: types.Price.fromDecoded(dec.referenceSwapPriceB),
isCommunity: dec.isCommunity,
rebalanceType: dec.rebalanceType,
padding1: dec.padding1,
rebalanceRaw: types.RebalanceRaw.fromDecoded(dec.rebalanceRaw),
padding2: dec.padding2,
tokenAFeesFromRewardsCumulative: dec.tokenAFeesFromRewardsCumulative,
tokenBFeesFromRewardsCumulative: dec.tokenBFeesFromRewardsCumulative,
strategyLookupTable: dec.strategyLookupTable,
lastSwapUnevenStepTimestamp: dec.lastSwapUnevenStepTimestamp,
farm: dec.farm,
rebalancesCap: types.WithdrawalCaps.fromDecoded(dec.rebalancesCap),
swapUnevenAuthority: dec.swapUnevenAuthority,
tokenATokenProgram: dec.tokenATokenProgram,
tokenBTokenProgram: dec.tokenBTokenProgram,
pendingAdmin: dec.pendingAdmin,
padding3: dec.padding3,
padding4: dec.padding4,
padding5: dec.padding5,
padding6: dec.padding6,
padding7: dec.padding7,
});
}
toJSON() {
return {
adminAuthority: this.adminAuthority,
globalConfig: this.globalConfig,
baseVaultAuthority: this.baseVaultAuthority,
baseVaultAuthorityBump: this.baseVaultAuthorityBump.toString(),
pool: this.pool,
poolTokenVaultA: this.poolTokenVaultA,
poolTokenVaultB: this.poolTokenVaultB,
tickArrayLower: this.tickArrayLower,
tickArrayUpper: this.tickArrayUpper,
position: this.position,
positionMint: this.positionMint,
positionMetadata: this.positionMetadata,
positionTokenAccount: this.positionTokenAccount,
tokenAVault: this.tokenAVault,
tokenBVault: this.tokenBVault,
deprecated0: this.deprecated0,
deprecated1: this.deprecated1.map((item) => item.toString()),
tokenAMint: this.tokenAMint,
tokenBMint: this.tokenBMint,
tokenAMintDecimals: this.tokenAMintDecimals.toString(),
tokenBMintDecimals: this.tokenBMintDecimals.toString(),
tokenAAmounts: this.tokenAAmounts.toString(),
tokenBAmounts: this.tokenBAmounts.toString(),
tokenACollateralId: this.tokenACollateralId.toString(),
tokenBCollateralId: this.tokenBCollateralId.toString(),
scopePrices: this.scopePrices,
deprecated2: this.deprecated2,
sharesMint: this.sharesMint,
sharesMintDecimals: this.sharesMintDecimals.toString(),
sharesMintAuthority: this.sharesMintAuthority,
sharesMintAuthorityBump: this.sharesMintAuthorityBump.toString(),
sharesIssued: this.sharesIssued.toString(),
status: this.status.toString(),
reward0Amount: this.reward0Amount.toString(),
reward0Vault: this.reward0Vault,
reward0CollateralId: this.reward0CollateralId.toString(),
reward0Decimals: this.reward0Decimals.toString(),
reward1Amount: this.reward1Amount.toString(),
reward1Vault: this.reward1Vault,
reward1CollateralId: this.reward1CollateralId.toString(),
reward1Decimals: this.reward1Decimals.toString(),
reward2Amount: this.reward2Amount.toString(),
reward2Vault: this.reward2Vault,
reward2CollateralId: this.reward2CollateralId.toString(),
reward2Decimals: this.reward2Decimals.toString(),
depositCapUsd: this.depositCapUsd.toString(),
feesACumulative: this.feesACumulative.toString(),
feesBCumulative: this.feesBCumulative.toString(),
reward0AmountCumulative: this.reward0AmountCumulative.toString(),
reward1AmountCumulative: this.reward1AmountCumulative.toString(),
reward2AmountCumulative: this.reward2AmountCumulative.toString(),
depositCapUsdPerIxn: this.depositCapUsdPerIxn.toString(),
withdrawalCapA: this.withdrawalCapA.toJSON(),
withdrawalCapB: this.withdrawalCapB.toJSON(),
maxPriceDeviationBps: this.maxPriceDeviationBps.toString(),
swapVaultMaxSlippageBps: this.swapVaultMaxSlippageBps,
swapVaultMaxSlippageFromReferenceBps: this.swapVaultMaxSlippageFromReferenceBps,
strategyType: this.strategyType.toString(),
padding0: this.padding0.toString(),
withdrawFee: this.withdrawFee.toString(),
feesFee: this.feesFee.toString(),
reward0Fee: this.reward0Fee.toString(),
reward1Fee: this.reward1Fee.toString(),
reward2Fee: this.reward2Fee.toString(),
positionTimestamp: this.positionTimestamp.toString(),
kaminoRewards: this.kaminoRewards.map((item) => item.toJSON()),
strategyDex: this.strategyDex.toString(),
raydiumProtocolPositionOrBaseVaultAuthority: this.raydiumProtocolPositionOrBaseVaultAuthority,
allowDepositWithoutInvest: this.allowDepositWithoutInvest.toString(),
raydiumPoolConfigOrBaseVaultAuthority: this.raydiumPoolConfigOrBaseVaultAuthority,
depositBlocked: this.depositBlocked,
creationStatus: this.creationStatus,
investBlocked: this.investBlocked,
shareCalculationMethod: this.shareCalculationMethod,
withdrawBlocked: this.withdrawBlocked,
reservedFlag2: this.reservedFlag2,
localAdminBlocked: this.localAdminBlocked,
flashVaultSwapAllowed: this.flashVaultSwapAllowed,
referenceSwapPriceA: this.referenceSwapPriceA.toJSON(),
referenceSwapPriceB: this.referenceSwapPriceB.toJSON(),
isCommunity: this.isCommunity,
rebalanceType: this.rebalanceType,
padding1: this.padding1,
rebalanceRaw: this.rebalanceRaw.toJSON(),
padding2: this.padding2,
tokenAFeesFromRewardsCumulative: this.tokenAFeesFromRewardsCumulative.toString(),
tokenBFeesFromRewardsCumulative: this.tokenBFeesFromRewardsCumulative.toString(),
strategyLookupTable: this.strategyLookupTable,
lastSwapUnevenStepTimestamp: this.lastSwapUnevenStepTimestamp.toString(),
farm: this.farm,
rebalancesCap: this.rebalancesCap.toJSON(),
swapUnevenAuthority: this.swapUnevenAuthority,
tokenATokenProgram: this.tokenATokenProgram,
tokenBTokenProgram: this.tokenBTokenProgram,
pendingAdmin: this.pendingAdmin,
padding3: this.padding3.toString(),
padding4: this.padding4.map((item) => item.toString()),
padding5: this.padding5.map((item) => item.toString()),
padding6: this.padding6.map((item) => item.toString()),
padding7: this.padding7.map((item) => item.toString()),
};
}
static fromJSON(obj) {
return new WhirlpoolStrategy({
adminAuthority: (0, kit_1.address)(obj.adminAuthority),
globalConfig: (0, kit_1.address)(obj.globalConfig),
baseVaultAuthority: (0, kit_1.address)(obj.baseVaultAuthority),
baseVaultAuthorityBump: new bn_js_1.default(obj.baseVaultAuthorityBump),
pool: (0, kit_1.address)(obj.pool),
poolTokenVaultA: (0, kit_1.address)(obj.poolTokenVaultA),
poolTokenVaultB: (0, kit_1.address)(obj.poolTokenVaultB),
tickArrayLower: (0, kit_1.address)(obj.tickArrayLower),
tickArrayUpper: (0, kit_1.address)(obj.tickArrayUpper),
position: (0, kit_1.address)(obj.position),
positionMint: (0, kit_1.address)(obj.positionMint),
positionMetadata: (0, kit_1.address)(obj.positionMetadata),
positionTokenAccount: (0, kit_1.address)(obj.positionTokenAccount),
tokenAVault: (0, kit_1.address)(obj.tokenAVault),
tokenBVault: (0, kit_1.address)(obj.tokenBVault),
deprecated0: obj.deprecated0.map((item) => (0, kit_1.address)(item)),
deprecated1: obj.deprecated1.map((item) => new bn_js_1.default(item)),
tokenAMint: (0, kit_1.address)(obj.tokenAMint),
tokenBMint: (0, kit_1.address)(obj.tokenBMint),
tokenAMintDecimals: new bn_js_1.default(obj.tokenAMintDecimals),
tokenBMintDecimals: new bn_js_1.default(obj.tokenBMintDecimals),
tokenAAmounts: new bn_js_1.default(obj.tokenAAmounts),
tokenBAmounts: new bn_js_1.default(obj.tokenBAmounts),
tokenACollateralId: new bn_js_1.default(obj.tokenACollateralId),
tokenBCollateralId: new bn_js_1.default(obj.tokenBCollateralId),
scopePrices: (0, kit_1.address)(obj.scopePrices),
deprecated2: (0, kit_1.address)(obj.deprecated2),
sharesMint: (0, kit_1.address)(obj.sharesMint),
sharesMintDecimals: new bn_js_1.default(obj.sharesMintDecimals),
sharesMintAuthority: (0, kit_1.address)(obj.sharesMintAuthority),
sharesMintAuthorityBump: new bn_js_1.default(obj.sharesMintAuthorityBump),
sharesIssued: new bn_js_1.default(obj.sharesIssued),
status: new bn_js_1.default(obj.status),
reward0Amount: new bn_js_1.default(obj.reward0Amount),
reward0Vault: (0, kit_1.address)(obj.reward0Vault),
reward0CollateralId: new bn_js_1.default(obj.reward0CollateralId),
reward0Decimals: new bn_js_1.default(obj.reward0Decimals),
reward1Amount: new bn_js_1.default(obj.reward1Amount),
reward1Vault: (0, kit_1.address)(obj.reward1Vault),
reward1CollateralId: new bn_js_1.default(obj.reward1CollateralId),
reward1Decimals: new bn_js_1.default(obj.reward1Decimals),
reward2Amount: new bn_js_1.default(obj.reward2Amount),
reward2Vault: (0, kit_1.address)(obj.reward2Vault),
reward2CollateralId: new bn_js_1.default(obj.reward2CollateralId),
reward2Decimals: new bn_js_1.default(obj.reward2Decimals),
depositCapUsd: new bn_js_1.default(obj.depositCapUsd),
feesACumulative: new bn_js_1.default(obj.feesACumulative),
feesBCumulative: new bn_js_1.default(obj.feesBCumulative),
reward0AmountCumulative: new bn_js_1.default(obj.reward0AmountCumulative),
reward1AmountCumulative: new bn_js_1.default(obj.reward1AmountCumulative),
reward2AmountCumulative: new bn_js_1.default(obj.reward2AmountCumulative),
depositCapUsdPerIxn: new bn_js_1.default(obj.depositCapUsdPerIxn),
withdrawalCapA: types.WithdrawalCaps.fromJSON(obj.withdrawalCapA),
withdrawalCapB: types.WithdrawalCaps.fromJSON(obj.withdrawalCapB),
maxPriceDeviationBps: new bn_js_1.default(obj.maxPriceDeviationBps),
swapVaultMaxSlippageBps: obj.swapVaultMaxSlippageBps,
swapVaultMaxSlippageFromReferenceBps: obj.swapVaultMaxSlippageFromReferenceBps,
strategyType: new bn_js_1.default(obj.strategyType),
padding0: new bn_js_1.default(obj.padding0),
withdrawFee: new bn_js_1.default(obj.withdrawFee),
feesFee: new bn_js_1.default(obj.feesFee),
reward0Fee: new bn_js_1.default(obj.reward0Fee),
reward1Fee: new bn_js_1.default(obj.reward1Fee),
reward2Fee: new bn_js_1.default(obj.reward2Fee),
positionTimestamp: new bn_js_1.default(obj.positionTimestamp),
kaminoRewards: obj.kaminoRewards.map((item) => types.KaminoRewardInfo.fromJSON(item)),
strategyDex: new bn_js_1.default(obj.strategyDex),
raydiumProtocolPositionOrBaseVaultAuthority: (0, kit_1.address)(obj.raydiumProtocolPositionOrBaseVaultAuthority),
allowDepositWithoutInvest: new bn_js_1.default(obj.allowDepositWithoutInvest),
raydiumPoolConfigOrBaseVaultAuthority: (0, kit_1.address)(obj.raydiumPoolConfigOrBaseVaultAuthority),
depositBlocked: obj.depositBlocked,
creationStatus: obj.creationStatus,
investBlocked: obj.investBlocked,
shareCalculationMethod: obj.shareCalculationMethod,
withdrawBlocked: obj.withdrawBlocked,
reservedFlag2: obj.reservedFlag2,
localAdminBlocked: obj.localAdminBlocked,
flashVaultSwapAllowed: obj.flashVaultSwapAllowed,
referenceSwapPriceA: types.Price.fromJSON(obj.referenceSwapPriceA),
referenceSwapPriceB: types.Price.fromJSON(obj.referenceSwapPriceB),
isCommunity: obj.isCommunity,
rebalanceType: obj.rebalanceType,
padding1: obj.padding1,
rebalanceRaw: types.RebalanceRaw.fromJSON(obj.rebalanceRaw),
padding2: obj.padding2,
tokenAFeesFromRewardsCumulative: new bn_js_1.default(obj.tokenAFeesFromRewardsCumulative),
tokenBFeesFromRewardsCumulative: new bn_js_1.default(obj.tokenBFeesFromRewardsCumulative),
strategyLookupTable: (0, kit_1.address)(obj.strategyLookupTable),
lastSwapUnevenStepTimestamp: new bn_js_1.default(obj.lastSwapUnevenStepTimestamp),
farm: (0, kit_1.address)(obj.farm),
rebalancesCap: types.WithdrawalCaps.fromJSON(obj.rebalancesCap),
swapUnevenAuthority: (0, kit_1.address)(obj.swapUnevenAuthority),
tokenATokenProgram: (0, kit_1.address)(obj.tokenATokenProgram),
tokenBTokenProgram: (0, kit_1.address)(obj.tokenBTokenProgram),
pendingAdmin: (0, kit_1.address)(obj.pendingAdmin),
padding3: new bn_js_1.default(obj.padding3),
padding4: obj.padding4.map((item) => new bn_js_1.default(item)),
padding5: obj.padding5.map((item) => new bn_js_1.default(item)),
padding6: obj.padding6.map((item) => new bn_js_1.default(item)),
padding7: obj.padding7.map((item) => new bn_js_1.default(item)),
});
}
}
exports.WhirlpoolStrategy = WhirlpoolStrategy;
//# sourceMappingURL=WhirlpoolStrategy.js.map