Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75c35f56f1 |
@@ -1119,9 +1119,11 @@ func pumpRoutePlanStatsV2(in uint64, out uint64, plan []RoutePlanStepV2, include
|
|||||||
|
|
||||||
func parseJupiterPumpAmmRoute(tx VersionedTransaction, instruction Instructions, in uint64, out uint64, plan []RoutePlanStep) (*TxSignal, bool, error) {
|
func parseJupiterPumpAmmRoute(tx VersionedTransaction, instruction Instructions, in uint64, out uint64, plan []RoutePlanStep) (*TxSignal, bool, error) {
|
||||||
var (
|
var (
|
||||||
isBuy bool
|
isBuy bool
|
||||||
isSell bool
|
isSell bool
|
||||||
count int
|
count int
|
||||||
|
sellPercent uint8
|
||||||
|
buyPercent uint8
|
||||||
)
|
)
|
||||||
for _, step := range plan {
|
for _, step := range plan {
|
||||||
if !isInputIdx0(step.InputIdx) {
|
if !isInputIdx0(step.InputIdx) {
|
||||||
@@ -1130,9 +1132,11 @@ func parseJupiterPumpAmmRoute(tx VersionedTransaction, instruction Instructions,
|
|||||||
if isPumpSwapSellKind(step.Swap.Kind) {
|
if isPumpSwapSellKind(step.Swap.Kind) {
|
||||||
isSell = true
|
isSell = true
|
||||||
count++
|
count++
|
||||||
|
sellPercent = step.Percent
|
||||||
} else if isPumpSwapBuyKind(step.Swap.Kind) {
|
} else if isPumpSwapBuyKind(step.Swap.Kind) {
|
||||||
isBuy = true
|
isBuy = true
|
||||||
count++
|
count++
|
||||||
|
buyPercent = step.Percent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
@@ -1154,6 +1158,9 @@ func parseJupiterPumpAmmRoute(tx VersionedTransaction, instruction Instructions,
|
|||||||
if in > 0 {
|
if in > 0 {
|
||||||
token0Amount = formatTokenAmount(in)
|
token0Amount = formatTokenAmount(in)
|
||||||
}
|
}
|
||||||
|
if sellPercent > 0 && sellPercent < 100 {
|
||||||
|
token0Amount = token0Amount.Mul(decimal.NewFromInt(int64(sellPercent))).Div(decimal.NewFromInt(100))
|
||||||
|
}
|
||||||
return &TxSignal{
|
return &TxSignal{
|
||||||
TxHash: tx.Signatures[0].String(),
|
TxHash: tx.Signatures[0].String(),
|
||||||
Maker: tx.StaticAccountKeys[0].String(),
|
Maker: tx.StaticAccountKeys[0].String(),
|
||||||
@@ -1189,6 +1196,10 @@ func parseJupiterPumpAmmRoute(tx VersionedTransaction, instruction Instructions,
|
|||||||
if in > 0 {
|
if in > 0 {
|
||||||
token1Amount = formatSolAmount(in)
|
token1Amount = formatSolAmount(in)
|
||||||
}
|
}
|
||||||
|
if buyPercent > 0 && buyPercent < 100 {
|
||||||
|
token1Amount = token1Amount.Mul(decimal.NewFromInt(int64(buyPercent))).Div(decimal.NewFromInt(100))
|
||||||
|
token0Amount = token0Amount.Mul(decimal.NewFromInt(int64(buyPercent))).Div(decimal.NewFromInt(100))
|
||||||
|
}
|
||||||
return &TxSignal{
|
return &TxSignal{
|
||||||
TxHash: tx.Signatures[0].String(),
|
TxHash: tx.Signatures[0].String(),
|
||||||
Maker: tx.StaticAccountKeys[0].String(),
|
Maker: tx.StaticAccountKeys[0].String(),
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ func TestDecodeRouteArg(t *testing.T) {
|
|||||||
name: "Jupiter V6 RouteArg Test 1",
|
name: "Jupiter V6 RouteArg Test 1",
|
||||||
hexData: "e517cb977ae3ad2a03000000646400017ab0b6c3d206f46577050000000c0000526401025f00640203bb628e2902000000338c430100000000320000",
|
hexData: "e517cb977ae3ad2a03000000646400017ab0b6c3d206f46577050000000c0000526401025f00640203bb628e2902000000338c430100000000320000",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Jupiter V6 RouteArg Test 2",
|
||||||
|
hexData: "e517cb977ae3ad2a04000000642300024b00000000410002761acfb15ea9fdcd0501200204769358e96343759bf8014402046196591e1e020000f5bf6fe101000000d00700",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user