Add build claim methods to test for UI Fee
This commit is contained in:
@@ -844,3 +844,25 @@ export const MARKETS: Record<string, Record<string, MarketConfig>> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function buildClaimParams(userAddress: string) {
|
||||||
|
const marketAddresses: string[] = [];
|
||||||
|
const tokenAddresses: string[] = [];
|
||||||
|
|
||||||
|
for (const [marketAddress, marketConfig] of Object.entries(MARKETS[ARBITRUM])) {
|
||||||
|
// Add market address twice (for long and short positions)
|
||||||
|
marketAddresses.push(marketAddress, marketAddress);
|
||||||
|
|
||||||
|
// Add long token and short token addresses
|
||||||
|
tokenAddresses.push(marketConfig.longTokenAddress, marketConfig.shortTokenAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
marketAddresses,
|
||||||
|
tokenAddresses,
|
||||||
|
userAddress
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example usage:
|
||||||
|
// const params = buildClaimParams("0x0AF60B5C1c349744Ef8fa8c4ed78Ee1A0d392Fe9");
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import {strict as assert} from 'node:assert';
|
||||||
|
import {test} from 'node:test';
|
||||||
|
import {buildClaimParams} from '../../src/generated/gmxsdk/configs/markets.js';
|
||||||
|
|
||||||
|
test('Market Claims Test - should generate claim parameters and output market and token addresses', () => {
|
||||||
|
const userAddress = "0x0AF60B5C1c349744Ef8fa8c4ed78Ee1A0d392Fe9";
|
||||||
|
const claimParams = buildClaimParams(userAddress);
|
||||||
|
|
||||||
|
const [marketAddresses, tokenAddresses, account] = claimParams;
|
||||||
|
|
||||||
|
console.log('Market Addresses:');
|
||||||
|
console.log('[');
|
||||||
|
(Array.isArray(marketAddresses) ? marketAddresses : [marketAddresses]).forEach((address, index, arr) => {
|
||||||
|
const comma = index < arr.length - 1 ? ',' : '';
|
||||||
|
console.log(` ${address}${comma}`);
|
||||||
|
});
|
||||||
|
console.log(']');
|
||||||
|
|
||||||
|
console.log('\nToken Addresses:');
|
||||||
|
console.log('[');
|
||||||
|
(Array.isArray(tokenAddresses) ? tokenAddresses : [tokenAddresses]).forEach((address, index, arr) => {
|
||||||
|
const comma = index < tokenAddresses.length - 1 ? ',' : '';
|
||||||
|
console.log(` ${address}${comma}`);
|
||||||
|
});
|
||||||
|
console.log(']');
|
||||||
|
|
||||||
|
console.log(`\nUser Address: ${account}`);
|
||||||
|
|
||||||
|
// Basic validation
|
||||||
|
assert.equal(marketAddresses.length, tokenAddresses.length);
|
||||||
|
assert.equal(account, userAddress);
|
||||||
|
assert.equal(marketAddresses.length % 2, 0); // Should be even (each market twice)
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user