@kamino-finance/klend-sdk
Version:
Typescript SDK for interacting with the Kamino Lending (klend) protocol
102 lines • 3.76 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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReserveFees = void 0;
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
const borsh = __importStar(require("@coral-xyz/borsh"));
/**
* Additional fee information on a reserve
*
* These exist separately from interest accrual fees, and are specifically for the program owner
* and referral fee. The fees are paid out as a percentage of liquidity token amounts during
* repayments and liquidations.
*/
class ReserveFees {
/**
* Fee assessed on `BorrowObligationLiquidity`, as scaled fraction (60 bits fractional part)
* Must be between `0` and `2^60`, such that `2^60 = 1`. A few examples for
* clarity:
* 1% = (1 << 60) / 100 = 11529215046068470
* 0.01% (1 basis point) = 115292150460685
* 0.00001% (Aave borrow fee) = 115292150461
*/
borrowFeeSf;
/**
* Fee for flash loan, expressed as scaled fraction.
* 0.3% (Aave flash loan fee) = 0.003 * 2^60 = 3458764513820541
*/
flashLoanFeeSf;
/** Used for allignment */
padding;
constructor(fields) {
this.borrowFeeSf = fields.borrowFeeSf;
this.flashLoanFeeSf = fields.flashLoanFeeSf;
this.padding = fields.padding;
}
static layout(property) {
return borsh.struct([
borsh.u64("borrowFeeSf"),
borsh.u64("flashLoanFeeSf"),
borsh.array(borsh.u8(), 8, "padding"),
], property);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static fromDecoded(obj) {
return new ReserveFees({
borrowFeeSf: obj.borrowFeeSf,
flashLoanFeeSf: obj.flashLoanFeeSf,
padding: obj.padding,
});
}
static toEncodable(fields) {
return {
borrowFeeSf: fields.borrowFeeSf,
flashLoanFeeSf: fields.flashLoanFeeSf,
padding: fields.padding,
};
}
toJSON() {
return {
borrowFeeSf: this.borrowFeeSf.toString(),
flashLoanFeeSf: this.flashLoanFeeSf.toString(),
padding: this.padding,
};
}
static fromJSON(obj) {
return new ReserveFees({
borrowFeeSf: new bn_js_1.default(obj.borrowFeeSf),
flashLoanFeeSf: new bn_js_1.default(obj.flashLoanFeeSf),
padding: obj.padding,
});
}
toEncodable() {
return ReserveFees.toEncodable(this);
}
}
exports.ReserveFees = ReserveFees;
//# sourceMappingURL=ReserveFees.js.map
;