swap amount input
This commit is contained in:
@@ -15,6 +15,11 @@ type metaoraPoolInitializePoolData struct {
|
||||
TokenBAmount uint64 `json:"tokenBAmount"`
|
||||
}
|
||||
|
||||
type metaoraPoolSwapArgs struct {
|
||||
InAmount uint64
|
||||
MinimumOutAmount uint64
|
||||
}
|
||||
|
||||
var (
|
||||
meteoraVaultProgram = solana.MustPublicKeyFromBase58("24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi")
|
||||
meteoraVaultDepositDiscriminator = []byte{0xf2, 0x23, 0xc6, 0x89, 0x52, 0xe1, 0xf2, 0xb6}
|
||||
@@ -726,6 +731,10 @@ func metaoraPoolRemoveLiquidity(tx *Tx, instruction Instruction, innerInstructio
|
||||
}
|
||||
|
||||
func metaoraPoolSwap(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
var args metaoraPoolSwapArgs
|
||||
if err := agbinary.NewBorshDecoder(instruction.Data[8:]).Decode(&args); err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed to decode meteora pools swap args: %w", err)
|
||||
}
|
||||
pool := tx.rawTx.accountList[instruction.Accounts[0]]
|
||||
payer := tx.rawTx.accountList[instruction.Accounts[12]]
|
||||
|
||||
@@ -874,5 +883,10 @@ func metaoraPoolSwap(tx *Tx, instruction Instruction, innerInstructions InnerIns
|
||||
EntryContract: entryContract,
|
||||
},
|
||||
}
|
||||
swaps[0].SetSwapAmountInfo(
|
||||
SwapModeExactIn,
|
||||
decimal.NewFromUint64(args.InAmount),
|
||||
decimal.NewFromUint64(args.MinimumOutAmount),
|
||||
)
|
||||
return swaps, offset, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user