Skip to content

Commit 853ff60

Browse files
committed
2 parents 1c0c55d + 57ddb8e commit 853ff60

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

.changeset/fuzzy-ducks-mate.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@xchainjs/xchain-client': patch
3+
'@xchainjs/xchain-utxo': patch
4+
'@xchainjs/xchain-evm': patch
5+
---
6+
7+
Updated get fee rates to observe Mayachain as well

packages/xchain-client/src/BaseXChainClient.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export abstract class BaseXChainClient implements XChainClient {
117117
case 'gwei':
118118
return gasRate // Already in gwei for EVM chains
119119
case 'mwei':
120-
return gasRate / 1e6 // Convert mwei to gwei
120+
return gasRate / 1e3 // Convert mwei to gwei (1 mwei = 0.001 gwei)
121121
case 'centigwei':
122122
return gasRate / 100 // Convert centigwei to gwei
123123
case 'satsperbyte':
@@ -182,40 +182,25 @@ export abstract class BaseXChainClient implements XChainClient {
182182
console.debug(`Mayachain gas_rate for ${this.chain}: ${gasRate} ${gasRateUnits}`)
183183
}
184184

185-
// Maya supports a subset of chains, using same unit conversion logic as Thorchain
186-
switch (this.chain) {
187-
case 'ETH':
188-
// Already in gwei, which is what EVM client expects
189-
if (gasRateUnits !== 'gwei') {
190-
console.warn(`Unexpected gas_rate_units for ETH on Maya: ${gasRateUnits}`)
191-
}
185+
// Prefer unit-based conversion (parity with Thornode logic)
186+
switch (gasRateUnits) {
187+
case 'gwei':
192188
return gasRate
193-
194-
case 'ARB':
195-
// ARB returns centigwei (10^-2 gwei = 0.01 gwei), but EVM client expects gwei
196-
// Need to convert: centigwei to gwei = divide by 100
197-
if (gasRateUnits === 'centigwei') {
198-
return gasRate / 100
199-
}
200-
console.warn(`Unexpected gas_rate_units for ARB: ${gasRateUnits}`)
189+
case 'mwei':
190+
return gasRate / 1e3
191+
case 'centigwei':
192+
return gasRate / 100
193+
case 'satsperbyte':
201194
return gasRate
202-
203-
case 'BTC':
204-
case 'DASH':
205-
// UTXO chains return satsperbyte, which is what clients expect
206-
if (gasRateUnits !== 'satsperbyte') {
207-
console.warn(`Unexpected gas_rate_units for ${this.chain} on Maya: ${gasRateUnits}`)
208-
}
195+
case 'drop':
209196
return gasRate
210-
211-
case 'KUJI':
212-
case 'MAYA':
213-
case 'THOR':
214-
// Cosmos-based chains return in smallest unit
197+
case 'uatom':
215198
return gasRate
216-
217199
default:
218-
console.warn(`Unknown chain ${this.chain} on Maya with gas_rate_units: ${gasRateUnits}`)
200+
// Chain-specific fallbacks for nano/micro prefixes
201+
if (gasRateUnits.startsWith('n') && gasRateUnits.length > 1) return gasRate
202+
if (gasRateUnits.startsWith('u') && gasRateUnits.length > 1) return gasRate
203+
console.warn(`Unknown gas_rate_units "${gasRateUnits}" for chain ${this.chain} on Mayachain. Using raw value.`)
219204
return gasRate
220205
}
221206
}

0 commit comments

Comments
 (0)