@q-dev/q-js-sdk
Version:
Typescript Library to interact with Q System Contracts
65 lines • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SavingInstance = void 0;
const SystemContractInstance_1 = require("../SystemContractInstance");
const CompoundRateKeeperInstance_1 = require("../common/CompoundRateKeeperInstance");
/**
* Saving instance to interact with Saving contract.
* See [onchain documentation](@system-contracts-repo/@network/Saving/) for more details.
* An instance of this class for a deployed network can be obtained via {@link ContractRegistryInstance.saving}
*/
class SavingInstance extends SystemContractInstance_1.SystemContractInstance {
constructor(signerOrProvider, address) {
super(signerOrProvider, 'Saving.json', address);
}
/** @deprecated use getCompoundRateKeeper */
async compoundRateKeeper() {
return this.instance.compoundRateKeeper();
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#getcompoundratekeeper)
*/
async getCompoundRateKeeper() {
const compoundRateKeeperAddress = await this.instance.compoundRateKeeper();
return new CompoundRateKeeperInstance_1.CompoundRateKeeperInstance(this.adapter.signerOrProvider, compoundRateKeeperAddress);
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#normalizedcapitals)
*/
async normalizedCapitals(address) {
return (await this.instance.normalizedCapitals(address)).toString();
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#getbalancedetails)
*/
async getBalanceDetails(address) {
const balanceDe = await this.instance.getBalanceDetails({ from: address });
return {
currentBalance: balanceDe.currentBalance.toString(),
normalizedBalance: balanceDe.normalizedBalance.toString(),
compoundRate: balanceDe.compoundRate.toString(),
lastUpdateOfCompoundRate: balanceDe.lastUpdateOfCompoundRate.toString(),
interestRate: balanceDe.interestRate.toString(),
};
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#updatecompoundrate)
*/
async updateCompoundRate(txOptions) {
return this.submitTransaction('updateCompoundRate', [], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#deposit)
*/
async deposit(amount, txOptions) {
return this.submitTransaction('deposit', [amount], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Saving/#withdraw)
*/
async withdraw(amount, txOptions) {
return this.submitTransaction('withdraw', [amount], txOptions);
}
}
exports.SavingInstance = SavingInstance;
//# sourceMappingURL=SavingInstance.js.map