From 6b78970b50a48b37664431c899a5a5e4ced84346 Mon Sep 17 00:00:00 2001 From: fedorovdg Date: Tue, 5 Aug 2025 16:01:54 +0400 Subject: [PATCH 1/3] fix: fixed _ensureAllowance --- src/utils.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 94de240..9519d4e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -246,8 +246,18 @@ export const _ensureAllowance = async function (this: Llamalend, coins: string[] const contract = this.contracts[coins[i]].contract; const _approveAmount = isMax ? MAX_ALLOWANCE : _amounts[i]; await this.updateFeeData(); + + if (allowance[i] > parseUnits("0")) { + const gasLimit = _mulBy1_3(DIGas(await contract.approve.estimateGas(spender, parseUnits("0"), this.constantOptions))); + const resetTx = await contract.approve(spender, parseUnits("0"), { ...this.options, gasLimit }); + txHashes.push(resetTx.hash); + await resetTx.wait(); + } + const gasLimit = _mulBy1_3(DIGas(await contract.approve.estimateGas(spender, _approveAmount, this.constantOptions))); - txHashes.push((await contract.approve(spender, _approveAmount, { ...this.options, gasLimit })).hash); + const approveTx = await contract.approve(spender, _approveAmount, { ...this.options, gasLimit }); + txHashes.push(approveTx.hash); + await approveTx.wait(); } } From b441439d2f354dad48971fb2a1198b139d1d36fa Mon Sep 17 00:00:00 2001 From: fedorovdg Date: Tue, 5 Aug 2025 16:03:39 +0400 Subject: [PATCH 2/3] build: v1.0.27 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bc09d99..6a40961 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/llamalend-api", - "version": "1.0.26", + "version": "1.0.27", "description": "JavaScript library for Curve Lending", "main": "lib/index.js", "author": "Macket", From 1d6c3d1e79077b0115fe64f1bf5e0c2219005f37 Mon Sep 17 00:00:00 2001 From: fedorovdg Date: Tue, 5 Aug 2025 16:05:21 +0400 Subject: [PATCH 3/3] fix: fixed _allowance --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 9519d4e..1321653 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -247,7 +247,7 @@ export const _ensureAllowance = async function (this: Llamalend, coins: string[] const _approveAmount = isMax ? MAX_ALLOWANCE : _amounts[i]; await this.updateFeeData(); - if (allowance[i] > parseUnits("0")) { + if (_allowance[i] > parseUnits("0")) { const gasLimit = _mulBy1_3(DIGas(await contract.approve.estimateGas(spender, parseUnits("0"), this.constantOptions))); const resetTx = await contract.approve(spender, parseUnits("0"), { ...this.options, gasLimit }); txHashes.push(resetTx.hash);