Skip to content

Commit 76a6a9c

Browse files
committed
Merge branch 'main' into staging
2 parents 5abe25b + 1719ac8 commit 76a6a9c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/services/request-handler/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
getSignature,
3838
getSigner,
3939
handleOneTimeApproval,
40+
logBalance,
4041
} from "../../utils/onchain-allocator";
4142
import { config } from "../../config";
4243
import {
@@ -107,6 +108,8 @@ export class RequestHandlerService {
107108

108109
// This is needed before being able to submit withdraw requests
109110
await handleOneTimeApproval();
111+
// Log the balance of the onchain-allocator sender wallet for tracking purposes
112+
await logBalance();
110113

111114
const txHash = await contract.write.submitWithdrawRequest([
112115
payloadParams as any,
@@ -252,6 +255,8 @@ export class RequestHandlerService {
252255

253256
// This is needed before being able to submit withdraw requests
254257
await handleOneTimeApproval();
258+
// Log the balance of the onchain-allocator sender wallet for tracking purposes
259+
await logBalance();
255260

256261
const txHash = await contract.write.submitWithdrawRequest([
257262
payloadParams as any,

src/utils/onchain-allocator.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import {
1212
parseAbi,
1313
zeroAddress,
1414
maxUint256,
15+
formatUnits,
1516
} from "viem";
1617
import { privateKeyToAccount, publicKeyToAddress } from "viem/accounts";
1718

1819
import { KmsSigner } from "./viem-kms-signer";
1920
import { getChain } from "../common/chains";
2021
import { externalError } from "../common/error";
22+
import { logger } from "../common/logger";
2123
import { config } from "../config";
2224
import { getWithdrawalRequest } from "../models/withdrawal-requests";
2325

@@ -114,6 +116,21 @@ export const getOnchainAllocator = async () => {
114116
};
115117
};
116118

119+
export const logBalance = async () => {
120+
const { walletClient, publicClient } = await getPublicAndWalletClients();
121+
122+
const balance = await publicClient.getBalance({
123+
address: walletClient.account.address,
124+
});
125+
logger.info(
126+
"balance",
127+
JSON.stringify({
128+
msg: "Balance of onchain-allocator sender wallet",
129+
balance: Number(formatUnits(balance, 18)),
130+
})
131+
);
132+
};
133+
117134
let _allowanceCache: bigint | undefined;
118135
export const handleOneTimeApproval = async () => {
119136
const { walletClient } = await getPublicAndWalletClients();

0 commit comments

Comments
 (0)