diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 043514a..0000000 --- a/flake.lock +++ /dev/null @@ -1,200 +0,0 @@ -{ - "nodes": { - "aiken": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - }, - "locked": { - "lastModified": 1705531678, - "narHash": "sha256-jxUnn5oq6AWVCHj5qnIeFaO2w3L3+iuPv5088QmYSSA=", - "ref": "refs/heads/nix-macos-build-libs", - "rev": "328514182ed9777581aa222aca0a5431e41ef4a7", - "revCount": 2147, - "type": "git", - "url": "file:///Users/card/Dev/job/sundaeswap/aiken" - }, - "original": { - "owner": "aiken-lang", - "ref": "v1.0.20-alpha", - "repo": "aiken", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1690463849, - "narHash": "sha256-n/ej009hs6+q/wxPR+OlYrNMXXv9qVK+FRyl7IyDuG0=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "3173ae5d63ebd44ce99b70965557906800a1fb02", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1706683685, - "narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "aiken": "aiken", - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_3" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1690424156, - "narHash": "sha256-Bpml+L280tHTQpwpC5/BJbU4HSvEzMvW8IZ4gAXimhE=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "f335a0213504c7e6481c359dc1009be9cf34432c", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 9fc1e85..0000000 --- a/flake.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - description = "A description of your project"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - aiken.url = "github:aiken-lang/aiken/v1.0.20-alpha"; - # wont work on macos till they cut a release with the coreservices stuff - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { self, nixpkgs, aiken, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ aiken.outputs.overlays.${system}.default ]; - }; - in - { - devShell = pkgs.mkShell { - buildInputs = [ pkgs.aiken ]; - }; - } - ); -} diff --git a/validators/pool.ak b/validators/pool.ak index 2593295..0c1598f 100644 --- a/validators/pool.ak +++ b/validators/pool.ak @@ -408,20 +408,15 @@ validator(settings_policy_id: PolicyId) { // Confirm that the correct funds (at least one asset A, at least one asset B, exactly 3 tokens, including the pool NFT) is correct here // Note: should we instead just compare the expected pool output? let funds_spent_to_pool = and { - coin_a_amt_sans_protocol_fees >= 1, - coin_b_amt >= 1, - // BUG SSW-201 - // pool with pair without ADA will have an additional token - // so we should test for exotic pairs without ada - list.length(value.flatten(pool_output.value)) <= 3, - value.quantity_of( - pool_output.value, - own_policy_id, - new_pool_nft_token, - ) == 1, - } - // BUG SSW-001: pool_output.address unchecked - // for testing, we can run the whole of has_expected_pool_value + coin_a_amt_sans_protocol_fees >= 1, + coin_b_amt >= 1, + list.length(value.flatten(pool_output.value)) <= 3, + value.quantity_of( + pool_output.value, + own_policy_id, + new_pool_nft_token, + ) == 1 + } // Make sure we send the pool metadata token to the metadata admin // We use an index from the redeemer to skip to the right output, in case there are multiple outputs to the metadata admin @@ -1067,9 +1062,6 @@ fn scoop_swap_deposit(options: ScoopTestOptions) { result } -// this is for test -// FIXME(Elaine) figure out how to organize test globals etc -// this is slightly annoying because aiken is picky about variable scope with tests const hash_of_pool_script = #"00000000000000000000000000000000000000000000000000000000" fn pool_test_tx_input() -> Input { let funds_input = @@ -1083,16 +1075,15 @@ fn pool_test_tx_input() -> Input { } test mint_test_two_nfts() { - // let pool_id = pool_ident_from_input(pool_test_tx_input()) - // let (_, new_pool_nft_token, _) = shared.pool_token_names(pool_id) - // // if we add on another pool NFT token to the pool output, it should fail - // !mint_test_modify( - // value.add(_, hash_of_pool_script, new_pool_nft_token, 1), // lift this over Output - // identity, - // identity, - // identity - // ) - True + let pool_id = pool_ident_from_input(pool_test_tx_input()) + let (_, new_pool_nft_token, _) = shared.pool_token_names(pool_id) + // if we add on another pool NFT token to the pool output, it should fail + !mint_test_modify( + fn(output) { Output { ..output, value: output.value.add(_, hash_of_pool_script, new_pool_nft_token, 1) } }, + identity, + identity, + identity + ) } fn pool_ident_from_input (tx_input: Input) -> ByteArray { @@ -1186,102 +1177,3 @@ test mint_test() { mint_test_modify(identity, identity, identity, identity) } -// BUG SSW-201 -// pool with pair without ADA will have an additional token -// so we should test for exotic pairs without ada -test mint_test_non_ada() { - let settings_policy_id = - #"00000000000000000000000000000000000000000000000000000000" - let hash_of_pool_script = - #"00000000000000000000000000000000000000000000000000000000" - let pool_address = script_address(hash_of_pool_script) - let rberry_policy_id = - #"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d77" - let rberry_token_name = #"524245525259" - let sberry_policy_id = - #"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d77" - let sberry_token_name = #"534245525259" - - let settings_policy_id = #"00000000000000000000000000000000000000000000000000000000" - let hash_of_pool_script = #"00000000000000000000000000000000000000000000000000000000" - let pool_address = script_address(hash_of_pool_script) - let rberry_policy_id = #"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d77" - let rberry_token_name = #"524245525259" - let user_address = - wallet_address(#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513") - let settings_input = mk_valid_settings_input([], 1) - - let funds_input = pool_test_tx_input() - let pool_id = pool_ident_from_input(funds_input) - let (new_pool_ref_token, new_pool_nft_token, new_pool_lp_token) = shared.pool_token_names(pool_id) - let inline_pool_datum = InlineDatum( - PoolDatum { - identifier: pool_id, - assets: ((rberry_policy_id, rberry_token_name), (sberry_policy_id, sberry_token_name)), - circulating_lp: 1_000_000_000, - fees_per_10_thousand: (5, 5), - market_open: 0, - fee_finalized: 0, - protocol_fees: 2_000_000, - } - ) - let pool_output_val = - value.from_asset(rberry_policy_id, rberry_token_name, 1_000_000_000) - |> value.add(sberry_policy_id, sberry_token_name, 1_000_000_000) - |> value.add(hash_of_pool_script, new_pool_nft_token, 1) - |> value.merge(value.from_lovelace(2_000_000)) - let pool_output = new_tx_output(pool_address, 0, inline_pool_datum) // 1_002_000_000 = 1_000_000_000 ADA for pool + 2_000_000 ADA for protocol_fees - |> add_asset_to_tx_output(pool_output_val) - - let lp_output_val = - value.from_asset(hash_of_pool_script, pool_lp_name(pool_id), 1_000_000_000) - |> value.merge(value.from_lovelace(2_000_000)) - let lp_output = - new_tx_output(user_address, 0, NoDatum) // we can probably get rid of the rider, it gets auto added - |> add_asset_to_tx_output(lp_output_val) - - let ref_output_val = - value.from_asset(hash_of_pool_script, new_pool_ref_token, 1) - |> value.merge(value.from_lovelace(2_000_000)) - let ref_output = - new_tx_output(user_address, 0, NoDatum) // we can probably get rid of the rider, it gets auto added - |> add_asset_to_tx_output(ref_output_val) - - let poolMintRedeemer = CreatePool { - assets: ((rberry_policy_id, rberry_token_name), (sberry_policy_id, sberry_token_name)), - pool_output: 0, - metadata_output: 2, - } - - let ctx = interval.between(1,2) - |> build_txn_context() - |> mint_assets(hash_of_pool_script, value.to_minted_value( - value.from_lovelace(0) - |> value.add(hash_of_pool_script, new_pool_lp_token, 1_000_000_000) - |> value.add(hash_of_pool_script, new_pool_nft_token, 1) - |> value.add(hash_of_pool_script, new_pool_ref_token, 1) - )) - |> add_tx_input(funds_input) - |> add_tx_ref_input(settings_input) - - // these must be in reverse order like so, in order to get [pool_output, lp_output, ref_output] - |> add_tx_output(ref_output) - |> add_tx_output(lp_output) - |> add_tx_output(pool_output) - - let result = mint(settings_policy_id, poolMintRedeemer, ctx) - !result -} - -// BUG SSW-001: pool_output.address unchecked -// for testing, we can run the whole of has_expected_pool_value -test mint_test_wrong_address () { - let minted = mint_test_modify( - // change pool nft output address to destination that shouldn't be possible - fn (output) { Output{..output, address: from_verification_key(#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513") }}, - identity, - identity, - identity - ) - minted -}