Skip to content

Commit 65939cc

Browse files
committed
Merge branch 'main' into fix/refactor-tests
2 parents 6c7d315 + ac07093 commit 65939cc

File tree

2 files changed

+4
-35
lines changed

2 files changed

+4
-35
lines changed

packages/client/src/utils/reserves.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function pickHighestSupplyApyReserve(
1515
}
1616

1717
return reserves.reduce((max, reserve) => {
18-
return reserve.summary.supplyApy.value > max.summary.supplyApy.value
18+
return reserve.summary.supplyApy.value.gt(max.summary.supplyApy.value)
1919
? reserve
2020
: max;
2121
}, reserves[0]);
@@ -35,7 +35,7 @@ export function pickLowestBorrowApyReserve(
3535
}
3636

3737
return reserves.reduce((min, reserve) => {
38-
return reserve.summary.borrowApy.value < min.summary.borrowApy.value
38+
return reserve.summary.borrowApy.value.lt(min.summary.borrowApy.value)
3939
? reserve
4040
: min;
4141
}, reserves[0]);

packages/client/src/viem.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ import {
2626
} from '@aave/types-next';
2727
import {
2828
type Account,
29-
BaseError,
3029
type Chain,
31-
createPublicClient,
3230
defineChain,
33-
http,
3431
type ProviderRpcError,
35-
type PublicClient,
3632
type RpcError,
3733
SwitchChainError,
3834
TransactionExecutionError,
@@ -44,7 +40,6 @@ import {
4440
} from 'viem';
4541
import {
4642
estimateGas as estimateGasWithViem,
47-
getBlock,
4843
sendTransaction as sendTransactionWithViem,
4944
signTypedData,
5045
waitForTransactionReceipt,
@@ -146,45 +141,19 @@ function ensureChain(
146141
});
147142
}
148143

149-
function getBlockGasLimit(
150-
publicClient: PublicClient,
151-
): ResultAsync<bigint, SigningError> {
152-
return ResultAsync.fromPromise(
153-
getBlock(publicClient, {
154-
blockTag: 'latest',
155-
}),
156-
(err) => SigningError.from(err),
157-
).map((block) => block.gasLimit);
158-
}
159-
160144
function estimateGas(
161145
walletClient: WalletClient,
162146
request: TransactionRequest,
163147
): ResultAsync<bigint, SigningError> {
164-
const publicClient = createPublicClient({
165-
chain: walletClient.chain,
166-
transport: http(),
167-
});
168-
169148
return ResultAsync.fromPromise(
170-
estimateGasWithViem(publicClient, {
149+
estimateGasWithViem(walletClient, {
171150
account: walletClient.account,
172151
data: request.data,
173152
to: request.to,
174153
value: BigInt(request.value),
175154
}),
176155
(err) => SigningError.from(err),
177-
)
178-
.map((gas) => (gas * 115n) / 100n) // 15% buffer
179-
.orElse((err) => {
180-
if (
181-
err instanceof BaseError &&
182-
err.shortMessage.includes('exceeds allowance')
183-
) {
184-
return getBlockGasLimit(publicClient);
185-
}
186-
return err.asResultAsync();
187-
});
156+
).map((gas) => (gas * 115n) / 100n); // 15% buffer
188157
}
189158

190159
function sendEip1559Transaction(

0 commit comments

Comments
 (0)