Skip to content

Commit 8ca3a2d

Browse files
committed
Add hub pool address to config
1 parent c322e00 commit 8ca3a2d

File tree

7 files changed

+24
-4
lines changed

7 files changed

+24
-4
lines changed

app/app.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/sprintertech/sprinter-signing/api/handlers"
2323
"github.com/sprintertech/sprinter-signing/cache"
2424
"github.com/sprintertech/sprinter-signing/chains/evm"
25+
"github.com/sprintertech/sprinter-signing/chains/evm/calls/contracts"
2526
"github.com/sprintertech/sprinter-signing/chains/evm/calls/events"
2627
evmListener "github.com/sprintertech/sprinter-signing/chains/evm/listener"
2728
evmMessage "github.com/sprintertech/sprinter-signing/chains/evm/message"
@@ -139,6 +140,7 @@ func Run() error {
139140
confirmationsPerChain := make(map[uint64]map[uint64]uint64)
140141
domains := make(map[uint64]relayer.RelayedChain)
141142

143+
var hubPoolContract evmMessage.TokenMatcher
142144
acrossPools := make(map[uint64]common.Address)
143145
for _, chainConfig := range configuration.ChainConfigs {
144146
switch chainConfig["type"] {
@@ -151,6 +153,14 @@ func Run() error {
151153
poolAddress := common.HexToAddress(config.AcrossPool)
152154
acrossPools[*config.GeneralChainConfig.Id] = poolAddress
153155
}
156+
157+
if config.HubPool != "" {
158+
client, err := evmClient.NewEVMClient(config.GeneralChainConfig.Endpoint, nil)
159+
panicOnError(err)
160+
161+
hubPoolAddress := common.HexToAddress(config.HubPool)
162+
hubPoolContract = contracts.NewHubPoolContract(client, hubPoolAddress, config.Tokens)
163+
}
154164
}
155165
default:
156166
panic(fmt.Errorf("type '%s' not recognized", chainConfig["type"]))
@@ -182,6 +192,7 @@ func Run() error {
182192
communication,
183193
keyshareStore,
184194
priceAPI,
195+
hubPoolContract,
185196
sigChn,
186197
config.Tokens,
187198
config.ConfirmationsByValue,

chains/evm/calls/contracts/hubPool.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/ethereum/go-ethereum/accounts/abi"
1111
"github.com/ethereum/go-ethereum/common"
12+
"github.com/sprintertech/sprinter-signing/chains/evm"
1213
"github.com/sprintertech/sprinter-signing/chains/evm/calls/consts"
1314
"github.com/sygmaprotocol/sygma-core/chains/evm/client"
1415
"github.com/sygmaprotocol/sygma-core/chains/evm/contracts"
@@ -17,13 +18,13 @@ import (
1718
type HubPoolContract struct {
1819
contracts.Contract
1920
client client.Client
20-
tokens map[string]common.Address
21+
tokens map[string]evm.TokenConfig
2122
}
2223

2324
func NewHubPoolContract(
2425
client client.Client,
2526
address common.Address,
26-
l1Tokens map[string]common.Address,
27+
l1Tokens map[string]evm.TokenConfig,
2728
) *HubPoolContract {
2829
return &HubPoolContract{
2930
Contract: contracts.NewContract(address, consts.HubPoolABI, nil, client, nil),
@@ -33,12 +34,12 @@ func NewHubPoolContract(
3334
}
3435

3536
func (c *HubPoolContract) DestinationToken(destinationChainId *big.Int, symbol string) (common.Address, error) {
36-
tokenAddress, ok := c.tokens[symbol]
37+
tokenConfig, ok := c.tokens[symbol]
3738
if !ok {
3839
return common.Address{}, fmt.Errorf("no hub pool token configured for symbol %s", symbol)
3940
}
4041

41-
res, err := c.CallContract("poolRebalanceRoute", destinationChainId, tokenAddress)
42+
res, err := c.CallContract("poolRebalanceRoute", destinationChainId, tokenConfig.Address)
4243
if err != nil {
4344
return common.Address{}, err
4445
}

chains/evm/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type EVMConfig struct {
2525
GeneralChainConfig chain.GeneralChainConfig
2626
Admin string
2727
AcrossPool string
28+
HubPool string
2829
LiqudityPool string
2930
Tokens map[string]TokenConfig
3031
// usd bucket -> confirmations
@@ -38,6 +39,7 @@ type RawEVMConfig struct {
3839
Admin string `mapstructure:"admin"`
3940
LiqudityPool string `mapstructure:"liquidityPool"`
4041
AcrossPool string `mapstructure:"acrossPool"`
42+
HubPool string `mapstructure:"hubPool"`
4143
Tokens map[string]interface{} `mapstructure:"tokens"`
4244
ConfirmationsByValue map[string]interface{} `mapstructure:"confirmationsByValue"`
4345
BlockInterval int64 `mapstructure:"blockInterval" default:"5"`
@@ -111,6 +113,7 @@ func NewEVMConfig(chainConfig map[string]interface{}) (*EVMConfig, error) {
111113
Admin: c.Admin,
112114
LiqudityPool: c.LiqudityPool,
113115
AcrossPool: c.AcrossPool,
116+
HubPool: c.HubPool,
114117
// nolint:gosec
115118
BlockRetryInterval: time.Duration(c.BlockRetryInterval) * time.Second,
116119
BlockInterval: big.NewInt(c.BlockInterval),

chains/evm/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfigWithCustomTxParams() {
109109
"admin": "adminAddress",
110110
"liquidityPool": "pool",
111111
"acrossPool": "acrossPool",
112+
"hubPool": "hubPool",
112113
"maxGasPrice": 1000,
113114
"gasMultiplier": 1000,
114115
"gasIncreasePercentage": 20,
@@ -158,6 +159,7 @@ func (s *NewEVMConfigTestSuite) Test_ValidConfigWithCustomTxParams() {
158159
Admin: "adminAddress",
159160
LiqudityPool: "pool",
160161
AcrossPool: "acrossPool",
162+
HubPool: "hubPool",
161163
ConfirmationsByValue: expectedBlockConfirmations,
162164
Tokens: expectedTokens,
163165
})

example/cfg/config_evm-evm_1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "evm",
2323
"endpoint": "wss://ethereum-sepolia-rpc.publicnode.com",
2424
"acrossPool": "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
25+
"hubPool": "0x14224e63716afAcE30C9a417E0542281869f7d9e",
2526
"tokens": {
2627
"USDC":
2728
{

example/cfg/config_evm-evm_2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "evm",
2323
"endpoint": "wss://ethereum-sepolia-rpc.publicnode.com",
2424
"acrossPool": "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
25+
"hubPool": "0x14224e63716afAcE30C9a417E0542281869f7d9e",
2526
"tokens": {
2627
"USDC":
2728
{

example/cfg/config_evm-evm_3.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "evm",
2323
"endpoint": "wss://ethereum-sepolia-rpc.publicnode.com",
2424
"acrossPool": "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
25+
"hubPool": "0x14224e63716afAcE30C9a417E0542281869f7d9e",
2526
"tokens": {
2627
"USDC":
2728
{

0 commit comments

Comments
 (0)