Skip to content

Commit

Permalink
Temporary fix to gas estimation (#245)
Browse files Browse the repository at this point in the history
* temprorary fix for Moonbeam GLMR transfers

* fix gas estimation as a temporary solution to estimateGas issues

* add changeset
  • Loading branch information
mmaurello authored May 8, 2024
1 parent 4433189 commit 8d31dc2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-carrots-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moonbeam-network/xcm-sdk': patch
---

Fix estimated gas value as temporary fix
7 changes: 6 additions & 1 deletion packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@ export class Xtokens implements TransferContractInterface {
return contract[this.#config.func].estimateGas(...this.#config.args);
}

// eslint-disable-next-line class-methods-use-this
async getViemContractEstimatedGas(
contract: XtokensContract,
): Promise<bigint> {
if (!contract) {
return 0n;
}

// Temporary fix to Module(ModuleError { index: 51, error: [0, 0, 0, 0], message: None })
// To be reverted next week when Moonbeam is in RT2900
return 100000n;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return contract.estimateGas[this.#config.func](this.#config.args as any);
// return contract.estimateGas[this.#config.func](this.#config.args as any);
}

async getFee(amount: bigint): Promise<bigint> {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DestinationFeeConfig,
FeeAssetConfig,
TransferConfig,
movr,
} from '@moonbeam-network/xcm-config';
import { AnyChain, AssetAmount } from '@moonbeam-network/xcm-types';
import {
Expand Down Expand Up @@ -133,12 +132,13 @@ export async function getSourceData({

const contract = config.contract?.build({
address: destinationAddress,
amount: asset === movr ? 1n : balance, // Temporary fix for MOVR gas estimation, pending resolution with moonsong labs team
amount: balance,
asset: chain.getAssetId(asset),
destination: destination.chain,
fee: destinationFee.amount,
feeAsset: chain.getAssetId(destinationFee),
});

const destinationFeeBalanceAmount = zeroDestinationFeeAmount.copyWith({
amount: destinationFeeBalance,
});
Expand Down

0 comments on commit 8d31dc2

Please sign in to comment.