Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions chains/lighter/message/lighter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

var (
ARBITRUM_CHAIN_ID = big.NewInt(42161)
FEE = big.NewInt(2000000)
USDC_ACCOUNT_INDEX = 3
)

Expand Down Expand Up @@ -146,24 +145,19 @@
return errors.New("transfer account index invalid")
}

if tx.Transfer.AssetIndex != uint64(USDC_ACCOUNT_INDEX) {

Check failure on line 148 in chains/lighter/message/lighter.go

View workflow job for this annotation

GitHub Actions / linter-check

G115: integer overflow conversion int -> uint64 (gosec)
return errors.New("only usdc asset supported on lighter")
}

if tx.Transfer.Amount <= FEE.Uint64() {
return errors.New("fee higher than withdrawal amount")
}

return nil
}

func (h *LighterMessageHandler) calldata(tx *lighter.LighterTx) ([]byte, error) {
borrowAmount := new(big.Int).Sub(new(big.Int).SetUint64(tx.Transfer.Amount), FEE)
return consts.LighterABI.Pack(
"fulfillWithdraw",
common.HexToHash(tx.Hash),
common.BytesToAddress(tx.Transfer.Memo[:20]),
borrowAmount)
new(big.Int).SetUint64(tx.Transfer.Amount))
}

func (h *LighterMessageHandler) Listen(ctx context.Context) {
Expand Down
43 changes: 0 additions & 43 deletions chains/lighter/message/lighter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,49 +112,6 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() {
s.Nil(err)
}

func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_FeeHigherThanAmount() {
s.mockCommunication.EXPECT().Broadcast(
gomock.Any(),
gomock.Any(),
comm.LighterMsg,
"lighter",
).Return(nil)
p, _ := pstoremem.NewPeerstore()
s.mockHost.EXPECT().Peerstore().Return(p)

errChn := make(chan error, 1)
ad := &message.LighterData{
ErrChn: errChn,
Nonce: big.NewInt(101),
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
OrderHash: "orderHash",
DepositTxHash: "orderHash",
}

s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(&lighter.LighterTx{
Type: lighter.TxTypeL2Transfer,
Transfer: &lighter.Transfer{
Amount: 2000000,
AssetIndex: 3,
ToAccountIndex: 3,
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
},
}, 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 *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
s.mockCommunication.EXPECT().Broadcast(
gomock.Any(),
Expand Down
Loading