Skip to content

Commit

Permalink
Add PTON straw
Browse files Browse the repository at this point in the history
  • Loading branch information
erokhinav committed Oct 9, 2024
1 parent 42f0f52 commit 051d668
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions pkg/bath/stonfi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bath

import (
"github.com/tonkeeper/tongo/tlb"
"github.com/tonkeeper/tongo/ton"
"math/big"

Expand Down Expand Up @@ -123,16 +124,16 @@ var StonfiSwapStraw = Straw[BubbleJettonSwap]{
}

var StonfiV2PTONStraw = Straw[BubbleJettonTransfer]{
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.JettonTransferMsgOp)},
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.PtonTonTransferMsgOp)},
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
tx := bubble.Info.(BubbleTx)
newAction.master, _ = tx.additionalInfo.JettonMaster(tx.account.Address)
newAction.senderWallet = tx.account.Address
newAction.sender = tx.inputFrom
body := tx.decodedBody.Value.(abi.JettonTransferMsgBody)
newAction.amount = body.Amount
body := tx.decodedBody.Value.(abi.PtonTonTransferMsgBody)
newAction.amount = tlb.VarUInteger16(*big.NewInt(int64(body.TonAmount)))
newAction.isWrappedTon = true
recipient, err := ton.AccountIDFromTlb(body.Destination)
recipient, err := ton.AccountIDFromTlb(body.RefundAddress)
if err == nil {
newAction.recipient = &Account{Address: *recipient}
}
Expand Down Expand Up @@ -195,14 +196,14 @@ var StonfiSwapV2Straw = Straw[BubbleJettonSwap]{
if body.QueryId > 0 && a.IsZero() && b.IsZero() {
return nil
}
newAction.Out.Amount = big.Int(body.DexPayload.SwapBody.MinOut)
s, err := tongo.AccountIDFromTlb(body.FromUser)
s, err := tongo.AccountIDFromTlb(body.DexPayload.TokenWallet1)
if err != nil {
return err
}
if s != nil && *s == b {
if s != nil && *s == a {
a, b = b, a
}
newAction.In.Amount = big.Int(body.RightAmount)
newAction.In.JettonWallet = a
newAction.Out.JettonWallet = b
if tx.additionalInfo != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/bath/straws.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var DefaultStraws = []Merger{
NftTransferStraw,
NftTransferNotifyStraw,
JettonTransferPTONStraw,
StonfiV2PTONStraw,
JettonTransferClassicStraw,
JettonTransferMinimalStraw,
JettonBurnStraw,
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func CollectAdditionalInfo(ctx context.Context, infoSource InformationSource, tr
additionalInfo.NftSaleContract = &sale
}
}
if hasInterface(trace.AccountInterfaces, abi.StonfiPool) {
if hasInterface(trace.AccountInterfaces, abi.StonfiPool) || hasInterface(trace.AccountInterfaces, abi.StonfiPoolV2) {
if pool, ok := stonfiPools[trace.Account]; ok {
additionalInfo.STONfiPool = &pool
additionalInfo.SetJettonMaster(pool.Token0, masters[pool.Token0])
Expand Down

0 comments on commit 051d668

Please sign in to comment.