Skip to content

Commit b2c6703

Browse files
authored
Merge pull request #33 from curvefi/fix/fixed-gasLimit
Fix/fixed gas limit
2 parents bbe64c7 + ad310e6 commit b2c6703

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@curvefi/stablecoin-api",
3-
"version": "1.5.11",
3+
"version": "1.5.12",
44
"description": "JavaScript library for Curve Stablecoin",
55
"main": "lib/index.js",
66
"author": "Macket",

src/crvusd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class Crvusd implements Icrvusd {
224224
default_bands: 10,
225225
A: 100,
226226
monetary_policy_abi: MonetaryPolicy2ABI,
227+
isNewMarket: i >= collaterals.length - 3,
227228
}
228229
}
229230
}

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface ILlamma {
2020
default_bands: number,
2121
A: number,
2222
monetary_policy_abi: any
23+
isNewMarket?: boolean
2324
}
2425

2526
export interface Icrvusd {

src/llammas/LlammaTemplate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { _getUserCollateral } from "../external-api.js";
2323

2424
export class LlammaTemplate {
2525
id: string;
26+
isNewMarket: boolean;
2627
address: string;
2728
controller: string;
2829
monetaryPolicy: string;
@@ -120,6 +121,7 @@ export class LlammaTemplate {
120121
const llammaData = crvusd.constants.LLAMMAS[id];
121122

122123
this.id = id;
124+
this.isNewMarket = llammaData.isNewMarket || false;
123125
this.address = llammaData.amm_address;
124126
this.controller = llammaData.controller_address;
125127
this.monetaryPolicy = llammaData.monetary_policy_address;
@@ -1058,12 +1060,12 @@ export class LlammaTemplate {
10581060
const [_, n1] = await this.userBands(address);
10591061
const { stablecoin } = await this.userState(address);
10601062
const n = (BN(stablecoin).gt(0)) ? MAX_ACTIVE_BAND : n1 - 1; // In liquidation mode it doesn't matter if active band moves
1061-
const gas = await contract.estimateGas.repay(_debt, address, n, isEth(this.collateral), crvusd.constantOptions);
1063+
const gas = this.isNewMarket ? await contract.estimateGas.repay(_debt, address, n, crvusd.constantOptions) : await contract.estimateGas.repay(_debt, address, n, isEth(this.collateral), crvusd.constantOptions);
10621064
if (estimateGas) return gas.toNumber();
10631065

10641066
await crvusd.updateFeeData();
10651067
const gasLimit = gas.mul(130).div(100);
1066-
return (await contract.repay(_debt, address, n, isEth(this.collateral), { ...crvusd.options, gasLimit })).hash
1068+
return (this.isNewMarket ? await contract.repay(_debt, address, n, { ...crvusd.options, gasLimit }) : await contract.repay(_debt, address, n, isEth(this.collateral), { ...crvusd.options, gasLimit })).hash
10671069
}
10681070

10691071
public async repayEstimateGas(debt: number | string, address = ""): Promise<number> {

0 commit comments

Comments
 (0)