Skip to content

Commit

Permalink
add chainlink rate limits script
Browse files Browse the repository at this point in the history
  • Loading branch information
hashxtree committed Dec 24, 2024
1 parent c719c08 commit a716f89
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/deployments/chainlink-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function chainlinkAdapterTask(taskName: string) {
const args = [bridge, gasLimit, router, allowlist, rmn];

const [signer] = await hre.ethers.getSigners();
let admin = hre.ethers.isAddress(adminArg)
const admin = hre.ethers.isAddress(adminArg)
? adminArg
: await signer.getAddress();

Expand Down
75 changes: 75 additions & 0 deletions scripts/setup/chainlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,78 @@ task('setup-token-pool', 'Configure TokenPoolAdapter smart-contract')

console.log('DONE');
});

task('setup-ccip-apply-updates', 'Apply CCIP token pool updates')
.addParam('clAdapter', 'The address of chainlink adapter smart-contract')
.addParam('lbtc', 'The address of LBTC smart-contract at remote chain')
.addParam('remoteSelector', 'Remote chain selector of destination chain')
.addParam('remotePool', 'The address of remote token pool')
.addOptionalParam('inboundLimitRate')
.addOptionalParam('inboundLimitCap')
.addOptionalParam('outboundLimitRate')
.addOptionalParam('outboundLimitCap')
.addFlag('disable', 'Disable pathway')
.setAction(async (taskArgs, hre, network) => {
const { ethers } = hre;

const {
clAdapter,
remoteSelector,
remotePool,
lbtc,

disable: disableArg,

inboundLimitRate,
inboundLimitCap,

outboundLimitRate,
outboundLimitCap,
} = taskArgs;

const adapter = await ethers.getContractAt('CLAdapter', clAdapter);

const tokenPool = await ethers.getContractAt(
'LombardTokenPool',
await adapter.tokenPool()
);

const remotePoolAddress =
remotePool.length != 42
? remotePool
: hre.ethers.AbiCoder.defaultAbiCoder().encode(
['address'],
[remotePool]
);

const lbtcEncoded =
lbtc.length != 42
? lbtc
: hre.ethers.AbiCoder.defaultAbiCoder().encode(
['address'],
[lbtc]
);

await tokenPool.applyChainUpdates([
{
remoteChainSelector: remoteSelector,
allowed: !disableArg,
remotePoolAddress,
remoteTokenAddress: lbtcEncoded,
inboundRateLimiterConfig: {
isEnabled: inboundLimitRate && inboundLimitCap,
rate: inboundLimitRate || 0,
capacity: inboundLimitCap || 0,
},
outboundRateLimiterConfig: {
isEnabled: outboundLimitRate && outboundLimitCap,
rate: outboundLimitRate || 0,
capacity: outboundLimitCap || 0,
},
},
]);

console.log(
`Chain update applied chain for selector ${remoteSelector}`
);
});

0 comments on commit a716f89

Please sign in to comment.