Skip to content

Commit

Permalink
Add method to show current transfer policy
Browse files Browse the repository at this point in the history
  • Loading branch information
koirikivi committed Jun 7, 2024
1 parent 5aa3c15 commit 02f9032
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions bridge_contracts/config/runes/hardhat.config.runes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,48 @@ task(`${PREFIX}set-evm-to-btc-transfer-policy`)
}));


task(`${PREFIX}show-evm-to-btc-transfer-policy`)
.addParam("bridgeAddress", "RuneBridge contract address")
.addParam("token", "Token address")
.setAction(async ({
bridgeAddress,
token,
}, hre) => {
const ethers = hre.ethers;

const bridge = await ethers.getContractAt("RuneBridge", bridgeAddress);
console.log("Bridge at %s", bridge.address);

let decimals, tokenDisplay;
if (token !== "0x0000000000000000000000000000000000000000") {
const tokenContract = await ethers.getContractAt("RuneToken", token);
decimals = await tokenContract.decimals();
tokenDisplay = `${await tokenContract.name()} (${await tokenContract.symbol()})`;
} else {
tokenDisplay = "BASE CURRENCY";
decimals = 18;
}
console.log(
"Token %s at %s with %s decimals",
tokenDisplay,
token,
decimals
)

const oldPolicy = await bridge.getEvmToBtcTransferPolicy(token);
const dynamicFeeDivisor = await bridge.DYNAMIC_FEE_DIVISOR();

let policyDisplay = {
maxTokenAmount: ethers.formatUnits(oldPolicy.maxTokenAmount, decimals),
minTokenAmount: ethers.formatUnits(oldPolicy.minTokenAmount, decimals),
flatFeeBaseCurrency: ethers.formatUnits(oldPolicy.flatFeeBaseCurrency, decimals),
flatFeeTokens: ethers.formatUnits(oldPolicy.flatFeeTokens, decimals),
dynamicFeeTokens: `${Number(oldPolicy.dynamicFeeTokens) * 100 / Number(dynamicFeeDivisor)} %`,
};
console.table(policyDisplay);
});


task(`${PREFIX}list-tokens`)
.addParam("bridgeAddress", "RuneBridge contract address")
.setAction(jsonAction(async ({
Expand Down

0 comments on commit 02f9032

Please sign in to comment.