@kamino-finance/farms-sdk
Version:
83 lines (76 loc) • 2.64 kB
text/typescript
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/
import {
combineCodec,
getArrayDecoder,
getArrayEncoder,
getStructDecoder,
getStructEncoder,
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
} from "@solana/kit";
import {
getRewardPerTimeUnitPointDecoder,
getRewardPerTimeUnitPointEncoder,
type RewardPerTimeUnitPoint,
type RewardPerTimeUnitPointArgs,
} from ".";
export type 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: Array<RewardPerTimeUnitPoint>;
};
export type RewardScheduleCurveArgs = {
/**
* 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: Array<RewardPerTimeUnitPointArgs>;
};
export function getRewardScheduleCurveEncoder(): FixedSizeEncoder<RewardScheduleCurveArgs> {
return getStructEncoder([
[
"points",
getArrayEncoder(getRewardPerTimeUnitPointEncoder(), { size: 20 }),
],
]);
}
export function getRewardScheduleCurveDecoder(): FixedSizeDecoder<RewardScheduleCurve> {
return getStructDecoder([
[
"points",
getArrayDecoder(getRewardPerTimeUnitPointDecoder(), { size: 20 }),
],
]);
}
export function getRewardScheduleCurveCodec(): FixedSizeCodec<
RewardScheduleCurveArgs,
RewardScheduleCurve
> {
return combineCodec(
getRewardScheduleCurveEncoder(),
getRewardScheduleCurveDecoder(),
);
}