Skip to content

Commit fefbefb

Browse files
committed
chore: update examples to use quote asset checker
Signed-off-by: shankar <shankar@layerzerolabs.org>
1 parent 6381ecf commit fefbefb

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

‎examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_FeeAbstraction.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CHAIN_IDS,
88
EthersSigner,
99
getCoreSpotDeployment,
10+
isQuoteAsset,
1011
useBigBlock,
1112
useSmallBlock,
1213
} from '@layerzerolabs/hyperliquid-composer'
@@ -73,6 +74,30 @@ const deploy: DeployFunction = async (hre) => {
7374
// Validates and returns the native spot
7475
const hip1Token = getCoreSpotDeployment(coreSpotIndex, isTestnet)
7576

77+
// Check if the token is a quote asset - warn if it is
78+
console.log(`\nChecking if token ${coreSpotIndex} is a quote asset...`)
79+
const { isQuoteAsset: isQuote, tokenName } = await isQuoteAsset(isTestnet, parseInt(coreSpotIndex), loglevel)
80+
81+
if (isQuote) {
82+
console.warn(`\n[WARNING] Token ${coreSpotIndex}${tokenName ? ` (${tokenName})` : ''} IS a quote asset!`)
83+
console.warn(`For quote assets, you should use MyHyperLiquidComposer_FeeToken instead.`)
84+
console.warn(`FeeToken composer provides automatic user activation using the token itself.\n`)
85+
86+
const { continueAnyway } = await inquirer.prompt([
87+
{
88+
type: 'confirm',
89+
name: 'continueAnyway',
90+
message: 'Do you want to continue with FeeAbstraction anyway?',
91+
default: false,
92+
},
93+
])
94+
95+
if (!continueAnyway) {
96+
console.log('Deployment cancelled.')
97+
process.exit(0)
98+
}
99+
}
100+
76101
const { address: address_oft } = await hre.deployments.get(contractName_oft).catch(async () => {
77102
console.log(`Deployment file for ${contractName_oft}.json in deployments/${networkName} not found`)
78103
const { proceedWithOFTAddress } = await inquirer.prompt([

‎examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_FeeToken.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CHAIN_IDS,
88
EthersSigner,
99
getCoreSpotDeployment,
10+
isQuoteAsset,
1011
useBigBlock,
1112
useSmallBlock,
1213
} from '@layerzerolabs/hyperliquid-composer'
@@ -52,6 +53,23 @@ const deploy: DeployFunction = async (hre) => {
5253
// Validates and returns the native spot
5354
const hip1Token = getCoreSpotDeployment(coreSpotIndex, isTestnet)
5455

56+
// Check if the token is a quote asset - required for FeeToken composer
57+
console.log(`\nChecking if token ${coreSpotIndex} is a quote asset...`)
58+
const { isQuoteAsset: isQuote, tokenName } = await isQuoteAsset(isTestnet, parseInt(coreSpotIndex), loglevel)
59+
60+
if (!isQuote) {
61+
console.error(`\n[ERROR] Token ${coreSpotIndex} is NOT a quote asset!`)
62+
console.error(`The FeeToken composer can ONLY be used with quote assets (tokens paired with HYPE).`)
63+
console.error(`\nThis token is not a quote asset. Please use one of the following composers instead:`)
64+
console.error(` - MyHyperliquidComposer (regular)`)
65+
console.error(` - MyHyperLiquidComposer_FeeAbstraction`)
66+
console.error(` - MyHyperLiquidComposer_Recoverable`)
67+
throw new Error(`Token ${coreSpotIndex} is not a quote asset. FeeToken composer requires a quote asset.`)
68+
}
69+
70+
console.log(`[OK] Confirmed: Token ${coreSpotIndex}${tokenName ? ` (${tokenName})` : ''} is a quote asset`)
71+
console.log(` FeeToken composer can be used for automatic user activation.\n`)
72+
5573
const { address: address_oft } = await hre.deployments.get(contractName_oft).catch(async () => {
5674
console.log(`Deployment file for ${contractName_oft}.json in deployments/${networkName} not found`)
5775
const { proceedWithOFTAddress } = await inquirer.prompt([

‎examples/oft-hyperliquid/deploy/MyHyperLiquidComposer_Recoverable.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CHAIN_IDS,
88
EthersSigner,
99
getCoreSpotDeployment,
10+
isQuoteAsset,
1011
useBigBlock,
1112
useSmallBlock,
1213
} from '@layerzerolabs/hyperliquid-composer'
@@ -54,6 +55,30 @@ const deploy: DeployFunction = async (hre) => {
5455
// Validates and returns the native spot
5556
const hip1Token = getCoreSpotDeployment(coreSpotIndex, isTestnet)
5657

58+
// Check if the token is a quote asset - warn if it is
59+
console.log(`\nChecking if token ${coreSpotIndex} is a quote asset...`)
60+
const { isQuoteAsset: isQuote, tokenName } = await isQuoteAsset(isTestnet, parseInt(coreSpotIndex), loglevel)
61+
62+
if (isQuote) {
63+
console.warn(`\n[WARNING] Token ${coreSpotIndex}${tokenName ? ` (${tokenName})` : ''} IS a quote asset!`)
64+
console.warn(`For quote assets, you should use MyHyperLiquidComposer_FeeToken instead.`)
65+
console.warn(`FeeToken composer provides automatic user activation using the token itself.\n`)
66+
67+
const { continueAnyway } = await inquirer.prompt([
68+
{
69+
type: 'confirm',
70+
name: 'continueAnyway',
71+
message: 'Do you want to continue with recoverable composer anyway?',
72+
default: false,
73+
},
74+
])
75+
76+
if (!continueAnyway) {
77+
console.log('Deployment cancelled.')
78+
process.exit(0)
79+
}
80+
}
81+
5782
const { address: address_oft } = await hre.deployments.get(contractName_oft).catch(async () => {
5883
console.log(`Deployment file for ${contractName_oft}.json in deployments/${networkName} not found`)
5984
const { proceedWithOFTAddress } = await inquirer.prompt([

‎examples/oft-hyperliquid/deploy/MyHyperliquidComposer.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CHAIN_IDS,
88
EthersSigner,
99
getCoreSpotDeployment,
10+
isQuoteAsset,
1011
useBigBlock,
1112
useSmallBlock,
1213
} from '@layerzerolabs/hyperliquid-composer'
@@ -52,6 +53,30 @@ const deploy: DeployFunction = async (hre) => {
5253
// Validates and returns the native spot
5354
const hip1Token = getCoreSpotDeployment(coreSpotIndex, isTestnet)
5455

56+
// Check if the token is a quote asset - warn if it is
57+
console.log(`\nChecking if token ${coreSpotIndex} is a quote asset...`)
58+
const { isQuoteAsset: isQuote, tokenName } = await isQuoteAsset(isTestnet, parseInt(coreSpotIndex), loglevel)
59+
60+
if (isQuote) {
61+
console.warn(`\n[WARNING] Token ${coreSpotIndex}${tokenName ? ` (${tokenName})` : ''} IS a quote asset!`)
62+
console.warn(`For quote assets, you should use MyHyperLiquidComposer_FeeToken instead.`)
63+
console.warn(`FeeToken composer provides automatic user activation using the token itself.\n`)
64+
65+
const { continueAnyway } = await inquirer.prompt([
66+
{
67+
type: 'confirm',
68+
name: 'continueAnyway',
69+
message: 'Do you want to continue with regular composer anyway?',
70+
default: false,
71+
},
72+
])
73+
74+
if (!continueAnyway) {
75+
console.log('Deployment cancelled.')
76+
process.exit(0)
77+
}
78+
}
79+
5580
const { address: address_oft } = await hre.deployments.get(contractName_oft).catch(async () => {
5681
console.log(`Deployment file for ${contractName_oft}.json in deployments/${networkName} not found`)
5782
const { proceedWithOFTAddress } = await inquirer.prompt([

0 commit comments

Comments
 (0)