34 lines
964 B
TypeScript
34 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)
|
|
|
|
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')
|
|
} catch (error) {
|
|
console.log('error', error)
|
|
|
|
// Test that the error is related to actual execution rather than parameter validation
|
|
assert.fail(error.message)
|
|
}
|
|
})
|
|
})
|