@hubbleprotocol/farms-sdk
Version:
147 lines • 7.26 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 (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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RewardInfo = void 0;
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
const types = __importStar(require("../types")); // eslint-disable-line @typescript-eslint/no-unused-vars
const borsh = __importStar(require("@coral-xyz/borsh"));
class RewardInfo {
constructor(fields) {
this.token = new types.TokenInfo(Object.assign({}, fields.token));
this.rewardsVault = fields.rewardsVault;
this.rewardsAvailable = fields.rewardsAvailable;
this.rewardScheduleCurve = new types.RewardScheduleCurve(Object.assign({}, fields.rewardScheduleCurve));
this.minClaimDurationSeconds = fields.minClaimDurationSeconds;
this.lastIssuanceTs = fields.lastIssuanceTs;
this.rewardsIssuedUnclaimed = fields.rewardsIssuedUnclaimed;
this.rewardsIssuedCumulative = fields.rewardsIssuedCumulative;
this.rewardPerShareScaled = fields.rewardPerShareScaled;
this.placeholder0 = fields.placeholder0;
this.rewardType = fields.rewardType;
this.rewardsPerSecondDecimals = fields.rewardsPerSecondDecimals;
this.padding0 = fields.padding0;
this.padding1 = fields.padding1;
}
static layout(property) {
return borsh.struct([
types.TokenInfo.layout("token"),
borsh.publicKey("rewardsVault"),
borsh.u64("rewardsAvailable"),
types.RewardScheduleCurve.layout("rewardScheduleCurve"),
borsh.u64("minClaimDurationSeconds"),
borsh.u64("lastIssuanceTs"),
borsh.u64("rewardsIssuedUnclaimed"),
borsh.u64("rewardsIssuedCumulative"),
borsh.u128("rewardPerShareScaled"),
borsh.u64("placeholder0"),
borsh.u8("rewardType"),
borsh.u8("rewardsPerSecondDecimals"),
borsh.array(borsh.u8(), 6, "padding0"),
borsh.array(borsh.u64(), 20, "padding1"),
], property);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static fromDecoded(obj) {
return new RewardInfo({
token: types.TokenInfo.fromDecoded(obj.token),
rewardsVault: obj.rewardsVault,
rewardsAvailable: obj.rewardsAvailable,
rewardScheduleCurve: types.RewardScheduleCurve.fromDecoded(obj.rewardScheduleCurve),
minClaimDurationSeconds: obj.minClaimDurationSeconds,
lastIssuanceTs: obj.lastIssuanceTs,
rewardsIssuedUnclaimed: obj.rewardsIssuedUnclaimed,
rewardsIssuedCumulative: obj.rewardsIssuedCumulative,
rewardPerShareScaled: obj.rewardPerShareScaled,
placeholder0: obj.placeholder0,
rewardType: obj.rewardType,
rewardsPerSecondDecimals: obj.rewardsPerSecondDecimals,
padding0: obj.padding0,
padding1: obj.padding1,
});
}
static toEncodable(fields) {
return {
token: types.TokenInfo.toEncodable(fields.token),
rewardsVault: fields.rewardsVault,
rewardsAvailable: fields.rewardsAvailable,
rewardScheduleCurve: types.RewardScheduleCurve.toEncodable(fields.rewardScheduleCurve),
minClaimDurationSeconds: fields.minClaimDurationSeconds,
lastIssuanceTs: fields.lastIssuanceTs,
rewardsIssuedUnclaimed: fields.rewardsIssuedUnclaimed,
rewardsIssuedCumulative: fields.rewardsIssuedCumulative,
rewardPerShareScaled: fields.rewardPerShareScaled,
placeholder0: fields.placeholder0,
rewardType: fields.rewardType,
rewardsPerSecondDecimals: fields.rewardsPerSecondDecimals,
padding0: fields.padding0,
padding1: fields.padding1,
};
}
toJSON() {
return {
token: this.token.toJSON(),
rewardsVault: this.rewardsVault.toString(),
rewardsAvailable: this.rewardsAvailable.toString(),
rewardScheduleCurve: this.rewardScheduleCurve.toJSON(),
minClaimDurationSeconds: this.minClaimDurationSeconds.toString(),
lastIssuanceTs: this.lastIssuanceTs.toString(),
rewardsIssuedUnclaimed: this.rewardsIssuedUnclaimed.toString(),
rewardsIssuedCumulative: this.rewardsIssuedCumulative.toString(),
rewardPerShareScaled: this.rewardPerShareScaled.toString(),
placeholder0: this.placeholder0.toString(),
rewardType: this.rewardType,
rewardsPerSecondDecimals: this.rewardsPerSecondDecimals,
padding0: this.padding0,
padding1: this.padding1.map((item) => item.toString()),
};
}
static fromJSON(obj) {
return new RewardInfo({
token: types.TokenInfo.fromJSON(obj.token),
rewardsVault: new web3_js_1.PublicKey(obj.rewardsVault),
rewardsAvailable: new bn_js_1.default(obj.rewardsAvailable),
rewardScheduleCurve: types.RewardScheduleCurve.fromJSON(obj.rewardScheduleCurve),
minClaimDurationSeconds: new bn_js_1.default(obj.minClaimDurationSeconds),
lastIssuanceTs: new bn_js_1.default(obj.lastIssuanceTs),
rewardsIssuedUnclaimed: new bn_js_1.default(obj.rewardsIssuedUnclaimed),
rewardsIssuedCumulative: new bn_js_1.default(obj.rewardsIssuedCumulative),
rewardPerShareScaled: new bn_js_1.default(obj.rewardPerShareScaled),
placeholder0: new bn_js_1.default(obj.placeholder0),
rewardType: obj.rewardType,
rewardsPerSecondDecimals: obj.rewardsPerSecondDecimals,
padding0: obj.padding0,
padding1: obj.padding1.map((item) => new bn_js_1.default(item)),
});
}
toEncodable() {
return RewardInfo.toEncodable(this);
}
}
exports.RewardInfo = RewardInfo;
//# sourceMappingURL=RewardInfo.js.map