Enhance Privy integration by adding getWalletIdFromAddress function to retrieve wallet IDs directly from addresses. Update callContract and related methods to utilize the new function for improved transaction handling. Modify tests to reflect changes in wallet address handling and ensure accurate position management.

This commit is contained in:
2025-12-30 03:02:23 +07:00
parent 274effc749
commit 95e60108af
5 changed files with 75 additions and 27 deletions

View File

@@ -1,15 +1,15 @@
import {test} from 'node:test'
import assert from 'node:assert'
import {closeGmxPositionImpl, getClientForAddress} from '../../src/plugins/custom/gmx'
import {TradeDirection} from '../../src/generated/ManagingApiTypes'
import {Ticker, TradeDirection} from '../../src/generated/ManagingApiTypes'
test('GMX Position Closing', async (t) => {
await t.test('should close position', async () => {
const sdk = await getClientForAddress('0x1aDD85ee6f327d20340A451A8210FB32c4c97504')
const sdk = await getClientForAddress('0x932167388dD9aad41149b3cA23eBD489E2E2DD78')
const result = await closeGmxPositionImpl(
sdk,
"XRP",
Ticker.BTC,
TradeDirection.Long
)
console.log('Position closing result:', result)

View File

@@ -14,8 +14,8 @@ test('GMX Position Opening', async (t) => {
0.00012, // ~5.3 USDC collateral with 2x leverage (fits available balance of 5.69 USDC)
2,
87856,
undefined, // No stop-loss
undefined // No take-profit
75000,
100000
)
console.log('Position opening result:', result)
assert.ok(result, 'Position opening result should be defined')

View File

@@ -8,18 +8,18 @@ describe('swap tokens implementation', () => {
it('should swap SOL to USDC successfully', async () => {
try {
const testAccount = '0x932167388dD9aad41149b3cA23eBD489E2E2DD78'
const sdk = await getClientForAddress(testAccount)
console.log('Account', sdk.account)
const result = await swapGmxTokensImpl(
sdk,
Ticker.USDC,
Ticker.SOL,
3,
'market',
undefined,
0.5
)
const result = await swapGmxTokensImpl(
sdk,
Ticker.SOL,
Ticker.USDC,
0.0495,
'market',
undefined,
0.5
)
assert.strictEqual(typeof result, 'string')
assert.strictEqual(result, 'swap_order_created')