Files
managing-apps/src/Managing.Web3Proxy/test/plugins/swap-tokens.test.ts
2025-12-11 12:23:01 +07:00

31 lines
964 B
TypeScript

import {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.js'
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.BTC,
Ticker.USDC,
0.00007559
)
assert.strictEqual(typeof result, 'string')
assert.strictEqual(result, 'swap_order_created')
} catch (error) {
console.log('error', error)
// Test that the error is related to actual execution rather than parameter validation
assert.fail(error.message)
}
})
})