Skip to content

Commit c7dabd1

Browse files
authored
fix: remove lighter fee (#119)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue Or Context <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Otherwise, describe context and motivation for change herre --> Closes: #<issue> ## How Has This Been Tested? Testing details. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot
1 parent da6b5c3 commit c7dabd1

File tree

2 files changed

+4
-53
lines changed

2 files changed

+4
-53
lines changed

chains/lighter/message/lighter.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import (
2424
)
2525

2626
var (
27-
ARBITRUM_CHAIN_ID = big.NewInt(42161)
28-
FEE = big.NewInt(2000000)
29-
USDC_ACCOUNT_INDEX = 3
27+
ARBITRUM_CHAIN_ID = big.NewInt(42161)
28+
USDC_ACCOUNT_INDEX uint64 = 3
3029
)
3130

3231
type Coordinator interface {
@@ -146,24 +145,19 @@ func (h *LighterMessageHandler) verifyWithdrawal(tx *lighter.LighterTx) error {
146145
return errors.New("transfer account index invalid")
147146
}
148147

149-
if tx.Transfer.AssetIndex != uint64(USDC_ACCOUNT_INDEX) {
148+
if tx.Transfer.AssetIndex != USDC_ACCOUNT_INDEX {
150149
return errors.New("only usdc asset supported on lighter")
151150
}
152151

153-
if tx.Transfer.Amount <= FEE.Uint64() {
154-
return errors.New("fee higher than withdrawal amount")
155-
}
156-
157152
return nil
158153
}
159154

160155
func (h *LighterMessageHandler) calldata(tx *lighter.LighterTx) ([]byte, error) {
161-
borrowAmount := new(big.Int).Sub(new(big.Int).SetUint64(tx.Transfer.Amount), FEE)
162156
return consts.LighterABI.Pack(
163157
"fulfillWithdraw",
164158
common.HexToHash(tx.Hash),
165159
common.BytesToAddress(tx.Transfer.Memo[:20]),
166-
borrowAmount)
160+
new(big.Int).SetUint64(tx.Transfer.Amount))
167161
}
168162

169163
func (h *LighterMessageHandler) Listen(ctx context.Context) {

chains/lighter/message/lighter_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -112,49 +112,6 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() {
112112
s.Nil(err)
113113
}
114114

115-
func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_FeeHigherThanAmount() {
116-
s.mockCommunication.EXPECT().Broadcast(
117-
gomock.Any(),
118-
gomock.Any(),
119-
comm.LighterMsg,
120-
"lighter",
121-
).Return(nil)
122-
p, _ := pstoremem.NewPeerstore()
123-
s.mockHost.EXPECT().Peerstore().Return(p)
124-
125-
errChn := make(chan error, 1)
126-
ad := &message.LighterData{
127-
ErrChn: errChn,
128-
Nonce: big.NewInt(101),
129-
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
130-
OrderHash: "orderHash",
131-
DepositTxHash: "orderHash",
132-
}
133-
134-
s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(&lighter.LighterTx{
135-
Type: lighter.TxTypeL2Transfer,
136-
Transfer: &lighter.Transfer{
137-
Amount: 2000000,
138-
AssetIndex: 3,
139-
ToAccountIndex: 3,
140-
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},
141-
},
142-
}, nil)
143-
144-
m := &coreMessage.Message{
145-
Data: ad,
146-
Source: 0,
147-
Destination: 10,
148-
}
149-
prop, err := s.handler.HandleMessage(m)
150-
151-
s.Nil(prop)
152-
s.NotNil(err)
153-
154-
err = <-errChn
155-
s.NotNil(err)
156-
}
157-
158115
func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
159116
s.mockCommunication.EXPECT().Broadcast(
160117
gomock.Any(),

0 commit comments

Comments
 (0)