diff --git a/Makefile b/Makefile index a43ae01f..8e2cc586 100644 --- a/Makefile +++ b/Makefile @@ -36,9 +36,7 @@ genmocks: mockgen -destination=./comm/p2p/mock/conn/conn.go github.com/libp2p/go-libp2p/core/network Conn mockgen -destination=./comm/p2p/mock/stream/stream.go github.com/libp2p/go-libp2p/core/network Stream,Conn mockgen -source=./chains/evm/message/across.go -destination=./chains/evm/message/mock/across.go - mockgen -source=./chains/evm/message/rhinestone.go -destination=./chains/evm/message/mock/rhinestone.go mockgen -source=./chains/evm/message/lifiEscrow.go -destination=./chains/evm/message/mock/lifiEscrow.go - mockgen -source=./chains/evm/message/mayan.go -destination=./chains/evm/message/mock/mayan.go mockgen -source=./chains/evm/message/confirmations.go -destination=./chains/evm/message/mock/confirmations.go mockgen -source=./api/handlers/signing.go -destination=./api/handlers/mock/signing.go mockgen -package mock_message -destination=./chains/evm/message/mock/pricing.go github.com/sprintertech/lifi-solver/pkg/pricing OrderPricer diff --git a/api/handlers/signing.go b/api/handlers/signing.go index 24157c31..10aeeed9 100644 --- a/api/handlers/signing.go +++ b/api/handlers/signing.go @@ -19,8 +19,6 @@ type ProtocolType string const ( AcrossProtocol ProtocolType = "across" - MayanProtocol ProtocolType = "mayan" - RhinestoneProtocol ProtocolType = "rhinestone" LifiEscrowProtocol ProtocolType = "lifi-escrow" LighterProtocol ProtocolType = "lighter" SprinterCreditProtocol ProtocolType = "sprinter-credit" @@ -91,36 +89,6 @@ func (h *SigningHandler) HandleSigning(w http.ResponseWriter, r *http.Request) { RepaymentChainID: b.RepaymentChainId, }) } - case MayanProtocol: - { - m = evmMessage.NewMayanMessage(0, b.ChainId, &evmMessage.MayanData{ - OrderHash: b.DepositId, - Nonce: b.Nonce.Int, - LiquidityPool: common.HexToAddress(b.LiquidityPool), - Caller: common.HexToAddress(b.Caller), - ErrChn: errChn, - Calldata: b.Calldata, - DepositTxHash: b.DepositTxHash, - Source: 0, - Destination: b.ChainId, - Deadline: b.Deadline, - BorrowAmount: b.BorrowAmount.Int, - }) - } - case RhinestoneProtocol: - { - m = evmMessage.NewRhinestoneMessage(0, b.ChainId, &evmMessage.RhinestoneData{ - BundleID: b.DepositId, - Nonce: b.Nonce.Int, - LiquidityPool: common.HexToAddress(b.LiquidityPool), - Caller: common.HexToAddress(b.Caller), - ErrChn: errChn, - Source: 0, - Destination: b.ChainId, - Deadline: b.Deadline, - BorrowAmount: b.BorrowAmount.Int, - }) - } case LifiEscrowProtocol: { m = evmMessage.NewLifiEscrowMessage(0, b.ChainId, &evmMessage.LifiEscrowData{ diff --git a/api/handlers/signing_test.go b/api/handlers/signing_test.go index e107408a..820a46a9 100644 --- a/api/handlers/signing_test.go +++ b/api/handlers/signing_test.go @@ -299,78 +299,6 @@ func (s *SigningHandlerTestSuite) Test_HandleSigning_AcrossSuccess() { s.Equal(http.StatusAccepted, recorder.Code) } -func (s *SigningHandlerTestSuite) Test_HandleSigning_MayanSuccess() { - msgChn := make(chan []*message.Message) - handler := handlers.NewSigningHandler(msgChn, s.chains) - - input := handlers.SigningBody{ - DepositId: "1000", - Protocol: "mayan", - LiquidityPool: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657", - Caller: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657", - Calldata: "0xbe5", - Nonce: &handlers.BigInt{big.NewInt(1001)}, - BorrowAmount: &handlers.BigInt{big.NewInt(1000)}, - //nolint:gosec - Deadline: uint64(time.Now().Unix()), - } - body, _ := json.Marshal(input) - - req := httptest.NewRequest(http.MethodPost, "/v1/chains/1/signatures", bytes.NewReader(body)) - req = mux.SetURLVars(req, map[string]string{ - "chainId": "1", - }) - req.Header.Set("Content-Type", "application/json") - - recorder := httptest.NewRecorder() - - go func() { - msg := <-msgChn - ad := msg[0].Data.(*across.MayanData) - ad.ErrChn <- nil - }() - - handler.HandleSigning(recorder, req) - - s.Equal(http.StatusAccepted, recorder.Code) -} - -func (s *SigningHandlerTestSuite) Test_HandleSigning_RhinestoneSuccess() { - msgChn := make(chan []*message.Message) - handler := handlers.NewSigningHandler(msgChn, s.chains) - - input := handlers.SigningBody{ - DepositId: "depositID", - Protocol: "rhinestone", - LiquidityPool: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657", - Caller: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657", - Calldata: "0xbe5", - Nonce: &handlers.BigInt{big.NewInt(1001)}, - BorrowAmount: &handlers.BigInt{big.NewInt(1000)}, - //nolint:gosec - Deadline: uint64(time.Now().Unix()), - } - body, _ := json.Marshal(input) - - req := httptest.NewRequest(http.MethodPost, "/v1/chains/1/signatures", bytes.NewReader(body)) - req = mux.SetURLVars(req, map[string]string{ - "chainId": "1", - }) - req.Header.Set("Content-Type", "application/json") - - recorder := httptest.NewRecorder() - - go func() { - msg := <-msgChn - ad := msg[0].Data.(*across.RhinestoneData) - ad.ErrChn <- nil - }() - - handler.HandleSigning(recorder, req) - - s.Equal(http.StatusAccepted, recorder.Code) -} - func (s *SigningHandlerTestSuite) Test_HandleSigning_LifiSuccess() { msgChn := make(chan []*message.Message) handler := handlers.NewSigningHandler(msgChn, s.chains) diff --git a/app/app.go b/app/app.go index b2d9bdef..ba7cd00e 100644 --- a/app/app.go +++ b/app/app.go @@ -49,7 +49,6 @@ import ( "github.com/sprintertech/sprinter-signing/protocol/across" "github.com/sprintertech/sprinter-signing/protocol/lifi" lighterAPI "github.com/sprintertech/sprinter-signing/protocol/lighter" - "github.com/sprintertech/sprinter-signing/protocol/mayan" "github.com/sprintertech/sprinter-signing/topology" "github.com/sprintertech/sprinter-signing/tss" coreEvm "github.com/sygmaprotocol/sygma-core/chains/evm" @@ -170,7 +169,6 @@ func Run() error { var hubPoolContract across.TokenMatcher acrossPools := make(map[uint64]common.Address) - mayanPools := make(map[uint64]common.Address) lifiOutputSettlers := make(map[uint64]common.Address) repayerAddresses := make(map[uint64]common.Address) tokens := make(map[uint64]map[string]config.TokenConfig) @@ -189,11 +187,6 @@ func Run() error { acrossPools[*c.GeneralChainConfig.Id] = poolAddress } - if c.MayanSwift != "" { - poolAddress := common.HexToAddress(c.MayanSwift) - mayanPools[*c.GeneralChainConfig.Id] = poolAddress - } - if c.LifiOutputSettler != "" { settlerAddress := common.HexToAddress(c.LifiOutputSettler) lifiOutputSettlers[*c.GeneralChainConfig.Id] = settlerAddress @@ -273,30 +266,6 @@ func Run() error { confirmationsPerChain[*c.GeneralChainConfig.Id] = c.ConfirmationsByValue } - if c.MayanSwift != "" { - mayanSwiftContract := contracts.NewMayanSwiftContract(client, common.HexToAddress(c.MayanSwift)) - mayanApi := mayan.NewMayanExplorer() - mayanMh := evmMessage.NewMayanMessageHandler( - *c.GeneralChainConfig.Id, - client, - repayerAddresses, - mayanPools, - coordinator, - host, - communication, - keyshareStore, - watcher, - tokenStore, - mayanSwiftContract, - mayanApi, - sigChn) - go mayanMh.Listen(ctx) - - mh.RegisterMessageHandler(message.MessageType(comm.MayanMsg.String()), mayanMh) - supportedChains[*c.GeneralChainConfig.Id] = struct{}{} - confirmationsPerChain[*c.GeneralChainConfig.Id] = c.ConfirmationsByValue - } - if c.LifiOutputSettler != "" { usdPricer := pyth.NewClient(ctx) err = usdPricer.Start(ctx) diff --git a/chains/evm/calls/consts/mayan.go b/chains/evm/calls/consts/mayan.go deleted file mode 100644 index fa2ca0b4..00000000 --- a/chains/evm/calls/consts/mayan.go +++ /dev/null @@ -1,1433 +0,0 @@ -// nolint -package consts - -import ( - "strings" - - "github.com/ethereum/go-ethereum/accounts/abi" -) - -var MayanSwiftABI, _ = abi.JSON(strings.NewReader(`[ - { - "inputs":[ - { - "internalType":"address", - "name":"_wormhole", - "type":"address" - }, - { - "internalType":"address", - "name":"_feeManager", - "type":"address" - }, - { - "internalType":"uint16", - "name":"_auctionChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"_auctionAddr", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"_solanaEmitter", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"_consistencyLevel", - "type":"uint8" - } - ], - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "inputs":[ - - ], - "name":"DeadlineViolation", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"DuplicateOrder", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"FeesTooHigh", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidAction", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidAmount", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidAuctionMode", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidBpsFee", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidDestChain", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidEmitterAddress", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidEmitterChain", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidEvmAddr", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidGasDrop", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidOrderHash", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidOrderStatus", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidSrcChain", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidWormholeFee", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"OrderNotExists", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"Paused", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"SmallAmountIn", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"Unauthorized", - "type":"error" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bytes32", - "name":"key", - "type":"bytes32" - }, - { - "indexed":false, - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - } - ], - "name":"OrderCanceled", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bytes32", - "name":"key", - "type":"bytes32" - } - ], - "name":"OrderCreated", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bytes32", - "name":"key", - "type":"bytes32" - }, - { - "indexed":false, - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"netAmount", - "type":"uint256" - } - ], - "name":"OrderFulfilled", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bytes32", - "name":"key", - "type":"bytes32" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"netAmount", - "type":"uint256" - } - ], - "name":"OrderRefunded", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bytes32", - "name":"key", - "type":"bytes32" - } - ], - "name":"OrderUnlocked", - "type":"event" - }, - { - "inputs":[ - - ], - "name":"auctionAddr", - "outputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"auctionChainId", - "outputs":[ - { - "internalType":"uint16", - "name":"", - "type":"uint16" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - }, - { - "components":[ - { - "internalType":"bytes32", - "name":"trader", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"minAmountOut", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"auctionMode", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"random", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.OrderParams", - "name":"params", - "type":"tuple" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"uint8", - "name":"protocolBps", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"canceler", - "type":"bytes32" - } - ], - "name":"cancelOrder", - "outputs":[ - { - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - } - ], - "stateMutability":"payable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"newGuardian", - "type":"address" - } - ], - "name":"changeGuardian", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"claimGuardian", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"consistencyLevel", - "outputs":[ - { - "internalType":"uint8", - "name":"", - "type":"uint8" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "components":[ - { - "internalType":"bytes32", - "name":"trader", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"minAmountOut", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"auctionMode", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"random", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.OrderParams", - "name":"params", - "type":"tuple" - } - ], - "name":"createOrderWithEth", - "outputs":[ - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - } - ], - "stateMutability":"payable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"tokenIn", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amountIn", - "type":"uint256" - }, - { - "components":[ - { - "internalType":"bytes32", - "name":"trader", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"minAmountOut", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"auctionMode", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"random", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.OrderParams", - "name":"params", - "type":"tuple" - }, - { - "internalType":"uint256", - "name":"submissionFee", - "type":"uint256" - }, - { - "internalType":"bytes", - "name":"signedOrderHash", - "type":"bytes" - }, - { - "components":[ - { - "internalType":"uint256", - "name":"value", - "type":"uint256" - }, - { - "internalType":"uint256", - "name":"deadline", - "type":"uint256" - }, - { - "internalType":"uint8", - "name":"v", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"r", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"s", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.PermitParams", - "name":"permitParams", - "type":"tuple" - } - ], - "name":"createOrderWithSig", - "outputs":[ - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"tokenIn", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amountIn", - "type":"uint256" - }, - { - "components":[ - { - "internalType":"bytes32", - "name":"trader", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"minAmountOut", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"auctionMode", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"random", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.OrderParams", - "name":"params", - "type":"tuple" - } - ], - "name":"createOrderWithToken", - "outputs":[ - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"feeManager", - "outputs":[ - { - "internalType":"contract IFeeManager", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"fulfillAmount", - "type":"uint256" - }, - { - "internalType":"bytes", - "name":"encodedVm", - "type":"bytes" - }, - { - "internalType":"bytes32", - "name":"recepient", - "type":"bytes32" - }, - { - "internalType":"bool", - "name":"batch", - "type":"bool" - } - ], - "name":"fulfillOrder", - "outputs":[ - { - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - } - ], - "stateMutability":"payable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"fulfillAmount", - "type":"uint256" - }, - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"protocolBps", - "type":"uint8" - }, - { - "components":[ - { - "internalType":"bytes32", - "name":"trader", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"minAmountOut", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"auctionMode", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"random", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.OrderParams", - "name":"params", - "type":"tuple" - }, - { - "internalType":"bytes32", - "name":"recepient", - "type":"bytes32" - }, - { - "internalType":"bool", - "name":"batch", - "type":"bool" - } - ], - "name":"fulfillSimple", - "outputs":[ - { - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - } - ], - "stateMutability":"payable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32[]", - "name":"orderHashes", - "type":"bytes32[]" - } - ], - "name":"getOrders", - "outputs":[ - { - "components":[ - { - "internalType":"enum MayanSwift.Status", - "name":"status", - "type":"uint8" - }, - { - "internalType":"uint64", - "name":"amountIn", - "type":"uint64" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - } - ], - "internalType":"struct MayanSwift.Order[]", - "name":"", - "type":"tuple[]" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"guardian", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"nextGuardian", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "name":"orders", - "outputs":[ - { - "internalType":"enum MayanSwift.Status", - "name":"status", - "type":"uint8" - }, - { - "internalType":"uint64", - "name":"amountIn", - "type":"uint64" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encoded", - "type":"bytes" - } - ], - "name":"parseFulfillPayload", - "outputs":[ - { - "components":[ - { - "internalType":"uint8", - "name":"action", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"destChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"destAddr", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"driver", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"tokenOut", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"promisedAmount", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"gasDrop", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"deadline", - "type":"uint64" - }, - { - "internalType":"bytes32", - "name":"referrerAddr", - "type":"bytes32" - }, - { - "internalType":"uint8", - "name":"referrerBps", - "type":"uint8" - }, - { - "internalType":"uint8", - "name":"protocolBps", - "type":"uint8" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.FulfillMsg", - "name":"fulfillMsg", - "type":"tuple" - } - ], - "stateMutability":"pure", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encoded", - "type":"bytes" - } - ], - "name":"parseRefundPayload", - "outputs":[ - { - "components":[ - { - "internalType":"uint8", - "name":"action", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"recipient", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"canceler", - "type":"bytes32" - }, - { - "internalType":"uint64", - "name":"cancelFee", - "type":"uint64" - }, - { - "internalType":"uint64", - "name":"refundFee", - "type":"uint64" - } - ], - "internalType":"struct MayanSwift.RefundMsg", - "name":"refundMsg", - "type":"tuple" - } - ], - "stateMutability":"pure", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encoded", - "type":"bytes" - } - ], - "name":"parseUnlockPayload", - "outputs":[ - { - "components":[ - { - "internalType":"uint8", - "name":"action", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"recipient", - "type":"bytes32" - } - ], - "internalType":"struct MayanSwift.UnlockMsg", - "name":"unlockMsg", - "type":"tuple" - } - ], - "stateMutability":"pure", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"paused", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32[]", - "name":"orderHashes", - "type":"bytes32[]" - } - ], - "name":"postBatch", - "outputs":[ - { - "internalType":"uint64", - "name":"sequence", - "type":"uint64" - } - ], - "stateMutability":"payable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encodedVm", - "type":"bytes" - } - ], - "name":"refundOrder", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint8", - "name":"_consistencyLevel", - "type":"uint8" - } - ], - "name":"setConsistencyLevel", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"_feeManager", - "type":"address" - } - ], - "name":"setFeeManager", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bool", - "name":"_pause", - "type":"bool" - } - ], - "name":"setPause", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"solanaEmitter", - "outputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encodedVm", - "type":"bytes" - } - ], - "name":"unlockBatch", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "name":"unlockMsgs", - "outputs":[ - { - "internalType":"uint8", - "name":"action", - "type":"uint8" - }, - { - "internalType":"bytes32", - "name":"orderHash", - "type":"bytes32" - }, - { - "internalType":"uint16", - "name":"srcChainId", - "type":"uint16" - }, - { - "internalType":"bytes32", - "name":"tokenIn", - "type":"bytes32" - }, - { - "internalType":"bytes32", - "name":"recipient", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"encodedVm", - "type":"bytes" - } - ], - "name":"unlockSingle", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"wormhole", - "outputs":[ - { - "internalType":"contract IWormhole", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "stateMutability":"payable", - "type":"receive" - } -]`)) diff --git a/chains/evm/calls/consts/rhinestone.go b/chains/evm/calls/consts/rhinestone.go deleted file mode 100644 index faec3097..00000000 --- a/chains/evm/calls/consts/rhinestone.go +++ /dev/null @@ -1,187 +0,0 @@ -package consts - -import ( - "strings" - - "github.com/ethereum/go-ethereum/accounts/abi" -) - -var RhinestoneABI, _ = abi.JSON(strings.NewReader(` -[ - { - "type":"function", - "name":"fill", - "inputs":[ - { - "name":"payload", - "type":"tuple", - "internalType":"struct IRhinestoneSpokePool.IntentFillPayload", - "components":[ - { - "name":"segments", - "type":"tuple[]", - "internalType":"struct IRhinestoneSpokePool.SegmentData[]", - "components":[ - { - "name":"tokenIn", - "type":"uint256[2][]", - "internalType":"uint256[2][]" - }, - { - "name":"tokenOut", - "type":"uint256[2][]", - "internalType":"uint256[2][]" - }, - { - "name":"originModule", - "type":"address", - "internalType":"address" - }, - { - "name":"originWETHAddress", - "type":"address", - "internalType":"address" - }, - { - "name":"originChainId", - "type":"uint256", - "internalType":"uint256" - }, - { - "name":"compactNonce", - "type":"uint256", - "internalType":"uint256" - } - ] - }, - { - "name":"message", - "type":"bytes", - "internalType":"bytes" - }, - { - "name":"orchestratorSig", - "type":"bytes", - "internalType":"bytes" - } - ] - }, - { - "name":"exclusiveRelayer", - "type":"address", - "internalType":"address" - }, - { - "name":"repaymentAddresses", - "type":"address[]", - "internalType":"address[]" - }, - { - "name":"repaymentChainIds", - "type":"uint256[]", - "internalType":"uint256[]" - }, - { - "name":"accountCreation", - "type":"tuple", - "internalType":"AccountCreation ", - "components":[ - { - "name":"account", - "type":"address", - "internalType":"address" - }, - { - "name":"initCode", - "type":"bytes", - "internalType":"bytes" - } - ] - } - ], - "outputs":[ - - ], - "stateMutability":"nonpayable" - }, - { - "type":"function", - "name":"fill", - "inputs":[ - { - "name":"payload", - "type":"tuple", - "internalType":"struct IRhinestoneSpokePool.IntentFillPayload", - "components":[ - { - "name":"segments", - "type":"tuple[]", - "internalType":"struct IRhinestoneSpokePool.SegmentData[]", - "components":[ - { - "name":"tokenIn", - "type":"uint256[2][]", - "internalType":"uint256[2][]" - }, - { - "name":"tokenOut", - "type":"uint256[2][]", - "internalType":"uint256[2][]" - }, - { - "name":"originModule", - "type":"address", - "internalType":"address" - }, - { - "name":"originWETHAddress", - "type":"address", - "internalType":"address" - }, - { - "name":"originChainId", - "type":"uint256", - "internalType":"uint256" - }, - { - "name":"compactNonce", - "type":"uint256", - "internalType":"uint256" - } - ] - }, - { - "name":"message", - "type":"bytes", - "internalType":"bytes" - }, - { - "name":"orchestratorSig", - "type":"bytes", - "internalType":"bytes" - } - ] - }, - { - "name":"exclusiveRelayer", - "type":"address", - "internalType":"address" - }, - { - "name":"repaymentAddresses", - "type":"address[]", - "internalType":"address[]" - }, - { - "name":"repaymentChainIds", - "type":"uint256[]", - "internalType":"uint256[]" - } - ], - "outputs":[ - - ], - "stateMutability":"nonpayable" - } -] -`)) diff --git a/chains/evm/calls/contracts/mayanSwift.go b/chains/evm/calls/contracts/mayanSwift.go deleted file mode 100644 index a6d04b88..00000000 --- a/chains/evm/calls/contracts/mayanSwift.go +++ /dev/null @@ -1,264 +0,0 @@ -// The Licensed Work is (c) 2022 Sygma -// SPDX-License-Identifier: LGPL-3.0-only - -package contracts - -import ( - "encoding/binary" - "fmt" - "math/big" - "strconv" - - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/consts" - "github.com/sprintertech/sprinter-signing/protocol/mayan" - "github.com/sygmaprotocol/sygma-core/chains/evm/client" - "github.com/sygmaprotocol/sygma-core/chains/evm/contracts" -) - -type OrderStatus uint8 - -const ( - WORMHOLE_DECIMALS = 8 - - OrderCreated OrderStatus = 0 -) - -type MayanOrder struct { - Status OrderStatus - AmountIn uint64 - DestChainId uint16 -} - -type MayanKey struct { - Trader common.Hash - SrcChainId uint16 - TokenIn common.Hash - DestAddr common.Hash - DestChainId uint16 - TokenOut common.Hash - MinAmountOut uint64 - GasDrop uint64 - CancelFee uint64 - RefundFee uint64 - Deadline uint64 - ReferrerAddr common.Hash - ReferrerBps uint8 - ProtocolBps uint8 - AuctionMode uint8 - Random common.Hash -} - -type MayanFulfillMsg struct { - Action uint8 - OrderHash [32]byte - DestChainId uint16 - DestAddr [32]byte - Driver [32]byte - TokenOut [32]byte - PromisedAmount uint64 - GasDrop uint64 - Deadline uint64 - ReferrerAddr [32]byte - ReferrerBps uint8 - ProtocolBps uint8 - SrcChainId uint16 - TokenIn [32]byte -} - -type MayanFulfillParams struct { - FulfillAmount *big.Int - EncodedVm []byte - Recipient [32]byte - Batch bool -} - -type MayanSwiftContract struct { - contracts.Contract - client client.Client -} - -func NewMayanSwiftContract( - client client.Client, - address common.Address, -) *MayanSwiftContract { - return &MayanSwiftContract{ - Contract: contracts.NewContract(address, consts.MayanSwiftABI, nil, client, nil), - client: client, - } -} - -func (c *MayanSwiftContract) GetOrder( - msg *MayanFulfillMsg, - swap *mayan.MayanSwap, - srcTokenDecimals uint8) (*MayanOrder, error) { - amountOut, err := strconv.ParseUint(swap.MinAmountOut64, 10, 64) - if err != nil { - return nil, err - } - key := &MayanKey{ - Trader: common.HexToHash(swap.Trader), - SrcChainId: msg.SrcChainId, - TokenIn: msg.TokenIn, - DestAddr: msg.DestAddr, - DestChainId: msg.DestChainId, - TokenOut: msg.TokenOut, - MinAmountOut: amountOut, - GasDrop: msg.GasDrop, - CancelFee: ConvertFloatToUint(swap.RedeemRelayerFee, srcTokenDecimals), - RefundFee: ConvertFloatToUint(swap.RefundRelayerFee, srcTokenDecimals), - Deadline: msg.Deadline, - ReferrerAddr: msg.ReferrerAddr, - ReferrerBps: msg.ReferrerBps, - ProtocolBps: swap.MayanBps, - AuctionMode: swap.AuctionMode, - Random: common.HexToHash(swap.RandomKey), - } - - res, err := c.CallContract("orders", common.BytesToHash(crypto.Keccak256(encodeKey(key)))) - if err != nil { - return nil, err - } - - status := abi.ConvertType(res[0], new(uint8)).(*uint8) - amountIn := abi.ConvertType(res[1], new(uint64)).(*uint64) - destChainId := abi.ConvertType(res[2], new(uint16)).(*uint16) - return &MayanOrder{ - Status: OrderStatus(*status), - AmountIn: *amountIn, - DestChainId: *destChainId, - }, nil -} - -func (c *MayanSwiftContract) DecodeFulfillCall(calldata []byte) (*MayanFulfillParams, *MayanFulfillMsg, error) { - method, ok := c.ABI.Methods["fulfillOrder"] - if !ok { - return nil, nil, fmt.Errorf("no method fulfillOrder") - } - - res, err := method.Inputs.Unpack(calldata[4:]) - if err != nil { - return nil, nil, err - } - - amount := abi.ConvertType(res[0], new(big.Int)).(*big.Int) - vm := abi.ConvertType(res[1], new([]byte)).(*[]byte) - recipient := abi.ConvertType(res[2], new([32]byte)).(*[32]byte) - batch := abi.ConvertType(res[3], new(bool)).(*bool) - - params := &MayanFulfillParams{ - FulfillAmount: amount, - EncodedVm: *vm, - Recipient: *recipient, - Batch: *batch, - } - - msg, err := c.ParseFulfillPayload(extractWormholeVMPayload(params.EncodedVm)) - if err != nil { - return nil, nil, err - } - - return params, msg, nil -} - -func (c *MayanSwiftContract) ParseFulfillPayload(calldata []byte) (*MayanFulfillMsg, error) { - res, err := c.CallContract("parseFulfillPayload", calldata) - if err != nil { - return nil, err - } - - out := abi.ConvertType(res[0], new(MayanFulfillMsg)).(*MayanFulfillMsg) - return out, nil -} - -func extractWormholeVMPayload(encodedVM []byte) []byte { - signersLen := int(encodedVM[5]) // Read signature count from byte 5 - payloadStart := 6 + (signersLen * 66) + 51 // Calculate payload offset - return encodedVM[payloadStart:] -} - -// encodeKey encodes mayan key into the order hash expected on-chain -func encodeKey(key *MayanKey) []byte { - data := make([]byte, 239) - offset := 0 - - copy(data[offset:], key.Trader[:]) // 0-31 (32 bytes) - offset += 32 - - binary.BigEndian.PutUint16(data[offset:], key.SrcChainId) // 32-33 (2 bytes) - offset += 2 - - copy(data[offset:], key.TokenIn[:]) // 34-65 (32 bytes) - offset += 32 - - copy(data[offset:], key.DestAddr[:]) // 66-97 (32 bytes) - offset += 32 - - binary.BigEndian.PutUint16(data[offset:], key.DestChainId) // 98-99 (2 bytes) - offset += 2 - - copy(data[offset:], key.TokenOut[:]) // 100-131 (32 bytes) - offset += 32 - - // uint64 sequence (40 bytes total) - binary.BigEndian.PutUint64(data[offset:], key.MinAmountOut) // 132-139 - offset += 8 - binary.BigEndian.PutUint64(data[offset:], key.GasDrop) // 140-147 - offset += 8 - binary.BigEndian.PutUint64(data[offset:], key.CancelFee) // 148-155 - offset += 8 - binary.BigEndian.PutUint64(data[offset:], key.RefundFee) // 156-163 - offset += 8 - binary.BigEndian.PutUint64(data[offset:], key.Deadline) // 164-171 - offset += 8 - - copy(data[offset:], key.ReferrerAddr[:]) // 172-203 (32 bytes) - offset += 32 - - data[offset] = key.ReferrerBps // 204 (1 byte) - offset += 1 - - // Final group (protocolBps + auctionMode + random) - data[offset] = key.ProtocolBps // 205 (1 byte) - offset += 1 - data[offset] = key.AuctionMode // 206 (1 byte) - offset += 1 - copy(data[offset:], key.Random[:]) // 207-238 (32 bytes) - - return data -} - -// DenormalizeAmount converts a normalized amount back to its original precision -func DenormalizeAmount(amount *big.Int, decimals uint8) *big.Int { - if decimals > WORMHOLE_DECIMALS { - exponent := new(big.Int).Exp( - big.NewInt(10), - big.NewInt(int64(decimals-WORMHOLE_DECIMALS)), - nil, - ) - return new(big.Int).Mul(amount, exponent) - } - return new(big.Int).Set(amount) -} - -// ConvertFloatToUint convert mayan float amount to the nomalized uint64 amount -func ConvertFloatToUint(amount string, decimals uint8) uint64 { - ratValue := new(big.Rat) - if _, success := ratValue.SetString(amount); !success { - return 0 - } - - minDecimals := min(WORMHOLE_DECIMALS, decimals) - multiplier := new(big.Int).Exp( - big.NewInt(10), - big.NewInt(int64(minDecimals)), - nil, - ) - - scaled := new(big.Rat).Mul(ratValue, new(big.Rat).SetInt(multiplier)) - result := new(big.Int).Div(scaled.Num(), scaled.Denom()) - - return result.Uint64() -} diff --git a/chains/evm/calls/contracts/rhinestone.go b/chains/evm/calls/contracts/rhinestone.go deleted file mode 100644 index 04d00d31..00000000 --- a/chains/evm/calls/contracts/rhinestone.go +++ /dev/null @@ -1,66 +0,0 @@ -// The Licensed Work is (c) 2022 Sygma -// SPDX-License-Identifier: LGPL-3.0-only - -package contracts - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/consts" -) - -type SegmentData struct { - TokenIn [][2]*big.Int `abi:"tokenIn"` - TokenOut [][2]*big.Int `abi:"tokenOut"` - OriginModule common.Address `abi:"originModule"` - OriginWETHAddress common.Address `abi:"originWETHAddress"` - OriginChainId *big.Int `abi:"originChainId"` - CompactNonce *big.Int `abi:"compactNonce"` -} - -type IntentFillPayload struct { - Segments []SegmentData `abi:"segments"` - Message []byte `abi:"message"` - OrchestratorSig []byte `abi:"orchestratorSig"` -} - -type AccountCreation struct { - Account common.Address `abi:"account"` - InitCode []byte `abi:"initCode"` -} - -type FillInput struct { - Payload IntentFillPayload `abi:"payload"` - ExclusiveRelayer common.Address `abi:"exclusiveRelayer"` - RepaymentAddresses []common.Address `abi:"repaymentAddresses"` - RepaymentChainIds []*big.Int `abi:"repaymentChainIds"` - AccountCreation AccountCreation `abi:"accountCreation"` -} - -type RhinestoneContract struct { - abi abi.ABI -} - -func NewRhinestoneContract() *RhinestoneContract { - return &RhinestoneContract{ - abi: consts.RhinestoneABI, - } -} - -func (c *RhinestoneContract) DecodeFillCall(calldata []byte) (*FillInput, error) { - var fillInput FillInput - method := c.abi.Methods["fill"] - res, err := method.Inputs.Unpack(calldata[4:]) - if err != nil { - return nil, err - } - - err = method.Inputs.Copy(&fillInput, res) - if err != nil { - return nil, err - } - - return &fillInput, nil -} diff --git a/chains/evm/calls/events/events.go b/chains/evm/calls/events/events.go index 29daa454..d4655f69 100644 --- a/chains/evm/calls/events/events.go +++ b/chains/evm/calls/events/events.go @@ -22,7 +22,6 @@ const ( KeyRefreshSig EventSig = "KeyRefresh(string)" AcrossDepositSig EventSig = "FundsDeposited(bytes32,bytes32,uint256,uint256,uint256,uint256,uint32,uint32,uint32,bytes32,bytes32,bytes32,bytes)" - MayanDepositSig EventSig = "OrderCreated(bytes32)" ) // Refresh struct holds key refresh event data diff --git a/chains/evm/config.go b/chains/evm/config.go index 8495079b..6dc53580 100644 --- a/chains/evm/config.go +++ b/chains/evm/config.go @@ -25,7 +25,6 @@ type EVMConfig struct { AcrossPool string AcrossHubPool string - MayanSwift string LifiOutputSettler string LifiInputSettlerEscrow string Repayer string @@ -117,7 +116,6 @@ func NewEVMConfig(chainConfig map[string]interface{}, solverConfig solverConfig. Repayer: solverConfig.ProtocolsMetadata.Sprinter.Repayer[id], AcrossPool: solverConfig.ProtocolsMetadata.Across.SpokePools[id], AcrossHubPool: solverConfig.ProtocolsMetadata.Across.HubPools[id], - MayanSwift: solverConfig.ProtocolsMetadata.Mayan.SwiftContracts[id], LifiOutputSettler: solverConfig.ProtocolsMetadata.Lifi.OutputSettler, LifiInputSettlerEscrow: solverConfig.ProtocolsMetadata.Lifi.InputSettlerEscrow, Liquidators: liquidators, diff --git a/chains/evm/config_test.go b/chains/evm/config_test.go index 74662919..0c25260e 100644 --- a/chains/evm/config_test.go +++ b/chains/evm/config_test.go @@ -98,11 +98,6 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfig() { "eip155:1": "acrossHubPool", }, }, - Mayan: &solverConfig.MayanMetadata{ - SwiftContracts: map[string]string{ - "eip155:1": "mayanSwift", - }, - }, Sprinter: &solverConfig.SprinterMetadata{ Repayer: map[string]string{ "eip155:1": "repayer", @@ -140,7 +135,6 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfig() { Repayer: "repayer", AcrossPool: "acrossPool", AcrossHubPool: "acrossHubPool", - MayanSwift: "mayanSwift", LifiOutputSettler: "settler", LifiInputSettlerEscrow: "escrowSettler", ConfirmationsByValue: make(map[uint64]uint64), @@ -160,7 +154,6 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfigWithCustomTxParams() { "admin": "adminAddress", "acrossPool": "acrossPool", "acrossHubPool": "hubPool", - "mayanSwift": "mayanSwift", "maxGasPrice": 1000, "gasMultiplier": 1000, "gasIncreasePercentage": 20, @@ -229,11 +222,6 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfigWithCustomTxParams() { "eip155:1": "acrossHubPool", }, }, - Mayan: &solverConfig.MayanMetadata{ - SwiftContracts: map[string]string{ - "eip155:1": "mayanSwift", - }, - }, Sprinter: &solverConfig.SprinterMetadata{ Repayer: map[string]string{ "eip155:1": "repayer", @@ -261,7 +249,6 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfigWithCustomTxParams() { Admin: "adminAddress", AcrossPool: "acrossPool", AcrossHubPool: "acrossHubPool", - MayanSwift: "mayanSwift", LifiOutputSettler: "settler", Repayer: "repayer", ConfirmationsByValue: expectedBlockConfirmations, diff --git a/chains/evm/message/mayan.go b/chains/evm/message/mayan.go deleted file mode 100644 index c9883a63..00000000 --- a/chains/evm/message/mayan.go +++ /dev/null @@ -1,328 +0,0 @@ -package message - -import ( - "context" - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/libp2p/go-libp2p/core/host" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/rs/zerolog/log" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts" - "github.com/sprintertech/sprinter-signing/chains/evm/signature" - "github.com/sprintertech/sprinter-signing/comm" - "github.com/sprintertech/sprinter-signing/config" - "github.com/sprintertech/sprinter-signing/protocol/mayan" - "github.com/sprintertech/sprinter-signing/tss" - "github.com/sprintertech/sprinter-signing/tss/ecdsa/signing" - "github.com/sygmaprotocol/sygma-core/relayer/message" - "github.com/sygmaprotocol/sygma-core/relayer/proposal" -) - -var ( - BPS_DENOMINATOR = big.NewInt(10000) -) - -type MayanContract interface { - DecodeFulfillCall(calldata []byte) (*contracts.MayanFulfillParams, *contracts.MayanFulfillMsg, error) - GetOrder( - msg *contracts.MayanFulfillMsg, - swap *mayan.MayanSwap, - srcTokenDecimals uint8, - ) (*contracts.MayanOrder, error) -} - -type SwapFetcher interface { - GetSwap(hash string) (*mayan.MayanSwap, error) -} - -type MayanMessageHandler struct { - client EventFilterer - chainID uint64 - - mayanPools map[uint64]common.Address - liquidityPools map[uint64]common.Address - confirmationWatcher ConfirmationWatcher - tokenStore config.TokenStore - mayanDecoder MayanContract - swapFetcher SwapFetcher - - coordinator Coordinator - host host.Host - comm comm.Communication - fetcher signing.SaveDataFetcher - - sigChn chan any -} - -func NewMayanMessageHandler( - chainID uint64, - client EventFilterer, - liquidityPools map[uint64]common.Address, - mayanPools map[uint64]common.Address, - coordinator Coordinator, - host host.Host, - comm comm.Communication, - fetcher signing.SaveDataFetcher, - confirmationWatcher ConfirmationWatcher, - tokenStore config.TokenStore, - mayanDecoder MayanContract, - swapFetcher SwapFetcher, - sigChn chan any, -) *MayanMessageHandler { - return &MayanMessageHandler{ - chainID: chainID, - client: client, - mayanPools: mayanPools, - liquidityPools: liquidityPools, - coordinator: coordinator, - host: host, - comm: comm, - fetcher: fetcher, - sigChn: sigChn, - confirmationWatcher: confirmationWatcher, - mayanDecoder: mayanDecoder, - swapFetcher: swapFetcher, - tokenStore: tokenStore, - } -} - -// HandleMessage finds the Mayan deposit with the according deposit ID and starts -// the MPC signature process for it. The result will be saved into the signature -// cache through the result channel. -func (h *MayanMessageHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error) { - data := m.Data.(*MayanData) - - log.Info().Str("depositId", data.OrderHash).Msgf("Handling mayan message %+v", data) - - err := h.notify(data) - if err != nil { - log.Warn().Msgf("Failed to notify relayers because of %s", err) - } - - calldataBytes, err := hex.DecodeString(data.Calldata) - if err != nil { - data.ErrChn <- err - return nil, err - } - - params, msg, err := h.mayanDecoder.DecodeFulfillCall(calldataBytes) - if err != nil { - data.ErrChn <- err - return nil, err - } - swap, err := h.swapFetcher.GetSwap(data.OrderHash) - if err != nil { - data.ErrChn <- err - return nil, err - } - - tokenIn := common.BytesToAddress(msg.TokenIn[12:]) - symbol, token, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn) - if err != nil { - data.ErrChn <- err - return nil, err - } - - destChainId, err := mayan.WormholeToEVMChainID(msg.DestChainId) - if err != nil { - data.ErrChn <- err - return nil, err - } - destinationBorrowToken, err := h.tokenStore.ConfigBySymbol(destChainId, symbol) - if err != nil { - data.ErrChn <- err - return nil, err - } - - order, err := h.mayanDecoder.GetOrder(msg, swap, token.Decimals) - if err != nil { - data.ErrChn <- err - return nil, err - } - - err = h.verifyOrder(msg, params, order, swap, data) - if err != nil { - data.ErrChn <- err - return nil, err - } - - err = h.confirmationWatcher.WaitForTokenConfirmations( - context.Background(), - h.chainID, - common.HexToHash(swap.CreateTxHash), - tokenIn, - new(big.Int).SetUint64(msg.PromisedAmount)) - if err != nil { - data.ErrChn <- err - return nil, err - } - - data.ErrChn <- nil - - unlockHash, err := signature.BorrowUnlockHash( - calldataBytes, - data.BorrowAmount, - destinationBorrowToken.Address, - new(big.Int).SetUint64(destChainId), - h.mayanPools[destChainId], - data.Deadline, - data.Caller, - data.LiquidityPool, - data.Nonce, - ) - if err != nil { - return nil, err - } - - sessionID := fmt.Sprintf("%d-%s", h.chainID, swap.OrderHash) - signing, err := signing.NewSigning( - new(big.Int).SetBytes(unlockHash), - sessionID, - sessionID, - h.host, - h.comm, - h.fetcher) - if err != nil { - return nil, err - } - - err = h.coordinator.Execute(context.Background(), []tss.TssProcess{signing}, h.sigChn, data.Coordinator) - if err != nil { - return nil, err - } - return nil, nil -} - -func (h *MayanMessageHandler) Listen(ctx context.Context) { - msgChn := make(chan *comm.WrappedMessage) - subID := h.comm.Subscribe(fmt.Sprintf("%d-%s", h.chainID, comm.MayanSessionID), comm.MayanMsg, msgChn) - - for { - select { - case wMsg := <-msgChn: - { - go func(wMsg *comm.WrappedMessage) { - d := &MayanData{} - err := json.Unmarshal(wMsg.Payload, d) - if err != nil { - log.Warn().Msgf("Failed unmarshaling Mayan message: %s", err) - return - } - - d.ErrChn = make(chan error, 1) - msg := NewMayanMessage(d.Source, d.Destination, d) - _, err = h.HandleMessage(msg) - if err != nil { - log.Err(err).Msgf("Failed handling Mayan message %+v because of: %s", msg, err) - } - }(wMsg) - } - case <-ctx.Done(): - { - h.comm.UnSubscribe(subID) - return - } - } - } -} - -func (h *MayanMessageHandler) verifyOrder( - msg *contracts.MayanFulfillMsg, - params *contracts.MayanFulfillParams, - order *contracts.MayanOrder, - swap *mayan.MayanSwap, - data *MayanData) error { - srcChainId, err := mayan.WormholeToEVMChainID(msg.SrcChainId) - if err != nil { - return err - } - - _, tc, err := h.tokenStore.ConfigByAddress(h.chainID, common.BytesToAddress(msg.TokenIn[12:])) - if err != nil { - return err - } - - denormalizedAmountIn := contracts.DenormalizeAmount(new(big.Int).SetUint64(order.AmountIn), tc.Decimals) - if data.BorrowAmount.Cmp(denormalizedAmountIn) != -1 { - return fmt.Errorf("requested borrow amount more than input amount") - } - - if srcChainId != h.chainID { - return fmt.Errorf("msg and handler chainID not matching") - } - - if swap.OrderHash != "0x"+hex.EncodeToString(msg.OrderHash[:]) { - return fmt.Errorf("swap and msg hash not matching") - } - - if order.Status != contracts.OrderCreated { - return fmt.Errorf("invalid order status %d", order.Status) - } - - srcLiquidityPool, ok := h.liquidityPools[h.chainID] - if !ok { - return fmt.Errorf("no source liqudity recipient configured") - } - - if common.BytesToAddress(params.Recipient[12:]) != srcLiquidityPool { - return fmt.Errorf("invalid recipient") - } - - promisedAmount := contracts.DenormalizeAmount( - new(big.Int).SetUint64(msg.PromisedAmount), - tc.Decimals) - netAmount, err := calculateNetAmount( - params.FulfillAmount, - msg.ReferrerBps, - msg.ProtocolBps) - if err != nil { - return err - } - if netAmount.Cmp(promisedAmount) == -1 { - return fmt.Errorf( - "net amount %s smaller than promised amount %s", - netAmount, - promisedAmount) - } - - return nil -} - -func (h *MayanMessageHandler) notify(data *MayanData) error { - if data.Coordinator != peer.ID("") { - return nil - } - - data.Coordinator = h.host.ID() - msgBytes, err := json.Marshal(data) - if err != nil { - return err - } - - return h.comm.Broadcast(h.host.Peerstore().Peers(), msgBytes, comm.MayanMsg, fmt.Sprintf("%d-%s", h.chainID, comm.MayanSessionID)) -} - -func calculateNetAmount( - fulfillAmount *big.Int, - referrerBps uint8, - protocolBps uint8, -) (*big.Int, error) { - referrerAmount := new(big.Int).Div( - new(big.Int).Mul(fulfillAmount, big.NewInt(int64(referrerBps))), - BPS_DENOMINATOR, - ) - - protocolAmount := new(big.Int).Div( - new(big.Int).Mul(fulfillAmount, big.NewInt(int64(protocolBps))), - BPS_DENOMINATOR, - ) - - netAmount := new(big.Int).Sub(fulfillAmount, referrerAmount) - netAmount.Sub(netAmount, protocolAmount) - - return netAmount, nil -} diff --git a/chains/evm/message/mayan_test.go b/chains/evm/message/mayan_test.go deleted file mode 100644 index c4b73feb..00000000 --- a/chains/evm/message/mayan_test.go +++ /dev/null @@ -1,374 +0,0 @@ -package message_test - -import ( - "encoding/hex" - "fmt" - "math/big" - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts" - "github.com/sprintertech/sprinter-signing/chains/evm/message" - mock_message "github.com/sprintertech/sprinter-signing/chains/evm/message/mock" - "github.com/sprintertech/sprinter-signing/comm" - mock_communication "github.com/sprintertech/sprinter-signing/comm/mock" - mock_host "github.com/sprintertech/sprinter-signing/comm/p2p/mock/host" - "github.com/sprintertech/sprinter-signing/config" - "github.com/sprintertech/sprinter-signing/keyshare" - "github.com/sprintertech/sprinter-signing/protocol/mayan" - mock_tss "github.com/sprintertech/sprinter-signing/tss/ecdsa/common/mock" - "github.com/stretchr/testify/suite" - coreMessage "github.com/sygmaprotocol/sygma-core/relayer/message" - "go.uber.org/mock/gomock" -) - -var ( - mayanCalldata = "488c35910000000000000000000000000000000000000000000000000022a234ce522eb100000000000000000000000000000000000000000000000000000000000000800000000000000000000000006ffc5848c46319e7c6d48f56ca2152b213d4535f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000047201000000040d000881698215359f2238fc4a826edb226cdb16341fd05312ff489d7b1a6802532b48442301a935850009067ca2cceef73ba79e6c99ec42e3c458fb7549be2dcc9d00025f7076ea20ea888ceb6ec245583131597cf53eb9ebb501b6e78d8c0237afe60a45dbd6264085f06c66ff4c507ce80f5594065c6580c557d57035cc19acd34cdd0103c667ce54fbd7aa89a4c6e6d96b6d96a67f14294119deba644b719ca7bde5ba617f97feefb528549eed7a11ddfed160ce3f4b9f2c1448e27d92af2d42edc0520e0004f9cf8fb86762d87f26d46e13489bf36c4441b416dfe05779f57ab0356021d67505cffd6decd0c2b3903d9a7d2ed92b9c5cbf276c9310176fd9e1d8c0bd5e5ffe00069ca2f7e36c13d58c700e8a33d18bbec53070072b8d60e8dac41f24615caa9bec7491f889a1fa7bc9b2b387a44597d149576b5ca3f2fb4f44afe73afd32744a6d0107f70c20d919f0c3dabec14adad9cad9c3b9a0f74fd71296509f733b232c31d76b6e297068214b8b68ef30b499d1d7739641e849741f4b16000b714c901708e666000835370a611742837d40c0d7fbb2d90bf3809d664ec86972d9e5a78b647facb8113d5c6f649cb482466e04f6d0b4036ce5eed0e0f42f38330f288985d0893dd36b010aeec9bbe877140e75fbfdc6bdd2d1ef2736d4ae01811f30dceebf7eb440cb1ec17d2dfa894ba4c8a6dbccf91da5182de86cf2142a049de515b666a051853ed858000b89963305c356b251c5d4402ec7af7adc182d385d5327dd0c43f344f7593382b4083998f702371dca1b507d83f254b12b2fbe4c4cb3d6a905a7c7f2acbd3d5f3c010d4c3655823a39abaf93a7cc0c4a73c67e63b79535452b2dd8d6e27713e48326ed7b4b28fbb690595d0545c6a2f3e42165520eba0311d24ffa1f6bfeb67b14428b000f5689a1d5550361c616b03b875e02d9de688047a0cb59e6da104fe3589712232c7384a1a653e28a22dffc8d484fd1c40b133622d99a9be586c928eb9d681e976f01106a96bd0c9f66811485a6cc017ddb31a4e38335479b9f75fda3259275b640698b4a308ca3d93df6f4cbb5f62ee3b3e815fb74267e10d1cae23372c92a250a697d0011ffdeb06d9dc35e134b5e40c9cc4db2cb1d06b46ce5b4717c6355fb9319f0ee275bcaa57246984aa694c717583d4b4d35f198f1c105025376275bceab861163780167f7c47900000000000134cdc6b2623f36d60ae820e95b60f764e81ec2cd3b57b77e3f8e25ddd43ac37300000000000e158d01015ab756fa13dcf3b79c9d4636c5d241018ee1a797582e979b095872e13b01e2e000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f24f2160676ae01f5a8754e544e132298868a367001e000000000000000000000000000000000000000000000000000000000000000000000000000eded400000000000000000000000067f7c90c000000000000000000000000a5aa6e2171b416e1d27ec53ca8c13db3f91a89cd00030000000000000000000000006ffc5848c46319e7c6d48f56ca2152b213d4535f0000000000000000000000000000" -) - -type MayanMessageHandlerTestSuite struct { - suite.Suite - - mockCommunication *mock_communication.MockCommunication - mockCoordinator *mock_message.MockCoordinator - mockEventFilterer *mock_message.MockEventFilterer - mockHost *mock_host.MockHost - mockFetcher *mock_tss.MockSaveDataFetcher - mockWatcher *mock_message.MockConfirmationWatcher - mockSwapFetcher *mock_message.MockSwapFetcher - mockContract *mock_message.MockMayanContract - - handler *message.MayanMessageHandler - sigChn chan interface{} - - validLog []byte -} - -func TestRunMayanMessageHandlerTestSuite(t *testing.T) { - suite.Run(t, new(MayanMessageHandlerTestSuite)) -} - -func (s *MayanMessageHandlerTestSuite) SetupTest() { - ctrl := gomock.NewController(s.T()) - - s.mockCommunication = mock_communication.NewMockCommunication(ctrl) - s.mockCoordinator = mock_message.NewMockCoordinator(ctrl) - s.mockEventFilterer = mock_message.NewMockEventFilterer(ctrl) - - s.mockHost = mock_host.NewMockHost(ctrl) - s.mockHost.EXPECT().ID().Return(peer.ID("")).AnyTimes() - - s.mockFetcher = mock_tss.NewMockSaveDataFetcher(ctrl) - s.mockFetcher.EXPECT().UnlockKeyshare().AnyTimes() - s.mockFetcher.EXPECT().LockKeyshare().AnyTimes() - s.mockFetcher.EXPECT().GetKeyshare().AnyTimes().Return(keyshare.ECDSAKeyshare{}, nil) - - s.mockWatcher = mock_message.NewMockConfirmationWatcher(ctrl) - s.mockContract = mock_message.NewMockMayanContract(ctrl) - s.mockSwapFetcher = mock_message.NewMockSwapFetcher(ctrl) - - pools := make(map[uint64]common.Address) - pools[8453] = common.HexToAddress("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5") - - liquidityPools := make(map[uint64]common.Address) - liquidityPools[10] = common.HexToAddress("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C6") - - s.sigChn = make(chan interface{}, 1) - - // Ethereum: 0x93a9d5e32f5c81cbd17ceb842edc65002e3a79da4efbdc9f1e1f7e97fbcd669b - s.validLog, _ = hex.DecodeString("000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000119baee0ab0400000000000000000000000000000000000000000000000000001199073ea3008d0000000000000000000000000000000000000000000000000000000067bc6e3f0000000000000000000000000000000000000000000000000000000067bc927b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001886a1eb051c10f20c7386576a6a0716b20b2734000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000") - - tokens := make(map[uint64]map[string]config.TokenConfig) - tokens[10] = make(map[string]config.TokenConfig) - tokens[10]["ETH"] = config.TokenConfig{ - Address: common.HexToAddress("0x0000000000000000000000000000000000000000"), - Decimals: 18, - } - tokens[8453] = make(map[string]config.TokenConfig) - tokens[8453]["ETH"] = config.TokenConfig{ - Address: common.HexToAddress("0x0000000000000000000000000000000000000000"), - Decimals: 18, - } - tokenStore := config.TokenStore{ - Tokens: tokens, - } - confirmations := make(map[uint64]uint64) - confirmations[1000] = 100 - confirmations[2000] = 200 - - s.handler = message.NewMayanMessageHandler( - 10, - s.mockEventFilterer, - liquidityPools, - pools, - s.mockCoordinator, - s.mockHost, - s.mockCommunication, - s.mockFetcher, - s.mockWatcher, - tokenStore, - s.mockContract, - s.mockSwapFetcher, - s.sigChn, - ) -} - -func (s *MayanMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.MayanMsg, - fmt.Sprintf("%d-%s", 10, comm.MayanSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.MayanData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Calldata: mayanCalldata, - BorrowAmount: big.NewInt(9000000000000000), - OrderHash: "orderHash", - DepositTxHash: "0x6cd3de31d0085c8318a19eb1299b00e1d0636838cb6359da6199adcd6d142952", - } - - calldataBytes, _ := hex.DecodeString(ad.Calldata) - orderHash := common.HexToHash(common.Bytes2Hex([]byte("orderHash"))) - - s.mockContract.EXPECT().DecodeFulfillCall(calldataBytes).Return( - &contracts.MayanFulfillParams{ - Recipient: common.HexToHash("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C6"), - FulfillAmount: big.NewInt(9900000000000000), - }, - &contracts.MayanFulfillMsg{ - OrderHash: orderHash, - SrcChainId: 24, - DestChainId: 30, - ReferrerAddr: common.HexToHash(ad.Caller.Hex()), - Driver: common.HexToHash(ad.Caller.Hex()), - ReferrerBps: 1, - ProtocolBps: 3, - PromisedAmount: 989000, - }, - nil) - s.mockSwapFetcher.EXPECT().GetSwap(ad.OrderHash).Return(&mayan.MayanSwap{ - OrderHash: orderHash.Hex(), - }, nil) - s.mockContract.EXPECT().GetOrder(gomock.Any(), gomock.Any(), uint8(18)).Return(&contracts.MayanOrder{ - Status: contracts.OrderCreated, - AmountIn: 1000000, - }, nil) - s.mockWatcher.EXPECT().WaitForTokenConfirmations(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) - s.mockCoordinator.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.Nil(err) - - err = <-errChn - s.Nil(err) -} - -func (s *MayanMessageHandlerTestSuite) Test_HandleMessage_BorrowAmountTooHigh() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.MayanMsg, - fmt.Sprintf("%d-%s", 10, comm.MayanSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.MayanData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Calldata: mayanCalldata, - BorrowAmount: big.NewInt(900000000000000000), - OrderHash: "orderHash", - DepositTxHash: "0x6cd3de31d0085c8318a19eb1299b00e1d0636838cb6359da6199adcd6d142952", - } - - calldataBytes, _ := hex.DecodeString(ad.Calldata) - orderHash := common.HexToHash(common.Bytes2Hex([]byte("orderHash"))) - - s.mockContract.EXPECT().DecodeFulfillCall(calldataBytes).Return( - &contracts.MayanFulfillParams{ - Recipient: common.HexToHash("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C6"), - FulfillAmount: big.NewInt(99000000000000000), - }, - &contracts.MayanFulfillMsg{ - OrderHash: orderHash, - SrcChainId: 24, - DestChainId: 30, - ReferrerAddr: common.HexToHash(ad.Caller.Hex()), - Driver: common.HexToHash(ad.Caller.Hex()), - ReferrerBps: 1, - ProtocolBps: 3, - PromisedAmount: 989000, - }, - nil) - s.mockSwapFetcher.EXPECT().GetSwap(ad.OrderHash).Return(&mayan.MayanSwap{ - OrderHash: orderHash.Hex(), - }, nil) - s.mockContract.EXPECT().GetOrder(gomock.Any(), gomock.Any(), uint8(18)).Return(&contracts.MayanOrder{ - Status: contracts.OrderCreated, - AmountIn: 1000000, - }, nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} - -func (s *MayanMessageHandlerTestSuite) Test_HandleMessage_InvalidOrderHash() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.MayanMsg, - fmt.Sprintf("%d-%s", 10, comm.MayanSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.MayanData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Calldata: mayanCalldata, - BorrowAmount: big.NewInt(900000000000000000), - DepositTxHash: "0x6cd3de31d0085c8318a19eb1299b00e1d0636838cb6359da6199adcd6d142952", - OrderHash: "orderHash", - } - - calldataBytes, _ := hex.DecodeString(ad.Calldata) - orderHash := common.HexToHash(common.Bytes2Hex([]byte("orderHash"))) - - s.mockContract.EXPECT().DecodeFulfillCall(calldataBytes).Return( - &contracts.MayanFulfillParams{ - Recipient: common.HexToHash("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C6"), - FulfillAmount: big.NewInt(99000000000000000), - }, - &contracts.MayanFulfillMsg{ - OrderHash: orderHash, - SrcChainId: 24, - DestChainId: 30, - ReferrerAddr: common.HexToHash(ad.Caller.Hex()), - Driver: common.HexToHash(ad.Caller.Hex()), - ReferrerBps: 1, - ProtocolBps: 3, - PromisedAmount: 989000, - }, - nil) - s.mockSwapFetcher.EXPECT().GetSwap(ad.OrderHash).Return(&mayan.MayanSwap{ - OrderHash: "invalid", - }, nil) - s.mockContract.EXPECT().GetOrder(gomock.Any(), gomock.Any(), uint8(18)).Return(&contracts.MayanOrder{ - Status: contracts.OrderCreated, - AmountIn: 100000000000, - }, nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} - -func (s *MayanMessageHandlerTestSuite) Test_HandleMessage_InvalidFulfillAmount() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.MayanMsg, - fmt.Sprintf("%d-%s", 10, comm.MayanSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.MayanData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - Calldata: mayanCalldata, - BorrowAmount: big.NewInt(900000000000000000), - DepositTxHash: "0x6cd3de31d0085c8318a19eb1299b00e1d0636838cb6359da6199adcd6d142952", - OrderHash: "orderHash", - } - - calldataBytes, _ := hex.DecodeString(ad.Calldata) - orderHash := common.HexToHash(common.Bytes2Hex([]byte("orderHash"))) - - s.mockContract.EXPECT().DecodeFulfillCall(calldataBytes).Return( - &contracts.MayanFulfillParams{ - Recipient: common.HexToHash("0x5c7BCd6E7De5423a257D81B442095A1a6ced35C6"), - FulfillAmount: big.NewInt(99000000000000000), - }, - &contracts.MayanFulfillMsg{ - OrderHash: orderHash, - SrcChainId: 24, - DestChainId: 30, - ReferrerAddr: common.HexToHash(ad.Caller.Hex()), - Driver: common.HexToHash(ad.Caller.Hex()), - ReferrerBps: 1, - ProtocolBps: 3, - PromisedAmount: 9900000, - }, - nil) - s.mockSwapFetcher.EXPECT().GetSwap(ad.OrderHash).Return(&mayan.MayanSwap{ - OrderHash: orderHash.Hex(), - }, nil) - s.mockContract.EXPECT().GetOrder(gomock.Any(), gomock.Any(), uint8(18)).Return(&contracts.MayanOrder{ - Status: contracts.OrderCreated, - AmountIn: 100000000000, - }, nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} diff --git a/chains/evm/message/message.go b/chains/evm/message/message.go index 6e634d69..8b037f8a 100644 --- a/chains/evm/message/message.go +++ b/chains/evm/message/message.go @@ -41,56 +41,6 @@ func NewAcrossMessage(source, destination uint64, acrossData *AcrossData) *messa } } -type MayanData struct { - ErrChn chan error `json:"-"` - - OrderHash string - Coordinator peer.ID - LiquidityPool common.Address - Caller common.Address - DepositTxHash string - Calldata string - Nonce *big.Int - BorrowAmount *big.Int - Deadline uint64 - Source uint64 - Destination uint64 -} - -func NewMayanMessage(source, destination uint64, mayanData *MayanData) *message.Message { - return &message.Message{ - Source: source, - Destination: destination, - Data: mayanData, - Type: message.MessageType(comm.MayanMsg.String()), - Timestamp: time.Now(), - } -} - -type RhinestoneData struct { - ErrChn chan error `json:"-"` - - BundleID string - Coordinator peer.ID - LiquidityPool common.Address - Caller common.Address - BorrowAmount *big.Int - Nonce *big.Int - Source uint64 - Deadline uint64 - Destination uint64 -} - -func NewRhinestoneMessage(source, destination uint64, rhinestoneData *RhinestoneData) *message.Message { - return &message.Message{ - Source: source, - Destination: destination, - Data: rhinestoneData, - Type: message.MessageType(comm.RhinestoneMsg.String()), - Timestamp: time.Now(), - } -} - type LifiEscrowData struct { ErrChn chan error `json:"-"` diff --git a/chains/evm/message/mock/mayan.go b/chains/evm/message/mock/mayan.go deleted file mode 100644 index 06365093..00000000 --- a/chains/evm/message/mock/mayan.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./chains/evm/message/mayan.go -// -// Generated by this command: -// -// mockgen -source=./chains/evm/message/mayan.go -destination=./chains/evm/message/mock/mayan.go -// - -// Package mock_message is a generated GoMock package. -package mock_message - -import ( - reflect "reflect" - - contracts "github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts" - mayan "github.com/sprintertech/sprinter-signing/protocol/mayan" - gomock "go.uber.org/mock/gomock" -) - -// MockMayanContract is a mock of MayanContract interface. -type MockMayanContract struct { - ctrl *gomock.Controller - recorder *MockMayanContractMockRecorder - isgomock struct{} -} - -// MockMayanContractMockRecorder is the mock recorder for MockMayanContract. -type MockMayanContractMockRecorder struct { - mock *MockMayanContract -} - -// NewMockMayanContract creates a new mock instance. -func NewMockMayanContract(ctrl *gomock.Controller) *MockMayanContract { - mock := &MockMayanContract{ctrl: ctrl} - mock.recorder = &MockMayanContractMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockMayanContract) EXPECT() *MockMayanContractMockRecorder { - return m.recorder -} - -// DecodeFulfillCall mocks base method. -func (m *MockMayanContract) DecodeFulfillCall(calldata []byte) (*contracts.MayanFulfillParams, *contracts.MayanFulfillMsg, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DecodeFulfillCall", calldata) - ret0, _ := ret[0].(*contracts.MayanFulfillParams) - ret1, _ := ret[1].(*contracts.MayanFulfillMsg) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// DecodeFulfillCall indicates an expected call of DecodeFulfillCall. -func (mr *MockMayanContractMockRecorder) DecodeFulfillCall(calldata any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecodeFulfillCall", reflect.TypeOf((*MockMayanContract)(nil).DecodeFulfillCall), calldata) -} - -// GetOrder mocks base method. -func (m *MockMayanContract) GetOrder(msg *contracts.MayanFulfillMsg, swap *mayan.MayanSwap, srcTokenDecimals uint8) (*contracts.MayanOrder, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOrder", msg, swap, srcTokenDecimals) - ret0, _ := ret[0].(*contracts.MayanOrder) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetOrder indicates an expected call of GetOrder. -func (mr *MockMayanContractMockRecorder) GetOrder(msg, swap, srcTokenDecimals any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrder", reflect.TypeOf((*MockMayanContract)(nil).GetOrder), msg, swap, srcTokenDecimals) -} - -// MockSwapFetcher is a mock of SwapFetcher interface. -type MockSwapFetcher struct { - ctrl *gomock.Controller - recorder *MockSwapFetcherMockRecorder - isgomock struct{} -} - -// MockSwapFetcherMockRecorder is the mock recorder for MockSwapFetcher. -type MockSwapFetcherMockRecorder struct { - mock *MockSwapFetcher -} - -// NewMockSwapFetcher creates a new mock instance. -func NewMockSwapFetcher(ctrl *gomock.Controller) *MockSwapFetcher { - mock := &MockSwapFetcher{ctrl: ctrl} - mock.recorder = &MockSwapFetcherMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockSwapFetcher) EXPECT() *MockSwapFetcherMockRecorder { - return m.recorder -} - -// GetSwap mocks base method. -func (m *MockSwapFetcher) GetSwap(hash string) (*mayan.MayanSwap, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSwap", hash) - ret0, _ := ret[0].(*mayan.MayanSwap) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetSwap indicates an expected call of GetSwap. -func (mr *MockSwapFetcherMockRecorder) GetSwap(hash any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSwap", reflect.TypeOf((*MockSwapFetcher)(nil).GetSwap), hash) -} diff --git a/chains/evm/message/mock/mockBundle.go b/chains/evm/message/mock/mockBundle.go deleted file mode 100644 index afd4546c..00000000 --- a/chains/evm/message/mock/mockBundle.go +++ /dev/null @@ -1,113 +0,0 @@ -package mock_message - -const MockBundleJSON = `{ - "status": "STARTED", - "claims": [ - { - "depositId": "95343720360036425709348767244941479423577393545335380997521643611774314128786", - "chainId": 8453, - "status": "CLAIMED", - "claimTransactionHash": "0x4823a24b334928a7a1f07eb43af9360154ebf6f772c7b5c1d9544597e77e1360", - "claimTimestamp": 1749152997 - } - ], - "targetChainId": 42161, - "userAddress": "0x26949F13231fFA4139191752415Cc13451C5D479", - "bundleData": { - "nonce": "95343720360036425709348767244941479423577393545335380997521643611774314128786", - "expires": "1780688990", - "sponsor": "0x26949F13231fFA4139191752415Cc13451C5D479", - "segments": [ - { - "arbiter": "0x0000000000AFc904aE9860D9c4B96D7c529c58b8", - "chainId": "8453", - "witness": { - "execs": [ - { - "to": "0x0000000000f6Ed8Be424d673c63eeFF8b9267420", - "data": "0x27c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0160addfde316ea01952100a17e817b8c2aaa267bf75e21caa23e12a2191ebf9e000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041aa078528fa83851e8174dac27c42e39e2e5cce37dcb373368e2a55d6ebfde94b6f965895604e9beddbaf128807ccab1c6e0bc3c708d06bf73dad8a7fbc3e51e21b00000000000000000000000000000000000000000000000000000000000000", - "value": "0" - }, - { - "to": "0x0000000000f6Ed8Be424d673c63eeFF8b9267420", - "data": "0x27c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0a97d80efbd10d5457041e58c09a0fa3875c105baa956062ca4b333bf4c9f7b28000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453182af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041d2865ee12ea92f6f613831581bd6c5c2c0edf4cc64a8eabb6b76ca2f28897f1c7d1e2d52a7389ff8fd0ea80f68489aafa24e374b86d1d0fb8d49b96f49a94d661c00000000000000000000000000000000000000000000000000000000000000", - "value": "0" - }, - { - "to": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", - "data": "0x2e1a7d4d0000000000000000000000000000000000000000000000000008cbdab42f6801", - "value": "0" - }, - { - "to": "0x00000000002B0eCfbD0496EE71e01257dA0E37DE", - "data": "0x217124070000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009e39df09e983069a03944afa27997fde1fea41fb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000209a8c0869a7ecb60b23974626f13ddbdf3fa5277561faee108f443871674542fd00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001764d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c627974657320646174612900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000003111cd8e92337c100f22b7a9dbf8dee301000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "value": "0" - }, - { - "to": "0x1ebdb1a9d7cb1d5a5c04ff69fb442f09e33e3113", - "data": "0x", - "value": "2475940000000000" - } - ], - "tokenOut": [ - [ - "21847980266613871481014731415167448634647776251198795536684055616834884337664", - "2475940000000001" - ] - ], - "depositId": "95343720360036425709348767244941479423577393545335380997521643611774314128786", - "maxFeeBps": 0, - "recipient": "0x26949F13231fFA4139191752415Cc13451C5D479", - "userOpHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "targetChain": "42161", - "fillDeadline": "1749153290" - }, - "idsAndAmounts": [ - [ - "21847980266613871481014731415167448634647776251198795536684055616834884337664", - "2493365192379645" - ] - ] - } - ], - "targetSignature": "0x2483da3a338895199e5e538530213157e931bf065f87df8de2f86cb153c7c6851adebcda6e46d6261e53a3c9a15a4613a3e3831e37ec016bfa7a4fc5218ff5f655ceba8ffd81bb025f6620f55eb054d10805f8451c", - "originSignatures": [ - "0x2483da3a338895199e5e538530213157e931bf065f87df8de2f86cb153c7c6851adebcda6e46d6261e53a3c9a15a4613a3e3831e37ec016bfa7a4fc5218ff5f655ceba8ffd81bb025f6620f55eb054d10805f8451c" - ] - }, - "bundleEvent": { - "type": "RhinestoneBundle", - "bundleId": "95343720360036425709348767244941479423577393545335380997521643611774314128786", - "targetFillPayload": { - "to": "0x000000000060f6e853447881951574CDd0663530", - "data": "0x37accafa00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012a000000000000000000000000000000000000000000000000000000000000012e000000000000000000000000000000000000000000000000000000000000013200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000011800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000afc904ae9860d9c4b96d7c529c58b800000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000002105d2caa223e380f3288031daa68b82b85bcfb85d55d8f7dce6c82e97c630e4a5920000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008dbb3d2964cfd0000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000f2101000000000000000000000000000000000000000000000000000000000000002000000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000afc904ae9860d9c4b96d7c529c58b80000000000000000000000000000000000000000000000000000000000002105d2caa223e380f3288031daa68b82b85bcfb85d55d8f7dce6c82e97c630e4a592000000000000000000000000000000000000000000000000000000006a23285ef181b36813d1cbcc4e7e4366b5faa6881575e088845945aaa6fb2306f440a4700000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000e8000000000000000000000000026949f13231ffa4139191752415cc13451c5d47900000000000000000000000000000000000000000000000000000000000000c000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000006841f60a0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0160addfde316ea01952100a17e817b8c2aaa267bf75e21caa23e12a2191ebf9e000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041aa078528fa83851e8174dac27c42e39e2e5cce37dcb373368e2a55d6ebfde94b6f965895604e9beddbaf128807ccab1c6e0bc3c708d06bf73dad8a7fbc3e51e21b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0a97d80efbd10d5457041e58c09a0fa3875c105baa956062ca4b333bf4c9f7b28000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453182af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041d2865ee12ea92f6f613831581bd6c5c2c0edf4cc64a8eabb6b76ca2f28897f1c7d1e2d52a7389ff8fd0ea80f68489aafa24e374b86d1d0fb8d49b96f49a94d661c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000242e1a7d4d0000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0ecfbd0496ee71e01257da0e37de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000564217124070000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009e39df09e983069a03944afa27997fde1fea41fb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000209a8c0869a7ecb60b23974626f13ddbdf3fa5277561faee108f443871674542fd00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001764d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c627974657320646174612900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000003111cd8e92337c100f22b7a9dbf8dee301000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ebdb1a9d7cb1d5a5c04ff69fb442f09e33e31130000000000000000000000000000000000000000000000000008cbdab42f68000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000552483da3a338895199e5e538530213157e931bf065f87df8de2f86cb153c7c6851adebcda6e46d6261e53a3c9a15a4613a3e3831e37ec016bfa7a4fc5218ff5f655ceba8ffd81bb025f6620f55eb054d10805f8451c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a30b6d6b7056ea40726f90daef5ac0fbd1f1bcddc49a8557af824933fe433ffc6e3255081530e6f82d025c0689ee56139eaba8dd85ed91d3dea6783f0196f5d41c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e59aaf21c4d9cf92d9ed4537f4404ba031f83b230000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000210500000000000000000000000026949f13231ffa4139191752415cc13451c5d47900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000758000000001d1d5004a02bafab9de2d6ce5b7b13deea6d13ac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000000000000d3254452a909e4eed47455af7e27c2890000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000066477182ae600000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004c0000000000000000000000000000000000000000000000000000000000000058000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000000145e61073F32f5605Add1788ceEDb69DdaE201422E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000002483da3a338895199e5e538530213157e931bf06000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005e61073f32f5605add1788ceedb69ddae201422e00000000000000000000000000000000002b0ecfbd0496ee71e01257da0e37de000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043ff16d5776c7f0f65ec485c17ca04000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e5a37279a001301a837a91b5de1d5e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000e5a37279a001301a837a91b5de1d5e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000053a5be8cb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000069e2a187aeffb852bf3ccdc95151b20000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000006d0515e8e499468dce9583626f0ca15b887f9d0300000000000000000000000099b02b2b538d1cb83b0cdd031c14f45edb549943000000000000000000000000000000000000000000000000000000000000000000000000", - "value": "0", - "chainId": 42161 - }, - "acrossDepositEvents": [ - { - "message": "0x01000000000000000000000000000000000000000000000000000000000000002000000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000afc904ae9860d9c4b96d7c529c58b80000000000000000000000000000000000000000000000000000000000002105d2caa223e380f3288031daa68b82b85bcfb85d55d8f7dce6c82e97c630e4a592000000000000000000000000000000000000000000000000000000006a23285ef181b36813d1cbcc4e7e4366b5faa6881575e088845945aaa6fb2306f440a4700000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000e8000000000000000000000000026949f13231ffa4139191752415cc13451c5d47900000000000000000000000000000000000000000000000000000000000000c000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000006841f60a0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0160addfde316ea01952100a17e817b8c2aaa267bf75e21caa23e12a2191ebf9e000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041aa078528fa83851e8174dac27c42e39e2e5cce37dcb373368e2a55d6ebfde94b6f965895604e9beddbaf128807ccab1c6e0bc3c708d06bf73dad8a7fbc3e51e21b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0a97d80efbd10d5457041e58c09a0fa3875c105baa956062ca4b333bf4c9f7b28000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453182af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041d2865ee12ea92f6f613831581bd6c5c2c0edf4cc64a8eabb6b76ca2f28897f1c7d1e2d52a7389ff8fd0ea80f68489aafa24e374b86d1d0fb8d49b96f49a94d661c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000242e1a7d4d0000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0ecfbd0496ee71e01257da0e37de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000564217124070000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009e39df09e983069a03944afa27997fde1fea41fb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000209a8c0869a7ecb60b23974626f13ddbdf3fa5277561faee108f443871674542fd00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001764d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c627974657320646174612900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000003111cd8e92337c100f22b7a9dbf8dee301000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ebdb1a9d7cb1d5a5c04ff69fb442f09e33e31130000000000000000000000000000000000000000000000000008cbdab42f68000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000552483da3a338895199e5e538530213157e931bf065f87df8de2f86cb153c7c6851adebcda6e46d6261e53a3c9a15a4613a3e3831e37ec016bfa7a4fc5218ff5f655ceba8ffd81bb025f6620f55eb054d10805f8451c0000000000000000000000", - "depositId": "48294649208082656552010960162210682017172414278805315478346890598788477444581", - "depositor": "0x26949F13231fFA4139191752415Cc13451C5D479", - "recipient": "0x26949F13231fFA4139191752415Cc13451C5D479", - "inputToken": "0x4200000000000000000000000000000000000006", - "inputAmount": "2493365192379645", - "outputToken": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", - "fillDeadline": "1749153290", - "outputAmount": "2475940000000001", - "quoteTimestamp": 1749152993, - "exclusiveRelayer": "0x000000000060f6e853447881951574CDd0663530", - "destinationChainId": 42161, - "originClaimPayload": { - "to": "0x0000000000AFc904aE9860D9c4B96D7c529c58b8", - "data": "0xb2b9d471000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000044000000000000000000000000026949f13231ffa4139191752415cc13451c5d479d2caa223e380f3288031daa68b82b85bcfb85d55d8f7dce6c82e97c630e4a592000000000000000000000000000000000000000000000000000000006a23285e00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000a4b100000000000000000000000026949f13231ffa4139191752415cc13451c5d479000000000000000000000000000000000000000000000000000000006841f60a00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008dbb3d2964cfd0000000000000000000000000000000000000000000000000000000000000001304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000041ce50fd0ce63383e9b244d5cca50db1ac180a30c67f12320d603ea995fd11f34c08fc81971a13c4386654558bc579aedeb71c9cd00fd70983e4d8cd5d15f46e981b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000552483da3a338895199e5e538530213157e931bf065f87df8de2f86cb153c7c6851adebcda6e46d6261e53a3c9a15a4613a3e3831e37ec016bfa7a4fc5218ff5f655ceba8ffd81bb025f6620f55eb054d10805f8451c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0160addfde316ea01952100a17e817b8c2aaa267bf75e21caa23e12a2191ebf9e000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041aa078528fa83851e8174dac27c42e39e2e5cce37dcb373368e2a55d6ebfde94b6f965895604e9beddbaf128807ccab1c6e0bc3c708d06bf73dad8a7fbc3e51e21b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6ed8be424d673c63eeff8b926742000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016427c777a9000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0a97d80efbd10d5457041e58c09a0fa3875c105baa956062ca4b333bf4c9f7b28000000000000000000000000000000000000000000000000000000006a23285e304d84c3d9a7be3b28c9453182af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000008cbdab42f680100000000000000000000000026949f13231ffa4139191752415cc13451c5d4790000000000000000000000000000000000000000000000000000000000000041d2865ee12ea92f6f613831581bd6c5c2c0edf4cc64a8eabb6b76ca2f28897f1c7d1e2d52a7389ff8fd0ea80f68489aafa24e374b86d1d0fb8d49b96f49a94d661c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000242e1a7d4d0000000000000000000000000000000000000000000000000008cbdab42f68010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0ecfbd0496ee71e01257da0e37de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000564217124070000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000e03000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009e39df09e983069a03944afa27997fde1fea41fb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000209a8c0869a7ecb60b23974626f13ddbdf3fa5277561faee108f443871674542fd00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001764d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c627974657320646174612900000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000003111cd8e92337c100f22b7a9dbf8dee301000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ebdb1a9d7cb1d5a5c04ff69fb442f09e33e31130000000000000000000000000000000000000000000000000008cbdab42f680000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", - "value": "0", - "chainId": 8453 - }, - "exclusivityDeadline": "1749153290" - } - ] - }, - "fillTransactionHash": "0xc62872d1157f2dd2faf6ae04447d0638943c8575977339bac25674f385227d97", - "fillTimestamp": 1749153002 -}` diff --git a/chains/evm/message/mock/rhinestone.go b/chains/evm/message/mock/rhinestone.go deleted file mode 100644 index bcb5bb15..00000000 --- a/chains/evm/message/mock/rhinestone.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./chains/evm/message/rhinestone.go -// -// Generated by this command: -// -// mockgen -source=./chains/evm/message/rhinestone.go -destination=./chains/evm/message/mock/rhinestone.go -// - -// Package mock_message is a generated GoMock package. -package mock_message - -import ( - reflect "reflect" - - rhinestone "github.com/sprintertech/sprinter-signing/protocol/rhinestone" - gomock "go.uber.org/mock/gomock" -) - -// MockBundleFetcher is a mock of BundleFetcher interface. -type MockBundleFetcher struct { - ctrl *gomock.Controller - recorder *MockBundleFetcherMockRecorder - isgomock struct{} -} - -// MockBundleFetcherMockRecorder is the mock recorder for MockBundleFetcher. -type MockBundleFetcherMockRecorder struct { - mock *MockBundleFetcher -} - -// NewMockBundleFetcher creates a new mock instance. -func NewMockBundleFetcher(ctrl *gomock.Controller) *MockBundleFetcher { - mock := &MockBundleFetcher{ctrl: ctrl} - mock.recorder = &MockBundleFetcherMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockBundleFetcher) EXPECT() *MockBundleFetcherMockRecorder { - return m.recorder -} - -// GetBundle mocks base method. -func (m *MockBundleFetcher) GetBundle(bundleID string) (*rhinestone.Bundle, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBundle", bundleID) - ret0, _ := ret[0].(*rhinestone.Bundle) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetBundle indicates an expected call of GetBundle. -func (mr *MockBundleFetcherMockRecorder) GetBundle(bundleID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBundle", reflect.TypeOf((*MockBundleFetcher)(nil).GetBundle), bundleID) -} diff --git a/chains/evm/message/rhinestone.go b/chains/evm/message/rhinestone.go deleted file mode 100644 index aed84f25..00000000 --- a/chains/evm/message/rhinestone.go +++ /dev/null @@ -1,261 +0,0 @@ -package message - -import ( - "context" - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/libp2p/go-libp2p/core/host" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/rs/zerolog/log" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts" - "github.com/sprintertech/sprinter-signing/chains/evm/signature" - "github.com/sprintertech/sprinter-signing/comm" - "github.com/sprintertech/sprinter-signing/config" - "github.com/sprintertech/sprinter-signing/protocol/rhinestone" - "github.com/sprintertech/sprinter-signing/tss" - "github.com/sprintertech/sprinter-signing/tss/ecdsa/signing" - "github.com/sygmaprotocol/sygma-core/relayer/message" - "github.com/sygmaprotocol/sygma-core/relayer/proposal" -) - -type BundleFetcher interface { - GetBundle(bundleID string) (*rhinestone.Bundle, error) -} - -type RhinestoneMessageHandler struct { - chainID uint64 - - bundleFetcher BundleFetcher - tokenStore config.TokenStore - rhinestoneContract contracts.RhinestoneContract - - coordinator Coordinator - host host.Host - comm comm.Communication - fetcher signing.SaveDataFetcher - - sigChn chan any -} - -func NewRhinestoneMessageHandler( - chainID uint64, - coordinator Coordinator, - host host.Host, - comm comm.Communication, - fetcher signing.SaveDataFetcher, - tokenStore config.TokenStore, - rhinestoneContract contracts.RhinestoneContract, - bundleFetcher BundleFetcher, - sigChn chan any, -) *RhinestoneMessageHandler { - return &RhinestoneMessageHandler{ - chainID: chainID, - coordinator: coordinator, - host: host, - comm: comm, - fetcher: fetcher, - sigChn: sigChn, - rhinestoneContract: rhinestoneContract, - bundleFetcher: bundleFetcher, - tokenStore: tokenStore, - } -} - -// HandleMessage verifies the bundle data and signs the unlock hash to use liquidity -// for the Rhinestone protocol -func (h *RhinestoneMessageHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error) { - data := m.Data.(*RhinestoneData) - err := h.notify(data) - if err != nil { - log.Warn().Msgf("Failed to notify relayers because of %s", err) - } - - bundle, err := h.bundleFetcher.GetBundle(data.BundleID) - if err != nil { - data.ErrChn <- err - return nil, err - } - - calldata, err := hex.DecodeString(bundle.BundleEvent.FillPayload.Data[2:]) - if err != nil { - data.ErrChn <- err - return nil, err - } - - err = h.verifyOrder(bundle, data, calldata) - if err != nil { - data.ErrChn <- err - return nil, err - } - - borrowToken, err := h.outputToken( - bundle.BundleEvent.AcrossDepositEvents[0].OriginClaimPayload.ChainID, - bundle.TargetChainId, - common.HexToAddress(bundle.BundleEvent.AcrossDepositEvents[0].InputToken), - ) - if err != nil { - data.ErrChn <- err - return nil, err - } - data.ErrChn <- nil - - unlockHash, err := signature.BorrowUnlockHash( - calldata, - data.BorrowAmount, - borrowToken, - new(big.Int).SetUint64(bundle.TargetChainId), - common.HexToAddress(bundle.BundleEvent.FillPayload.To), - data.Deadline, - data.Caller, - data.LiquidityPool, - data.Nonce, - ) - if err != nil { - return nil, err - } - - sessionID := fmt.Sprintf("%d-%s", bundle.TargetChainId, bundle.BundleEvent.BundleId) - signing, err := signing.NewSigning( - new(big.Int).SetBytes(unlockHash), - sessionID, - sessionID, - h.host, - h.comm, - h.fetcher) - if err != nil { - return nil, err - } - - err = h.coordinator.Execute(context.Background(), []tss.TssProcess{signing}, h.sigChn, data.Coordinator) - if err != nil { - return nil, err - } - return nil, nil -} - -// outputToken fetches the matching output token to the -// input token of the across deposit -func (h *RhinestoneMessageHandler) outputToken( - srcChainID uint64, - dstChainID uint64, - token common.Address, -) (common.Address, error) { - symbol, _, err := h.tokenStore.ConfigByAddress(srcChainID, token) - if err != nil { - return common.Address{}, err - } - - cfg, err := h.tokenStore.ConfigBySymbol(dstChainID, symbol) - if err != nil { - return common.Address{}, err - } - - return cfg.Address, nil -} - -// verifyOrder checks that the order is an existing valid order on-chain -// and the fill calldata is corresponds to the expected stash fill -func (h *RhinestoneMessageHandler) verifyOrder( - bundle *rhinestone.Bundle, - data *RhinestoneData, - calldata []byte, -) error { - if bundle.Status == rhinestone.StatusCompleted { - return fmt.Errorf("invalid order status %s", bundle.Status) - } - - inputToken := bundle.BundleEvent.AcrossDepositEvents[0].InputToken - outputToken := bundle.BundleEvent.AcrossDepositEvents[0].OutputToken - inputAmount := big.NewInt(0) - for _, d := range bundle.BundleEvent.AcrossDepositEvents { - if d.InputToken != inputToken || d.OutputToken != outputToken { - return fmt.Errorf("order has different tokens in the bundle") - } - - bigInputAmount, _ := new(big.Int).SetString(d.InputAmount, 10) - inputAmount.Add(inputAmount, bigInputAmount) - } - - if data.BorrowAmount.Cmp(inputAmount) == 1 { - return fmt.Errorf( - "requested borrow amount %s larger than input amount %s", - data.BorrowAmount, inputAmount) - } - - fillInput, err := h.rhinestoneContract.DecodeFillCall(calldata) - if err != nil { - return err - } - - for _, address := range fillInput.RepaymentAddresses { - if address != data.LiquidityPool { - return fmt.Errorf( - "repayment address %s different from liquidity pool address %s", - address, - data.LiquidityPool, - ) - } - } - for _, chainID := range fillInput.RepaymentChainIds { - if chainID.Uint64() != h.chainID { - return fmt.Errorf( - "repayment chainID %d different than expected chainID %d", - chainID.Uint64(), - h.chainID, - ) - } - } - - return nil -} - -func (h *RhinestoneMessageHandler) Listen(ctx context.Context) { - msgChn := make(chan *comm.WrappedMessage) - subID := h.comm.Subscribe(comm.RhinestoneSessionID, comm.RhinestoneMsg, msgChn) - - for { - select { - case wMsg := <-msgChn: - { - go func(wMsg *comm.WrappedMessage) { - d := &RhinestoneData{} - err := json.Unmarshal(wMsg.Payload, d) - if err != nil { - log.Warn().Msgf("Failed unmarshaling rhinestone message: %s", err) - return - } - - d.ErrChn = make(chan error, 1) - msg := NewRhinestoneMessage(d.Source, d.Destination, d) - _, err = h.HandleMessage(msg) - if err != nil { - log.Err(err).Msgf("Failed handling rhinestone message %+v because of: %s", msg, err) - } - }(wMsg) - } - case <-ctx.Done(): - { - h.comm.UnSubscribe(subID) - return - } - } - } -} - -func (h *RhinestoneMessageHandler) notify(data *RhinestoneData) error { - if data.Coordinator != peer.ID("") { - return nil - } - - data.Coordinator = h.host.ID() - msgBytes, err := json.Marshal(data) - if err != nil { - return err - } - - return h.comm.Broadcast(h.host.Peerstore().Peers(), msgBytes, comm.RhinestoneMsg, fmt.Sprintf("%d-%s", h.chainID, comm.RhinestoneSessionID)) -} diff --git a/chains/evm/message/rhinestone_test.go b/chains/evm/message/rhinestone_test.go deleted file mode 100644 index 2809714a..00000000 --- a/chains/evm/message/rhinestone_test.go +++ /dev/null @@ -1,248 +0,0 @@ -package message_test - -import ( - "encoding/json" - "fmt" - "math/big" - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem" - "github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts" - "github.com/sprintertech/sprinter-signing/chains/evm/message" - mock_message "github.com/sprintertech/sprinter-signing/chains/evm/message/mock" - "github.com/sprintertech/sprinter-signing/comm" - mock_communication "github.com/sprintertech/sprinter-signing/comm/mock" - mock_host "github.com/sprintertech/sprinter-signing/comm/p2p/mock/host" - "github.com/sprintertech/sprinter-signing/config" - "github.com/sprintertech/sprinter-signing/keyshare" - "github.com/sprintertech/sprinter-signing/protocol/rhinestone" - mock_tss "github.com/sprintertech/sprinter-signing/tss/ecdsa/common/mock" - "github.com/stretchr/testify/suite" - coreMessage "github.com/sygmaprotocol/sygma-core/relayer/message" - "go.uber.org/mock/gomock" -) - -type RhinestoneMessageHandlerTestSuite struct { - suite.Suite - - mockCommunication *mock_communication.MockCommunication - mockCoordinator *mock_message.MockCoordinator - mockHost *mock_host.MockHost - mockFetcher *mock_tss.MockSaveDataFetcher - sigChn chan interface{} - - mockBundleFetcher *mock_message.MockBundleFetcher - mockBundle *rhinestone.Bundle - handler *message.RhinestoneMessageHandler -} - -func TestRunRhinestoneMessageHandlerTestSuite(t *testing.T) { - suite.Run(t, new(RhinestoneMessageHandlerTestSuite)) -} - -func (s *RhinestoneMessageHandlerTestSuite) SetupTest() { - ctrl := gomock.NewController(s.T()) - - s.mockCommunication = mock_communication.NewMockCommunication(ctrl) - s.mockCoordinator = mock_message.NewMockCoordinator(ctrl) - - s.mockHost = mock_host.NewMockHost(ctrl) - s.mockHost.EXPECT().ID().Return(peer.ID("")).AnyTimes() - - s.mockFetcher = mock_tss.NewMockSaveDataFetcher(ctrl) - s.mockFetcher.EXPECT().UnlockKeyshare().AnyTimes() - s.mockFetcher.EXPECT().LockKeyshare().AnyTimes() - s.mockFetcher.EXPECT().GetKeyshare().AnyTimes().Return(keyshare.ECDSAKeyshare{}, nil) - - s.mockBundleFetcher = mock_message.NewMockBundleFetcher(ctrl) - b := new(rhinestone.Bundle) - if err := json.Unmarshal([]byte(mock_message.MockBundleJSON), b); err != nil { - panic(err) - } - s.mockBundle = b - - rhinestoneContract := contracts.NewRhinestoneContract() - - s.sigChn = make(chan interface{}, 1) - - tokens := make(map[uint64]map[string]config.TokenConfig) - tokens[42161] = make(map[string]config.TokenConfig) - tokens[42161]["WETH"] = config.TokenConfig{ - Address: common.HexToAddress("0x0000000000000000000000000000000000000000"), - Decimals: 18, - } - tokens[8453] = make(map[string]config.TokenConfig) - tokens[8453]["WETH"] = config.TokenConfig{ - Address: common.HexToAddress("0x4200000000000000000000000000000000000006"), - Decimals: 18, - } - tokenStore := config.TokenStore{ - Tokens: tokens, - } - confirmations := make(map[uint64]uint64) - confirmations[1000] = 100 - confirmations[2000] = 200 - - s.handler = message.NewRhinestoneMessageHandler( - 8453, - s.mockCoordinator, - s.mockHost, - s.mockCommunication, - s.mockFetcher, - tokenStore, - *rhinestoneContract, - s.mockBundleFetcher, - s.sigChn, - ) -} - -func (s *RhinestoneMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.RhinestoneMsg, - fmt.Sprintf("%d-%s", 8453, comm.RhinestoneSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.RhinestoneData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xe59aaf21c4D9Cf92d9eD4537f4404BA031f83b23"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - BorrowAmount: big.NewInt(2493365192379644), - BundleID: "bundleID", - } - - s.mockBundleFetcher.EXPECT().GetBundle("bundleID").Return(s.mockBundle, nil) - s.mockCoordinator.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.Nil(err) - - err = <-errChn - s.Nil(err) -} - -func (s *RhinestoneMessageHandlerTestSuite) Test_HandleMessage_FetchingBundleFails() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.RhinestoneMsg, - fmt.Sprintf("%d-%s", 8453, comm.RhinestoneSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.RhinestoneData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xe59aaf21c4D9Cf92d9eD4537f4404BA031f83b23"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - BorrowAmount: big.NewInt(3493365192379644), - BundleID: "bundleID", - } - - s.mockBundleFetcher.EXPECT().GetBundle("bundleID").Return(s.mockBundle, fmt.Errorf("error")) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} - -func (s *RhinestoneMessageHandlerTestSuite) Test_HandleMessage_InvalidBorrowAmount() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.RhinestoneMsg, - fmt.Sprintf("%d-%s", 8453, comm.RhinestoneSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.RhinestoneData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xe59aaf21c4D9Cf92d9eD4537f4404BA031f83b23"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - BorrowAmount: big.NewInt(3493365192379644), - BundleID: "bundleID", - } - - s.mockBundleFetcher.EXPECT().GetBundle("bundleID").Return(s.mockBundle, nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} - -func (s *RhinestoneMessageHandlerTestSuite) Test_HandleMessage_InvalidRepaymentAddresses() { - s.mockCommunication.EXPECT().Broadcast( - gomock.Any(), - gomock.Any(), - comm.RhinestoneMsg, - fmt.Sprintf("%d-%s", 8453, comm.RhinestoneSessionID), - ).Return(nil) - p, _ := pstoremem.NewPeerstore() - s.mockHost.EXPECT().Peerstore().Return(p) - - errChn := make(chan error, 1) - ad := &message.RhinestoneData{ - ErrChn: errChn, - Nonce: big.NewInt(101), - LiquidityPool: common.HexToAddress("0xinvalid"), - Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"), - BorrowAmount: big.NewInt(2493365192379644), - BundleID: "bundleID", - } - - s.mockBundleFetcher.EXPECT().GetBundle("bundleID").Return(s.mockBundle, nil) - - m := &coreMessage.Message{ - Data: ad, - Source: 0, - Destination: 10, - } - - prop, err := s.handler.HandleMessage(m) - - s.Nil(prop) - s.NotNil(err) - - err = <-errChn - s.NotNil(err) -} diff --git a/chains/lighter/message/lighter.go b/chains/lighter/message/lighter.go index f82f3324..12db97a2 100644 --- a/chains/lighter/message/lighter.go +++ b/chains/lighter/message/lighter.go @@ -80,7 +80,7 @@ func NewLighterMessageHandler( } } -// HandleMessage finds the Mayan deposit with the according deposit ID and starts +// HandleMessage finds the Lighter deposit with the according deposit ID and starts // the MPC signature process for it. The result will be saved into the signature // cache through the result channel. func (h *LighterMessageHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error) { diff --git a/comm/messages.go b/comm/messages.go index 60b51c02..73ece870 100644 --- a/comm/messages.go +++ b/comm/messages.go @@ -39,14 +39,10 @@ const ( AcrossMsg // SprinterCreditMsg message type is used for the process coordinator to share sprinter data SprinterCreditMsg - // MayanMsg message type is used for the process coordinator to share mayan data - MayanMsg // LighterMsg message type is used for the process coordinator to share lighter data LighterMsg // LifiEscrowMsg message type is used for the process coordinator to share lifi data LifiEscrowMsg - // Rhinestone message type is used for the process coordinator to share rhinestone data - RhinestoneMsg // LifiUnlockMsg message type is used for the process coordinator to share lifi unlock data LifiUnlockMsg // Unknown message type @@ -57,9 +53,7 @@ const ( SignatureSessionID = "signatures" AcrossSessionID = "across" SprinterCreditSessionID = "sprinter-credit" - MayanSessionID = "mayan" LifiEscrowSessionID = "lifi-escrow" - RhinestoneSessionID = "rhinestone" LighterSessionID = "lighter" LifiUnlockSessionID = "lifi-unlock" ) @@ -95,10 +89,6 @@ func (msgType MessageType) String() string { return "CoordinatorPingResponseMsg" case AcrossMsg: return "AcrossMsg" - case MayanMsg: - return "MayanMsg" - case RhinestoneMsg: - return "RhinestoneMsg" case LifiEscrowMsg: return "LifiEscrowMsg" case LifiUnlockMsg: diff --git a/protocol/mayan/api.go b/protocol/mayan/api.go deleted file mode 100644 index 56c755ba..00000000 --- a/protocol/mayan/api.go +++ /dev/null @@ -1,66 +0,0 @@ -package mayan - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "time" -) - -const ( - MAYAN_EXPLORER_URL = "https://explorer-api.mayan.finance" - WORMHOLE_DECIMALS = 8 -) - -type MayanSwap struct { - OrderHash string - RandomKey string - MayanBps uint8 - AuctionMode uint8 - RedeemRelayerFee string - RedeemRelayerFee64 uint64 - RefundRelayerFee string - RefundRelayerFee64 uint64 - Trader string - MinAmountOut64 string - SourceTxHash string - CreateTxHash string -} - -type MayanExplorer struct { - HTTPClient *http.Client -} - -func NewMayanExplorer() *MayanExplorer { - return &MayanExplorer{ - HTTPClient: &http.Client{ - Timeout: 10 * time.Second, - }, - } -} - -func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) { - url := fmt.Sprintf("%s/v3/swap/order-id/SWIFT_%s", MAYAN_EXPLORER_URL, hash) - resp, err := c.HTTPClient.Get(url) - if err != nil { - return nil, fmt.Errorf("request failed: %w", err) - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode, url) - } - - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) - } - - s := new(MayanSwap) - if err := json.Unmarshal(body, s); err != nil { - return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) - } - - return s, nil -} diff --git a/protocol/mayan/api_test.go b/protocol/mayan/api_test.go deleted file mode 100644 index 2bc59238..00000000 --- a/protocol/mayan/api_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package mayan_test - -import ( - "bytes" - "errors" - "fmt" - "io" - "net/http" - "testing" - - "github.com/sprintertech/sprinter-signing/protocol/mayan" -) - -// roundTripperFunc allows mocking HTTP transport -type roundTripperFunc func(*http.Request) (*http.Response, error) - -func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) { - return f(req) -} - -func Test_MayanExplorer_GetSwap(t *testing.T) { - tests := []struct { - name string - hash string - mockResponse []byte - statusCode int - mockError error - wantResult *mayan.MayanSwap - wantErr bool - }{ - { - name: "successful response", - hash: "testhash", - mockResponse: []byte(`{ - "orderHash": "0x123", - "randomKey": "key", - "mayanBps": 10, - "auctionMode": 1, - "redeemRelayerFee": "0.1", - "refundRelayerFee": "0.05", - "trader": "0xTrader", - "minAmountOut64": "100", - "sourceTxHash": "0xhash", - "createTxHash": "0xcreatehash" - }`), - statusCode: http.StatusOK, - wantResult: &mayan.MayanSwap{ - OrderHash: "0x123", - RandomKey: "key", - MayanBps: 10, - AuctionMode: 1, - RedeemRelayerFee: "0.1", - RefundRelayerFee: "0.05", - Trader: "0xTrader", - MinAmountOut64: "100", - SourceTxHash: "0xhash", - CreateTxHash: "0xcreatehash", - }, - }, - { - name: "HTTP error", - hash: "errorhash", - mockError: errors.New("connection refused"), - wantErr: true, - }, - { - name: "non-200 status", - hash: "badstatus", - mockResponse: []byte("Not found"), - statusCode: http.StatusNotFound, - wantErr: true, - }, - { - name: "invalid JSON", - hash: "badjson", - mockResponse: []byte("{invalid"), - statusCode: http.StatusOK, - wantErr: true, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - client := mayan.NewMayanExplorer() - client.HTTPClient.Transport = roundTripperFunc(func(req *http.Request) (*http.Response, error) { - // Verify URL construction - expectedURL := fmt.Sprintf("%s/v3/swap/order-id/SWIFT_%s", mayan.MAYAN_EXPLORER_URL, tc.hash) - if req.URL.String() != expectedURL { - return nil, fmt.Errorf("unexpected URL: got %s, want %s", req.URL.String(), expectedURL) - } - - if tc.mockError != nil { - return nil, tc.mockError - } - - return &http.Response{ - StatusCode: tc.statusCode, - Body: io.NopCloser(bytes.NewReader(tc.mockResponse)), - Header: make(http.Header), - }, nil - }) - - got, err := client.GetSwap(tc.hash) - - if tc.wantErr { - if err == nil { - t.Errorf("expected error got %v", err) - } - } else if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - if tc.wantResult != nil { - if got == nil { - t.Fatal("expected non-nil result, got nil") - } - if *got != *tc.wantResult { - t.Errorf("expected %+v, got %+v", tc.wantResult, got) - } - } else if got != nil { - t.Errorf("expected nil result, got %+v", got) - } - }) - } -} diff --git a/protocol/mayan/chainID.go b/protocol/mayan/chainID.go deleted file mode 100644 index 23a8579d..00000000 --- a/protocol/mayan/chainID.go +++ /dev/null @@ -1,39 +0,0 @@ -package mayan - -import "errors" - -// Convert Wormhole chain ID to EVM chain ID -func WormholeToEVMChainID(whChainID uint16) (uint64, error) { - switch whChainID { - case 2: // Ethereum - return 1, nil - case 4: // BSC - return 56, nil - case 5: // Polygon - return 137, nil - case 6: // Avalanche - return 43114, nil - case 7: // Oasis - return 42262, nil - case 10: // Fantom - return 250, nil - case 14: // Celo - return 42220, nil - case 16: // Moonbeam - return 1284, nil - case 23: // Arbitrum - return 42161, nil - case 24: // Optimism - return 10, nil - case 25: // Gnosis - return 100, nil - case 30: // Base - return 8453, nil - case 35: // Mantle - return 5000, nil - case 38: // Linea - return 59144, nil - default: - return 0, errors.New("unknown Wormhole chain ID") - } -} diff --git a/protocol/rhinestone/mock/response.json b/protocol/rhinestone/mock/response.json deleted file mode 100644 index dc544f67..00000000 --- a/protocol/rhinestone/mock/response.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "status": "COMPLETED", - "claims": [ - { - "depositId": "1566632349852817507569732921128369748446911234273639335443882769857984331776", - "chainId": 8453, - "status": "CLAIMED", - "claimTransactionHash": "0x8422bd857f21b75f0031e3b290f492b970cdf47065fef98d226b70038f9bd806", - "claimTimestamp": 1750756975 - } - ], - "targetChainId": 8453, - "userAddress": "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - "bundleData": { - "nonce": "1566632349852817507569732921128369748446911234273639335443882769857984331776", - "expires": "1782292973", - "sponsor": "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - "segments": [ - { - "arbiter": "0x000000000043ff16d5776c7F0f65Ec485C17Ca04", - "chainId": "8453", - "witness": { - "execs": [], - "tokenOut": [ - [ - "21847980266613871481014731415916520385541239541773571998015149469595626121491", - "10000000" - ], - [ - "21847980266613871481014731415167448634647776251198795536684055616834884337664", - "4183613581492" - ] - ], - "depositId": "1566632349852817507569732921128369748446911234273639335443882769857984331776", - "maxFeeBps": 0, - "recipient": "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - "userOpHash": "0xe2263d3bd40b1f89fe24c9f622b1055d341d68b9fb3043ddf1740b00fb8d7a92", - "targetChain": "8453", - "fillDeadline": "1750757273" - }, - "idsAndAmounts": [ - [ - "21847980266613871481014731415916520385541239541773571998015149469595626121491", - "10000000" - ], - [ - "21847980266613871481014731415916520385541239541773571998015149469595626121491", - "11766" - ] - ] - } - ], - "targetSignature": "0x00000000002b0ecfbd0496ee71e01257da0e37de7ecfb5b0dbc6dba6c26c49bf7b5acba9d9159e34ad4f5013add137056ecd433cce6151861f6c21ea60c2e2a39e3cc1a0e83624d3ae925450345c05d1f4b4fd9d367dcc0c0f2b09ae85dcc82d6552be6ca6dfd55d74e5719b0efcd305aa659b971b879092155f8d9fb336bded993d6d72ecdc7116def4f754d8023b99a88622cd70ef973b97c8158fe7e7080c3b1c6798a12a7c2c6bd187004a575d27faaa823f704d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c62797465732064617461290176", - "originSignatures": [ - "0x00000000002b0ecfbd0496ee71e01257da0e37de7ecfb5b0dbc6dba6c26c49bf7b5acba9d9159e34ad4f5013add137056ecd433cce6151861f6c21ea60c2e2a39e3cc1a0e83624d3ae925450345c05d1f4b4fd9d367dcc0c0f2b09ae85dcc82d6552be6ca6dfd55d74e5719b0efcd305aa659b971b879092155f8d9fb336bded993d6d72ecdc7116def4f754d8023b99a88622cd70ef973b97c8158fe7e7080c3b1c6798a12a7c2c6bd187004a575d27faaa823f704d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c62797465732064617461290176" - ] - }, - "bundleEvent": { - "type": "RhinestoneBundle", - "bundleId": "1566632349852817507569732921128369748446911234273639335443882769857984331776", - "targetFillPayload": { - "to": "0x000000000060f6e853447881951574CDd0663530", - "data": "0x17d905e4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a200000000000000000000000000000000000000000000000000000000000001a60000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000019200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000afc904ae9860d9c4b96d7c529c58b8000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000021050376aeb77ab9ee73632a3f81ab5eec6e1b33a87f2527271ba3380000000000000000000000000000000000000000000000000000000000000000000000000002304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000989680304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000002df60000000000000000000000000000000000000000000000000000000000000002304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000989680304d84c3d9a7be3b28c945310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ce12cd28b4000000000000000000000000000000000000000000000000000000000000164105000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000043ff16d5776c7f0f65ec485c17ca04000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000012e000000000000000000000000000000000000000000000000000000000000013000000000000000000000000006dc7354cea1b225b299fe06b97ac12ac5066b8990376aeb77ab9ee73632a3f81ab5eec6e1b33a87f2527271ba338000000000000000000000000000000000000000000000000000000000000000000006a3ba1ed00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000021050000000000000000000000006dc7354cea1b225b299fe06b97ac12ac5066b89900000000000000000000000000000000000000000000000000000000685a6f9900000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000180000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000989680304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000002df60000000000000000000000000000000000000000000000000000000000000002304d84c3d9a7be3b28c94531833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000989680304d84c3d9a7be3b28c945310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ce12cd28b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000006dc7354cea1b225b299fe06b97ac12ac5066b8990000000000000000002b0ecfbd0496ee71e01257da0e37de000000000000008a000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000002cb2c000000000000000000000000000d4e150000000000000000000000000000000000000000000000000000000000022dd5000000000000000000000000001406f4000000000000000000000000002db6b50000000000000000000000000000000000000000000000000000000000000ea00000000000000000000000000000000000000000000000000000000000000ec000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d24e9ae5c53010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000cc000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000060f6e853447881951574cdd0663530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000084a2418864270a26d4c70a9c9621dd14795b6fcb54fda2399b73f05a7f1845782452d6d4e08929904039f9bb5d9053c78743307a374a905bbbaaccf2e1e05e9796630b9bed0376aeb77ab9ee73632a3f81ab5eec6e1b33a87f2527271ba33800000000000000000000000000000000000000000000000000000000000000000000685a6f9900000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000007D6108A444b02970E5cb9c4E81fDee01F49d9E6a000000000000000000000000000000000000000000000000000000000098968000000000000000000000000000000000000000000000000000000000000000000000000000000000d338af1e0af0ca7a31752ae2ac0e16b2cb64f78a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000984a9af1dcd000000000000000000000000000000000000000000000000000000000011e2bc0000000000000000000000006dc7354cea1b225b299fe06b97ac12ac5066b8990000000000000000000000002538dcb94f9962dbc54c66291de487f00e59d5fc1092253dee1314b308d0e9eac71d046220f795b88a12af3fdd7bafe705e28f310000000000000000000000000000000000000000000000000000000000004e2000000000000000000000000000000000000000000000000000000000685e62e200000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913095ea7b300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000400000000000000000000000001231DEB6f5749EF6cE6943a275A1D3E7486F4EaE00000000000000000000000000000000000000000000000000000000009896800000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae4666fc800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000700c2bc6ea75ef67f647f193e81a0238e0347fbb07515880d2095de8a87ec60f5a500000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000006dc7354cea1b225b299fe06b97ac12ac5066b899000000000000000000000000000000000000000000000000000000000000233e000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783030303030303030303030303030303030303030303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000000000111111125421ca6dc452d289314280a0f8842a65000000000000000000000000111111125421ca6dc452d289314280a0f8842a65000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf000000000000000000000000000000000000000000000000000000000098968000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000048807ed23790000000000000000000000006ea77f83ec8693666866ece250411c974ab962a8000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf0000000000000000000000006ea77f83ec8693666866ece250411c974ab962a80000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000989680000000000000000000000000000000000000000000000000000000000000233e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000033100000000000000000000000000000000000000000000000000000000031300a0c9e75c48000000000000000014b40000000000000000000000000000000000000000000000000002e500029700a007e5c0d200000000000000000000000000000000000000000000000000027300021000a007e5c0d20000000000000000000000000000000000000000000000000001ec0000b05121000000000022d473030f116ddee9f6b43ac78ba3833589fcd6edb6e08f4c7c32d4f71b54bda02913004487517c45000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000076578ecf9a141296ec657847fb45b0585bcda3a600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412076578ecf9a141296ec657847fb45b0585bcda3a60064750283bc0000000000000000000000007b4c560f33a71a9f7a500af3c4c65b46fbbafdb7000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c9a0d8221d38800000000000000000000000000000000000000000000000000000000686105eb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000001fb7ee63c1e581c211e1f853a898bd1302385ccde55f33a8c4b3f34200000000000000000000000000000000000006111111125421ca6dc452d289314280a0f8842a65482023d5103782389f305ec402961fa8d46875c49e4c833589fcd6edb6e08f4c7c32d4f71b54bda02913dd93f59a000000000000000000000000111111125421ca6dc452d289314280a0f8842a650000000000000000000000000000002a94d114000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062008e40c4babf6ea19b7be00b0762ddd9c09f7831e7591c27681d27823ae23024f4acb46e365d926510fb1b3c18c3ebced7de9467ee6aa2cfa25237e46437c9753a7eb83d5b64cdca783263d49c74682dc0bb1ed48de1cdcd396b0a149e793b03371c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000414b1cbeea52901df80d097b16a23abb657bd3da0340cd348106b381fd4c4434177a71b249b2388b90b885e53227ff430c69b97995883c8055ef4d88508bae8d0f1b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022d00000000002b0ecfbd0496ee71e01257da0e37de7ecfb5b0dbc6dba6c26c49bf7b5acba9d9159e34ad4f5013add137056ecd433cce6151861f6c21ea60c2e2a39e3cc1a0e83624d3ae925450345c05d1f4b4fd9d367dcc0c0f2b09ae85dcc82d6552be6ca6dfd55d74e5719b0efcd305aa659b971b879092155f8d9fb336bded993d6d72ecdc7116def4f754d8023b99a88622cd70ef973b97c8158fe7e7080c3b1c6798a12a7c2c6bd187004a575d27faaa823f704d756c7469636861696e436f6d7061637428616464726573732073706f6e736f722c75696e74323536206e6f6e63652c75696e7432353620657870697265732c5365676d656e745b5d207365676d656e7473295365676d656e74286164647265737320617262697465722c75696e7432353620636861696e49642c75696e743235365b325d5b5d20696473416e64416d6f756e74732c5769746e657373207769746e657373295769746e657373286164647265737320726563697069656e742c75696e743235365b325d5b5d20746f6b656e4f75742c75696e74323536206465706f73697449642c75696e7432353620746172676574436861696e2c75696e7433322066696c6c446561646c696e652c58636861696e457865635b5d2065786563732c6279746573333220757365724f70486173682c75696e743332206d61784665654270732958636861696e45786563286164647265737320746f2c75696e743235362076616c75652c6279746573206461746129017600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041c026ba98052bbd863993d749b16f0065bcf2f0e2b3e6ec31123a353abbe7d3af54d5d33161ac74283e80c4b8d9f5bae1f518231959d6ff567443e38246a6ab1f1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e59aaf21c4d9cf92d9ed4537f4404ba031f83b2300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000002105", - "value": "0", - "chainId": 8453 - }, - "acrossDepositEvents": [ - { - "message": "0x", - "depositId": "72508795011696122011199505727503554569122957656552787329084847407262805528117", - "depositor": "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - "recipient": "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - "inputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - "inputAmount": "10000000", - "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - "fillDeadline": "1750757273", - "outputAmount": "10000000", - "quoteTimestamp": 1750756973, - "exclusiveRelayer": "0x000000000060f6e853447881951574CDd0663530", - "destinationChainId": 8453, - "originClaimPayload": { - "to": "0x0000000000000000000000000000000000000000", - "data": "0x", - "value": "0", - "chainId": 0 - }, - "exclusivityDeadline": "1750757273" - } - ] - }, - "fillTransactionHash": "0x8422bd857f21b75f0031e3b290f492b970cdf47065fef98d226b70038f9bd806", - "fillTimestamp": 1750756975 -} \ No newline at end of file diff --git a/protocol/rhinestone/orchestrator.go b/protocol/rhinestone/orchestrator.go deleted file mode 100644 index a3ede051..00000000 --- a/protocol/rhinestone/orchestrator.go +++ /dev/null @@ -1,60 +0,0 @@ -package rhinestone - -import ( - "context" - "encoding/json" - "fmt" - "io" - "math/big" - "net/http" - "time" -) - -const ( - RHINESTONE_ORCHESTRATOR_URL = "https://orchestrator.rhinestone.dev" -) - -type RhinestoneOrchestrator struct { - apiKey string - Client *http.Client -} - -func NewRhinestoneOrchestrator(apiKey string) *RhinestoneOrchestrator { - return &RhinestoneOrchestrator{ - Client: &http.Client{ - Timeout: 10 * time.Second, - }, - apiKey: apiKey, - } -} - -func (o *RhinestoneOrchestrator) GetBundle(ctx context.Context, bundleID *big.Int) (*Bundle, error) { - url := fmt.Sprintf("%s/bundles/%s", RHINESTONE_ORCHESTRATOR_URL, bundleID.String()) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if err != nil { - return nil, err - } - req.Header.Add("x-api-key", o.apiKey) - - resp, err := o.Client.Do(req) - if err != nil { - return nil, fmt.Errorf("request failed: %w", err) - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode, url) - } - - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) - } - - b := new(Bundle) - if err := json.Unmarshal(body, b); err != nil { - return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) - } - - return b, nil -} diff --git a/protocol/rhinestone/orchestrator_test.go b/protocol/rhinestone/orchestrator_test.go deleted file mode 100644 index 0fcaf210..00000000 --- a/protocol/rhinestone/orchestrator_test.go +++ /dev/null @@ -1,144 +0,0 @@ -// nolint -package rhinestone_test - -import ( - "bytes" - "context" - "errors" - "fmt" - "io" - "math/big" - "net/http" - "os" - "testing" - - "github.com/sprintertech/sprinter-signing/protocol/rhinestone" -) - -// roundTripperFunc allows mocking HTTP transport -type roundTripperFunc func(*http.Request) (*http.Response, error) - -func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) { - return f(req) -} - -func Test_RhinestoneOrchestrator_GetBundle(t *testing.T) { - mockResponse, _ := os.ReadFile("./mock/response.json") - bundleID, _ := new(big.Int).SetString("1566632349852817507569732921128369748446911234273639335443882769857984331776", 10) - - tests := []struct { - name string - bundleID *big.Int - mockResponse []byte - statusCode int - mockError error - wantResult *rhinestone.Bundle - wantErr bool - }{ - { - name: "successful response", - bundleID: bundleID, - mockResponse: mockResponse, - statusCode: http.StatusOK, - wantResult: &rhinestone.Bundle{ - Status: rhinestone.StatusCompleted, - TargetChainId: uint64(8453), - UserAddress: "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - BundleData: rhinestone.BundleData{ - Nonce: "1566632349852817507569732921128369748446911234273639335443882769857984331776", - Expires: "1782292973", - }, - BundleEvent: rhinestone.BundleEvent{ - BundleId: bundleID.String(), - AcrossDepositEvents: []rhinestone.AcrossDepositEvent{ - { - Message: "0x", - DepositId: "72508795011696122011199505727503554569122957656552787329084847407262805528117", - Depositor: "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - Recipient: "0x6Dc7354cEA1b225B299Fe06b97aC12ac5066B899", - InputToken: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - InputAmount: "10000000", - OutputToken: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - FillDeadline: "1750757273", - OutputAmount: "10000000", - QuoteTimestamp: 1750756973, - ExclusiveRelayer: "0x000000000060f6e853447881951574CDd0663530", - DestinationChainId: uint64(8453), - ExclusivityDeadline: "1750757273", - }, - }, - }, - }, - }, - { - name: "HTTP error", - bundleID: bundleID, - mockError: errors.New("connection refused"), - wantErr: true, - }, - { - name: "non-200 status", - bundleID: bundleID, - mockResponse: []byte("Not found"), - statusCode: http.StatusNotFound, - wantErr: true, - }, - { - name: "invalid JSON", - bundleID: bundleID, - mockResponse: []byte("{invalid"), - statusCode: http.StatusOK, - wantErr: true, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - orchestrator := rhinestone.NewRhinestoneOrchestrator("api-key") - orchestrator.Client.Transport = roundTripperFunc(func(req *http.Request) (*http.Response, error) { - // Verify URL construction - expectedURL := fmt.Sprintf("%s/bundles/%s", rhinestone.RHINESTONE_ORCHESTRATOR_URL, tc.bundleID) - if req.URL.String() != expectedURL { - return nil, fmt.Errorf("unexpected URL: got %s, want %s", req.URL.String(), expectedURL) - } - - if tc.mockError != nil { - return nil, tc.mockError - } - - return &http.Response{ - StatusCode: tc.statusCode, - Body: io.NopCloser(bytes.NewReader(tc.mockResponse)), - Header: make(http.Header), - }, nil - }) - - got, err := orchestrator.GetBundle(context.Background(), tc.bundleID) - - if tc.wantErr { - if err == nil { - t.Errorf("expected error got %v", err) - } - } else if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - if tc.wantResult != nil { - if got == nil { - t.Fatal("expected non-nil result, got nil") - } - if got.BundleData != tc.wantResult.BundleData { - t.Errorf("expected %+v, got %+v", tc.wantResult, got) - } - if got.Status != tc.wantResult.Status { - t.Errorf("expected %+v, got %+v", tc.wantResult, got) - } - if got.BundleEvent.AcrossDepositEvents[0] != tc.wantResult.BundleEvent.AcrossDepositEvents[0] { - t.Errorf("expected %+v, got %+v", tc.wantResult, got) - } - } else if got != nil { - t.Errorf("expected nil result, got %+v", got) - } - }) - } -} diff --git a/protocol/rhinestone/types.go b/protocol/rhinestone/types.go deleted file mode 100644 index 895d7a96..00000000 --- a/protocol/rhinestone/types.go +++ /dev/null @@ -1,54 +0,0 @@ -package rhinestone - -type BundleStatus string - -const ( - StatusCompleted = "COMPLETED" -) - -type BundleData struct { - Nonce string `json:"nonce"` - Expires string `json:"expires"` -} - -type FillPayload struct { - To string `json:"to"` - Data string `json:"data"` - Value string `json:"value"` - ChainID uint64 `json:"chainId"` -} - -type BundleEvent struct { - BundleId string `json:"bundleId"` - AcrossDepositEvents []AcrossDepositEvent `json:"acrossDepositEvents"` - FillPayload FillPayload `json:"targetFillPayload"` -} - -type OriginClaimPayload struct { - ChainID uint64 `json:"chainId"` -} - -type AcrossDepositEvent struct { - Message string `json:"message"` - DepositId string `json:"depositId"` - Depositor string `json:"depositor"` - Recipient string `json:"recipient"` - InputToken string `json:"inputToken"` - InputAmount string `json:"inputAmount"` - OutputToken string `json:"outputToken"` - FillDeadline string `json:"fillDeadline"` - OutputAmount string `json:"outputAmount"` - QuoteTimestamp uint64 `json:"quoteTimestamp"` - ExclusiveRelayer string `json:"exclusiveRelayer"` - DestinationChainId uint64 `json:"destinationChainId"` - ExclusivityDeadline string `json:"exclusivityDeadline"` - OriginClaimPayload OriginClaimPayload `json:"originClaimPayload"` -} - -type Bundle struct { - Status BundleStatus `json:"status"` - TargetChainId uint64 `json:"targetChainId"` - UserAddress string `json:"userAddress"` - BundleData BundleData `json:"bundleData"` - BundleEvent BundleEvent `json:"bundleEvent"` -}