可能交换溶胶与USDC吗?
我正在尝试将SOL转换为USDC,这是我尝试使用Web3J,Raydium甚至木星尝试的,这些集成都没有返回积极的结果,另一方面,我没有找到有关该主题的文档,我知道如何发送令牌 - >令牌但没有加密(sol) - > 稳定的折磨(USDC)
我要做的是
现在要与木星一起工作,这是不可能的,有没有办法在SOL和USDC之间进行交换?代码示例
const jupiter = await Jupiter.load({
connection: this.connection,
cluster: "mainnet-beta",
user: wallet,
});
const tokens = await this.getTokens();
console.log(tokens);
const routeMap: Map<string, string[]> = jupiter.getRouteMap();
const outputToken = tokens.find((t) => t.address == "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const inputToken = tokens.find((t) => t.address == environment.swap.WrappedSolAddress);
const routes = await jupiter.computeRoutes({
inputMint: new PublicKey(inputToken.address),
outputMint: new PublicKey(outputToken.address),
inputAmount: LAMPORTS_PER_SOL * 1,
slippage: 1,
});
const { execute } = await jupiter.exchange({
routeInfo: routes.routesInfos[0],
});
const swapResult: any = await execute();
错误
TypeError: Cannot read properties of undefined (reading 'address')
at SolanaService.<anonymous> (/home/foo/GitHub/foo/dist/apps/foo/webpack:/doo/apps/foo-api/src/app/services/solana/solana.service.ts:208:55)
I am trying to SWAP from SOL to USDC, this is what I have tried with web3js, Raydium and even Jupiter, none of these integrations have returned a positive result, on the other hand I do not find much documentation on the subject, I know how to send TOKEN -> TOKEN but no CRYPTO (SOL) -> STABLE-COIN (USDC)
What I am trying to do is make the SWAP work now with Jupiter, this has been impossible, there is a way to make SWAP between SOL and USDC?
Code Example
const jupiter = await Jupiter.load({
connection: this.connection,
cluster: "mainnet-beta",
user: wallet,
});
const tokens = await this.getTokens();
console.log(tokens);
const routeMap: Map<string, string[]> = jupiter.getRouteMap();
const outputToken = tokens.find((t) => t.address == "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const inputToken = tokens.find((t) => t.address == environment.swap.WrappedSolAddress);
const routes = await jupiter.computeRoutes({
inputMint: new PublicKey(inputToken.address),
outputMint: new PublicKey(outputToken.address),
inputAmount: LAMPORTS_PER_SOL * 1,
slippage: 1,
});
const { execute } = await jupiter.exchange({
routeInfo: routes.routesInfos[0],
});
const swapResult: any = await execute();
Error
TypeError: Cannot read properties of undefined (reading 'address')
at SolanaService.<anonymous> (/home/foo/GitHub/foo/dist/apps/foo/webpack:/doo/apps/foo-api/src/app/services/solana/solana.service.ts:208:55)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您获取令牌的方式可能是错误的
The way you're fetching tokens might be wrong