Skip to content

Commit e3a6834

Browse files
new error types
1 parent 0bc52eb commit e3a6834

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

errors.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ export class DecimalConversionError extends Error {
3838
}
3939
}
4040

41+
export class HyperLiquidInsufficientHlTokenError extends Error {
42+
constructor(message: string) {
43+
super(message);
44+
this.name = "HyperLiquidInsufficientHlTokenError";
45+
}
46+
}
47+
48+
export class HyperLiquidInsufficientGasTokenError extends Error {
49+
constructor(message: string) {
50+
super(message);
51+
this.name = "HyperLiquidInsufficientGasTokenError";
52+
}
53+
}
54+
4155
export class BlockchainConnectionError extends Error {
4256
constructor(message: string) {
4357
super(message);

libs/HyperliquidManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { Hyperliquid } = require('hyperliquid')
22
import { setHLMigrationStatus } from '../database'
33
import { env } from '../env'
4-
import { HyperliquidError } from '../errors'
4+
import { HyperliquidError, HyperLiquidInsufficientGasTokenError, HyperLiquidInsufficientHlTokenError } from '../errors'
55
import { HLMigration, MigrationStatus } from '../interfaces'
66
import { DecimalConversion } from './DecimalConversion'
77

@@ -66,7 +66,16 @@ export class HyperliquidManager {
6666
console.info('Transfer successful')
6767
} else {
6868
console.info('Transfer failed', result.response)
69-
throw new HyperliquidError('Transfer failed: ' + result.response)
69+
70+
if(result.response.toLowerCase().includes('insufficient balance for token transfer')) {
71+
throw new HyperLiquidInsufficientHlTokenError('NEED TO TOP UP HL TOKEN BALANCE - ' + result.response)
72+
}
73+
74+
if(result.response.toLowerCase().includes('Insufficient USDC balance for token transfer gas')) {
75+
throw new HyperLiquidInsufficientGasTokenError('NEED TO TOP UP USDC GAS TOKEN BALANCE - ' + result.response)
76+
}
77+
78+
throw new HyperliquidError('Transfer failed for a reason not related to hl or gas balance - ' + result.response)
7079
}
7180
}
7281
//4000 migrations will take aroud 1000$ USDC!

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@aws-sdk/client-secrets-manager": "^3.692.0",
1616
"@aws-sdk/credential-providers": "^3.692.0",
17-
"@slack/web-api": "^7.9.1",
17+
"@slack/web-api": "^7.9.2",
1818
"@types/aws-lambda": "^8.10.147",
1919
"archiver": "^7.0.1",
2020
"aws-lambda": "^1.0.7",

0 commit comments

Comments
 (0)