You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// when minting an LP token, we just need to make sure the pool NFT is present in one of the inputs,
463
-
// meaning the pool script will enforce the correct name and quantity.
464
-
//
465
-
// Of particular note, you might expect this to fail when minting the initial LP tokens
466
-
// but the minting policy only runs once, so it would be running with a different redeemer in that case
467
-
// And it's not possible to include a *separate* minting redeemer to run the script twice; (TODO: check this)
468
-
// even if it were, the pool token wouldn't be on the **inuputs** when we're minting the pool.
462
+
// When minting an LP token, we just need to make sure the pool script is being spent, as it will enforce the correct
463
+
// name and quantity of the LP tokens.
469
464
//
470
-
// It's also important that the pool script and the minting script checks that *no other* tokens of this policy are minted,
471
-
// for example for a different pool. It should be ok if a token from a *different* policy is minted, though.
465
+
// To do that, we could check for the pool NFT on the inputs, but this is expensive, especially if the pool input ends up being one of the last.
466
+
// So instead we check that the pool NFT is in the first output (this is safe to assume because it's unique, and if it's in any other output it will fail)
467
+
// and that we're not minting the pool token (i.e. someone could "pretend" to mint LP tokens, but also mint the pool token to make it look like a scoop)
468
+
//
469
+
// So, lets enumerate the possible cases:
470
+
// - We use the CreatePool redeemer; this checks that *only* the correct pool token and correct number of LP tokens are minted
471
+
// - We use the MintLP redeemer; this checks that the pool token (which is unique and locked in the pool script) is in the outputs, and not minted
472
+
// - the pool script checks that only the correct number of LP tokens, and nothing else under this policy ID, are minted
473
+
// And the impossible cases:
474
+
// - During CreatePool, it would be impossible to mint multiple of the same pool tokens; a different pool token; a different number of LP tokens; or a different pool's LP tokens
475
+
// - During MintLP, it would be impossible to mint the relevant pool token; thus, the pool script must run, and thus it will be impossible to mint another pool token, a different pool
476
+
// ident pool token, a different quantity of LP tokens, or a different pools LP tokens
472
477
MintLP(pool_ident) -> {
473
478
expectMint(own_policy_id) = ctx.purpose
474
479
let pool_nft_name = shared.pool_nft_name(pool_ident)
0 commit comments