fix orcawhirpool int64 overflow
This commit is contained in:
@@ -13,7 +13,7 @@ var ()
|
||||
|
||||
func main() {
|
||||
|
||||
var slot uint64 = 414437304
|
||||
var slot uint64 = 414696178
|
||||
client := rpc.New("https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d")
|
||||
var rewards = false
|
||||
var version uint64 = 0
|
||||
|
||||
@@ -26,7 +26,7 @@ func main() {
|
||||
var data = NewBlockData(decimal.NewFromFloat(100.0))
|
||||
client := rpc.New("https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d")
|
||||
var version uint64 = 0
|
||||
txSig, _ := solana.SignatureFromBase58("33ausqKuyRbRi8A4SMFhoZRj6rAuNAnpneNdrme6DWnA6QGSQ42DJGMmwvZTqAnPpw6uwV3YV9cdYP4DNMMY4TNr")
|
||||
txSig, _ := solana.SignatureFromBase58("4sj82GCLtgTDExq7B8YrBsrrqPcE4FqT5Y1gKWmE4cHMDxs7wkCV1hik73dSZ99gZm3K4wyBZQ6U8Nmf48rM9Jri")
|
||||
tx, err := client.GetTransaction(context.Background(), txSig, &rpc.GetTransactionOpts{
|
||||
Commitment: rpc.CommitmentFinalized,
|
||||
Encoding: solana.EncodingBase64,
|
||||
@@ -78,7 +78,10 @@ func main() {
|
||||
i++
|
||||
}
|
||||
}
|
||||
fmt.Printf("swap: %d, program: %s, base: %s quote: %s \n", i, action.Program, action.BaseMint.String(), action.QuoteMint.String())
|
||||
fmt.Printf("swap: %d, program: %s, event: %s, base: %s quote: %s, base amount: %s, quote amount: %s, \n", i,
|
||||
action.Program, action.Event, action.BaseMint.String(), action.QuoteMint.String(),
|
||||
action.BaseAmount.String(),
|
||||
action.QuoteAmount.String())
|
||||
if err = HandleAction(context.Background(), result, actions, data); err != nil {
|
||||
//h.logger.Errorf("handle action error: %s - %v", result.RawTx.Transaction.Signatures[0].String(), err)
|
||||
fmt.Println("parse action error:", "tx", result.GetTxHash(), "i", i, "err", err)
|
||||
|
||||
@@ -263,10 +263,10 @@ func orcaWhirPoolLiquidityParser(tx *Tx, instruction Instruction, innerInstructi
|
||||
//return nil, increaseOffset(offset), fmt.Errorf("meta Bonding Curve initial parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(tx.rawTx.accountList[vault0]) || to.Equals(tx.rawTx.accountList[vault0])) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(tx.rawTx.accountList[vault1]) || to.Equals(tx.rawTx.accountList[vault1])) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
quoteFound = true
|
||||
}
|
||||
if baseFound && quoteFound {
|
||||
@@ -370,10 +370,10 @@ func orcaWhirPoolLiquidityV2Parser(tx *Tx, instruction Instruction, innerInstruc
|
||||
continue
|
||||
}
|
||||
if !baseFound && (from.Equals(tx.rawTx.accountList[vault0]) || to.Equals(tx.rawTx.accountList[vault0])) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(tx.rawTx.accountList[vault1]) || to.Equals(tx.rawTx.accountList[vault1])) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
quoteFound = true
|
||||
}
|
||||
if baseFound && quoteFound {
|
||||
@@ -475,10 +475,10 @@ func orcaWhirPoolCollectFeeParser(tx *Tx, instruction Instruction, innerInstruct
|
||||
//return nil, increaseOffset(offset), fmt.Errorf("orca whirpool parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(tx.rawTx.accountList[vault0]) || to.Equals(tx.rawTx.accountList[vault0])) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(tx.rawTx.accountList[vault1]) || to.Equals(tx.rawTx.accountList[vault1])) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
quoteFound = true
|
||||
}
|
||||
if (baseFound && quoteFound) || i >= 6 {
|
||||
@@ -577,10 +577,10 @@ func orcaWhirPoolCollectFeeV2Parser(tx *Tx, instruction Instruction, innerInstru
|
||||
//return nil, increaseOffset(offset), fmt.Errorf("meta Bonding Curve initial parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(tx.rawTx.accountList[vault0]) || to.Equals(tx.rawTx.accountList[vault0])) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(tx.rawTx.accountList[vault1]) || to.Equals(tx.rawTx.accountList[vault1])) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
quoteFound = true
|
||||
}
|
||||
if (baseFound && quoteFound) || i >= 6 {
|
||||
@@ -679,10 +679,10 @@ func orcaWhirPoolCollectProtocolFeeV2Parser(tx *Tx, instruction Instruction, inn
|
||||
// return nil, increaseOffset(offset), fmt.Errorf("meta Bonding Curve initial parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(tx.rawTx.accountList[vault0]) || to.Equals(tx.rawTx.accountList[vault0])) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(tx.rawTx.accountList[vault1]) || to.Equals(tx.rawTx.accountList[vault1])) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
quoteFound = true
|
||||
}
|
||||
if (baseFound && quoteFound) || i >= 6 {
|
||||
@@ -784,7 +784,7 @@ func orcaWhirPoolSwapParser(tx *Tx, instruction Instruction, innerInstructions I
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool swap parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(vault0Account) || to.Equals(vault0Account)) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(vault0Account) && to.Equals(token0Account) {
|
||||
event = "buy"
|
||||
} else if from.Equals(token0Account) && to.Equals(vault0Account) {
|
||||
@@ -792,7 +792,7 @@ func orcaWhirPoolSwapParser(tx *Tx, instruction Instruction, innerInstructions I
|
||||
}
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(vault1Account) || to.Equals(vault1Account)) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(vault1Account) && to.Equals(token1Account) {
|
||||
event = "sell"
|
||||
} else if from.Equals(token1Account) && to.Equals(vault1Account) {
|
||||
@@ -894,7 +894,7 @@ func orcaWhirPoolSwapV2Parser(tx *Tx, instruction Instruction, innerInstructions
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool swapv2 parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if !baseFound && (from.Equals(vault0Account) || to.Equals(vault0Account)) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(vault0Account) && to.Equals(token0Account) {
|
||||
event = "buy"
|
||||
} else if from.Equals(token0Account) && to.Equals(vault0Account) {
|
||||
@@ -902,7 +902,7 @@ func orcaWhirPoolSwapV2Parser(tx *Tx, instruction Instruction, innerInstructions
|
||||
}
|
||||
baseFound = true
|
||||
} else if !quoteFound && (from.Equals(vault1Account) || to.Equals(vault1Account)) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(vault1Account) && to.Equals(token1Account) {
|
||||
event = "sell"
|
||||
} else if from.Equals(token1Account) && to.Equals(vault1Account) {
|
||||
@@ -1011,7 +1011,7 @@ func orcaWhirPoolTwoHopSwapParser(tx *Tx, instruction Instruction, innerInstruct
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool two hop swap parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultBase]) || to.Equals(tx.rawTx.accountList[pool1VaultBase]) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultBase]) && to.Equals(tx.rawTx.accountList[pool1UserBase]) {
|
||||
event = "buy"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1UserBase]) && to.Equals(tx.rawTx.accountList[pool1VaultBase]) {
|
||||
@@ -1019,7 +1019,7 @@ func orcaWhirPoolTwoHopSwapParser(tx *Tx, instruction Instruction, innerInstruct
|
||||
}
|
||||
baseFound = true
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1VaultQuote]) || to.Equals(tx.rawTx.accountList[pool1VaultQuote]) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultQuote]) && to.Equals(tx.rawTx.accountList[pool1UserQuote]) {
|
||||
event = "sell"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1UserQuote]) && to.Equals(tx.rawTx.accountList[pool1VaultQuote]) {
|
||||
@@ -1087,7 +1087,7 @@ func orcaWhirPoolTwoHopSwapParser(tx *Tx, instruction Instruction, innerInstruct
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool two hop swap parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultBase]) || to.Equals(tx.rawTx.accountList[pool2VaultBase]) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultBase]) && to.Equals(tx.rawTx.accountList[pool2UserBase]) {
|
||||
event = "buy"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2UserBase]) && to.Equals(tx.rawTx.accountList[pool2VaultBase]) {
|
||||
@@ -1095,7 +1095,7 @@ func orcaWhirPoolTwoHopSwapParser(tx *Tx, instruction Instruction, innerInstruct
|
||||
}
|
||||
baseFound = true
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2VaultQuote]) || to.Equals(tx.rawTx.accountList[pool2VaultQuote]) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultQuote]) && to.Equals(tx.rawTx.accountList[pool2UserQuote]) {
|
||||
event = "sell"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2UserQuote]) && to.Equals(tx.rawTx.accountList[pool2VaultQuote]) {
|
||||
@@ -1221,7 +1221,7 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool two hop swap parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultBase]) || to.Equals(tx.rawTx.accountList[pool1VaultBase]) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultBase]) && to.Equals(tx.rawTx.accountList[pool1UserBase]) {
|
||||
event = "buy"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1UserBase]) && to.Equals(tx.rawTx.accountList[pool1VaultBase]) {
|
||||
@@ -1229,7 +1229,7 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru
|
||||
}
|
||||
baseFound = true
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1VaultQuote]) || to.Equals(tx.rawTx.accountList[pool1VaultQuote]) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool1VaultQuote]) && to.Equals(tx.rawTx.accountList[pool2VaultBase]) {
|
||||
event = "sell"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2VaultBase]) && to.Equals(tx.rawTx.accountList[pool1VaultQuote]) {
|
||||
@@ -1295,7 +1295,7 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru
|
||||
return nil, increaseOffset(offset), fmt.Errorf("orca whirpool two hop swap parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultBase]) || to.Equals(tx.rawTx.accountList[pool2VaultBase]) {
|
||||
baseAmount = decimal.NewFromInt(int64(amount))
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultBase]) && to.Equals(tx.rawTx.accountList[pool1VaultBase]) {
|
||||
event = "buy"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool1VaultBase]) && to.Equals(tx.rawTx.accountList[pool2VaultBase]) {
|
||||
@@ -1303,7 +1303,7 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru
|
||||
}
|
||||
baseFound = true
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2VaultQuote]) || to.Equals(tx.rawTx.accountList[pool2VaultQuote]) {
|
||||
quoteAmount = decimal.NewFromInt(int64(amount))
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
if from.Equals(tx.rawTx.accountList[pool2VaultQuote]) && to.Equals(tx.rawTx.accountList[pool2UserQuote]) {
|
||||
event = "sell"
|
||||
} else if from.Equals(tx.rawTx.accountList[pool2UserQuote]) && to.Equals(tx.rawTx.accountList[pool2VaultQuote]) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user