-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add max mint limit constraint #5492
base: ccip-warp-route
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,11 +491,28 @@ export class WarpCore { | |
const adapter = destinationToken.getAdapter(this.multiProvider); | ||
if ( | ||
destinationToken.standard === TokenStandard.EvmHypXERC20 || | ||
destinationToken.standard === TokenStandard.EvmHypXERC20Lockbox | ||
destinationToken.standard === TokenStandard.EvmHypXERC20Lockbox || | ||
destinationToken.standard === TokenStandard.EvmHypVSXERC20 || | ||
destinationToken.standard === TokenStandard.EvmHypVSXERC20Lockbox | ||
) { | ||
destinationBalance = await ( | ||
adapter as IHypXERC20Adapter<unknown> | ||
).getMintLimit(); | ||
const adapter = destinationToken.getAdapter( | ||
this.multiProvider, | ||
) as IHypXERC20Adapter<unknown>; | ||
destinationBalance = await adapter.getMintLimit(); | ||
|
||
if ( | ||
destinationToken.standard === TokenStandard.EvmHypVSXERC20 || | ||
destinationToken.standard === TokenStandard.EvmHypVSXERC20Lockbox | ||
) { | ||
const bufferCap = await adapter.getMintMaxLimit(); | ||
const max = bufferCap / 2n; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the limit has not replenished to the midpoint and is above it i.e we have recently burned more than minted, we would be allowed to mint more than half the buffer cap at this point. We could instead check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nambrot wants to avoid this situation where the mint limit is decreasing and the latency of message delivery can cause the transfer to appear mintable at dispatch time but not at process time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. otherwise we would not have made any changes to this adapter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense |
||
if (destinationBalance > max) { | ||
this.logger.debug( | ||
`Mint limit ${destinationBalance} exceeds max ${max}, using max`, | ||
); | ||
destinationBalance = max; | ||
} | ||
} | ||
} else { | ||
destinationBalance = await adapter.getBalance( | ||
destinationToken.addressOrDenom, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this standard get set? Right now, it is not yeah? wouldn't we need a corresponding change in the warp core config artifact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the config artifact is only in the UI afaik?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesnt need to be urgently merged as @Xaroz already made the change on the UI
this just protects against onchain limit changes