Skip to content

Commit 7b5c194

Browse files
committed
fix: testnet deposit support
1 parent 346a925 commit 7b5c194

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

packages/apps/ability-hyperliquid/src/generated/lit-action.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ipfsCid": "QmSvtArdy1UQ4q7eVQCENTYtfTTYoGqVYMugH9Uk38RS3P"
2+
"ipfsCid": "QmUnh3PKQPpUQ3yiiC5EkNCjR5TpPRWkxDWrrop36wDj3Z"
33
}

packages/apps/ability-hyperliquid/src/lib/ability-checks/deposit.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,23 @@ export interface DepositPrechecksResultFailure {
1919
export const depositPrechecks = async ({
2020
provider,
2121
agentWalletPkpEthAddress,
22-
depositAmount,
22+
depositAmountInMicroUsdc,
2323
useTestnet = false,
2424
}: {
2525
provider: ethers.providers.Provider;
2626
agentWalletPkpEthAddress: string;
27-
depositAmount: string;
27+
depositAmountInMicroUsdc: string;
2828
useTestnet?: boolean;
2929
}): Promise<DepositPrechecksResult> => {
3030
const usdcAddress = useTestnet ? ARBITRUM_USDC_ADDRESS_TESTNET : ARBITRUM_USDC_ADDRESS_MAINNET;
3131
const usdcContract = new ethers.Contract(usdcAddress, ERC20_ABI, provider);
32-
const amountInMicroUsdc = ethers.utils.parseUnits(depositAmount, 6);
3332

3433
const balance = await usdcContract.balanceOf(agentWalletPkpEthAddress);
3534

36-
if (balance.lt(amountInMicroUsdc)) {
35+
if (balance.lt(depositAmountInMicroUsdc)) {
3736
return {
3837
success: false,
39-
reason: `Insufficient USDC balance. Required: ${depositAmount} USDC, Available: ${ethers.utils.formatUnits(balance, 6)} USDC`,
38+
reason: `Insufficient USDC balance. Required: ${depositAmountInMicroUsdc} USDC, Available: ${ethers.utils.formatUnits(balance, 6)} USDC`,
4039
balance: ethers.utils.formatUnits(balance, 6),
4140
};
4241
}

packages/apps/ability-hyperliquid/src/lib/vincent-ability.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const vincentAbility = createVincentAbility({
9292
const result = await depositPrechecks({
9393
provider: new ethers.providers.StaticJsonRpcProvider(arbitrumRpcUrl),
9494
agentWalletPkpEthAddress: delegatorPkpInfo.ethAddress,
95-
depositAmount: abilityParams.deposit.amount,
95+
depositAmountInMicroUsdc: abilityParams.deposit.amount,
9696
useTestnet,
9797
});
9898

@@ -334,7 +334,9 @@ export const vincentAbility = createVincentAbility({
334334
}
335335

336336
// Get Arbitrum RPC URL
337-
const rpcUrl = await Lit.Actions.getRpcUrl({ chain: 'arbitrum' });
337+
const rpcUrl = await Lit.Actions.getRpcUrl({
338+
chain: useTestnet ? 'arbitrumSepolia' : 'arbitrum',
339+
});
338340

339341
// Select addresses based on network
340342
const bridgeAddress = ethers.utils.getAddress(

packages/apps/ability-hyperliquid/test/e2e/deposit.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('Hyperliquid Ability E2E Deposit Tests', () => {
2727
const ENV = getEnv({
2828
ARBITRUM_RPC_URL: z.string(),
2929
});
30-
const USDC_DEPOSIT_AMOUNT = '6000000';
31-
const USE_TESTNET = false;
30+
const USDC_DEPOSIT_AMOUNT = '1000000';
31+
const USE_TESTNET = true;
3232

3333
let agentPkpInfo: PkpInfo;
3434
let wallets: {
@@ -170,6 +170,7 @@ describe('Hyperliquid Ability E2E Deposit Tests', () => {
170170
const txHash = executeResult.result.txHash;
171171
expect(txHash).toMatch(/^0x[a-fA-F0-9]{64}$/);
172172

173+
const arbitrumRpcProvider = new ethers.providers.JsonRpcProvider(ENV.ARBITRUM_RPC_URL);
173174
const txReceipt = await arbitrumRpcProvider.waitForTransaction(txHash as string, 1);
174175
expect(txReceipt.status).toBe(1);
175176
});

0 commit comments

Comments
 (0)