Skip to content

Commit cbd9954

Browse files
committed
Use repayment account from solver config
1 parent b21d327 commit cbd9954

File tree

7 files changed

+27
-17
lines changed

7 files changed

+27
-17
lines changed

chains/lighter/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var (
1818
type LighterConfig struct {
1919
WithdrawalAddress common.Address
2020
UsdcAddress common.Address
21+
RepaymentAddress string
2122
}
2223

2324
func NewLighterConfig(solverConfig solverConfig.SolverConfig) (*LighterConfig, error) {
@@ -38,6 +39,7 @@ func NewLighterConfig(solverConfig solverConfig.SolverConfig) (*LighterConfig, e
3839

3940
return &LighterConfig{
4041
WithdrawalAddress: common.HexToAddress(withdrawalAddress),
42+
RepaymentAddress: solverConfig.ProtocolsMetadata.Lighter.RepaymentAddress,
4143
UsdcAddress: common.HexToAddress(usdcConfig.Address),
4244
}, nil
4345
}

chains/lighter/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (s *NewLighterConfigTestSuite) Test_ValidConfig() {
8080
Chains: solverChains,
8181
ProtocolsMetadata: solverConfig.ProtocolsMetadata{
8282
Lighter: &solverConfig.Lighter{
83+
RepaymentAddress: "3",
8384
FastWithdrawalContract: map[string]string{
8485
"eip155:42161": "withdrawal",
8586
},
@@ -91,5 +92,6 @@ func (s *NewLighterConfigTestSuite) Test_ValidConfig() {
9192
s.Equal(config, &lighter.LighterConfig{
9293
WithdrawalAddress: common.HexToAddress("withdrawal"),
9394
UsdcAddress: common.HexToAddress("usdc"),
95+
RepaymentAddress: "3",
9496
})
9597
}

chains/lighter/message/lighter.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"math/big"
9+
"strconv"
910
"time"
1011

1112
"github.com/ethereum/go-ethereum/common"
@@ -23,9 +24,8 @@ import (
2324
)
2425

2526
var (
26-
ARBITRUM_CHAIN_ID = big.NewInt(42161)
27-
FILL_DEADLINE = time.Minute * 5
28-
WITHDRAWAL_ACCOUNT_INDEX uint64 = 3
27+
ARBITRUM_CHAIN_ID = big.NewInt(42161)
28+
FILL_DEADLINE = time.Minute * 5
2929
)
3030

3131
type Coordinator interface {
@@ -43,14 +43,16 @@ type LighterMessageHandler struct {
4343
fetcher signing.SaveDataFetcher
4444
sigChn chan any
4545

46-
lighterAddress common.Address
47-
usdcAddress common.Address
48-
txFetcher TxFetcher
46+
lighterAddress common.Address
47+
usdcAddress common.Address
48+
repaymentAccount string
49+
txFetcher TxFetcher
4950
}
5051

5152
func NewLighterMessageHandler(
5253
lighterAddress common.Address,
5354
usdcAddress common.Address,
55+
repaymentAccount string,
5456
txFetcher TxFetcher,
5557
coordinator Coordinator,
5658
host host.Host,
@@ -59,14 +61,15 @@ func NewLighterMessageHandler(
5961
sigChn chan any,
6062
) *LighterMessageHandler {
6163
return &LighterMessageHandler{
62-
txFetcher: txFetcher,
63-
usdcAddress: usdcAddress,
64-
lighterAddress: lighterAddress,
65-
coordinator: coordinator,
66-
host: host,
67-
comm: comm,
68-
fetcher: fetcher,
69-
sigChn: sigChn,
64+
txFetcher: txFetcher,
65+
usdcAddress: usdcAddress,
66+
repaymentAccount: repaymentAccount,
67+
lighterAddress: lighterAddress,
68+
coordinator: coordinator,
69+
host: host,
70+
comm: comm,
71+
fetcher: fetcher,
72+
sigChn: sigChn,
7073
}
7174
}
7275

@@ -139,7 +142,7 @@ func (h *LighterMessageHandler) verifyWithdrawal(tx *lighter.LighterTx, borrowAm
139142
return errors.New("invalid transaction type")
140143
}
141144

142-
if tx.Transfer.ToAccountIndex != WITHDRAWAL_ACCOUNT_INDEX {
145+
if strconv.Itoa(tx.Transfer.ToAccountIndex) != h.repaymentAccount {
143146
return errors.New("transfer account index invalid")
144147
}
145148

chains/lighter/message/lighter_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (s *LighterMessageHandlerTestSuite) SetupTest() {
5858
s.handler = message.NewLighterMessageHandler(
5959
common.Address{},
6060
common.Address{},
61+
"3",
6162
s.mockTxFetcher,
6263
s.mockCoordinator,
6364
s.mockHost,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/spf13/cobra v1.8.1
2222
github.com/spf13/viper v1.9.0
2323
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166
24-
github.com/sprintertech/solver-config/go v0.0.0-20251024140304-ee77ffefd608
24+
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e
2525
github.com/stretchr/testify v1.10.0
2626
github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82
2727
go.opentelemetry.io/otel v1.16.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,8 @@ github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166 h1:mCcKOx
950950
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166/go.mod h1:EbAH3JJxioBVuHvyjaP5zTh6uPmumCpbE93WEjwpRm0=
951951
github.com/sprintertech/solver-config/go v0.0.0-20251024140304-ee77ffefd608 h1:J5RxJUhqMGfoIUb8XnSjDBlUMH658nM9NIjXft+DjkA=
952952
github.com/sprintertech/solver-config/go v0.0.0-20251024140304-ee77ffefd608/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
953+
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e h1:5sSP6GbqCT/ApxxZmUtav6GHy5Ke98zh5oqQxewhJd4=
954+
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
953955
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
954956
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
955957
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

protocol/lighter/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
type Transfer struct {
2323
USDCAmount uint64
2424
FromAccountIndex uint64
25-
ToAccountIndex uint64
25+
ToAccountIndex int
2626
Fee uint64
2727
}
2828

0 commit comments

Comments
 (0)