Circular Trading
Diaph
Hey guys!
I'm trying to make a circular swap but I keep getting the same error. Am I doing something wrong?
const transaction = new Transaction();
// Get first quote
const quoteResponse1 = await getQuote({
tokenIn: "0x2::sui::SUI",
tokenOut: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
amountIn: "1000000000"
});
// Build first quote
const result1 = await buildTx({
quoteResponse: quoteResponse1,
devInspect: true,
accountAddress: "my_address",
slippage: 1,
commission: {
partner: "my_addess",
commissionBps: 0
},
extendTx: {
tx: transaction
}
});
const { coinOut } = result1 || {};
// Get second quote (back)
const quoteResponse2 = await getQuote({
tokenOut: "0x2::sui::SUI",
tokenIn: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
amountIn: quoteResponse1.returnAmountWithDecimal,
});
// Build second quote (back)
const result2 = await buildTx({
quoteResponse: quoteResponse2,
devInspect: true,
accountAddress: "my_address",
slippage: 0.5,
commission: {
partner: "my_address",
commissionBps: 0
},
extendTx: {
tx: transaction,
coinIn: coinOut
}
});
// Error from here
const signed = await client.signAndExecuteTransaction({
transaction,
signer: keypair
});
This is the error I get:
Dry run failed, could not automatically determine a budget: UnusedValueWithoutDrop { result_idx: 1, secondary_idx: 0 }
I also have no errors returned by "devInspectTransactionBlock".