jupiter-core-example's Issues
Error - error: TypeError: items.at is not a function or its return value is not iterable
When I run the project with yarn start I got this error:
Getting routes for 1 USDC -> USDT...
{
error: TypeError: items.at is not a function or its return value is not iterable
at r (/Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:113:48)
at cartesianIterator.next ()
at cartesianIterator (/Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:113:12)
at cartesianIterator.next ()
at cartesian (/Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:117:44)
at forEach (/Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:221:41)
at Map.forEach ()
at walkTheTree (/Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:171:25)
at /Users/daro/projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/src/lib/computeRouteInfos.ts:202:11
at Map.forEach ()
}
Is there any way to set intermediateTokens
I want to use some specific tokens as the intermediateTokens, is there any method to do this?
Buffer Layout Type throwing error - causes Jupiter SDK to globally fail and crash app
I'm getting a resolution issue related to the "@solana/buffer-layout": "4.0.0"
resolution and breaking changes to the lib.
There's an extensive thread related to this issue located at solana-labs/solana-program-library#2534 and I've tried all the options suggested without success.
The issue first surfaces when doing a yarn install
where the following warning appears: warning Resolution field "@solana/[email protected]" is incompatible with requested version "@solana/buffer-layout@^3.0.0"
If I use typescript types I get the following stack trace error:
TypeError: fields must be array of Layout instances
at new Structure (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/src/Layout.ts:1107:13)
at Object.struct (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/src/Layout.ts:2615:5)
at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/web3.js/src/system-program.ts:648:26)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .js] (~/arby/node_modules/ts-node/src/index.ts:1445:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
[nodemon] app crashed - waiting for file changes before starting...
If I switch to JS without the need for types I get the following stack trace error:
~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:999
throw new TypeError('fields must be array of Layout instances');
^
TypeError: fields must be array of Layout instances
at new Structure (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:999:19)
at Object.exports.struct (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:2373:57)
at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/web3.js/lib/index.cjs.js:3525:37)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/dist/cjs/index.js:32:29)
Here's my package.json deps:
{
"dependencies": {
"@jup-ag/core": "^1.0.0-beta.24",
"@solana/web3.js": "^1.42.0",
"axios": "^0.27.2",
"bcrypt": "^5.0.1",
"client-sessions": "^0.8.0",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.1",
"express": "^4.17.1",
"helmet": "^4.6.0",
"migrate": "^1.7.0",
"morgan": "^1.10.0",
"pg": "^8.7.1",
"sql-template-strings": "^2.2.2",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/client-sessions": "^0.8.3",
"@types/express": "^4.17.13",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.33",
"nodemon": "^2.0.12",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
},
"resolutions": {
"@solana/buffer-layout": "4.0.0"
}
}
I'm out of options for this one. Any help, feedback or fix suggestions welcome.
Tick Array error
Keep getting the following errors:
Error: Invariant failed: tickArray is null
Error: Crossed the maximum number of tick arrays
TypeError: fields must be array of Layout instances
Right after the start of the application, it's crashing.
➜ jupiter-core-example git:(main) ✗ yarn start
yarn run v1.22.5
$ npm run watch & nodemon --watch ./dist --exec 'node ./dist/main.js' --delay 1000ms
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dist/**/*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./dist/main.js`
npm WARN lifecycle The node binary used for scripts is /var/folders/b_/695p375x3cd0tfxp0nzgyb9w0000gp/T/yarn--1641625841043-0.08431479813294107/node but npm is using /Users/necmttn/.nvm/versions/node/v14.17.6/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> [email protected] watch /Users/necmttn/Projects/crypto/jupiter-core-example
> parcel watch
/Users/necmttn/Projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/node_modules/@saberhq/token-utils/node_modules/@solana/buffer-layout/lib/Layout.js:999
throw new TypeError('fields must be array of Layout instances');
^
TypeError: fields must be array of Layout instances
at new Structure (/Users/necmttn/Projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/node_modules/@saberhq/token-utils/node_modules/@solana/buffer-layout/lib/Layout.js:999:19)
at Object.exports.struct (/Users/necmttn/Projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/node_modules/@saberhq/token-utils/node_modules/@solana/buffer-layout/lib/Layout.js:2373:57)
at structLayout (/Users/necmttn/Projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/node_modules/@saberhq/token-utils/dist/cjs/layout.js:18:73)
at Object.<anonymous> (/Users/necmttn/Projects/crypto/jupiter-core-example/node_modules/@jup-ag/core/node_modules/@saberhq/stableswap-sdk/dist/cjs/state/layout.js:23:59)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
[nodemon] app crashed - waiting for file changes before starting...
Errors while creating open orders for serum.
Jupiter swap often makes an error when creating open orders for serum.
> Program log: Instruction: CreateOpenOrders
> Invoking System Program
> Allocate: account Address { address: CQeJQmFyxTVvpEhpoeNMGuEzFs2od8hPrb3y5wHbCqC8, base: None } already in use
> Program returned error: custom program error: 0x0
> Program [Jupiter Aggregator v3](https://solscan.io/address/JUP3c2Uh3WA4Ng34tw6kPd2G4C5BB21Xo36Je1s32Ph) consumed 8440 of 1231817 compute units
SDK: can't cancel orders + expired orders issue
I'm trying to cancel orders via SDK (batchCancelExpiredOrder
, cancelOrder
). It runs without errors, but the orders are never canceled, although if you go to the website, they are canceled there.
Also, when creating an order createOrder
, I specify expiredAt
, but the orders remain open, do they need to be manually closed with batchCancelExpiredOrder
?
Unexpected timeouts while using jup.ag swap api in NodeJS
Hi guys, I just started to use the Jupiter APIs, but I have one problem with them. It is terribly slow. The code does work, it will swap, but 9 out of 10 times it will time out and I don't know why. I tried to find out where the code gets stuck and it is on the following code: await connection.confirmTransaction(txid);
Why could that be? I have also used different RPC endpoints, for example the Helius one, and it was still super slow. I have also made a "race" between trying to swap in in the Jupiter GUI using my custom Helios RPC endpoint and my code with the same Helios RPC endpoint and the GUI was significantly faster. What am I missing please?
This is the code:
const { Connection, Keypair, VersionedTransaction } = require('@solana/web3.js');
const fetch = require('cross-fetch');
const bs58 = require('bs58');
const private_key = 'YOUR_PRIVATE_KEY';
const inputMint = 'So11111111111111111111111111111111111111112';
const outputMint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const amount = 100000;
const slippageBps = 10;
const rpcEndpoint = 'https://api.mainnet-beta.solana.com';
//setup connection
const connection = new Connection(rpcEndpoint);
// Setup wallet
const secretKey = bs58.decode(private_key);
const wallet = Keypair.fromSecretKey(secretKey);
async function swap() {
try {
// Get quote
const quoteResponse = await (
await fetch(`https://quote-api.jup.ag/v6/quote?inputMint=${inputMint}&outputMint=${outputMint}&amount=${amount}&slippageBps=${slippageBps}`)
).json();
// Get serialized transactions for the swap
const { swapTransaction } = await (
await fetch('https://quote-api.jup.ag/v6/swap', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
quoteResponse,
userPublicKey: wallet.publicKey.toString(),
wrapAndUnwrapSol: true,
dynamicComputeUnitLimit: true,
prioritizationFeeLamports: 'auto'
})
})
).json();
// Deserialize and sign the transaction
const swapTransactionBuf = Buffer.from(swapTransaction, 'base64');
const transaction = VersionedTransaction.deserialize(swapTransactionBuf);
transaction.sign([wallet]);
// Execute the transaction
const rawTransaction = transaction.serialize();
const txid = await connection.sendRawTransaction(rawTransaction, {
skipPreflight: true,
maxRetries: 2
});
await connection.confirmTransaction(txid);
console.log(`Swap successful! Transaction ID: ${txid}`);
console.log(`View the transaction on Solscan: https://solscan.io/tx/${txid}`);
} catch (error) {
console.error('Error during swap:', error);
}
}
// Run the swap function
swap();
Thank you for you time!
API: add information about order filling
![image](https://private-user-images.githubusercontent.com/13103045/302969151-9a1ab3a2-86ec-4eb5-bde5-ae66145b68d5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxODA2MDAsIm5iZiI6MTcyMjE4MDMwMCwicGF0aCI6Ii8xMzEwMzA0NS8zMDI5NjkxNTEtOWExYWIzYTItODZlYy00ZWI1LWJkZTUtYWU2NjE0NWI2OGQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDE1MjUwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJiNTE1M2Q1YTczMGU4NjA2NDdkMjAyY2VlYTZlODIzMDBiMWVlODdkOTVhZGUyZDhmN2VmMzhmOGM1OWQzMWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.OjBtMbHg7Zd7KHCy2gElg3dBC879Aiier_a7kUHd9tc)
Please add it to endpoint: https://jup.ag/api/limit/v1/openOrders
Thanks!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.