浏览代码

token swap example test working

John 1 年之前
父节点
当前提交
f2bdbd47c2

+ 1 - 1
tokens/token-swap/anchor/Anchor.toml

@@ -5,7 +5,7 @@ resolution = true
 skip-lint = false
 
 [programs.devnet]
-swap_example = "9mcG7PFTBuii5oyfHbJm3kL8eQZrYqNYe9NEgaME21ff"
+swap_example = "AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn"
 
 [registry]
 url = "https://api.apr.dev"

+ 1 - 3
tokens/token-swap/anchor/programs/token-swap/Cargo.toml

@@ -20,7 +20,5 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
 anchor-lang = { version = "0.30.0", features = ["init-if-needed"] }
 anchor-spl = { version = "0.30.0" }
 fixed = "1.23.1"
-half = "=2.2.1"
-fixed-sqrt = "0.2.5"
-solana-program = "1.18.10"
+
 

+ 2 - 4
tokens/token-swap/anchor/programs/token-swap/src/instructions/create_pool.rs

@@ -6,7 +6,6 @@ use anchor_spl::{
 
 use crate::{
     constants::{AUTHORITY_SEED, LIQUIDITY_SEED},
-    errors::*,
     state::{Amm, Pool},
 };
 
@@ -27,7 +26,7 @@ pub struct CreatePool<'info> {
         ],
         bump,
     )]
-    pub amm: Account<'info, Amm>,
+    pub amm: Box<Account<'info, Amm>>,
 
     #[account(
         init,
@@ -39,9 +38,8 @@ pub struct CreatePool<'info> {
             mint_b.key().as_ref(),
         ],
         bump,
-        constraint = mint_a.key() < mint_b.key() @ TutorialError::InvalidMint
     )]
-    pub pool: Account<'info, Pool>,
+    pub pool: Box<Account<'info, Pool>>,
 
     /// CHECK: Read only authority
     #[account(

+ 3 - 5
tokens/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs

@@ -137,7 +137,7 @@ pub struct DepositLiquidity<'info> {
         has_one = mint_a,
         has_one = mint_b,
     )]
-    pub pool: Account<'info, Pool>,
+    pub pool: Box<Account<'info, Pool>>,
 
     /// CHECK: Read only authority
     #[account(
@@ -193,16 +193,14 @@ pub struct DepositLiquidity<'info> {
     pub depositor_account_liquidity: Box<Account<'info, TokenAccount>>,
 
     #[account(
-        init_if_needed,
-        payer = payer,
+        mut,
         associated_token::mint = mint_a,
         associated_token::authority = depositor,
     )]
     pub depositor_account_a: Box<Account<'info, TokenAccount>>,
 
     #[account(
-        init_if_needed,
-        payer = payer,
+        mut,
         associated_token::mint = mint_b,
         associated_token::authority = depositor,
     )]

+ 1 - 2
tokens/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs

@@ -153,8 +153,7 @@ pub struct WithdrawLiquidity<'info> {
     pub pool_account_b: Box<Account<'info, TokenAccount>>,
 
     #[account(
-        init_if_needed,
-        payer = payer,
+        mut,
         associated_token::mint = mint_liquidity,
         associated_token::authority = depositor,
     )]

+ 1 - 1
tokens/token-swap/anchor/programs/token-swap/src/lib.rs

@@ -8,7 +8,7 @@ mod instructions;
 mod state;
 
 // Set the correct key here
-declare_id!("9mcG7PFTBuii5oyfHbJm3kL8eQZrYqNYe9NEgaME21ff");
+declare_id!("AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn");
 
 #[program]
 pub mod swap_example {

+ 0 - 2
tokens/token-swap/anchor/tests/create-pool.ts

@@ -21,8 +21,6 @@ describe("Create pool", () => {
       .accounts({ amm: values.ammKey, admin: values.admin.publicKey })
       .rpc();
 
-    console.log(values.ammKey);
-
     await mintingTokens({
       connection,
       creator: values.admin,