carbon-js-sdk 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/clients/ETHClient.js
CHANGED
|
@@ -69,13 +69,15 @@ class ETHClient {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
approveERC20(params) {
|
|
72
|
+
var _a;
|
|
72
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
74
|
const { token, gasPriceGwei, gasLimit, ethAddress, spenderAddress, signer, amount } = params;
|
|
74
75
|
const contractAddress = token.tokenAddress;
|
|
75
76
|
const rpcProvider = this.getProvider();
|
|
76
77
|
const contract = new ethers_1.ethers.Contract(contractAddress, eth_1.ABIs.erc20, rpcProvider);
|
|
78
|
+
const approvalAmount = ethers_1.ethers.BigNumber.from((_a = amount === null || amount === void 0 ? void 0 : amount.toString(10)) !== null && _a !== void 0 ? _a : ethers_1.ethers.constants.MaxUint256);
|
|
77
79
|
const nonce = yield this.getTxNonce(ethAddress, params.nonce, rpcProvider);
|
|
78
|
-
const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress,
|
|
80
|
+
const approveResultTx = yield contract.connect(signer).approve(spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : token.bridgeAddress, approvalAmount, Object.assign(Object.assign({ nonce }, gasPriceGwei && ({ gasPrice: gasPriceGwei.shiftedBy(9).toString(10) })), gasLimit && ({ gasLimit: gasLimit.toString(10) })));
|
|
79
81
|
return approveResultTx;
|
|
80
82
|
});
|
|
81
83
|
}
|
|
@@ -19,6 +19,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
|
19
19
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
20
20
|
const long_1 = __importDefault(require("long"));
|
|
21
21
|
const base_1 = __importDefault(require("./base"));
|
|
22
|
+
const number_1 = require("../util/number");
|
|
22
23
|
class LiquidityPoolModule extends base_1.default {
|
|
23
24
|
create(params, opts) {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -164,14 +165,14 @@ class LiquidityPoolModule extends base_1.default {
|
|
|
164
165
|
getWeeklyRewardsRealInflation() {
|
|
165
166
|
var _a;
|
|
166
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
const mintDataResponse = yield this.sdkProvider.query.inflation.MintData({});
|
|
169
|
+
let weeklyRewards = number_1.BN_ZERO;
|
|
170
|
+
if (mintDataResponse.mintData) {
|
|
171
|
+
const mintData = mintDataResponse.mintData;
|
|
172
|
+
const currentSupply = new bignumber_js_1.BigNumber(mintData.currentSupply);
|
|
173
|
+
const swthInflationRate = new bignumber_js_1.BigNumber(mintData.inflationRate).shiftedBy(-18);
|
|
174
|
+
weeklyRewards = currentSupply.times(swthInflationRate).div(52);
|
|
173
175
|
}
|
|
174
|
-
const weeklyRewards = INITIAL_SUPPLY.div(52).times(inflationRate);
|
|
175
176
|
// Calculate weekly rewards earned by liquidity providers
|
|
176
177
|
// Weekly LP Rewards = liquidityRewardRatio * weeklyRewards
|
|
177
178
|
const distributionParams = yield this.sdkProvider.query.distribution.Params({});
|