@mihalex/farms-sdk-tests
Version:
74 lines • 3.19 kB
JavaScript
;
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RewardScheduleCurve = void 0;
const types = __importStar(require("../types")); // eslint-disable-line @typescript-eslint/no-unused-vars
const borsh = __importStar(require("@coral-xyz/borsh"));
class RewardScheduleCurve {
/**
* This is a stepwise function, meaning that each point represents
* how many rewards are issued per time unit since the beginning
* of that point until the beginning of the next point.
* This is not a linear curve, there is no interpolation going on.
* A curve can be [[t0, 100], [t1, 50], [t2, 0]]
* meaning that from t0 to t1, 100 rewards are issued per time unit,
* from t1 to t2, 50 rewards are issued per time unit, and after t2 it stops
* Another curve, can be [[t0, 100], [u64::max, 0]]
* meaning that from t0 to u64::max, 100 rewards are issued per time unit
*/
points;
constructor(fields) {
this.points = fields.points.map((item) => new types.RewardPerTimeUnitPoint({ ...item }));
}
static layout(property) {
return borsh.struct([borsh.array(types.RewardPerTimeUnitPoint.layout(), 20, "points")], property);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static fromDecoded(obj) {
return new RewardScheduleCurve({
points: obj.points.map((item /* eslint-disable-line @typescript-eslint/no-explicit-any */) => types.RewardPerTimeUnitPoint.fromDecoded(item)),
});
}
static toEncodable(fields) {
return {
points: fields.points.map((item) => types.RewardPerTimeUnitPoint.toEncodable(item)),
};
}
toJSON() {
return {
points: this.points.map((item) => item.toJSON()),
};
}
static fromJSON(obj) {
return new RewardScheduleCurve({
points: obj.points.map((item) => types.RewardPerTimeUnitPoint.fromJSON(item)),
});
}
toEncodable() {
return RewardScheduleCurve.toEncodable(this);
}
}
exports.RewardScheduleCurve = RewardScheduleCurve;
//# sourceMappingURL=RewardScheduleCurve.js.map