Execution Reverted: !Amt Error

What it means

The escrowPackContents function was called in the createPack function in the Pack contract. The total number of reward units available for distribution is not divisible by the number of rewards in each pack to be distributed, resulting in a remainder. This error occurs when the distribution of reward units is not balanced and evenly divisible.

Explanation of Reward Units in Pack Contract:

In the Pack contract, a reward unit represents the contents that a user receives when opening a pack. It can be a combination of ERC20, ERC721, or ERC1155 tokens. For instance, a reward unit could be something like "2 BoredApe NFTs" or "50 USDC."

 

The contract allows specifying two things for each pack:

  1. The composition of the reward unit, which determines what the user will receive when opening a pack.
  1. The number of reward units to distribute to the opener when they open a pack.

For successful execution of the escrowPackContents function, it is essential to ensure that the total number of reward units is a multiple of the number of reward units per pack open. Any deviation from this requirement will trigger the !Amt error, indicating that the contract cannot perform the distribution due to the presence of a remainder.

How to fix it

  1. Validate Total Reward Units: Ensure that the total number of reward units available for distribution (sumOfRewardUnits) is divisible by the number of reward units per pack open (amountPerOpen). sumOfRewardUnits should be a multiple of amountPerOpen.
  1. Check Reward Units Composition: Verify that each reward unit defined in the _contents array has a valid composition and totalAmount value. Make sure that the totalAmount is not zero. For ERC721 the totalAmount must be 1.
  1. Handling Non-Divisible Reward Units: Adjusting the total reward units or the number of reward units per pack to make them divisible.
Did this answer your question?
😞
😐
🤩