@celo/contractkit
Version:
Celo's ContractKit to interact with Celo network
58 lines • 3.23 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EpochRewardsWrapper = void 0;
const fixidity_1 = require("@celo/utils/lib/fixidity");
const BaseWrapper_1 = require("./BaseWrapper");
const parseFixidity = (v) => (0, fixidity_1.fromFixed)((0, BaseWrapper_1.valueToBigNumber)(v));
class EpochRewardsWrapper extends BaseWrapper_1.BaseWrapper {
constructor() {
super(...arguments);
this.getRewardsMultiplierParameters = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getRewardsMultiplierParameters, undefined, (res) => ({
max: parseFixidity(res[0]),
underspendAdjustment: parseFixidity(res[1]),
overspendAdjustment: parseFixidity(res[2]),
}));
this.getTargetVotingYieldParameters = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getTargetVotingYieldParameters, undefined, (res) => ({
target: parseFixidity(res[0]),
max: parseFixidity(res[1]),
adjustment: parseFixidity(res[2]),
}));
this.getCommunityReward = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getCommunityRewardFraction, undefined, parseFixidity);
this.getCarbonOffsetting = () => __awaiter(this, void 0, void 0, function* () {
const factor = parseFixidity(yield this.contract.methods.getCarbonOffsettingFraction().call());
const partner = yield this.contract.methods.carbonOffsettingPartner().call();
return {
factor,
partner,
};
});
this.getTargetValidatorEpochPayment = (0, BaseWrapper_1.proxyCall)(this.contract.methods.targetValidatorEpochPayment, undefined, BaseWrapper_1.valueToBigNumber);
}
getConfig() {
return __awaiter(this, void 0, void 0, function* () {
const rewardsMultiplier = yield this.getRewardsMultiplierParameters();
const carbonOffsetting = yield this.getCarbonOffsetting();
const communityReward = yield this.getCommunityReward();
const targetVotingYield = yield this.getTargetVotingYieldParameters();
const targetValidatorEpochPayment = yield this.getTargetValidatorEpochPayment();
return {
rewardsMultiplier,
carbonOffsetting,
communityReward,
targetVotingYield,
targetValidatorEpochPayment,
};
});
}
}
exports.EpochRewardsWrapper = EpochRewardsWrapper;
//# sourceMappingURL=EpochRewards.js.map
;