Swap feature
This commit is contained in:
@@ -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')
|
||||
|
||||
32
src/Managing.Web3Proxy/test/plugins/swap-tokens.test.ts
Normal file
32
src/Managing.Web3Proxy/test/plugins/swap-tokens.test.ts
Normal 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)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user