Update SDK (#35)

* Update SDK for swap

* Fix web3proxy build

* Update types

* Fix swap

* Send token test and BASE transfer

* fix cache and hook

* Fix send

* Update health check with uiFeereceiver

* Fix sdk

* Fix get positions

* Fix timeoutloop

* Fix open position

* Fix closes positions

* Review
This commit is contained in:
Oda
2025-09-17 14:28:56 +07:00
committed by GitHub
parent 271dd70ad7
commit cee3902a4d
91 changed files with 21375 additions and 2831 deletions

View File

@@ -3,7 +3,7 @@ import assert from 'node:assert';
import {claimGmxFundingFeesImpl, getClientForAddress} from '../../src/plugins/custom/gmx.js';
test('GMX Claim Funding Fees', async (t) => {
const testAccount = '0xbBA4eaA534cbD0EcAed5E2fD6036Aec2E7eE309f';
const testAccount = '0x0af60b5c1c349744ef8fa8c4ed78ee1a0d392fe9';
await t.test('should claim funding fees for valid account', async () => {
try {

View File

@@ -5,11 +5,11 @@ import {TradeDirection} from '../../src/generated/ManagingApiTypes'
test('GMX Position Closing', async (t) => {
await t.test('should close a long position for BTC', async () => {
const sdk = await getClientForAddress('0x0b4A132cb6ed8fa66953bf61a53D0B91DaCaAd78')
const sdk = await getClientForAddress('0x932167388dD9aad41149b3cA23eBD489E2E2DD78')
const result = await closeGmxPositionImpl(
sdk,
"BTC",
"ETH",
TradeDirection.Long
)
console.log('Position closing result:', result)

View File

@@ -0,0 +1,48 @@
import {describe, it} from 'node:test'
import assert from 'node:assert'
import {sendTokenImpl} from '../../src/plugins/custom/privy.js'
import {Ticker} from '../../src/generated/ManagingApiTypes.js'
import {ARBITRUM} from '../../src/generated/gmxsdk/configs/chains.js'
describe('send token implementation', () => {
it('should send USDC token successfully', async () => {
try {
// Test addresses - you can replace these with actual addresses
const senderAddress = '0x0af60b5c1c349744ef8fa8c4ed78ee1a0d392fe9'
const recipientAddress = '0xeba3adc12481db743884bbd11f2a75e0c4cffcf6'
// Amount as string (will be converted to smallest units internally)
const amount = "0.000547" // ETH amount
const ticker = Ticker.ETH
console.log('Testing token transfer:')
console.log('Sender:', senderAddress)
console.log('Recipient:', recipientAddress)
console.log('Amount:', amount.toString())
console.log('Ticker:', ticker)
const result = await sendTokenImpl(
senderAddress,
recipientAddress,
ticker,
amount,
ARBITRUM
)
// Verify the result is a transaction hash (string starting with 0x)
assert.strictEqual(typeof result, 'string')
assert.strictEqual(result.startsWith('0x'), true)
assert.strictEqual(result.length, 66) // Standard transaction hash length
console.log('Transaction hash:', result)
} catch (error) {
console.log('Error during token transfer:', error)
// Test that the error is related to actual execution rather than parameter validation
// This could be due to insufficient balance, allowance, or network issues
assert.fail(`Token transfer failed: ${error.message}`)
}
})
})

View File

@@ -1,29 +1,30 @@
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'
import {Ticker} from '../../src/generated/ManagingApiTypes.js'
describe('swap tokens implementation', () => {
it('should swap USDC to ETH successfully', async () => {
it('should swap SOL to USDC successfully', async () => {
try {
const testAccount = '0x0AF60B5C1c349744Ef8fa8c4ed78Ee1A0d392Fe9'
const testAccount = '0xbBA4eaA534cbD0EcAed5E2fD6036Aec2E7eE309f'
const sdk = await getClientForAddress(testAccount)
console.log('Account', sdk.account)
const result = await swapGmxTokensImpl(
sdk,
Ticker.SOL, // fromTicker
Ticker.USDC, // toTicker
0.001 // amount
)
const result = await swapGmxTokensImpl(
sdk,
Ticker.PENDLE,
Ticker.USDC,
13.339559522
)
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.ok(error instanceof Error)
console.log('Expected error during test execution:', error.message)
assert.fail(error.message)
}
})
})