Skip to content

Commit 54240cb

Browse files
committed
Merge branch 'feat/shared-solver-config' into feat/mayan-message-handling
2 parents 6be76bd + dd8998b commit 54240cb

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

app/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ func Run() error {
175175
hubPoolContract = contracts.NewHubPoolContract(client, hubPoolAddress, c.Tokens)
176176
}
177177

178-
if c.LiqudityPool != "" {
179-
lpAddress := common.HexToAddress(c.LiqudityPool)
178+
if c.LiquidityPool != "" {
179+
lpAddress := common.HexToAddress(c.LiquidityPool)
180180
liquidityPools[*c.GeneralChainConfig.Id] = lpAddress
181181
}
182182

chains/evm/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type EVMConfig struct {
2323
AcrossPool string
2424
HubPool string
2525
MayanSwift string
26-
LiqudityPool string
26+
LiquidityPool string
2727
Tokens map[string]config.TokenConfig
2828
// usd bucket -> confirmations
2929
ConfirmationsByValue map[uint64]uint64
@@ -34,7 +34,7 @@ type EVMConfig struct {
3434
type RawEVMConfig struct {
3535
chain.GeneralChainConfig `mapstructure:",squash"`
3636
Admin string `mapstructure:"admin"`
37-
LiqudityPool string `mapstructure:"liquidityPool"`
37+
LiquidityPool string `mapstructure:"liquidityPool"`
3838
AcrossPool string `mapstructure:"acrossPool"`
3939
MayanSwift string `mapstructure:"mayanSwift"`
4040
HubPool string `mapstructure:"hubPool"`
@@ -109,7 +109,7 @@ func NewEVMConfig(chainConfig map[string]interface{}) (*EVMConfig, error) {
109109
config := &EVMConfig{
110110
GeneralChainConfig: c.GeneralChainConfig,
111111
Admin: c.Admin,
112-
LiqudityPool: c.LiqudityPool,
112+
LiquidityPool: c.LiquidityPool,
113113
AcrossPool: c.AcrossPool,
114114
HubPool: c.HubPool,
115115
MayanSwift: c.MayanSwift,

chains/evm/message/mayan.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type MayanMessageHandler struct {
4343
chainID uint64
4444

4545
mayanPools map[uint64]common.Address
46-
liqudityPools map[uint64]common.Address
46+
liquidityPools map[uint64]common.Address
4747
confirmationWatcher ConfirmationWatcher
4848
tokenStore config.TokenStore
4949
mayanDecoder MayanContract
@@ -60,7 +60,7 @@ type MayanMessageHandler struct {
6060
func NewMayanMessageHandler(
6161
chainID uint64,
6262
client EventFilterer,
63-
liqudityPools map[uint64]common.Address,
63+
liquidityPools map[uint64]common.Address,
6464
mayanPools map[uint64]common.Address,
6565
coordinator Coordinator,
6666
host host.Host,
@@ -76,7 +76,7 @@ func NewMayanMessageHandler(
7676
chainID: chainID,
7777
client: client,
7878
mayanPools: mayanPools,
79-
liqudityPools: liqudityPools,
79+
liquidityPools: liquidityPools,
8080
coordinator: coordinator,
8181
host: host,
8282
comm: comm,
@@ -118,14 +118,16 @@ func (h *MayanMessageHandler) HandleMessage(m *message.Message) (*proposal.Propo
118118
return nil, err
119119
}
120120

121-
symbol, token, err := h.tokenStore.ConfigByAddress(h.chainID, common.BytesToAddress(msg.TokenIn[12:]))
121+
tokenIn := common.BytesToAddress(msg.TokenIn[12:])
122+
symbol, token, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn)
122123
if err != nil {
123124
data.ErrChn <- err
124125
return nil, err
125126
}
126127

127128
destChainId, err := mayan.WormholeToEVMChainID(msg.DestChainId)
128129
if err != nil {
130+
data.ErrChn <- err
129131
return nil, err
130132
}
131133
destinationBorrowToken, err := h.tokenStore.ConfigBySymbol(destChainId, symbol)
@@ -150,7 +152,7 @@ func (h *MayanMessageHandler) HandleMessage(m *message.Message) (*proposal.Propo
150152
context.Background(),
151153
h.chainID,
152154
txHash,
153-
common.BytesToAddress(msg.TokenIn[12:]),
155+
tokenIn,
154156
new(big.Int).SetUint64(msg.PromisedAmount))
155157
if err != nil {
156158
data.ErrChn <- err
@@ -240,8 +242,6 @@ func (h *MayanMessageHandler) verifyOrder(
240242
return err
241243
}
242244

243-
fmt.Printf("%+v", msg)
244-
245245
denormalizedAmountIn := contracts.DenormalizeAmount(new(big.Int).SetUint64(order.AmountIn), tc.Decimals)
246246
if data.BorrowAmount.Cmp(denormalizedAmountIn) != -1 {
247247
return fmt.Errorf("requested borrow amount more than input amount")
@@ -263,7 +263,7 @@ func (h *MayanMessageHandler) verifyOrder(
263263
return fmt.Errorf("invalid order status %d", order.Status)
264264
}
265265

266-
srcLiquidityPool, ok := h.liqudityPools[h.chainID]
266+
srcLiquidityPool, ok := h.liquidityPools[h.chainID]
267267
if !ok {
268268
return fmt.Errorf("no source liqudity recipient configured")
269269
}

protocol/mayan/api.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ func NewMayanExplorer() *MayanExplorer {
3939
}
4040

4141
func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) {
42-
fullURL := fmt.Sprintf("%s/v3/swap/trx/%s", MAYAN_EXPLORER_URL, hash)
43-
44-
resp, err := c.HTTPClient.Get(fullURL)
42+
url := fmt.Sprintf("%s/v3/swap/trx/%s", MAYAN_EXPLORER_URL, hash)
43+
resp, err := c.HTTPClient.Get(url)
4544
if err != nil {
4645
return nil, fmt.Errorf("request failed: %w", err)
4746
}
4847
defer resp.Body.Close()
4948

5049
if resp.StatusCode != http.StatusOK {
51-
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
50+
return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode, url)
5251
}
5352

5453
body, err := io.ReadAll(resp.Body)
@@ -57,7 +56,7 @@ func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) {
5756
}
5857

5958
var s *MayanSwap
60-
if err := json.Unmarshal(body, &s); err != nil {
59+
if err := json.Unmarshal(body, s); err != nil {
6160
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
6261
}
6362

0 commit comments

Comments
 (0)