Skip to content

Commit 5b07893

Browse files
committed
fix: ensure rate limit checks work correctly when threshold > 1
1 parent eb4e792 commit 5b07893

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

programs/portal/src/instructions/redeem.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ pub fn redeem(ctx: Context<Redeem>, _args: RedeemArgs) -> Result<()> {
113113
)?;
114114

115115
let message: NttManagerMessage<Payload> = transceiver_message.message.ntt_manager_payload;
116-
let mut amount = 0;
117116

118117
if !accs.inbox_item.init {
119118
let mut inbox_item = InboxItem {
@@ -134,7 +133,7 @@ pub fn redeem(ctx: Context<Redeem>, _args: RedeemArgs) -> Result<()> {
134133
match &message.payload {
135134
Payload::NativeTokenTransfer(ntt) => {
136135
// all transfers will have a recipient and amount
137-
amount = ntt
136+
let amount = ntt
138137
.amount
139138
.untrim(accs.mint.decimals)
140139
.map_err(NTTError::from)?;
@@ -175,6 +174,8 @@ pub fn redeem(ctx: Context<Redeem>, _args: RedeemArgs) -> Result<()> {
175174
return Ok(());
176175
}
177176

177+
let amount = accs.inbox_item.transfer.amount;
178+
178179
let release_timestamp = match accs.inbox_rate_limit.rate_limit.consume_or_delay(amount) {
179180
RateLimitResult::Consumed(now) => {
180181
// When receiving a transfer, we refill the outbound rate limit with

0 commit comments

Comments
 (0)