Swap feature

This commit is contained in:
2025-06-10 13:00:05 +07:00
parent d016095460
commit 38656d705c
5 changed files with 294 additions and 16 deletions

View File

@@ -9,8 +9,8 @@ test('GMX Position Closing', async (t) => {
const result = await closeGmxPositionImpl(
sdk,
Ticker.AAVE,
TradeDirection.Short
Ticker.SOL,
TradeDirection.Long
)
console.log('Position closing result:', result)
assert.ok(result, 'Position closing result should be defined')

View File

@@ -0,0 +1,32 @@
import {before, describe, it} from 'node:test'
import assert from 'node:assert'
import {getClientForAddress, swapGmxTokensImpl} from '../../src/plugins/custom/gmx.js'
import {Ticker} from '../../src/generated/ManagingApiTypes'
describe('swap tokens implementation', () => {
let sdk: any
before(async () => {
// Initialize the SDK with a test account
const testAccount = '0xbba4eaa534cbd0ecaed5e2fd6036aec2e7ee309f'
sdk = await getClientForAddress(testAccount)
})
it('should swap USDC to ETH successfully', async () => {
try {
const result = await swapGmxTokensImpl(
sdk,
Ticker.GMX, // fromTicker
Ticker.USDC, // toTicker
2.06 // amount
)
assert.strictEqual(typeof result, 'string')
assert.strictEqual(result, 'swap_order_created')
} catch (error) {
// Test that the error is related to actual execution rather than parameter validation
assert.ok(error instanceof Error)
console.log('Expected error during test execution:', error.message)
}
})
})