Skip to content
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

attach stake credential to Liquidity Pool creation transaction #51

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
}
},
{
"title": "pool_hash",
"title": "pool_address",
"schema": {
"$ref": "#/definitions/ByteArray"
"$ref": "#/definitions/aiken~1transaction~1credential~1Address"
}
},
{
Expand All @@ -106,8 +106,8 @@
}
}
],
"compiledCode": "590b7f010000323232323232323232232232222232323232533300f3232323253330133370e900118088008991919191919191919191919191919191919191919191919191929998169919191919191919299981a99b8f00700313372000a002266e4001c00cdd7181c800981c8011bae30370013030011375c606a002606a0046eb8c0cc004c0b003c4c8c94ccc0bccdc3a4000605a002264646464646464646464646464a66607e6084002264a66607a66e1cccc0040180e5221034d534600480084c8c8c8c94ccc110c11c0084c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc1594ccc158cdc80038028a99982b19b90003001153330563371e00e0682a6660ac66e3c0040c854ccc158cdc7814802899b8f02900314a029405280a5014a026464a6660b660bc00426464646464646464646464646464646464646464646464646464646464646464646464a6660f666ebc06c1d054ccc1eccdd780c82e8a99983d99baf01705b1533307b3370e02a00a2a6660f666e1c04c01c54ccc1eccdc38088030a99983d99b884800001c54ccc1eccdc42400000c2a6660f666e2120140051533307b3370e01e01a2a6660f6a6660f666e2403d20a01f13371290050078a501533307b533307b00914a026660f6941282511533307b3375e01698103d87a80001533307b3375e6e98c8cc004004180894ccc2000400452f5bded8c0264646464a6661020266e3d220100002100313308501337606ea4008dd3000998030030019bab308201003375c6100020046108020046104020026e98cccc008cccc008cccc0092f5bded8c00ee9101034d534600480081dd2201034d535000480081dc13920feffffffffffffffff0113375e6e98004dd30108a5014a029405280a5014a029405280a5014a029405280a5014a06666002666600266660026666002666600297adef6c6048810048810048302a294101501480181401380141d813400c1d9221034d5350004800888894ccc1f4cdc3800a40002008264646600200200c44a666106020022661080266ec0dd48031ba60034bd6f7b63009919191929998420099baf3300c00a0024c0103d879800013308801337606ea4028dd30038028a9998420099b8f00a002132325333086013370e90000008998450099bb03752018611602610a0200400a200a61060200264a66610a02a6661100200229445280a60103d87a800013374a900019844809ba60014bd701919800800801112999844808008998450099bb037520166ea00292f5bded8c0264646464a6661140266ebccc04803c00930103d879800013308e01337606ea403cdd40070028a9998450099b8f00f00213232533308c013370e90000008998480099bb0375202261220261160200400a200a61120200264a6661160266e1c005200014c103d87a800013374a900019847809ba80014bd7019b8000100e13308e01337606ea4008dd4000998030030019bad308b01003375c611202004611a020046116020022661100266ec0dd48011ba6001330060060033756610a020066eb8c20c04008c21c04008c21404004c8c8008c8cc004004008894ccc20c0400452613253330840100114984c8c8c8c8c8c8c94ccc22004cdc3a4000002266014014661180200c00a2c610a020026601c0040026eb8c2180400cdd7184280801984480801984380801184300801184300800998408099bb037520046ea00052f5bded8c044a6660f466e400080045300103d87980001533307a3371e0040022980103d87a800014c103d87b800033702907f7fffffffffffffff8099b8100148050c8c94ccc1e0cdc419b8200100100213370000290010800a99983b99b88001480005854ccc1dccdc3800a4000290000a99983b99b870014800852002153330773370e00290020a400426464666002002006004444a6660f666e200040084ccc00c00c004cdc199b803370600a0020029002080119b803370600290022400466e08008004ccc0e406c12c1254ccc1d14ccc1d0cdc78272450013371e0989110014a0266e0400520c0a8a504100133303701904d04b3370e900118399baa3077001307700230750013075002375a60e600260e60046eb4c1c4004c1c4008dd6983780098378011bad306d001306d002375a60d600260d600460d200260d200460ce00260ce00460ca00260bc00464a6660be66e1d20000011323232323232323232323232323232323232323253330763079002132323232498c94ccc1dccdc3a400000226464a6660f860fe0042930b1bad307d0013076007153330773370e90010008a99983d183b0038a4c2c2c60e800c60d002260ce02464a6660e866e1d2000001132325333079307c002132498c94ccc1dccdc3a400000226464a6660f860fe0042930b1bae307d0013076002153330773370e900100089919299983e183f8010a4c2c6eb8c1f4004c1d800858c1d000458c1e8004c1cc05054ccc1d0cdc3a40040022646464646464a6660fa6100020042930b1bad307e001307e002375a60f800260f80046eb4c1e8004c1cc05058c1c404c58cdc3a400460e66ea8c1dc004c1dc008c1d4004c1d4008dd6983980098398011bad30710013071002375a60de00260de0046eb4c1b4004c1b4008dd69835800983580118348009834801183380098338011832800982f0010b182e000980a000983080098308011bab305f001305f001305700116305c0013301c03d232323232323232533305e3370e900100089919299983019b8f05a00113370e66604800c0b8911034d535000480085281bae3064001305d00214a060b600260c200260b40066eacc17c004c17c008c174004c15800458dd7182d000982d0011bae30580013051006375c60ac00260ac0046eb8c150004c134010c108004c00c010c100004c0040188c94ccc12ccdc3a4008002260a060940042c6090002609a002609a0026098002608800a60920026092002609000260800062c608a002608a0046086002660060484646464646464a66608866ebc02c0044cdc39998040018202441034d53460048008528182400098208019bab304600130460023044001303d0011622232323253330423370e90010008a400026eb4c11cc104008c0fc004c94ccc104cdc3a4004002298103d87a8000132323300100100222533304700114c103d87a800013232323253330483371e014004266e9520003304c375000297ae0133006006003375a60920066eb8c11c008c12c008c124004dd598231820001181f00099198008008021129998220008a6103d87a800013232323253330453371e010004266e95200033049374c00297ae01330060060033756608c0066eb8c110008c120008c11800458cc0040948cdd78019820981d9820981d98209821181d8009119198008008019129998208008a5eb804c8c94ccc100c0140084cc110008cc0100100044cc010010004c114008c10c004c0f8004c0dc00cdd5981e000981e001181d0009819800981c000981c0009818000981a80098170008b191980080080c9129998198008a60103d87a80001323253330323375e606e606200403c266e952000330360024bd70099802002000981b801181a80099191801198009801198008048039801198008028019119b8a002001237260022c6eb8c0c4004c0c4008dd7181780098140049bae302d001302d002375c6056002604800e6eb8c0a4004c0a4008dd71813800981000c981280098128011811800980e00a1bab3021001302100130200023758603c002603c002603a0046eb0c06c004c050014c064004c04800458c05c004c05c008c054004c0380145261365632533300f3370e9000000899191919299980b180c8010991924c600e004600c0062c602e002602e004602a002601c00c2c601800a464a66601e66e1d200000113232323253330163019002149858dd7180b800980b8011bae3015001300e00216300c0013001004232533300d3370e9000000899191919299980a180b8010a4c2c6eb8c054004c054008dd7180980098060010b18050009bae001375c002460086ea80048c010dd5000ab9a5573aaae7955cfaba05742ae881",
"hash": "9049adb969fecb912e9ae30c567821c53d4747be84a98c9188514733"
"compiledCode": "590b6c0100003232323232323232322322222232323232533300e3232323253330123370e900118080008991919191919191919191919191919191919191919191919191929998161919191919191919299981a19b8f00700313372000a002266e4001c00cdd7181c000981c0011bae3036001302f011375c606800260680046eb8c0c8004c0ac03c4c8c94ccc0b8cdc3a40006058002264646464646464646464646464a66607c6082002264a66607866e1cccc0040180e1221034d534600480084c8c8c8c94ccc10cc1180084c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc1554ccc154cdc80038028a99982a99b90003001153330553371e00e0682a6660aa66e3c0040c854ccc154cdc7814802899b8f02900314a029405280a5014a026464a6660b460ba00426464646464646464646464646464646464646464646464646464646464646464646464a6660f466ebc06c1d054ccc1e8cdd780c82e8a99983d19baf01705b1533307a3370e02a00a2a6660f466e1c04c01c54ccc1e8cdc38088030a99983d19b884800001c54ccc1e8cdc42400000c2a6660f466e2120140051533307a3370e01e01a2a6660f4a6660f466e2403d20a01f13371290050078a501533307a533307a00914a026660f4941282511533307a3375e01698103d87a80001533307a3375e6e98c8cc004004180894ccc1fc00452f5bded8c0264646464a6661000266e3d220100002100313308401337606ea4008dd3000998030030019bab308101003375c60fe0046106020046102020026e98cccc008cccc008cccc0092f5bded8c00ec9101034d534600480081d92201034d535000480081d813920feffffffffffffffff0113375e6e98004dd30108a5014a029405280a5014a029405280a5014a029405280a5014a06666002666600266660026666002666600297adef6c6048810048810048302a294101501480181401380141d413400c1d5221034d5350004800888894ccc1f0cdc3800a40002008264646600200200c44a666104020022661060266ec0dd48031ba60034bd6f7b63009919191929998418099baf3300c00a0024c0103d879800013308701337606ea4028dd30038028a9998418099b8f00a002132325333085013370e90000008998448099bb0375201861140261080200400a200a61040200264a66610802a66610e0200229445280a60103d87a800013374a900019844009ba60014bd701919800800801112999844008008998448099bb037520166ea00292f5bded8c0264646464a6661120266ebccc04803c00930103d879800013308d01337606ea403cdd40070028a9998448099b8f00f00213232533308b013370e90000008998478099bb0375202261200261140200400a200a61100200264a6661140266e1c005200014c103d87a800013374a900019847009ba80014bd7019b8000100e13308d01337606ea4008dd4000998030030019bad308a01003375c61100200461180200461140200226610e0266ec0dd48011ba60013300600600337566108020066eb8c20804008c21804008c21004004c8c8008c8cc004004008894ccc2080400452613253330830100114984c8c8c8c8c8c8c94ccc21c04cdc3a4000002266014014661160200c00a2c6108020026601c0040026eb8c2140400cdd7184200801984400801984300801184280801184280800998400099bb037520046ea00052f5bded8c044a6660f266e400080045300103d8798000153330793371e0040022980103d87a800014c103d87b800033702907f7fffffffffffffff8099b8100148050c8c94ccc1dccdc419b8200100100213370000290010800a99983b19b88001480005854ccc1d8cdc3800a4000290000a99983b19b870014800852002153330763370e00290020a400426464666002002006004444a6660f466e200040084ccc00c00c004cdc199b803370600a0020029002080119b803370600290022400466e08008004ccc0e406c12c1254ccc1cd4ccc1cccdc78272450013371e0989110014a0266e0400520c0a8a504100133303701904d04b3370e900118391baa3076001307600230740013074002375a60e400260e40046eb4c1c0004c1c0008dd6983700098370011bad306c001306c002375a60d400260d400460d000260d000460cc00260cc00460c800260ba00464a6660bc66e1d20000011323232323232323232323232323232323232323253330753078002132323232498c94ccc1d8cdc3a400000226464a6660f660fc0042930b1bad307c0013075007153330763370e90010008a99983c983a8038a4c2c2c60e600c60d002260ce02464a6660e666e1d2000001132325333078307b002132498c94ccc1d8cdc3a400000226464a6660f660fc0042930b1bae307c0013075002153330763370e900100089919299983d983f0010a4c2c6eb8c1f0004c1d400858c1cc00458c1e4004c1c805054ccc1cccdc3a40040022646464646464a6660f860fe0042930b1bad307d001307d002375a60f600260f60046eb4c1e4004c1c805058c1c004c58cdc3a400460e46ea8c1d8004c1d8008c1d0004c1d0008dd6983900098390011bad30700013070002375a60dc00260dc0046eb4c1b0004c1b0008dd69835000983500118340009834001183300098330011832000982e8010b182d800980a000983000098300011bab305e001305e001305600116305b0013301c03d232323232323232533305d3370e90010008a99982e99baf05800613370e6660440080b2911034d535000480085280a50305a00130600013059003375660bc00260bc00460b800260aa0022c6eb8c164004c164008dd7182b80098280031bae30550013055002375c60a60026098008608400260060086080002600200c464a66609466e1d20040011304f3049002163047001304c001304c001304b0013043005304800130480013047001303f0031630440013044002304200133003024232323232323253330433375e016002266e1cccc02000c0fd221034d53460048008528182380098200019bab304500130450023043001303c0011622232323253330413370e90010008a400026eb4c118c100008c0f8004c94ccc100cdc3a4004002298103d87a8000132323300100100222533304600114c103d87a800013232323253330473371e014004266e9520003304b375000297ae0133006006003375a60900066eb8c118008c128008c120004dd59822981f801181e80099198008008021129998218008a6103d87a800013232323253330443371e010004266e95200033048374c00297ae01330060060033756608a0066eb8c10c008c11c008c11400458cc0040948cdd78019820181d1820181d18201820981d0009119198008008019129998200008a5eb804c8c94ccc0fcc0140084cc10c008cc0100100044cc010010004c110008c108004c0f4004c0d800cdd5981d800981d801181c8009819000981b800981b8009817800981a00098168008b191980080080c9129998190008a60103d87a80001323253330313375e606c606000403c266e952000330350024bd70099802002000981b001181a00099191801198009801198008048039801198008028019119b8a002001237260022c6eb8c0c0004c0c0008dd7181700098138049bae302c001302c002375c6054002604600e6eb8c0a0004c0a0008dd71813000980f80c981200098120011811000980d80a1bab30200013020001301f0023758603a002603a00260380046eb0c068004c04c014c060004c04400458c058004c058008c050004c0340145261365632533300e3370e9000000899191919299980a980c0010991924c600e004600c0062c602c002602c0046028002601a00c2c601600a464a66601c66e1d200000113232323253330153018002149858dd7180b000980b0011bae3014001300d00216300b0013001004232533300c3370e90000008991919192999809980b0010a4c2c6eb8c050004c050008dd7180900098058010b18048009bae001230043754002460086ea80055cd2ab9d5573caae7d5d02ba15745",
"hash": "93ad177812e38361e95a524fd1c6ce708da1cb58f4a9e1e26776f107"
},
{
"title": "order_validator.validate_expired_order_cancel",
Expand Down
10 changes: 9 additions & 1 deletion src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

import { Asset } from "./types/asset";
import { TxIn } from "./types/tx";
import { AddressPlutusData } from "./types/address";

type PlutusValidatorCompiled = {
title: string;
Expand Down Expand Up @@ -150,6 +151,13 @@ export function getContractScripts(lucid: Lucid): ContractScript {
script: applyParamsToScript(validators.pool.script, [authenPolicyId]),
};
const poolHash = lucid.utils.validatorToScriptHash(poolScript);
const poolCreationAddress = lucid.utils.validatorToAddress(
poolScript,
{
type: "Key",
hash: "83ec96719dc0591034b78e472d6f477446261fec4bc517fa4d047f02"
}
)
const poolBatchingScript: Script = {
type: "PlutusV2",
script: applyParamsToScript(validators.poolBatching.script, [
Expand Down Expand Up @@ -186,7 +194,7 @@ export function getContractScripts(lucid: Lucid): ContractScript {
type: "PlutusV2",
script: applyParamsToScript(validators.factory.script, [
authenPolicyId,
poolHash,
AddressPlutusData.toPlutus(poolCreationAddress),
poolBatchingStakeCredential,
]),
};
Expand Down
13 changes: 6 additions & 7 deletions validators/factory_validator.ak
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ use aiken/transaction/credential.{Address, ScriptCredential, StakeCredential}
use aiken/transaction/value.{PolicyId, ada_asset_name, ada_policy_id}
use amm_dex_v2/math
use amm_dex_v2/pool_validation
use amm_dex_v2/types.{
Asset, FactoryDatum, FactoryRedeemer, PoolDatum, ValidatorHash,
}
use amm_dex_v2/types.{Asset, FactoryDatum, FactoryRedeemer, PoolDatum}
use amm_dex_v2/utils

validator(
// The PolicyID of Authen Minting Policy
authen_policy_id: PolicyId,
// ValidatorHash of Pool Contract
pool_hash: ValidatorHash,
// Address of Pool Contract
// This address has Pool Validator Hash as Payment Credential and Stake Credential is controlled by Minswap Labs
pool_address: Address,
// Stake Credential of Pool Batching Contract
pool_batching_stake_credential: StakeCredential,
) {
Expand Down Expand Up @@ -135,8 +134,8 @@ validator(
let Address { payment_credential: out_addr_payment_credential, .. } =
out_addr
when out_addr_payment_credential is {
ScriptCredential(hash) -> and {
pool_hash == hash,
ScriptCredential(_) -> and {
pool_address == out_addr,
value.quantity_of(
out_value,
authen_policy_id,
Expand Down
Loading