From 97c8af25086f8a7d3eaa4ed29a5b8b6872f0bd4e Mon Sep 17 00:00:00 2001 From: yimingWOW <94727727+yimingWOW@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:04:47 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20yimingWO?= =?UTF-8?q?W/fall@66659f949cc855182b94c2bed68b2d4c51ec8cf2=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/{index-5Gr8TjuG.js => index-PbeSNPBW.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-5Gr8TjuG.js => index-PbeSNPBW.js} (57%) diff --git a/assets/index-5Gr8TjuG.js b/assets/index-PbeSNPBW.js similarity index 57% rename from assets/index-5Gr8TjuG.js rename to assets/index-PbeSNPBW.js index 2302c5a..f27cb35 100644 --- a/assets/index-5Gr8TjuG.js +++ b/assets/index-PbeSNPBW.js @@ -1 +1 @@ -import{A as C,P as R,a as p,S as T,u as I,b as P,r as k,j as e,B as f,i as _,C as Z,T as L,c as E,d as Q,g as B,e as D,f as te,h as H,k as Y,l as J,m as ee,n as ae,o as xe,p as ve,W as Ae,q as je,s as Ne,t as Pe,R as Se}from"./vendor-C_X21sW7.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const t of n)if(t.type==="childList")for(const r of t.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function a(n){const t={};return n.integrity&&(t.integrity=n.integrity),n.referrerPolicy&&(t.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?t.credentials="include":n.crossOrigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function i(n){if(n.ep)return;n.ep=!0;const t=a(n);fetch(n.href,t)}})();const Be="3DNfsn8oRdET1qob8PsoKuWkZ78r6qTCWfMZskUmpJgL",Te={name:"fall",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},Le=[{name:"borrow",discriminator:[228,253,131,202,207,116,89,18],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"borrow_amount",type:"u64"}]},{name:"create_amm",discriminator:[242,91,21,170,5,68,125,64],accounts:[{name:"amm",writable:!0,pda:{seeds:[{kind:"arg",path:"id"}]}},{name:"admin"},{name:"payer",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"id",type:"pubkey"}]},{name:"create_pool",discriminator:[233,146,209,142,207,104,64,188],accounts:[{name:"amm",pda:{seeds:[{kind:"account",path:"amm.id",account:"Amm"}]}},{name:"mint_a"},{name:"mint_b"},{name:"pool",writable:!0,pda:{seeds:[{kind:"account",path:"amm"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"amm"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"fee",type:"u16"}]},{name:"deposit_collateral",discriminator:[156,131,142,116,146,247,162,120],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount",type:"u64"}]},{name:"deposit_liquidity",discriminator:[245,99,59,25,151,71,233,249],accounts:[{name:"pool",writable:!0,pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"depositor",docs:["The account paying for all rents"],signer:!0},{name:"liquidity_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[98]}]}},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_liquidity",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"liquidity_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount_a",type:"u64"},{name:"amount_b",type:"u64"}]},{name:"init_lending_pool_1",discriminator:[111,87,89,249,229,194,59,237],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"mint_a"},{name:"mint_b"},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"init_lending_pool_2",discriminator:[70,160,247,111,154,255,24,219],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"init_lending_pool_3",discriminator:[226,110,186,213,63,178,83,62],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"lend",discriminator:[89,34,75,168,122,47,185,45],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"lender",signer:!0},{name:"lender_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"lender"},{kind:"const",value:[103]}]}},{name:"lender_lend_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lending_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_lending_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lender_lending_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"user_lending_amount",type:"u64"}]},{name:"liquidate",discriminator:[223,179,226,125,48,46,39,74],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"trader",signer:!0},{name:"trader_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower"},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"price",discriminator:[129,85,239,229,61,225,218,20],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[],returns:{defined:{name:"PriceResult"}}},{name:"redeem",discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"},{kind:"const",value:[97]}]}},{name:"mint_a"},{name:"mint_b"},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"lender",signer:!0},{name:"lender_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"lender"},{kind:"const",value:[103]}]}},{name:"lender_lending_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lending_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_lending_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lender_lending_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"repay",discriminator:[234,103,67,82,208,234,219,166],accounts:[{name:"mint_a"},{name:"mint_b"},{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"swap_exact_tokens_for_tokens",discriminator:[249,86,253,50,177,221,73,162],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"trader",signer:!0},{name:"trader_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"trader_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"swap_a",type:"bool"},{name:"input_amount",type:"u64"},{name:"min_output_amount",type:"u64"}]},{name:"withdraw_liquidity",discriminator:[149,158,33,185,47,243,253,31],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"depositor",signer:!0},{name:"liquidity_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[98]}]}},{name:"mint_a",writable:!0,relations:["pool"]},{name:"mint_b",writable:!0,relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_liquidity",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"liquidity_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount",type:"u64"}]}],Ee=[{name:"Amm",discriminator:[143,245,200,17,74,214,196,135]},{name:"Pool",discriminator:[241,154,109,4,17,177,109,188]}],Ie=[{code:6e3,name:"CalculationError",msg:"Calculation error"},{code:6001,name:"CalculationError1",msg:"Calculation error"},{code:6002,name:"InvalidFee",msg:"Invalid fee"}],Ce=[{name:"Amm",type:{kind:"struct",fields:[{name:"id",docs:["The primary key of the AMM"],type:"pubkey"},{name:"admin",docs:["Account that has admin authority over the AMM"],type:"pubkey"}]}},{name:"Pool",type:{kind:"struct",fields:[{name:"amm",docs:["Primary key of the AMM"],type:"pubkey"},{name:"mint_a",docs:["Mint of token A"],type:"pubkey"},{name:"mint_b",docs:["Mint of token B"],type:"pubkey"},{name:"fee",docs:["The LP fee taken on each trade, in basis points"],type:"u16"},{name:"token_a_amount",docs:["借贷池中token a的数量"],type:"u64"},{name:"token_b_amount",docs:["借贷池中token b的数量"],type:"u64"},{name:"min_collateral_ratio",docs:["最小抵押率 (基点表示,20000 = 200%)"],type:"u64"},{name:"borrow_interest_accumulator_block_height",docs:["记录上次借贷池interest_step更新时的区块高度"],type:"u64"},{name:"borrow_interest_accumulator",docs:["借款累计利息,随着区块高度增加而增加,但是增加幅度与资金借出量正相关"],type:"u64"},{name:"share_lending_block_height",docs:["共享借贷累加器区块高度"],type:"u64"},{name:"share_lending_accumulator",docs:["共享借贷累加器,资金借出量的时间积分"],type:"u64"}]}},{name:"PriceResult",type:{kind:"struct",fields:[{name:"token_a_amount",type:"u64"},{name:"token_b_amount",type:"u64"}]}}],Re=[{name:"AUTHORITY_SEED",type:"bytes",value:"[97]"},{name:"BASE_RATE",type:"u64",value:"10000"},{name:"BORROWER_AUTHORITY_SEED",type:"bytes",value:"[103]"},{name:"BORROWER_BORROW_BLOCK_HEIGHT_TOKEN_SEED",type:"bytes",value:"[106]"},{name:"BORROW_TOKEN_SEED",type:"bytes",value:"[102]"},{name:"COLLATERAL_TOKEN_SEED",type:"bytes",value:"[104]"},{name:"LENDER_LENDING_BLOCK_HEIGHT_TOKEN_SEED",type:"bytes",value:"[105]"},{name:"LENDING_AUTHORITY_SEED",type:"bytes",value:"[100]"},{name:"LENDING_TOKEN_SEED",type:"bytes",value:"[101]"},{name:"LIQUIDITY_SEED",type:"bytes",value:"[98]"},{name:"MINIMUM_LIQUIDITY",type:"u64",value:"100"},{name:"MIN_COLLATERAL_RATIO_BASE",type:"u64",value:"10000"}],j={address:Be,metadata:Te,instructions:Le,accounts:Ee,errors:Ie,types:Ce,constants:Re};async function De(o,s,a){try{const i=new C(s,o,{preflightCommitment:"confirmed"}),n=new R(j,i),[t]=p.findProgramAddressSync([a.toBuffer()],n.programId);return await n.methods.createAmm(a).accounts({amm:t,admin:i.wallet.publicKey,payer:i.wallet.publicKey,systemProgram:T.programId}).rpc()}catch(i){throw console.error("Error details:",i),i}}const Fe=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState(""),[n,t]=k.useState("500"),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),i(""),m(!0),!o){i("Please connect your wallet first"),m(!1);return}const d=Number(n);if(d<1||d>1e4){i("Fee must be between 1 and 10000"),m(!1);return}try{const h=p.unique(),b=await De(o,s,h);console.log(`Transaction URL: https://explorer.solana.com/tx/${b}`),g(h.toString()),t("500")}catch(h){console.error("Error creating AMM:",h),i(h instanceof Error?h.message:"Failed to create AMM. Please try again.")}finally{m(!1)}};return e.jsxs("div",{className:"create-amm-container",children:[a&&e.jsx("div",{className:"error-message",children:a}),l&&e.jsxs("div",{className:"success-message",children:["AMM created successfully! ID: ",l]}),e.jsx("form",{onSubmit:u,className:"form",children:e.jsx("button",{type:"submit",className:"submit-button",disabled:r||!o,children:r?"Creating...":"Create AMM"})})]})},Me=async(o,s)=>{console.log("Getting AMM accounts connection:",s);const a=new C(s,o,{preflightCommitment:"confirmed"}),n=await new R(j,a).account.amm.all();for(const t of n)console.log("AMM Account Details:",{publicKey:t.publicKey.toString(),id:t.account.id.toString(),admin:t.account.admin.toString()});return n.map(t=>({pubkey:t.publicKey.toString(),ammid:t.account.id.toString()}))},me=k.createContext(void 0),qe=({children:o})=>{const[s,a]=k.useState(null);return e.jsx(me.Provider,{value:{amm:s,setAmm:a},children:o})},ie=()=>{const o=k.useContext(me);if(!o)throw new Error("useAmm must be used within an AmmProvider");return o},Ke=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[n,t]=k.useState(!1),[r,m]=k.useState(""),{setAmm:l}=ie(),g=async()=>{if(o){t(!0);try{const c=await Me(o,s);i(c),c.length>0&&l(c[0])}catch(c){console.error("Error fetching AMMs:",c),m(c instanceof Error?c.message:"Failed to fetch AMMs")}finally{t(!1)}}};k.useEffect(()=>{g()},[o,s]);const u=c=>{l(c)};return e.jsxs("div",{className:"create-amm-container",children:[e.jsx("h2",{children:"Existing AMMs"}),r&&e.jsx("div",{className:"error-message",children:r}),n?e.jsx("div",{children:"Loading AMMs..."}):a.length===0?e.jsx("div",{className:"form-group",children:e.jsx("p",{children:"No AMMs found"})}):e.jsx("div",{className:"form-group",children:a.map(c=>e.jsxs("div",{className:"amm-item",onClick:()=>u(c),children:[e.jsxs("div",{className:"amm-details",children:[e.jsx("span",{className:"amm-label",children:"AMM Pubkey:"}),e.jsx("span",{className:"amm-value",children:c.pubkey})]}),e.jsxs("div",{className:"amm-details",children:[e.jsx("span",{className:"amm-label",children:"AMM ID:"}),e.jsxs("span",{className:"amm-value",children:[c.ammid," bps"]})]})]},c.pubkey))})]})};var de;const Oe=(de=j.constants.find(o=>o.name==="BASE_RATE"))==null?void 0:de.value,F="a",ue="b",M="d",$="e",q="f",U="g",O="h",oe="i",X="j";async function We(o,s,a,i,n,t){try{console.log("Step 1: Creating provider");const r=new C(s,o,{commitment:"confirmed",preflightCommitment:"confirmed"}),m=new R(j,r),[l]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),n.toBuffer()],m.programId),[g]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),n.toBuffer(),f.from(F)],m.programId),[u]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),n.toBuffer(),f.from(ue)],m.programId),c=await _.token.associatedAddress({mint:i,owner:g}),d=await _.token.associatedAddress({mint:n,owner:g}),[h]=p.findProgramAddressSync([l.toBuffer(),f.from(M)],m.programId),[b]=p.findProgramAddressSync([l.toBuffer(),f.from($)],m.programId),[w]=p.findProgramAddressSync([l.toBuffer(),f.from(q)],m.programId),[y]=p.findProgramAddressSync([l.toBuffer(),f.from(O)],m.programId),x=await _.token.associatedAddress({mint:i,owner:h}),v=await _.token.associatedAddress({mint:n,owner:h}),[A]=p.findProgramAddressSync([l.toBuffer(),f.from(oe)],m.programId),[N]=p.findProgramAddressSync([l.toBuffer(),f.from(X)],m.programId),S=Z.setComputeUnitLimit({units:1e6});console.log("Step 1: Creating pool...");let K="";await z(s,l)?console.log("Pool already exists, skipping..."):(K=await m.methods.createPool(t).accounts({amm:a,mintA:i,mintB:n,pool:l,poolAuthority:g,mintLiquidity:u,poolAccountA:c,poolAccountB:d,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([S]).rpc({commitment:"confirmed"}),await s.confirmTransaction(K,"confirmed"),console.log("Transaction signature:",K)),console.log("Step 2: Initializing lending pool...");let W="";await z(s,x)?console.log("Lending pool 1 already initialized, skipping..."):(W=await m.methods.initLendingPool1().accounts({pool:l,mintA:i,mintB:n,lendingPoolAuthority:h,lendingPoolTokenA:x,lendingPoolTokenB:v,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(W,"confirmed")),console.log("Step 3: Initializing lending pool...");let G="";await z(s,b)?console.log("Lending pool 2 already initialized, skipping..."):(G=await m.methods.initLendingPool2().accounts({pool:l,lendingPoolAuthority:h,lendingReceiptTokenMint:b,borrowReceiptTokenMint:w,collateralReceiptTokenMint:y,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(G,"confirmed")),console.log("Step 4: Initializing lending pool...");let V="";return await z(s,A)?console.log("Lending pool 3 already initialized, skipping..."):(V=await m.methods.initLendingPool3().accounts({pool:l,lendingPoolAuthority:h,lenderLendingBlockHeightMint:A,borrowerBorrowBlockHeightMint:N,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(V,"confirmed")),{tx:K,initTx1:W,initTx2:G,initTx3:V}}catch(r){console.error("Error",r)}return{tx:"",initTx1:"",initTx2:"",initTx3:""}}async function z(o,s){return await o.getAccountInfo(s)!==null}const Ge=()=>{const o=I(),{connection:s}=P(),{amm:a}=ie(),[i,n]=k.useState(""),[t,r]=k.useState(!1),[m,l]=k.useState(""),[g,u]=k.useState({mintA:"",mintB:"",fee:"500"}),c=async d=>{if(d.preventDefault(),n(""),l(""),r(!0),!o){n("Please connect your wallet first"),r(!1);return}if(!a){n("Please select an AMM first"),r(!1);return}try{const h=new p(a.pubkey),b=new p(g.mintA),w=new p(g.mintB),y=await We(o,s,h,b,w,Number(g.fee));console.log(`Transaction URL: https://explorer.solana.com/tx/${y}`),l(y.toString()),u({mintA:"",mintB:"",fee:"500"})}catch(h){console.error("Error creating pool:",h),n(h instanceof Error?h.message:"Failed to create pool")}finally{r(!1)}};return e.jsx("div",{children:e.jsxs("div",{className:"create-amm-container",children:[e.jsx("h2",{children:"Create Pool"}),i&&e.jsx("div",{className:"error-message",children:i}),m&&e.jsxs("div",{className:"success-message",children:["Pool created successfully!",e.jsx("a",{href:`https://explorer.solana.com/tx/${m}`,target:"_blank",rel:"noopener noreferrer",children:"View transaction"})]}),e.jsxs("form",{onSubmit:c,className:"form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"AMM Pubkey:"}),e.jsx("input",{type:"text",value:a?a.pubkey:"",readOnly:!0,disabled:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Token A Mint Address:"}),e.jsx("input",{type:"text",value:g.mintA,onChange:d=>u({...g,mintA:d.target.value}),placeholder:"Enter token A mint address",required:!0,disabled:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Token B Mint Address:"}),e.jsx("input",{type:"text",value:g.mintB,onChange:d=>u({...g,mintB:d.target.value}),placeholder:"Enter token B mint address",required:!0,disabled:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Fee (in basis points, 1-10000, default: 500 or 5%):"}),e.jsx("input",{type:"text",value:g.fee,onChange:d=>u({...g,fee:d.target.value}),placeholder:"500",required:!0,disabled:t})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:t||!o,children:t?"Creating...":"Create Pool"})]})]})})};async function ce(o,s){try{const a=new C(s,o,{preflightCommitment:"confirmed"});return(await new R(j,a).account.pool.all()).map(t=>({pubkey:t.publicKey.toString(),amm:t.account.amm.toString(),mintA:t.account.mintA.toString(),mintB:t.account.mintB.toString(),fee:t.account.fee.toString(),minCollateralRatio:t.account.minCollateralRatio.toString(),tokenAAmount:t.account.tokenAAmount.toString(),tokenBAmount:t.account.tokenBAmount.toString()}))}catch(a){throw console.error("Error fetching pool accounts:",a),a}}async function ne(o,s,a){try{const i=new p(s.pubkey),n=new p(s.mintA),t=new p(s.mintB),[r]=p.findProgramAddressSync([new p(s.amm).toBuffer(),new p(s.mintA).toBuffer(),new p(s.mintB).toBuffer(),f.from(F)],new p(j.address)),m=await B(new p(s.mintA),r,!0),l=await B(new p(s.mintB),r,!0),[g]=p.findProgramAddressSync([i.toBuffer(),a.toBuffer(),f.from(U)],new p(j.address)),u=await D(o,m),c=await D(o,l),d=Number(u.amount),h=Number(c.amount),b=h/d,w=d/h,[y]=p.findProgramAddressSync([i.toBuffer(),f.from(M)],new p(j.address)),[x]=p.findProgramAddressSync([i.toBuffer(),f.from($)],new p(j.address)),[v]=p.findProgramAddressSync([i.toBuffer(),f.from(q)],new p(j.address)),[A]=p.findProgramAddressSync([i.toBuffer(),f.from(O)],new p(j.address)),N=await B(n,y,!0),S=await B(t,y,!0),K=await D(o,N),W=await D(o,S),G=await te(o,x),V=await te(o,v),ge=await te(o,A);console.log("walletPublicKey",a);const he=await H(n,a,!0),ke=await B(t,a,!0),fe=await D(o,he),be=await D(o,ke),we=await re(o,g,x),ye=await re(o,g,v),_e=await re(o,g,A);return{pool:{aToB:b,bToA:w,tokenAAmount:d,tokenBAmount:h},lendingPool:{tokenAAmount:Number(K.amount),tokenBAmount:Number(W.amount),lendingReceiptSupply:Number(G.supply),borrowReceiptSupply:Number(V.supply),collateralReceiptSupply:Number(ge.supply),addresses:{lendingReceipt:x.toString(),borrowReceipt:v.toString(),collateralReceipt:A.toString()}},userAssets:{tokenAAmount:fe.amount.toString(),tokenBAmount:be.amount.toString(),lendingReceiptAmount:we.toString(),borrowReceiptAmount:ye.toString(),collateralReceiptAmount:_e.toString()}}}catch(i){throw console.error("Error getting lending pool details:",i),i}}async function re(o,s,a){try{const i=await B(a,s,!0),n=await D(o,i);return Number(n.amount)}catch(i){return console.log("getUserTokenAmount",i),0}}async function He(o,s,a,i,n,t,r,m,l){try{const g=new C(s,o,{preflightCommitment:"confirmed"}),u=new R(j,g),[c]=p.findProgramAddressSync([i.toBuffer(),n.toBuffer(),t.toBuffer(),f.from(F)],u.programId),d=await B(n,c,!0),h=await B(t,c,!0),b=await B(n,o.publicKey,!0),w=await B(t,o.publicKey,!0);return await u.methods.swapExactTokensForTokens(r,new Y.BN(m),new Y.BN(l)).accounts({amm:i,pool:a,poolAuthority:c,trader:o.publicKey,mintA:n,mintB:t,poolAccountA:d,poolAccountB:h,traderAccountA:b,traderAccountB:w,payer:o.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc()}catch(g){throw console.error("Error in swap:",g),g}}const Ue=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(!0),[u,c]=k.useState({inputAmount:"",minOutputAmount:""}),d=async h=>{h.preventDefault(),m(""),t(!0);try{const b=parseFloat(u.inputAmount),w=parseFloat(u.minOutputAmount),y=await He(a,i,new p(o.pubkey),new p(o.amm),new p(o.mintA),new p(o.mintB),l,b,w);s(y),c({inputAmount:"",minOutputAmount:""})}catch(b){console.error("Error in swap:",b),m(b instanceof Error?b.message:"Failed to swap")}finally{t(!1)}};return e.jsxs("form",{onSubmit:d,className:"swap-form",children:[r&&e.jsx("div",{className:"error-message",children:r}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"swap-direction",children:[e.jsx("button",{type:"button",className:`direction-button ${l?"active":""}`,onClick:()=>g(!0),children:"A → B"}),e.jsx("button",{type:"button",className:`direction-button ${l?"":"active"}`,onClick:()=>g(!1),children:"B → A"})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Input Amount:"}),e.jsx("input",{type:"number",step:"any",value:u.inputAmount,onChange:h=>c({...u,inputAmount:h.target.value}),placeholder:`Enter amount for token ${l?"A":"B"}`,required:!0,disabled:n})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Minimum Output Amount:"}),e.jsx("input",{type:"number",step:"any",value:u.minOutputAmount,onChange:h=>c({...u,minOutputAmount:h.target.value}),placeholder:`Minimum amount of token ${l?"B":"A"}`,required:!0,disabled:n})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:n||!a,children:n?"Swapping...":"Swap"})]})};async function Ve(o,s,a,i,n,t,r,m){try{const l=new C(s,o,{preflightCommitment:"confirmed"}),g=new R(j,l),[u]=p.findProgramAddressSync([i.toBuffer(),n.toBuffer(),t.toBuffer(),f.from(F)],g.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(ue)],g.programId),d=await B(n,u,!0),h=await B(t,u,!0),b=await B(n,o.publicKey,!0),w=await B(t,o.publicKey,!0),y=await B(c,o.publicKey,!0);return await g.methods.depositLiquidity(new Y.BN(r),new Y.BN(m)).accounts({pool:a,poolAuthority:u,mintA:n,mintB:t,depositor:o.publicKey,mintLiquidity:c,poolAccountA:d,poolAccountB:h,depositorAccountLiquidity:y,depositorAccountA:b,depositorAccountB:w,payer:o.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc({skipPreflight:!1,maxRetries:3,commitment:"confirmed"})}catch(l){throw console.error("Error in depositLiquidity:",l),l}}const Qe=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState({amountA:"",amountB:""}),u=async c=>{c.preventDefault(),m(""),t(!0);try{const d=parseFloat(l.amountA),h=parseFloat(l.amountB),b=await Ve(a,i,new p(o.pubkey),new p(o.amm),new p(o.mintA),new p(o.mintB),d,h);s(b),g({amountA:"",amountB:""})}catch(d){console.error("Error depositing liquidity:",d),m(d instanceof Error?d.message:"Failed to deposit liquidity")}finally{t(!1)}};return e.jsxs("form",{onSubmit:u,className:"deposit-form",children:[r&&e.jsx("div",{className:"error-message",children:r}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount Token A:"}),e.jsx("input",{type:"number",step:"any",value:l.amountA,onChange:c=>g({...l,amountA:c.target.value}),placeholder:"Enter amount for token A",required:!0,disabled:n})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount Token B:"}),e.jsx("input",{type:"number",step:"any",value:l.amountB,onChange:c=>g({...l,amountB:c.target.value}),placeholder:"Enter amount for token B",required:!0,disabled:n})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:n||!a,children:n?"Depositing...":"Confirm Deposit"})]})};async function Ze(o,s,a,i,n){try{const t=new C(s,o,{commitment:"confirmed",preflightCommitment:"confirmed"}),r=new R(j,t),[m]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],r.programId),[l]=p.findProgramAddressSync([a.toBuffer(),f.from($)],r.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),c=await _.token.associatedAddress({mint:i,owner:m}),d=await _.token.associatedAddress({mint:n,owner:m}),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],r.programId),[b]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),w=Z.setComputeUnitLimit({units:1e6});console.log("Step 1: Initializing lending pool...");let y="";await se(s,c)?console.log("Lending pool 1 already initialized, skipping..."):(y=await r.methods.initLendingPool1().accounts({pool:a,mintA:i,mintB:n,lendingPoolAuthority:m,lendingPoolTokenA:c,lendingPoolTokenB:d,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(y,"confirmed")),console.log("Step 2: Initializing lending pool...");let x="";await se(s,u)?console.log("Lending pool 2 already initialized, skipping..."):(x=await r.methods.initLendingPool2().accounts({pool:a,lendingPoolAuthority:m,lendingReceiptTokenMint:l,borrowReceiptTokenMint:g,collateralReceiptTokenMint:u,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(x,"confirmed")),console.log("Step 3: Initializing lending pool...");let v="";return await se(s,h)?console.log("Lending pool 3 already initialized, skipping..."):(v=await r.methods.initLendingPool3().accounts({pool:a,lendingPoolAuthority:m,lenderLendingBlockHeightMint:h,borrowerBorrowBlockHeightMint:b,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(v,"confirmed")),{initTx1:y,initTx2:x,initTx3:v}}catch(t){console.error("Error",t)}return{initTx1:"",initTx2:"",initTx3:""}}async function se(o,s){return await o.getAccountInfo(s)!==null}const Je=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),{amm:n}=ie(),[t,r]=k.useState(""),[m,l]=k.useState(!1),g=async()=>{if(r(""),l(!0),!a){r("Please connect your wallet first"),l(!1);return}if(!n){r("Please select an AMM first"),l(!1);return}try{const u=new p(o.pubkey),c=new p(o.mintA),d=new p(o.mintB),h=await Ze(a,i,u,c,d);console.log(`Transaction URL: https://explorer.solana.com/tx/${h}`),s&&s(h.toString())}catch(u){console.error("Error initializing pool:",u),r(u instanceof Error?u.message:"Failed to initialize pool")}finally{l(!1)}};return e.jsxs("div",{className:"init-pool-container",children:[t&&e.jsx("div",{className:"error-message",children:t}),e.jsx("button",{onClick:g,className:"submit-button",disabled:m||!a,children:m?"Initializing...":"Initialize Pool"})]})},$e=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[n,t]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await ne(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"AMM Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.amm.toString(),children:o.amm.toString()})]}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Fee:"}),e.jsx("span",{className:"pool-value",title:o.fee.toString(),children:o.fee})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Min Collateral Ratio:"}),e.jsx("span",{className:"pool-value",title:o.minCollateralRatio.toString(),children:o.minCollateralRatio})]})]}),e.jsx("div",{className:"pool-actions",children:e.jsx("button",{className:"action-button",onClick:()=>t(n==="initPool"?"none":"initPool"),children:n==="initPool"?"Hide Init Pool":"Init Pool"})}),n==="initPool"&&e.jsx("div",{className:"form-container",children:e.jsx(Je,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),e.jsxs("div",{className:"pool-price-info",children:[e.jsx("h4",{children:"Pool Liquidity & Prices"}),l?e.jsx("div",{className:"loading-prices",children:"Loading prices..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A Reserve:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B Reserve:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenBAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (A → B):"}),e.jsxs("span",{className:"pool-value",children:["1 A = ",r.pool.aToB.toFixed(6)," B"]})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (B → A):"}),e.jsxs("span",{className:"pool-value",children:["1 B = ",r.pool.bToA.toFixed(6)," A"]})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load prices"})]}),e.jsxs("div",{className:"pool-actions",children:[e.jsx("button",{className:"action-button",onClick:()=>t(n==="deposit"?"none":"deposit"),children:n==="deposit"?"Hide Deposit":"Deposit"}),e.jsx("button",{className:"action-button",onClick:()=>t(n==="swap"?"none":"swap"),children:n==="swap"?"Hide Swap":"Swap"})]}),n==="deposit"&&e.jsx("div",{className:"form-container",children:e.jsx(Qe,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),n==="swap"&&e.jsx("div",{className:"form-container",children:e.jsx(Ue,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),e.jsxs("div",{className:"lending-pool-info",children:[e.jsx("h4",{children:"Lending Pool"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenAAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenBAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenBAmount.toFixed(6)})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]})]})},Xe=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){t(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{t(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),n?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx($e,{pool:d,onTxSuccess:c},d.pubkey.toString()))})]})};async function ze(o,s,a,i){try{console.log("Executing liquidate...");const n=new C(s,o,{preflightCommitment:"confirmed"}),t=new R(j,n),r=await t.account.pool.fetch(a),m=r.mintA,l=r.mintB,[g]=p.findProgramAddressSync([r.amm.toBuffer(),m.toBuffer(),l.toBuffer(),f.from(F)],t.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],t.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],t.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],t.programId),[h]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),f.from(U)],t.programId),b=await _.token.associatedAddress({mint:c,owner:h}),w=await _.token.associatedAddress({mint:d,owner:h}),y=H(l,n.wallet.publicKey,!0),x=Z.setComputeUnitLimit({units:2e8});console.log("Sending liquidate transaction...");const v=await t.methods.liquidate().accounts({pool:a,poolAuthority:g,mintA:m,mintB:l,lendingPoolAuthority:u,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,trader:n.wallet.publicKey,traderAccountB:y,borrower:i,borrowerBorrowReceiptToken:b,borrowerCollateralReceiptToken:w,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([x]).rpc();return console.log("Liquidate transaction signature:",v),{tx:v,accounts:{poolKey:a,poolAuthority:g,lendingPoolAuthority:u,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,traderAccountB:y,borrowerBorrowReceiptToken:b,borrowerCollateralReceiptToken:w}}}catch(n){throw console.error("Error in liquidate:",n),n instanceof Error&&console.error("Error details:",{message:n.message,stack:n.stack}),n}}async function Ye(o,s,a){try{const i=new C(a,o,{preflightCommitment:"confirmed"}),n=new R(j,i),t=await n.account.pool.fetch(s),r=t.mintA,m=t.mintB,g=(await ne(a,{pubkey:s.toString(),amm:t.amm.toString(),mintA:r.toString(),mintB:m.toString()},o.publicKey)).pool.aToB,[u]=p.findProgramAddressSync([s.toBuffer(),f.from(q)],n.programId),[c]=p.findProgramAddressSync([s.toBuffer(),f.from(O)],n.programId),d=await a.getTokenLargestAccounts(u),h=[];for(const b of d.value){if(b.amount=="0")continue;const w=await D(a,b.address),y=w.owner,x=await eo(a,y,c);console.log("borrowReceiptToken amount",w.amount.toString()),console.log("collateralReceiptTokenAmount",x),console.log("Number(borrowTokenAccountInfo.amount) * 2*poolPrice",Number(w.amount)*2*g),x{const o=I(),{connection:s}=P(),[a,i]=k.useState(""),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),[u,c]=k.useState(""),[d,h]=k.useState([]),[b,w]=k.useState(!1),y=async v=>{if(v.preventDefault(),!o||!r){i("Please connect wallet and enter pool address");return}try{i(""),w(!0);const A=new p(r),N=await Ye(o,A,s);h(N)}catch(A){console.error("Error fetching pending liquidations:",A),i(A instanceof Error?A.message:"Failed to fetch pending liquidations"),h([])}finally{w(!1)}},x=async v=>{if(v.preventDefault(),i(""),t(!0),!o){i("Please connect your wallet first"),t(!1);return}let A,N;try{A=new p(r),N=new p(l)}catch{i("Invalid pool or borrower address"),t(!1);return}try{const S=await ze(o,s,A,N);console.log(`Transaction URL: https://explorer.solana.com/tx/${S.tx}`),c(S.tx),m(""),g("")}catch(S){console.error("Error liquidating position:",S),i(S instanceof Error?S.message:"Failed to liquidate. Please try again.")}finally{t(!1)}};return e.jsxs("div",{className:"liquidate-container",children:[a&&e.jsx("div",{className:"error-message",children:a}),u&&e.jsxs("div",{className:"success-message",children:["Liquidation successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${u}`,target:"_blank",rel:"noopener noreferrer",children:"View transaction"})]}),e.jsxs("div",{className:"search-form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"pool-address",children:"Pool Address:"}),e.jsxs("div",{className:"input-with-button",children:[e.jsx("input",{id:"pool-address",type:"text",value:r,onChange:v=>m(v.target.value),placeholder:"Enter pool address",className:"input-field"}),e.jsx("button",{onClick:y,disabled:b||!o||!r,className:"search-button",children:b?"Searching...":"Search"})]})]}),e.jsxs("div",{className:"pending-liquidations",children:[e.jsx("h3",{children:"Pending Liquidations"}),b?e.jsx("div",{className:"loading",children:"Loading pending liquidations..."}):d.length===0?e.jsx("p",{children:"No pending liquidations found"}):e.jsx("ul",{className:"liquidation-list",children:d.map((v,A)=>e.jsx("li",{className:"liquidation-item",onClick:()=>g(v.userAuthorityPda.toString()),children:e.jsxs("div",{children:["Borrower Authority PDA: ",v.userAuthorityPda.toString()]})},A))})]})]}),e.jsxs("form",{onSubmit:x,className:"liquidate-form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"borrower-address",children:"Note: The current demo does not yet support liquidation based on PDAs. The public key is not the same as the PDA. So the PDA above is useless now. U'd better to use another account to borrow and then liquidate that account with it's Public Key."}),e.jsx("label",{htmlFor:"borrower-address",children:"Borrower Address:"}),e.jsx("input",{id:"borrower-address",type:"text",value:l,onChange:v=>g(v.target.value),placeholder:"Enter borrower address",className:"input-field"})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:n||!o||!r||!l,children:n?"Liquidating...":"Liquidate Position"})]})]})};async function no(o,s,a,i){try{console.log("Executing lend...");const n=new C(s,o,{preflightCommitment:"confirmed"}),t=new R(j,n),r=await t.account.pool.fetch(a),m=r.mintA,l=r.mintB,[g]=p.findProgramAddressSync([r.amm.toBuffer(),m.toBuffer(),l.toBuffer(),f.from(F)],t.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],t.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from($)],t.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],t.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],t.programId),b=H(m,u,!0),w=H(l,u,!0),y=await _.token.associatedAddress({mint:m,owner:n.wallet.publicKey}),[x]=p.findProgramAddressSync([a.toBuffer(),n.wallet.publicKey.toBuffer(),f.from(U)],t.programId),v=await _.token.associatedAddress({mint:c,owner:x}),A=await _.token.associatedAddress({mint:h,owner:x});return{tx:await t.methods.lend(new ee(i)).accounts({pool:a,lendingPoolAuthority:u,lendingPoolTokenA:b,lendingReceiptTokenMint:c,lenderLendingBlockHeightMint:h,lender:n.wallet.publicKey,lenderTokenA:y,lenderAuthority:x,lenderLendReceiptToken:v,lenderLendingBlockHeightReceiptToken:A,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc(),accounts:{poolAuthority:g,lendingPoolAuthority:u,lendingReceiptTokenMint:c,borrowReceiptTokenMint:d,lendingPoolTokenA:b,lendingPoolTokenB:w,lenderTokenA:y,lenderLendReceiptToken:v,lenderLendingBlockHeightReceiptToken:A}}}catch(n){throw console.error("Error in lend:",n),n instanceof Error&&console.error("Error details:",{message:n.message,stack:n.stack}),n}}const to=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),t(""),m(!0),!a){t("Please connect your wallet first"),m(!1);return}try{const d=parseFloat(l);if(isNaN(d)||d<=0)throw new Error("Invalid amount");const h=new p(o.pubkey),b=await no(a,i,h,new ee(d));console.log(`Transaction URL: https://explorer.solana.com/tx/${b.tx}`),g(""),s(b.tx)}catch(d){console.error("Error lending:",d),t(d instanceof Error?d.message:"Failed to lend")}finally{m(!1)}};return console.log(o),e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Lend Tokens"}),n&&e.jsx("div",{className:"error-message",children:n}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to Lend:"}),e.jsx("input",{type:"number",value:l,onChange:c=>g(c.target.value),placeholder:"Enter amount to lend",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lendingPool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString()]}),e.jsxs("div",{children:["Token A: ",o.mintA.toString()]}),e.jsxs("div",{children:["Token B: ",o.mintB.toString()]})]}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Lend"})]})]})};async function ao(o,s,a){try{const i=new C(s,o,{preflightCommitment:"confirmed"}),n=new R(j,i),t=await n.account.pool.fetch(a),r=t.mintA,m=t.mintB,[l]=p.findProgramAddressSync([t.amm.toBuffer(),r.toBuffer(),m.toBuffer(),f.from(F)],n.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],n.programId),u=await _.token.associatedAddress({mint:r,owner:g}),c=await _.token.associatedAddress({mint:m,owner:g}),[d]=p.findProgramAddressSync([a.toBuffer(),f.from($)],n.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],n.programId),[b]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],n.programId),w=await _.token.associatedAddress({mint:r,owner:i.wallet.publicKey}),y=await _.token.associatedAddress({mint:m,owner:i.wallet.publicKey}),[x]=p.findProgramAddressSync([a.toBuffer(),i.wallet.publicKey.toBuffer(),f.from(U)],n.programId),v=await _.token.associatedAddress({mint:d,owner:x}),A=await _.token.associatedAddress({mint:b,owner:x});console.log("Sending redeem transaction...");const N=await n.methods.redeem().accounts({pool:a,poolAuthority:l,mintA:r,mintB:m,lendingPoolAuthority:g,lendingPoolTokenA:u,lendingPoolTokenB:c,lendingReceiptTokenMint:d,borrowReceiptTokenMint:h,lenderLendingBlockHeightTokenMint:b,lender:i.wallet.publicKey,lenderTokenA:w,lenderTokenB:y,lenderLendingReceiptToken:v,lenderLendingBlockHeightReceiptToken:A,payer:i.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc();return console.log("Redeem transaction signature:",N),N}catch(i){throw console.error("Error in redeem:",i),i}}const ro=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(""),[r,m]=k.useState(!1),l=async g=>{if(g.preventDefault(),t(""),m(!0),!a){t("Please connect your wallet first"),m(!1);return}try{const u=new p(o.pubkey),c=await ao(a,i,u);console.log(`Transaction URL: https://explorer.solana.com/tx/${c}`),s(c)}catch(u){console.error("Error redeeming:",u),t(u instanceof Error?u.message:"Failed to redeem")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Redeem Tokens"}),n&&e.jsx("div",{className:"error-message",children:n}),e.jsxs("form",{onSubmit:l,children:[e.jsxs("div",{className:"lending-pool-info-summary",children:[e.jsxs("div",{children:["Min Collateral Ratio: ",(o.minCollateralRatio/100).toFixed(2),"%"]}),e.jsxs("div",{children:["Base Rate: ",Oe,"%"]})]}),e.jsx("div",{className:"warning-message",children:"Note: This will redeem all your lending receipt tokens."}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Redeem"})]})]})},so=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[n,t]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await ne(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]})]}),e.jsxs("div",{className:"lending-pool-info",children:[e.jsx("h4",{children:"Lending Pool"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenAAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenBAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenBAmount.toFixed(6)})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-assets-details",children:[e.jsx("h4",{children:"Your Assets"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenA Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenAAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenB Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenBAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-lending-details",children:[e.jsx("h4",{children:"Your lending details"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"lended tokenA amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.lendingReceiptAmount})]})}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsx("div",{className:"lending-pool-actions",children:e.jsxs("div",{className:"lending-pool-action-buttons",children:[e.jsx("button",{className:"lending-pool-action-button",onClick:()=>t(n==="lend"?"none":"lend"),children:n==="lend"?"Hide Lend":"Lend"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>t(n==="redeem"?"none":"redeem"),children:n==="redeem"?"Hide Redeem":"Redeem"})]})}),e.jsx("div",{className:"lending-pool-actions",children:e.jsx("button",{className:"lending-pool-refresh-button",onClick:u,disabled:l,children:l?"Loading...":"🔄 Refresh"})}),n==="lend"&&e.jsx("div",{className:"form-container",children:e.jsx(to,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),n==="redeem"&&e.jsx("div",{className:"form-container",children:e.jsx(ro,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})})]})},io=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){t(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{t(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),n?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx(so,{pool:d,onTxSuccess:c}))})]})};async function co(o,s,a,i,n,t){try{console.log("Executing borrow...");const r=new C(s,o,{preflightCommitment:"confirmed"}),m=new R(j,r),l=await m.account.pool.fetch(a);console.log("Pool info:",{amm:l.amm.toString(),mintA:l.mintA.toString(),mintB:l.mintB.toString()});const[g]=p.findProgramAddressSync([l.amm.toBuffer(),i.toBuffer(),n.toBuffer(),f.from(F)],m.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],m.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],m.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],m.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],m.programId),b=await _.token.associatedAddress({mint:i,owner:g}),w=await _.token.associatedAddress({mint:n,owner:g}),y=await _.token.associatedAddress({mint:i,owner:u}),x=await _.token.associatedAddress({mint:n,owner:u}),v=await _.token.associatedAddress({mint:i,owner:r.wallet.publicKey}),A=await _.token.associatedAddress({mint:n,owner:r.wallet.publicKey}),[N]=p.findProgramAddressSync([a.toBuffer(),r.wallet.publicKey.toBuffer(),f.from(U)],m.programId),S=await _.token.associatedAddress({mint:c,owner:N}),K=await _.token.associatedAddress({mint:d,owner:N}),W=await _.token.associatedAddress({mint:h,owner:N});console.log("Sending borrow transaction...");const G=Z.setComputeUnitLimit({units:1e6});return await m.methods.borrow(t).accounts({pool:a,poolAuthority:g,mintA:i,mintB:n,poolAccountA:b,poolAccountB:w,lendingPoolAuthority:u,lendingPoolTokenA:y,lendingPoolTokenB:x,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,borrowerBorrowBlockHeightTokenMint:h,borrower:r.wallet.publicKey,borrowerTokenA:v,borrowerTokenB:A,borrowerBorrowReceiptToken:S,borrowerCollateralReceiptToken:K,borrowerBorrowBlockHeightReceiptToken:W,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([G]).rpc()}catch(r){throw console.error("Error in borrow:",r),r instanceof Error&&console.error("Error details:",{message:r.message,stack:r.stack}),r}}const lo=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async d=>{if(d.preventDefault(),t(""),m(!0),!a){t("Please connect your wallet first"),m(!1);return}try{const h=parseFloat(l);if(isNaN(h)||h<=0)throw new Error("Invalid borrow amount");const b=new p(o.pubkey),w=new p(o.mintA),y=new p(o.mintB),x=await co(a,i,b,w,y,new ee(h));console.log(`Transaction URL: https://explorer.solana.com/tx/${x}`),g(""),s(x)}catch(h){console.error("Error borrowing:",h),t(h instanceof Error?h.message:"Failed to borrow")}finally{m(!1)}},c=(o.minCollateralRatio/100).toFixed(2);return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Borrow Tokens"}),n&&e.jsx("div",{className:"error-message",children:n}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to Borrow (Token A):"}),e.jsx("input",{type:"number",value:l,onChange:d=>g(d.target.value),placeholder:"Enter amount to borrow",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lending-pool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString().slice(0,4),"...",o.pubkey.toString().slice(-4)]}),e.jsxs("div",{children:["Token A (Borrow): ",o.mintA.toString().slice(0,4),"...",o.mintA.toString().slice(-4)]}),e.jsxs("div",{children:["Token B (Collateral): ",o.mintB.toString().slice(0,4),"...",o.mintB.toString().slice(-4)]}),e.jsxs("div",{children:["Min Collateral Ratio: ",c,"%"]}),e.jsxs("div",{children:["Base Rate: ",(o.fee/100).toFixed(2),"%"]})]}),e.jsx("div",{className:"warning-message",children:"Note: Please ensure you provide sufficient collateral based on the minimum collateral ratio."}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Borrow"})]})]})};async function mo(o,s,a,i,n){try{console.log("Executing repay...");const t=new C(s,o,{preflightCommitment:"confirmed"}),r=new R(j,t),m=await r.account.pool.fetch(a),[l]=p.findProgramAddressSync([m.amm.toBuffer(),i.toBuffer(),n.toBuffer(),f.from(F)],r.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],r.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),d=await _.token.associatedAddress({mint:i,owner:g}),h=await _.token.associatedAddress({mint:n,owner:g}),b=await _.token.associatedAddress({mint:i,owner:t.wallet.publicKey}),w=await _.token.associatedAddress({mint:n,owner:t.wallet.publicKey}),[y]=p.findProgramAddressSync([a.toBuffer(),t.wallet.publicKey.toBuffer(),f.from(U)],r.programId),x=await _.token.associatedAddress({mint:u,owner:y}),v=await _.token.associatedAddress({mint:c,owner:y}),[A]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),N=await _.token.associatedAddress({mint:A,owner:y});console.log("Sending repay transaction...");const S=await r.methods.repay().accounts({mintA:i,mintB:n,pool:a,poolAuthority:l,lendingPoolAuthority:g,lendingPoolTokenA:d,lendingPoolTokenB:h,borrowReceiptTokenMint:u,collateralReceiptTokenMint:c,borrowerBorrowBlockHeightMint:A,borrower:t.wallet.publicKey,borrowerTokenA:b,borrowerTokenB:w,borrowerAuthority:y,borrowerBorrowReceiptToken:x,borrowerCollateralReceiptToken:v,borrowerBorrowBlockHeightReceiptToken:N,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc();return console.log("Repay transaction signature:",S),S}catch(t){throw console.error("Error in repay:",t),t}}const uo=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(""),[r,m]=k.useState(!1),l=async g=>{if(g.preventDefault(),t(""),m(!0),!a){t("Please connect your wallet first"),m(!1);return}try{const u=new p(o.pubkey),c=new p(o.mintA),d=new p(o.mintB),h=await mo(a,i,u,c,d);console.log(`Transaction URL: https://explorer.solana.com/tx/${h}`),s(h)}catch(u){console.error("Error repaying:",u),t(u instanceof Error?u.message:"Failed to repay")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Repay Loan"}),n&&e.jsx("div",{className:"error-message",children:n}),e.jsxs("form",{onSubmit:l,children:[e.jsx("div",{className:"form-group",children:e.jsx("div",{className:"info-message",children:"Repaying your loan will return your collateral proportionally."})}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Repay"})]})]})};async function po(o,s,a,i,n){try{console.log("Executing borrow...");const t=new C(s,o,{preflightCommitment:"confirmed"}),r=new R(j,t),[m]=p.findProgramAddressSync([a.toBuffer(),f.from(M)],r.programId),l=await H(i,m,!0),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),c=H(i,t.wallet.publicKey),[d]=p.findProgramAddressSync([a.toBuffer(),t.wallet.publicKey.toBuffer(),f.from(U)],r.programId),h=await H(g,d,!0),b=await _.token.associatedAddress({mint:u,owner:d});console.log("Sending borrow transaction...");const w=Z.setComputeUnitLimit({units:1e6});return{tx:await r.methods.depositCollateral(n).accounts({pool:a,lendingPoolAuthority:m,lendingPoolTokenB:l,collateralReceiptTokenMint:g,borrowerBorrowBlockHeightTokenMint:u,borrower:t.wallet.publicKey,borrowerTokenB:c,borrowerAuthority:d,borrowerCollateralReceiptToken:h,borrowerBorrowBlockHeightReceiptToken:b,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([w]).rpc()}}catch(t){throw console.error("Error in borrow:",t),t instanceof Error&&console.error("Error details:",{message:t.message,stack:t.stack}),t}}const go=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[n,t]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),t(""),m(!0),!a){t("Please connect your wallet first"),m(!1);return}try{const d=parseFloat(l);if(isNaN(d)||d<=0)throw new Error("Invalid amount");const h=new p(o.pubkey),b=new p(o.mintB),w=await po(a,i,h,b,new ee(d));console.log(`Transaction URL: https://explorer.solana.com/tx/${w.tx}`),g(""),s(w.tx)}catch(d){console.error("Error lending:",d),t(d instanceof Error?d.message:"Failed to lend")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"DepositCollateral Tokens"}),n&&e.jsx("div",{className:"error-message",children:n}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to DepositCollateral:"}),e.jsx("input",{type:"number",value:l,onChange:c=>g(c.target.value),placeholder:"Enter amount of collateral to deposit",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lendingPool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString()]}),e.jsxs("div",{children:["Token A: ",o.mintA.toString()]}),e.jsxs("div",{children:["Token B: ",o.mintB.toString()]})]}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm DepositCollateral"})]})]})},ho=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[n,t]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await ne(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Min Collateral Ratio:"}),e.jsx("span",{className:"pool-value",title:o.minCollateralRatio.toString(),children:o.minCollateralRatio})]})]}),e.jsxs("div",{className:"pool-price-info",children:[e.jsx("h4",{children:"Prices"}),l?e.jsx("div",{className:"loading-prices",children:"Loading prices..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"TokenA Amount:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"TokenB Amount:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenBAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (A → B):"}),e.jsxs("span",{className:"pool-value",children:["1 A = ",r.pool.aToB.toFixed(6)," B"]})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (B → A):"}),e.jsxs("span",{className:"pool-value",children:["1 B = ",r.pool.bToA.toFixed(6)," A"]})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load prices"})]}),e.jsxs("div",{className:"lending-pool-info",children:[e.jsx("h4",{children:"Lending Pool"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenAAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenBAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenBAmount.toFixed(6)})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-assets-details",children:[e.jsx("h4",{children:"Your Assets"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenA Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenAAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenB Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenBAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-lending-details",children:[e.jsx("h4",{children:"Your borrowing details"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"borrowed tokenB amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.borrowReceiptAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"collateral TokenA amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.collateralReceiptAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"lending-pool-actions",children:[e.jsxs("div",{className:"lending-pool-action-buttons",children:[e.jsx("button",{className:"lending-pool-action-button",onClick:()=>t(n==="depositCollateral"?"none":"depositCollateral"),children:n==="depositCollateral"?"Hide DepositCollateral":"DepositCollateral"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>t(n==="borrow"?"none":"borrow"),children:n==="borrow"?"Hide Borrow":"Borrow"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>t(n==="repay"?"none":"repay"),children:n==="repay"?"Hide Repay":"Repay"})]}),e.jsx("button",{className:"lending-pool-refresh-button",onClick:u,disabled:l,children:l?"Loading...":"🔄 Refresh"})]}),n==="borrow"&&e.jsx("div",{className:"form-container",children:e.jsx(lo,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),n==="repay"&&e.jsx("div",{className:"form-container",children:e.jsx(uo,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})}),n==="depositCollateral"&&e.jsx("div",{className:"form-container",children:e.jsx(go,{pool:o,onSuccess:c=>{s(c),t("none"),u()}})})]})},ko=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[n,t]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){t(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{t(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),n?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx(ho,{pool:d,onTxSuccess:c}))})]})},le="GUXNPX5ci1Qj76MZe2aRJ33zK48VmT6gXVyR86CsF4T5",fo=()=>{const{publicKey:o}=J(),[s,a]=k.useState("amm");return e.jsx(qe,{children:e.jsxs("div",{className:"defi-dashboard",children:[e.jsxs("div",{className:"tabs",children:[(o==null?void 0:o.toBase58())==le&&e.jsx("button",{className:`tab ${s==="amm"?"active":""}`,onClick:()=>a("amm"),children:"AMM"}),e.jsx("button",{className:`tab ${s==="pool"?"active":""}`,onClick:()=>a("pool"),children:"Swap"}),e.jsx("button",{className:`tab ${s==="lenderPool"?"active":""}`,onClick:()=>a("lenderPool"),children:"Lend"}),e.jsx("button",{className:`tab ${s==="borrowerPool"?"active":""}`,onClick:()=>a("borrowerPool"),children:"Borrow"}),e.jsx("button",{className:`tab ${s==="liquidate"?"active":""}`,onClick:()=>a("liquidate"),children:"Liquidate"})]}),e.jsx("div",{className:"content",children:s==="amm"&&(o==null?void 0:o.toBase58())==le?e.jsxs("div",{children:[e.jsx(Ke,{}),e.jsx(Fe,{})]}):s==="pool"?e.jsxs("div",{children:[e.jsx(Xe,{}),e.jsx(Ge,{})]}):s==="lenderPool"?e.jsx("div",{children:e.jsx(io,{})}):s==="borrowerPool"?e.jsx("div",{children:e.jsx(ko,{})}):s==="liquidate"?e.jsx("div",{children:e.jsx(oo,{})}):e.jsx(bo,{})})]})})},bo=()=>e.jsx("div",{children:e.jsx("h3",{children:" Coming Soon..."})}),pe=k.createContext({network:"localnet",setNetwork:()=>{}}),wo=()=>k.useContext(pe),yo={"mainnet-beta":ae("mainnet-beta"),testnet:ae("testnet"),devnet:ae("devnet"),localnet:"http://127.0.0.1:8899"},_o=({onChange:o,value:s})=>e.jsx("div",{className:"solana-network-select-container",children:e.jsxs("select",{onChange:a=>o(a.target.value),value:s,className:"solana-network-select",children:[e.jsx("option",{value:"localnet",children:"Localnet"}),e.jsx("option",{value:"devnet",children:"Devnet"}),e.jsx("option",{value:"testnet",children:"Testnet"}),e.jsx("option",{value:"mainnet-beta",children:"Mainnet"})]})}),xo=({children:o})=>{const[s,a]=k.useState("localnet"),i=k.useMemo(()=>yo[s],[s]),n=k.useMemo(()=>[new xe],[]);return e.jsx(pe.Provider,{value:{network:s,setNetwork:a},children:e.jsx(ve,{endpoint:i,children:e.jsx(Ae,{wallets:n,autoConnect:!0,children:e.jsx(je,{children:o})})})})},vo=()=>{const{connected:o}=J(),{network:s,setNetwork:a}=wo();return e.jsxs("div",{className:"container",children:[e.jsx("nav",{className:"navbar",children:e.jsxs("div",{className:"navbar-content",children:[e.jsx(_o,{onChange:a,value:s}),e.jsx(Ne,{})]})}),e.jsx("main",{className:"main-content",children:o?e.jsx(fo,{}):e.jsx("div",{className:"connect-prompt",children:e.jsx("h2",{children:"Please connect your wallet to continue"})})})]})};typeof window<"u"&&(window.global=window,window.Buffer=f);Pe.createRoot(document.getElementById("root")).render(e.jsx(Se.StrictMode,{children:e.jsx(xo,{children:e.jsx(vo,{})})})); +import{A as C,P as R,a as p,S as T,u as I,b as P,r as k,j as e,B as f,i as _,C as Z,T as L,c as E,d as Q,g as B,e as D,f as ne,h as H,k as Y,l as J,m as ee,n as ae,o as xe,p as ve,W as Ae,q as je,s as Ne,t as Pe,R as Se}from"./vendor-C_X21sW7.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const r of n.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function a(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(t){if(t.ep)return;t.ep=!0;const n=a(t);fetch(t.href,n)}})();const Be="3DNfsn8oRdET1qob8PsoKuWkZ78r6qTCWfMZskUmpJgL",Te={name:"fall",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},Le=[{name:"borrow",discriminator:[228,253,131,202,207,116,89,18],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"borrow_amount",type:"u64"}]},{name:"create_amm",discriminator:[242,91,21,170,5,68,125,64],accounts:[{name:"amm",writable:!0,pda:{seeds:[{kind:"arg",path:"id"}]}},{name:"admin"},{name:"payer",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"id",type:"pubkey"}]},{name:"create_pool",discriminator:[233,146,209,142,207,104,64,188],accounts:[{name:"amm",pda:{seeds:[{kind:"account",path:"amm.id",account:"Amm"}]}},{name:"mint_a"},{name:"mint_b"},{name:"pool",writable:!0,pda:{seeds:[{kind:"account",path:"amm"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"amm"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"fee",type:"u16"}]},{name:"deposit_collateral",discriminator:[156,131,142,116,146,247,162,120],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_b",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount",type:"u64"}]},{name:"deposit_liquidity",discriminator:[245,99,59,25,151,71,233,249],accounts:[{name:"pool",writable:!0,pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"depositor",docs:["The account paying for all rents"],signer:!0},{name:"liquidity_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[98]}]}},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_liquidity",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"liquidity_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount_a",type:"u64"},{name:"amount_b",type:"u64"}]},{name:"init_lending_pool_1",discriminator:[111,87,89,249,229,194,59,237],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"mint_a"},{name:"mint_b"},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"init_lending_pool_2",discriminator:[70,160,247,111,154,255,24,219],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"init_lending_pool_3",discriminator:[226,110,186,213,63,178,83,62],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"lend",discriminator:[89,34,75,168,122,47,185,45],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"lender",signer:!0},{name:"lender_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"lender"},{kind:"const",value:[103]}]}},{name:"lender_lend_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lending_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_lending_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lender_lending_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"user_lending_amount",type:"u64"}]},{name:"liquidate",discriminator:[223,179,226,125,48,46,39,74],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"trader",signer:!0},{name:"trader_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower"},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"price",discriminator:[129,85,239,229,61,225,218,20],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[],returns:{defined:{name:"PriceResult"}}},{name:"redeem",discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"},{kind:"const",value:[97]}]}},{name:"mint_a"},{name:"mint_b"},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"pool.mint_a",account:"Pool"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[101]}]}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"lender_lending_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[105]}]}},{name:"lender",signer:!0},{name:"lender_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lender"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"lender"},{kind:"const",value:[103]}]}},{name:"lender_lending_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lending_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lender_lending_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"lender_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"lender_lending_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"repay",discriminator:[234,103,67,82,208,234,219,166],accounts:[{name:"mint_a"},{name:"mint_b"},{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"lending_pool_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[100]}]}},{name:"lending_pool_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"lending_pool_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"lending_pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrow_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[102]}]}},{name:"collateral_receipt_token_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[104]}]}},{name:"borrower_borrow_block_height_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[106]}]}},{name:"borrower",signer:!0},{name:"borrower_token_a",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_token_b",writable:!0,pda:{seeds:[{kind:"account",path:"borrower"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_authority",pda:{seeds:[{kind:"account",path:"pool"},{kind:"account",path:"borrower"},{kind:"const",value:[103]}]}},{name:"borrower_borrow_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrow_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_collateral_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"collateral_receipt_token_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"borrower_borrow_block_height_receipt_token",writable:!0,pda:{seeds:[{kind:"account",path:"borrower_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"borrower_borrow_block_height_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"swap_exact_tokens_for_tokens",discriminator:[249,86,253,50,177,221,73,162],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"mint_a",relations:["pool"]},{name:"mint_b",relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"trader",signer:!0},{name:"trader_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"trader_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"trader"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"swap_a",type:"bool"},{name:"input_amount",type:"u64"},{name:"min_output_amount",type:"u64"}]},{name:"withdraw_liquidity",discriminator:[149,158,33,185,47,243,253,31],accounts:[{name:"pool",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"pool.mint_a",account:"Pool"},{kind:"account",path:"pool.mint_b",account:"Pool"}]}},{name:"pool_authority",pda:{seeds:[{kind:"account",path:"pool.amm",account:"Pool"},{kind:"account",path:"mint_a"},{kind:"account",path:"mint_b"},{kind:"const",value:[97]}]}},{name:"depositor",signer:!0},{name:"liquidity_mint",writable:!0,pda:{seeds:[{kind:"account",path:"pool"},{kind:"const",value:[98]}]}},{name:"mint_a",writable:!0,relations:["pool"]},{name:"mint_b",writable:!0,relations:["pool"]},{name:"pool_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"pool_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"pool_authority"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_liquidity",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"liquidity_mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_a",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_a"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"depositor_account_b",writable:!0,pda:{seeds:[{kind:"account",path:"depositor"},{kind:"const",value:[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{kind:"account",path:"mint_b"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"payer",docs:["The account paying for all rents"],writable:!0,signer:!0},{name:"token_program",docs:["Solana ecosystem accounts"],address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"associated_token_program",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount",type:"u64"}]}],Ee=[{name:"Amm",discriminator:[143,245,200,17,74,214,196,135]},{name:"Pool",discriminator:[241,154,109,4,17,177,109,188]}],Ie=[{code:6e3,name:"CalculationError",msg:"Calculation error"},{code:6001,name:"CalculationError1",msg:"Calculation error"},{code:6002,name:"InvalidFee",msg:"Invalid fee"}],Ce=[{name:"Amm",type:{kind:"struct",fields:[{name:"id",docs:["The primary key of the AMM"],type:"pubkey"},{name:"admin",docs:["Account that has admin authority over the AMM"],type:"pubkey"}]}},{name:"Pool",type:{kind:"struct",fields:[{name:"amm",docs:["Primary key of the AMM"],type:"pubkey"},{name:"mint_a",docs:["Mint of token A"],type:"pubkey"},{name:"mint_b",docs:["Mint of token B"],type:"pubkey"},{name:"fee",docs:["The LP fee taken on each trade, in basis points"],type:"u16"},{name:"token_a_amount",docs:["借贷池中token a的数量"],type:"u64"},{name:"token_b_amount",docs:["借贷池中token b的数量"],type:"u64"},{name:"min_collateral_ratio",docs:["最小抵押率 (基点表示,20000 = 200%)"],type:"u64"},{name:"borrow_interest_accumulator_block_height",docs:["记录上次借贷池interest_step更新时的区块高度"],type:"u64"},{name:"borrow_interest_accumulator",docs:["借款累计利息,随着区块高度增加而增加,但是增加幅度与资金借出量正相关"],type:"u64"},{name:"share_lending_block_height",docs:["共享借贷累加器区块高度"],type:"u64"},{name:"share_lending_accumulator",docs:["共享借贷累加器,资金借出量的时间积分"],type:"u64"}]}},{name:"PriceResult",type:{kind:"struct",fields:[{name:"token_a_amount",type:"u64"},{name:"token_b_amount",type:"u64"}]}}],Re=[{name:"AUTHORITY_SEED",type:"bytes",value:"[97]"},{name:"BASE_RATE",type:"u64",value:"10000"},{name:"BORROWER_AUTHORITY_SEED",type:"bytes",value:"[103]"},{name:"BORROWER_BORROW_BLOCK_HEIGHT_TOKEN_SEED",type:"bytes",value:"[106]"},{name:"BORROW_TOKEN_SEED",type:"bytes",value:"[102]"},{name:"COLLATERAL_TOKEN_SEED",type:"bytes",value:"[104]"},{name:"LENDER_LENDING_BLOCK_HEIGHT_TOKEN_SEED",type:"bytes",value:"[105]"},{name:"LENDING_AUTHORITY_SEED",type:"bytes",value:"[100]"},{name:"LENDING_TOKEN_SEED",type:"bytes",value:"[101]"},{name:"LIQUIDITY_SEED",type:"bytes",value:"[98]"},{name:"MINIMUM_LIQUIDITY",type:"u64",value:"100"},{name:"MIN_COLLATERAL_RATIO_BASE",type:"u64",value:"10000"}],j={address:Be,metadata:Te,instructions:Le,accounts:Ee,errors:Ie,types:Ce,constants:Re};async function De(o,s,a){try{const i=new C(s,o,{preflightCommitment:"confirmed"}),t=new R(j,i),[n]=p.findProgramAddressSync([a.toBuffer()],t.programId);return await t.methods.createAmm(a).accounts({amm:n,admin:i.wallet.publicKey,payer:i.wallet.publicKey,systemProgram:T.programId}).rpc()}catch(i){throw console.error("Error details:",i),i}}const Me=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState(""),[t,n]=k.useState("500"),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),i(""),m(!0),!o){i("Please connect your wallet first"),m(!1);return}const d=Number(t);if(d<1||d>1e4){i("Fee must be between 1 and 10000"),m(!1);return}try{const h=p.unique(),b=await De(o,s,h);console.log(`Transaction URL: https://explorer.solana.com/tx/${b}`),g(h.toString()),n("500")}catch(h){console.error("Error creating AMM:",h),i(h instanceof Error?h.message:"Failed to create AMM. Please try again.")}finally{m(!1)}};return e.jsxs("div",{className:"create-amm-container",children:[a&&e.jsx("div",{className:"error-message",children:a}),l&&e.jsxs("div",{className:"success-message",children:["AMM created successfully! ID: ",l]}),e.jsx("form",{onSubmit:u,className:"form",children:e.jsx("button",{type:"submit",className:"submit-button",disabled:r||!o,children:r?"Creating...":"Create AMM"})})]})},Fe=async(o,s)=>{console.log("Getting AMM accounts connection:",s);const a=new C(s,o,{preflightCommitment:"confirmed"}),t=await new R(j,a).account.amm.all();for(const n of t)console.log("AMM Account Details:",{publicKey:n.publicKey.toString(),id:n.account.id.toString(),admin:n.account.admin.toString()});return t.map(n=>({pubkey:n.publicKey.toString(),ammid:n.account.id.toString()}))},me=k.createContext(void 0),qe=({children:o})=>{const[s,a]=k.useState(null);return e.jsx(me.Provider,{value:{amm:s,setAmm:a},children:o})},ie=()=>{const o=k.useContext(me);if(!o)throw new Error("useAmm must be used within an AmmProvider");return o},Ke=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[t,n]=k.useState(!1),[r,m]=k.useState(""),{setAmm:l}=ie(),g=async()=>{if(o){n(!0);try{const c=await Fe(o,s);i(c),c.length>0&&l(c[0])}catch(c){console.error("Error fetching AMMs:",c),m(c instanceof Error?c.message:"Failed to fetch AMMs")}finally{n(!1)}}};k.useEffect(()=>{g()},[o,s]);const u=c=>{l(c)};return e.jsxs("div",{className:"create-amm-container",children:[e.jsx("h2",{children:"Existing AMMs"}),r&&e.jsx("div",{className:"error-message",children:r}),t?e.jsx("div",{children:"Loading AMMs..."}):a.length===0?e.jsx("div",{className:"form-group",children:e.jsx("p",{children:"No AMMs found"})}):e.jsx("div",{className:"form-group",children:a.map(c=>e.jsxs("div",{className:"amm-item",onClick:()=>u(c),children:[e.jsxs("div",{className:"amm-details",children:[e.jsx("span",{className:"amm-label",children:"AMM Pubkey:"}),e.jsx("span",{className:"amm-value",children:c.pubkey})]}),e.jsxs("div",{className:"amm-details",children:[e.jsx("span",{className:"amm-label",children:"AMM ID:"}),e.jsxs("span",{className:"amm-value",children:[c.ammid," bps"]})]})]},c.pubkey))})]})};var de;const Oe=(de=j.constants.find(o=>o.name==="BASE_RATE"))==null?void 0:de.value,M="a",ue="b",F="d",$="e",q="f",U="g",O="h",oe="i",X="j";async function We(o,s,a,i,t,n){try{console.log("Step 1: Creating provider");const r=new C(s,o,{commitment:"confirmed",preflightCommitment:"confirmed"}),m=new R(j,r),[l]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),t.toBuffer()],m.programId),[g]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),t.toBuffer(),f.from(M)],m.programId),[u]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),t.toBuffer(),f.from(ue)],m.programId),c=await _.token.associatedAddress({mint:i,owner:g}),d=await _.token.associatedAddress({mint:t,owner:g}),[h]=p.findProgramAddressSync([l.toBuffer(),f.from(F)],m.programId),[b]=p.findProgramAddressSync([l.toBuffer(),f.from($)],m.programId),[w]=p.findProgramAddressSync([l.toBuffer(),f.from(q)],m.programId),[y]=p.findProgramAddressSync([l.toBuffer(),f.from(O)],m.programId),x=await _.token.associatedAddress({mint:i,owner:h}),v=await _.token.associatedAddress({mint:t,owner:h}),[A]=p.findProgramAddressSync([l.toBuffer(),f.from(oe)],m.programId),[N]=p.findProgramAddressSync([l.toBuffer(),f.from(X)],m.programId),S=Z.setComputeUnitLimit({units:1e6});console.log("Step 1: Creating pool...");let K="";await z(s,l)?console.log("Pool already exists, skipping..."):(K=await m.methods.createPool(n).accounts({amm:a,mintA:i,mintB:t,pool:l,poolAuthority:g,mintLiquidity:u,poolAccountA:c,poolAccountB:d,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([S]).rpc({commitment:"confirmed"}),await s.confirmTransaction(K,"confirmed"),console.log("Transaction signature:",K)),console.log("Step 2: Initializing lending pool...");let W="";await z(s,x)?console.log("Lending pool 1 already initialized, skipping..."):(W=await m.methods.initLendingPool1().accounts({pool:l,mintA:i,mintB:t,lendingPoolAuthority:h,lendingPoolTokenA:x,lendingPoolTokenB:v,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(W,"confirmed")),console.log("Step 3: Initializing lending pool...");let G="";await z(s,b)?console.log("Lending pool 2 already initialized, skipping..."):(G=await m.methods.initLendingPool2().accounts({pool:l,lendingPoolAuthority:h,lendingReceiptTokenMint:b,borrowReceiptTokenMint:w,collateralReceiptTokenMint:y,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(G,"confirmed")),console.log("Step 4: Initializing lending pool...");let V="";return await z(s,A)?console.log("Lending pool 3 already initialized, skipping..."):(V=await m.methods.initLendingPool3().accounts({pool:l,lendingPoolAuthority:h,lenderLendingBlockHeightMint:A,borrowerBorrowBlockHeightMint:N,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).rpc(),await s.confirmTransaction(V,"confirmed")),{tx:K,initTx1:W,initTx2:G,initTx3:V}}catch(r){console.error("Error",r)}return{tx:"",initTx1:"",initTx2:"",initTx3:""}}async function z(o,s){return await o.getAccountInfo(s)!==null}const Ge=()=>{const o=I(),{connection:s}=P(),{amm:a}=ie(),[i,t]=k.useState(""),[n,r]=k.useState(!1),[m,l]=k.useState(""),[g,u]=k.useState({mintA:"",mintB:"",fee:"500"}),c=async d=>{if(d.preventDefault(),t(""),l(""),r(!0),!o){t("Please connect your wallet first"),r(!1);return}if(!a){t("Please select an AMM first"),r(!1);return}try{const h=new p(a.pubkey),b=new p(g.mintA),w=new p(g.mintB),y=await We(o,s,h,b,w,Number(g.fee));console.log(`Transaction URL: https://explorer.solana.com/tx/${y}`),l(y.toString()),u({mintA:"",mintB:"",fee:"500"})}catch(h){console.error("Error creating pool:",h),t(h instanceof Error?h.message:"Failed to create pool")}finally{r(!1)}};return e.jsx("div",{children:e.jsxs("div",{className:"create-amm-container",children:[e.jsx("h2",{children:"Create Pool"}),i&&e.jsx("div",{className:"error-message",children:i}),m&&e.jsxs("div",{className:"success-message",children:["Pool created successfully!",e.jsx("a",{href:`https://explorer.solana.com/tx/${m}`,target:"_blank",rel:"noopener noreferrer",children:"View transaction"})]}),e.jsxs("form",{onSubmit:c,className:"form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"AMM Pubkey:"}),e.jsx("input",{type:"text",value:a?a.pubkey:"",readOnly:!0,disabled:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Token A Mint Address:"}),e.jsx("input",{type:"text",value:g.mintA,onChange:d=>u({...g,mintA:d.target.value}),placeholder:"Enter token A mint address",required:!0,disabled:n})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Token B Mint Address:"}),e.jsx("input",{type:"text",value:g.mintB,onChange:d=>u({...g,mintB:d.target.value}),placeholder:"Enter token B mint address",required:!0,disabled:n})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Fee (in basis points, 1-10000, default: 500 or 5%):"}),e.jsx("input",{type:"text",value:g.fee,onChange:d=>u({...g,fee:d.target.value}),placeholder:"500",required:!0,disabled:n})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:n||!o,children:n?"Creating...":"Create Pool"})]})]})})};async function ce(o,s){try{const a=new C(s,o,{preflightCommitment:"confirmed"});return(await new R(j,a).account.pool.all()).map(n=>({pubkey:n.publicKey.toString(),amm:n.account.amm.toString(),mintA:n.account.mintA.toString(),mintB:n.account.mintB.toString(),fee:n.account.fee.toString(),minCollateralRatio:n.account.minCollateralRatio.toString(),tokenAAmount:n.account.tokenAAmount.toString(),tokenBAmount:n.account.tokenBAmount.toString()}))}catch(a){throw console.error("Error fetching pool accounts:",a),a}}async function te(o,s,a){try{const i=new p(s.pubkey),t=new p(s.mintA),n=new p(s.mintB),[r]=p.findProgramAddressSync([new p(s.amm).toBuffer(),new p(s.mintA).toBuffer(),new p(s.mintB).toBuffer(),f.from(M)],new p(j.address)),m=await B(new p(s.mintA),r,!0),l=await B(new p(s.mintB),r,!0),[g]=p.findProgramAddressSync([i.toBuffer(),a.toBuffer(),f.from(U)],new p(j.address)),u=await D(o,m),c=await D(o,l),d=Number(u.amount),h=Number(c.amount),b=h/d,w=d/h,[y]=p.findProgramAddressSync([i.toBuffer(),f.from(F)],new p(j.address)),[x]=p.findProgramAddressSync([i.toBuffer(),f.from($)],new p(j.address)),[v]=p.findProgramAddressSync([i.toBuffer(),f.from(q)],new p(j.address)),[A]=p.findProgramAddressSync([i.toBuffer(),f.from(O)],new p(j.address)),N=await B(t,y,!0),S=await B(n,y,!0),K=await D(o,N),W=await D(o,S),G=await ne(o,x),V=await ne(o,v),ge=await ne(o,A);console.log("walletPublicKey",a);const he=await H(t,a,!0),ke=await B(n,a,!0),fe=await D(o,he),be=await D(o,ke),we=await re(o,g,x),ye=await re(o,g,v),_e=await re(o,g,A);return{pool:{aToB:b,bToA:w,tokenAAmount:d,tokenBAmount:h},lendingPool:{tokenAAmount:Number(K.amount),tokenBAmount:Number(W.amount),lendingReceiptSupply:Number(G.supply),borrowReceiptSupply:Number(V.supply),collateralReceiptSupply:Number(ge.supply),addresses:{lendingReceipt:x.toString(),borrowReceipt:v.toString(),collateralReceipt:A.toString()}},userAssets:{tokenAAmount:fe.amount.toString(),tokenBAmount:be.amount.toString(),lendingReceiptAmount:we.toString(),borrowReceiptAmount:ye.toString(),collateralReceiptAmount:_e.toString()}}}catch(i){throw console.error("Error getting lending pool details:",i),i}}async function re(o,s,a){try{const i=await B(a,s,!0),t=await D(o,i);return Number(t.amount)}catch(i){return console.log("getUserTokenAmount",i),0}}async function He(o,s,a,i,t,n,r,m,l){try{const g=new C(s,o,{preflightCommitment:"confirmed"}),u=new R(j,g),[c]=p.findProgramAddressSync([i.toBuffer(),t.toBuffer(),n.toBuffer(),f.from(M)],u.programId),d=await B(t,c,!0),h=await B(n,c,!0),b=await B(t,o.publicKey,!0),w=await B(n,o.publicKey,!0);return await u.methods.swapExactTokensForTokens(r,new Y.BN(m),new Y.BN(l)).accounts({amm:i,pool:a,poolAuthority:c,trader:o.publicKey,mintA:t,mintB:n,poolAccountA:d,poolAccountB:h,traderAccountA:b,traderAccountB:w,payer:o.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc()}catch(g){throw console.error("Error in swap:",g),g}}const Ue=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(!0),[u,c]=k.useState({inputAmount:"",minOutputAmount:""}),d=async h=>{h.preventDefault(),m(""),n(!0);try{const b=parseFloat(u.inputAmount),w=parseFloat(u.minOutputAmount),y=await He(a,i,new p(o.pubkey),new p(o.amm),new p(o.mintA),new p(o.mintB),l,b,w);s(y),c({inputAmount:"",minOutputAmount:""})}catch(b){console.error("Error in swap:",b),m(b instanceof Error?b.message:"Failed to swap")}finally{n(!1)}};return e.jsxs("form",{onSubmit:d,className:"swap-form",children:[r&&e.jsx("div",{className:"error-message",children:r}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"swap-direction",children:[e.jsx("button",{type:"button",className:`direction-button ${l?"active":""}`,onClick:()=>g(!0),children:"A → B"}),e.jsx("button",{type:"button",className:`direction-button ${l?"":"active"}`,onClick:()=>g(!1),children:"B → A"})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Input Amount:"}),e.jsx("input",{type:"number",step:"any",value:u.inputAmount,onChange:h=>c({...u,inputAmount:h.target.value}),placeholder:`Enter amount for token ${l?"A":"B"}`,required:!0,disabled:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Minimum Output Amount:"}),e.jsx("input",{type:"number",step:"any",value:u.minOutputAmount,onChange:h=>c({...u,minOutputAmount:h.target.value}),placeholder:`Minimum amount of token ${l?"B":"A"}`,required:!0,disabled:t})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:t||!a,children:t?"Swapping...":"Swap"})]})};async function Ve(o,s,a,i,t,n,r,m){try{const l=new C(s,o,{preflightCommitment:"confirmed"}),g=new R(j,l),[u]=p.findProgramAddressSync([i.toBuffer(),t.toBuffer(),n.toBuffer(),f.from(M)],g.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(ue)],g.programId),d=await B(t,u,!0),h=await B(n,u,!0),b=await B(t,o.publicKey,!0),w=await B(n,o.publicKey,!0),y=await B(c,o.publicKey,!0);return await g.methods.depositLiquidity(new Y.BN(r),new Y.BN(m)).accounts({pool:a,poolAuthority:u,mintA:t,mintB:n,depositor:o.publicKey,mintLiquidity:c,poolAccountA:d,poolAccountB:h,depositorAccountLiquidity:y,depositorAccountA:b,depositorAccountB:w,payer:o.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc({skipPreflight:!1,maxRetries:3,commitment:"confirmed"})}catch(l){throw console.error("Error in depositLiquidity:",l),l}}const Qe=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState({amountA:"",amountB:""}),u=async c=>{c.preventDefault(),m(""),n(!0);try{const d=parseFloat(l.amountA),h=parseFloat(l.amountB),b=await Ve(a,i,new p(o.pubkey),new p(o.amm),new p(o.mintA),new p(o.mintB),d,h);s(b),g({amountA:"",amountB:""})}catch(d){console.error("Error depositing liquidity:",d),m(d instanceof Error?d.message:"Failed to deposit liquidity")}finally{n(!1)}};return e.jsxs("form",{onSubmit:u,className:"deposit-form",children:[r&&e.jsx("div",{className:"error-message",children:r}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount Token A:"}),e.jsx("input",{type:"number",step:"any",value:l.amountA,onChange:c=>g({...l,amountA:c.target.value}),placeholder:"Enter amount for token A",required:!0,disabled:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount Token B:"}),e.jsx("input",{type:"number",step:"any",value:l.amountB,onChange:c=>g({...l,amountB:c.target.value}),placeholder:"Enter amount for token B",required:!0,disabled:t})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:t||!a,children:t?"Depositing...":"Confirm Deposit"})]})};async function Ze(o,s,a,i,t){try{const n=new C(s,o,{commitment:"confirmed",preflightCommitment:"confirmed"}),r=new R(j,n),[m]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],r.programId),[l]=p.findProgramAddressSync([a.toBuffer(),f.from($)],r.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),c=await _.token.associatedAddress({mint:i,owner:m}),d=await _.token.associatedAddress({mint:t,owner:m}),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],r.programId),[b]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),w=Z.setComputeUnitLimit({units:1e6});console.log("Step 1: Initializing lending pool...");let y="";await se(s,c)?console.log("Lending pool 1 already initialized, skipping..."):(y=await r.methods.initLendingPool1().accounts({pool:a,mintA:i,mintB:t,lendingPoolAuthority:m,lendingPoolTokenA:c,lendingPoolTokenB:d,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(y,"confirmed")),console.log("Step 2: Initializing lending pool...");let x="";await se(s,u)?console.log("Lending pool 2 already initialized, skipping..."):(x=await r.methods.initLendingPool2().accounts({pool:a,lendingPoolAuthority:m,lendingReceiptTokenMint:l,borrowReceiptTokenMint:g,collateralReceiptTokenMint:u,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(x,"confirmed")),console.log("Step 3: Initializing lending pool...");let v="";return await se(s,h)?console.log("Lending pool 3 already initialized, skipping..."):(v=await r.methods.initLendingPool3().accounts({pool:a,lendingPoolAuthority:m,lenderLendingBlockHeightMint:h,borrowerBorrowBlockHeightMint:b,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId,rent:Q}).preInstructions([w]).rpc({commitment:"confirmed"}),await s.confirmTransaction(v,"confirmed")),{initTx1:y,initTx2:x,initTx3:v}}catch(n){console.error("Error",n)}return{initTx1:"",initTx2:"",initTx3:""}}async function se(o,s){return await o.getAccountInfo(s)!==null}const Je=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),{amm:t}=ie(),[n,r]=k.useState(""),[m,l]=k.useState(!1),g=async()=>{if(r(""),l(!0),!a){r("Please connect your wallet first"),l(!1);return}if(!t){r("Please select an AMM first"),l(!1);return}try{const u=new p(o.pubkey),c=new p(o.mintA),d=new p(o.mintB),h=await Ze(a,i,u,c,d);console.log(`Transaction URL: https://explorer.solana.com/tx/${h}`),s&&s(h.toString())}catch(u){console.error("Error initializing pool:",u),r(u instanceof Error?u.message:"Failed to initialize pool")}finally{l(!1)}};return e.jsxs("div",{className:"init-pool-container",children:[n&&e.jsx("div",{className:"error-message",children:n}),e.jsx("button",{onClick:g,className:"submit-button",disabled:m||!a,children:m?"Initializing...":"Initialize Pool"})]})},$e=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[t,n]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await te(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"AMM Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.amm.toString(),children:o.amm.toString()})]}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Fee:"}),e.jsx("span",{className:"pool-value",title:o.fee.toString(),children:o.fee})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Min Collateral Ratio:"}),e.jsx("span",{className:"pool-value",title:o.minCollateralRatio.toString(),children:o.minCollateralRatio})]})]}),e.jsx("div",{className:"pool-actions",children:e.jsx("button",{className:"action-button",onClick:()=>n(t==="initPool"?"none":"initPool"),children:t==="initPool"?"Hide Init Pool":"Init Pool"})}),t==="initPool"&&e.jsx("div",{className:"form-container",children:e.jsx(Je,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})}),e.jsxs("div",{className:"pool-price-info",children:[e.jsx("h4",{children:"Pool Liquidity & Prices"}),l?e.jsx("div",{className:"loading-prices",children:"Loading prices..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A Reserve:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B Reserve:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenBAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (A → B):"}),e.jsxs("span",{className:"pool-value",children:["1 A = ",r.pool.aToB.toFixed(6)," B"]})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (B → A):"}),e.jsxs("span",{className:"pool-value",children:["1 B = ",r.pool.bToA.toFixed(6)," A"]})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load prices"})]}),e.jsxs("div",{className:"pool-actions",children:[e.jsx("button",{className:"action-button",onClick:()=>n(t==="deposit"?"none":"deposit"),children:t==="deposit"?"Hide Deposit":"Deposit"}),e.jsx("button",{className:"action-button",onClick:()=>n(t==="swap"?"none":"swap"),children:t==="swap"?"Hide Swap":"Swap"})]}),t==="deposit"&&e.jsx("div",{className:"form-container",children:e.jsx(Qe,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})}),t==="swap"&&e.jsx("div",{className:"form-container",children:e.jsx(Ue,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})})]})},Xe=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){n(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{n(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),t?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx($e,{pool:d,onTxSuccess:c},d.pubkey.toString()))})]})};async function ze(o,s,a,i){try{console.log("Executing liquidate...");const t=new C(s,o,{preflightCommitment:"confirmed"}),n=new R(j,t),r=await n.account.pool.fetch(a),m=r.mintA,l=r.mintB,[g]=p.findProgramAddressSync([r.amm.toBuffer(),m.toBuffer(),l.toBuffer(),f.from(M)],n.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],n.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],n.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],n.programId),[h]=p.findProgramAddressSync([a.toBuffer(),i.toBuffer(),f.from(U)],n.programId),b=await _.token.associatedAddress({mint:c,owner:h}),w=await _.token.associatedAddress({mint:d,owner:h}),y=H(l,t.wallet.publicKey,!0),x=Z.setComputeUnitLimit({units:2e8});console.log("Sending liquidate transaction...");const v=await n.methods.liquidate().accounts({pool:a,poolAuthority:g,mintA:m,mintB:l,lendingPoolAuthority:u,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,trader:t.wallet.publicKey,traderAccountB:y,borrower:i,borrowerBorrowReceiptToken:b,borrowerCollateralReceiptToken:w,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([x]).rpc();return console.log("Liquidate transaction signature:",v),{tx:v,accounts:{poolKey:a,poolAuthority:g,lendingPoolAuthority:u,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,traderAccountB:y,borrowerBorrowReceiptToken:b,borrowerCollateralReceiptToken:w}}}catch(t){throw console.error("Error in liquidate:",t),t instanceof Error&&console.error("Error details:",{message:t.message,stack:t.stack}),t}}async function Ye(o,s,a){try{const i=new C(a,o,{preflightCommitment:"confirmed"}),t=new R(j,i),n=await t.account.pool.fetch(s),r=n.mintA,m=n.mintB,g=(await te(a,{pubkey:s.toString(),amm:n.amm.toString(),mintA:r.toString(),mintB:m.toString()},o.publicKey)).pool.aToB,[u]=p.findProgramAddressSync([s.toBuffer(),f.from(q)],t.programId),[c]=p.findProgramAddressSync([s.toBuffer(),f.from(O)],t.programId),d=await a.getTokenLargestAccounts(u),h=[];for(const b of d.value){if(b.amount=="0")continue;const w=await D(a,b.address),y=w.owner,x=await eo(a,y,c);console.log("borrowReceiptToken amount",w.amount.toString()),console.log("collateralReceiptTokenAmount",x),console.log("Number(borrowTokenAccountInfo.amount) * 2*poolPrice",Number(w.amount)*2*g),x{const o=I(),{connection:s}=P(),[a,i]=k.useState(""),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),[u,c]=k.useState(""),[d,h]=k.useState([]),[b,w]=k.useState(!1),y=async v=>{if(v.preventDefault(),!o||!r){i("Please connect wallet and enter pool address");return}try{i(""),w(!0);const A=new p(r),N=await Ye(o,A,s);h(N)}catch(A){console.error("Error fetching pending liquidations:",A),i(A instanceof Error?A.message:"Failed to fetch pending liquidations"),h([])}finally{w(!1)}},x=async v=>{if(v.preventDefault(),i(""),n(!0),!o){i("Please connect your wallet first"),n(!1);return}let A,N;try{A=new p(r),N=new p(l)}catch{i("Invalid pool or borrower address"),n(!1);return}try{const S=await ze(o,s,A,N);console.log(`Transaction URL: https://explorer.solana.com/tx/${S.tx}`),c(S.tx),m(""),g("")}catch(S){console.error("Error liquidating position:",S),i(S instanceof Error?S.message:"Failed to liquidate. Please try again.")}finally{n(!1)}};return e.jsxs("div",{className:"liquidate-container",children:[a&&e.jsx("div",{className:"error-message",children:a}),u&&e.jsxs("div",{className:"success-message",children:["Liquidation successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${u}`,target:"_blank",rel:"noopener noreferrer",children:"View transaction"})]}),e.jsxs("div",{className:"search-form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"pool-address",children:"Pool Address:"}),e.jsxs("div",{className:"input-with-button",children:[e.jsx("input",{id:"pool-address",type:"text",value:r,onChange:v=>m(v.target.value),placeholder:"Enter pool address",className:"input-field"}),e.jsx("button",{onClick:y,disabled:b||!o||!r,className:"search-button",children:b?"Searching...":"Search"})]})]}),e.jsxs("div",{className:"pending-liquidations",children:[e.jsx("h3",{children:"Pending Liquidations"}),b?e.jsx("div",{className:"loading",children:"Loading pending liquidations..."}):d.length===0?e.jsx("p",{children:"No pending liquidations found"}):e.jsx("ul",{className:"liquidation-list",children:d.map((v,A)=>e.jsx("li",{className:"liquidation-item",onClick:()=>g(v.userAuthorityPda.toString()),children:e.jsxs("div",{children:["Borrower Authority PDA: ",v.userAuthorityPda.toString()]})},A))})]})]}),e.jsxs("form",{onSubmit:x,className:"liquidate-form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"borrower-address",children:"Note: The current demo does not yet support liquidation based on PDAs. The public key is not the same as the PDA. So the PDA above is useless now. U'd better to use another account to borrow and then liquidate that account with it's Public Key."}),e.jsx("label",{htmlFor:"borrower-address",children:"Borrower Address:"}),e.jsx("input",{id:"borrower-address",type:"text",value:l,onChange:v=>g(v.target.value),placeholder:"Enter borrower address",className:"input-field"})]}),e.jsx("button",{type:"submit",className:"submit-button",disabled:t||!o||!r||!l,children:t?"Liquidating...":"Liquidate Position"})]})]})};async function to(o,s,a,i){try{console.log("Executing lend...");const t=new C(s,o,{preflightCommitment:"confirmed"}),n=new R(j,t),r=await n.account.pool.fetch(a),m=r.mintA,l=r.mintB,[g]=p.findProgramAddressSync([r.amm.toBuffer(),m.toBuffer(),l.toBuffer(),f.from(M)],n.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],n.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from($)],n.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],n.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],n.programId),b=H(m,u,!0),w=H(l,u,!0),y=await _.token.associatedAddress({mint:m,owner:t.wallet.publicKey}),[x]=p.findProgramAddressSync([a.toBuffer(),t.wallet.publicKey.toBuffer(),f.from(U)],n.programId),v=await _.token.associatedAddress({mint:c,owner:x}),A=await _.token.associatedAddress({mint:h,owner:x});return{tx:await n.methods.lend(new ee(i)).accounts({pool:a,lendingPoolAuthority:u,lendingPoolTokenA:b,lendingReceiptTokenMint:c,lenderLendingBlockHeightMint:h,lender:t.wallet.publicKey,lenderTokenA:y,lenderAuthority:x,lenderLendReceiptToken:v,lenderLendingBlockHeightReceiptToken:A,payer:t.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc(),accounts:{poolAuthority:g,lendingPoolAuthority:u,lendingReceiptTokenMint:c,borrowReceiptTokenMint:d,lendingPoolTokenA:b,lendingPoolTokenB:w,lenderTokenA:y,lenderLendReceiptToken:v,lenderLendingBlockHeightReceiptToken:A}}}catch(t){throw console.error("Error in lend:",t),t instanceof Error&&console.error("Error details:",{message:t.message,stack:t.stack}),t}}const no=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),n(""),m(!0),!a){n("Please connect your wallet first"),m(!1);return}try{const d=parseFloat(l);if(isNaN(d)||d<=0)throw new Error("Invalid amount");const h=new p(o.pubkey),b=await to(a,i,h,new ee(d));console.log(`Transaction URL: https://explorer.solana.com/tx/${b.tx}`),g(""),s(b.tx)}catch(d){console.error("Error lending:",d),n(d instanceof Error?d.message:"Failed to lend")}finally{m(!1)}};return console.log(o),e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Lend Tokens"}),t&&e.jsx("div",{className:"error-message",children:t}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to Lend:"}),e.jsx("input",{type:"number",value:l,onChange:c=>g(c.target.value),placeholder:"Enter amount to lend",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lendingPool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString()]}),e.jsxs("div",{children:["Token A: ",o.mintA.toString()]}),e.jsxs("div",{children:["Token B: ",o.mintB.toString()]})]}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Lend"})]})]})};async function ao(o,s,a){try{const i=new C(s,o,{preflightCommitment:"confirmed"}),t=new R(j,i),n=await t.account.pool.fetch(a),r=n.mintA,m=n.mintB,[l]=p.findProgramAddressSync([n.amm.toBuffer(),r.toBuffer(),m.toBuffer(),f.from(M)],t.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],t.programId),u=await _.token.associatedAddress({mint:r,owner:g}),c=await _.token.associatedAddress({mint:m,owner:g}),[d]=p.findProgramAddressSync([a.toBuffer(),f.from($)],t.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],t.programId),[b]=p.findProgramAddressSync([a.toBuffer(),f.from(oe)],t.programId),w=await _.token.associatedAddress({mint:r,owner:i.wallet.publicKey}),y=await _.token.associatedAddress({mint:m,owner:i.wallet.publicKey}),[x]=p.findProgramAddressSync([a.toBuffer(),i.wallet.publicKey.toBuffer(),f.from(U)],t.programId),v=await _.token.associatedAddress({mint:d,owner:x}),A=await _.token.associatedAddress({mint:b,owner:x});console.log("Sending redeem transaction...");const N=await t.methods.redeem().accounts({pool:a,poolAuthority:l,mintA:r,mintB:m,lendingPoolAuthority:g,lendingPoolTokenA:u,lendingPoolTokenB:c,lendingReceiptTokenMint:d,borrowReceiptTokenMint:h,lenderLendingBlockHeightTokenMint:b,lender:i.wallet.publicKey,lenderTokenA:w,lenderTokenB:y,lenderLendingReceiptToken:v,lenderLendingBlockHeightReceiptToken:A,payer:i.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc();return console.log("Redeem transaction signature:",N),N}catch(i){throw console.error("Error in redeem:",i),i}}const ro=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(""),[r,m]=k.useState(!1),l=async g=>{if(g.preventDefault(),n(""),m(!0),!a){n("Please connect your wallet first"),m(!1);return}try{const u=new p(o.pubkey),c=await ao(a,i,u);console.log(`Transaction URL: https://explorer.solana.com/tx/${c}`),s(c)}catch(u){console.error("Error redeeming:",u),n(u instanceof Error?u.message:"Failed to redeem")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Redeem Tokens"}),t&&e.jsx("div",{className:"error-message",children:t}),e.jsxs("form",{onSubmit:l,children:[e.jsxs("div",{className:"lending-pool-info-summary",children:[e.jsxs("div",{children:["Min Collateral Ratio: ",(o.minCollateralRatio/100).toFixed(2),"%"]}),e.jsxs("div",{children:["Base Rate: ",Oe,"%"]})]}),e.jsx("div",{className:"warning-message",children:"Note: This will redeem all your lending receipt tokens."}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Redeem"})]})]})},so=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[t,n]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await te(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]})]}),e.jsxs("div",{className:"lending-pool-info",children:[e.jsx("h4",{children:"Lending Pool"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenAAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenBAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenBAmount.toFixed(6)})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-assets-details",children:[e.jsx("h4",{children:"Your Assets"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenA Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenAAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenB Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenBAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-lending-details",children:[e.jsx("h4",{children:"Your lending details"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"lended tokenB amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.lendingReceiptAmount})]})}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsx("div",{className:"lending-pool-actions",children:e.jsxs("div",{className:"lending-pool-action-buttons",children:[e.jsx("button",{className:"lending-pool-action-button",onClick:()=>n(t==="lend"?"none":"lend"),children:t==="lend"?"Hide Lend":"Lend"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>n(t==="redeem"?"none":"redeem"),children:t==="redeem"?"Hide Redeem":"Redeem"})]})}),e.jsx("div",{className:"lending-pool-actions",children:e.jsx("button",{className:"lending-pool-refresh-button",onClick:u,disabled:l,children:l?"Loading...":"🔄 Refresh"})}),t==="lend"&&e.jsx("div",{className:"form-container",children:e.jsx(no,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})}),t==="redeem"&&e.jsx("div",{className:"form-container",children:e.jsx(ro,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})})]})},io=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){n(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{n(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),t?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx(so,{pool:d,onTxSuccess:c}))})]})};async function co(o,s,a,i,t,n){try{console.log("Executing borrow...");const r=new C(s,o,{preflightCommitment:"confirmed"}),m=new R(j,r),l=await m.account.pool.fetch(a);console.log("Pool info:",{amm:l.amm.toString(),mintA:l.mintA.toString(),mintB:l.mintB.toString()});const[g]=p.findProgramAddressSync([l.amm.toBuffer(),i.toBuffer(),t.toBuffer(),f.from(M)],m.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],m.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],m.programId),[d]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],m.programId),[h]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],m.programId),b=await _.token.associatedAddress({mint:i,owner:g}),w=await _.token.associatedAddress({mint:t,owner:g}),y=await _.token.associatedAddress({mint:i,owner:u}),x=await _.token.associatedAddress({mint:t,owner:u}),v=await _.token.associatedAddress({mint:i,owner:r.wallet.publicKey}),A=await _.token.associatedAddress({mint:t,owner:r.wallet.publicKey}),[N]=p.findProgramAddressSync([a.toBuffer(),r.wallet.publicKey.toBuffer(),f.from(U)],m.programId),S=await _.token.associatedAddress({mint:c,owner:N}),K=await _.token.associatedAddress({mint:d,owner:N}),W=await _.token.associatedAddress({mint:h,owner:N});console.log("Sending borrow transaction...");const G=Z.setComputeUnitLimit({units:1e6});return await m.methods.borrow(n).accounts({pool:a,poolAuthority:g,mintA:i,mintB:t,poolAccountA:b,poolAccountB:w,lendingPoolAuthority:u,lendingPoolTokenA:y,lendingPoolTokenB:x,borrowReceiptTokenMint:c,collateralReceiptTokenMint:d,borrowerBorrowBlockHeightTokenMint:h,borrower:r.wallet.publicKey,borrowerTokenA:v,borrowerTokenB:A,borrowerBorrowReceiptToken:S,borrowerCollateralReceiptToken:K,borrowerBorrowBlockHeightReceiptToken:W,payer:r.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([G]).rpc()}catch(r){throw console.error("Error in borrow:",r),r instanceof Error&&console.error("Error details:",{message:r.message,stack:r.stack}),r}}const lo=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async d=>{if(d.preventDefault(),n(""),m(!0),!a){n("Please connect your wallet first"),m(!1);return}try{const h=parseFloat(l);if(isNaN(h)||h<=0)throw new Error("Invalid borrow amount");const b=new p(o.pubkey),w=new p(o.mintA),y=new p(o.mintB),x=await co(a,i,b,w,y,new ee(h));console.log(`Transaction URL: https://explorer.solana.com/tx/${x}`),g(""),s(x)}catch(h){console.error("Error borrowing:",h),n(h instanceof Error?h.message:"Failed to borrow")}finally{m(!1)}},c=(o.minCollateralRatio/100).toFixed(2);return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Borrow Tokens"}),t&&e.jsx("div",{className:"error-message",children:t}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to Borrow (Token A):"}),e.jsx("input",{type:"number",value:l,onChange:d=>g(d.target.value),placeholder:"Enter amount to borrow",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lending-pool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString().slice(0,4),"...",o.pubkey.toString().slice(-4)]}),e.jsxs("div",{children:["Token A (Borrow): ",o.mintA.toString().slice(0,4),"...",o.mintA.toString().slice(-4)]}),e.jsxs("div",{children:["Token B (Collateral): ",o.mintB.toString().slice(0,4),"...",o.mintB.toString().slice(-4)]}),e.jsxs("div",{children:["Min Collateral Ratio: ",c,"%"]}),e.jsxs("div",{children:["Base Rate: ",(o.fee/100).toFixed(2),"%"]})]}),e.jsx("div",{className:"warning-message",children:"Note: Please ensure you provide sufficient collateral based on the minimum collateral ratio."}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Borrow"})]})]})};async function mo(o,s,a,i,t){try{console.log("Executing repay...");const n=new C(s,o,{preflightCommitment:"confirmed"}),r=new R(j,n),m=await r.account.pool.fetch(a),[l]=p.findProgramAddressSync([m.amm.toBuffer(),i.toBuffer(),t.toBuffer(),f.from(M)],r.programId),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(q)],r.programId),[c]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),d=await _.token.associatedAddress({mint:i,owner:g}),h=await _.token.associatedAddress({mint:t,owner:g}),b=await _.token.associatedAddress({mint:i,owner:n.wallet.publicKey}),w=await _.token.associatedAddress({mint:t,owner:n.wallet.publicKey}),[y]=p.findProgramAddressSync([a.toBuffer(),n.wallet.publicKey.toBuffer(),f.from(U)],r.programId),x=await _.token.associatedAddress({mint:u,owner:y}),v=await _.token.associatedAddress({mint:c,owner:y}),[A]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),N=await _.token.associatedAddress({mint:A,owner:y});console.log("Sending repay transaction...");const S=await r.methods.repay().accounts({mintA:i,mintB:t,pool:a,poolAuthority:l,lendingPoolAuthority:g,lendingPoolTokenA:d,lendingPoolTokenB:h,borrowReceiptTokenMint:u,collateralReceiptTokenMint:c,borrowerBorrowBlockHeightMint:A,borrower:n.wallet.publicKey,borrowerTokenA:b,borrowerTokenB:w,borrowerAuthority:y,borrowerBorrowReceiptToken:x,borrowerCollateralReceiptToken:v,borrowerBorrowBlockHeightReceiptToken:N,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).rpc();return console.log("Repay transaction signature:",S),S}catch(n){throw console.error("Error in repay:",n),n}}const uo=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(""),[r,m]=k.useState(!1),l=async g=>{if(g.preventDefault(),n(""),m(!0),!a){n("Please connect your wallet first"),m(!1);return}try{const u=new p(o.pubkey),c=new p(o.mintA),d=new p(o.mintB),h=await mo(a,i,u,c,d);console.log(`Transaction URL: https://explorer.solana.com/tx/${h}`),s(h)}catch(u){console.error("Error repaying:",u),n(u instanceof Error?u.message:"Failed to repay")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"Repay Loan"}),t&&e.jsx("div",{className:"error-message",children:t}),e.jsxs("form",{onSubmit:l,children:[e.jsx("div",{className:"form-group",children:e.jsx("div",{className:"info-message",children:"Repaying your loan will return your collateral proportionally."})}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm Repay"})]})]})};async function po(o,s,a,i,t){try{console.log("Executing borrow...");const n=new C(s,o,{preflightCommitment:"confirmed"}),r=new R(j,n),[m]=p.findProgramAddressSync([a.toBuffer(),f.from(F)],r.programId),l=await H(i,m,!0),[g]=p.findProgramAddressSync([a.toBuffer(),f.from(O)],r.programId),[u]=p.findProgramAddressSync([a.toBuffer(),f.from(X)],r.programId),c=H(i,n.wallet.publicKey),[d]=p.findProgramAddressSync([a.toBuffer(),n.wallet.publicKey.toBuffer(),f.from(U)],r.programId),h=await H(g,d,!0),b=await _.token.associatedAddress({mint:u,owner:d});console.log("Sending borrow transaction...");const w=Z.setComputeUnitLimit({units:1e6});return{tx:await r.methods.depositCollateral(t).accounts({pool:a,lendingPoolAuthority:m,lendingPoolTokenB:l,collateralReceiptTokenMint:g,borrowerBorrowBlockHeightTokenMint:u,borrower:n.wallet.publicKey,borrowerTokenB:c,borrowerAuthority:d,borrowerCollateralReceiptToken:h,borrowerBorrowBlockHeightReceiptToken:b,payer:n.wallet.publicKey,tokenProgram:L,associatedTokenProgram:E,systemProgram:T.programId}).preInstructions([w]).rpc()}}catch(n){throw console.error("Error in borrow:",n),n instanceof Error&&console.error("Error details:",{message:n.message,stack:n.stack}),n}}const go=({pool:o,onSuccess:s})=>{const a=I(),{connection:i}=P(),[t,n]=k.useState(""),[r,m]=k.useState(!1),[l,g]=k.useState(""),u=async c=>{if(c.preventDefault(),n(""),m(!0),!a){n("Please connect your wallet first"),m(!1);return}try{const d=parseFloat(l);if(isNaN(d)||d<=0)throw new Error("Invalid amount");const h=new p(o.pubkey),b=new p(o.mintB),w=await po(a,i,h,b,new ee(d));console.log(`Transaction URL: https://explorer.solana.com/tx/${w.tx}`),g(""),s(w.tx)}catch(d){console.error("Error lending:",d),n(d instanceof Error?d.message:"Failed to lend")}finally{m(!1)}};return e.jsxs("div",{className:"form-wrapper",children:[e.jsx("h3",{children:"DepositCollateral Tokens"}),t&&e.jsx("div",{className:"error-message",children:t}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Amount to DepositCollateral:"}),e.jsx("input",{type:"number",value:l,onChange:c=>g(c.target.value),placeholder:"Enter amount of collateral to deposit",required:!0,min:"0",step:"any",disabled:r})]}),e.jsxs("div",{className:"lendingPool-info-summary",children:[e.jsxs("div",{children:["Pool: ",o.pubkey.toString()]}),e.jsxs("div",{children:["Token A: ",o.mintA.toString()]}),e.jsxs("div",{children:["Token B: ",o.mintB.toString()]})]}),e.jsx("button",{type:"submit",className:"action-button",disabled:r||!a,children:r?"Processing...":"Confirm DepositCollateral"})]})]})},ho=({pool:o,onTxSuccess:s})=>{const{connection:a}=P(),{publicKey:i}=J(),[t,n]=k.useState("none"),[r,m]=k.useState(null),[l,g]=k.useState(!1),u=async()=>{try{g(!0);const c=await te(a,{pubkey:o.pubkey.toString(),amm:o.amm.toString(),mintA:o.mintA.toString(),mintB:o.mintB.toString()},i||new p(""));m(c)}catch(c){console.error("Error fetching pool prices:",c)}finally{g(!1)}};return k.useEffect(()=>{u()},[o,a,i]),e.jsxs("div",{className:"pool-item",children:[e.jsx("div",{className:"pool-header",children:e.jsx("h3",{children:"Pool Details"})}),e.jsxs("div",{className:"pool-info",children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Pool Pubkey:"}),e.jsx("span",{className:"pool-value",title:o.pubkey.toString(),children:o.pubkey.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token A mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintA.toString(),children:o.mintA.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Token B mint addr:"}),e.jsx("span",{className:"pool-value",title:o.mintB.toString(),children:o.mintB.toString()})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Min Collateral Ratio:"}),e.jsx("span",{className:"pool-value",title:o.minCollateralRatio.toString(),children:o.minCollateralRatio})]})]}),e.jsxs("div",{className:"pool-price-info",children:[e.jsx("h4",{children:"Prices"}),l?e.jsx("div",{className:"loading-prices",children:"Loading prices..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"TokenA Amount:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"TokenB Amount:"}),e.jsx("span",{className:"pool-value",children:r.pool.tokenBAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (A → B):"}),e.jsxs("span",{className:"pool-value",children:["1 A = ",r.pool.aToB.toFixed(6)," B"]})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Price (B → A):"}),e.jsxs("span",{className:"pool-value",children:["1 B = ",r.pool.bToA.toFixed(6)," A"]})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load prices"})]}),e.jsxs("div",{className:"lending-pool-info",children:[e.jsx("h4",{children:"Lending Pool"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenAAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenAAmount.toFixed(6)})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"Lending Pool tokenBAmount:"}),e.jsx("span",{className:"pool-value",children:r.lendingPool.tokenBAmount.toFixed(6)})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-assets-details",children:[e.jsx("h4",{children:"Your Assets"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenA Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenAAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"tokenB Balance:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.tokenBAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"user-lending-details",children:[e.jsx("h4",{children:"Your borrowing details"}),l?e.jsx("div",{className:"loading-lending-pool-details",children:"Loading lending pool details..."}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"borrowed tokenB amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.borrowReceiptAmount})]}),e.jsxs("div",{className:"pool-details",children:[e.jsx("span",{className:"pool-label",children:"collateral TokenA amount:"}),e.jsx("span",{className:"pool-value",children:r.userAssets.collateralReceiptAmount})]})]}):e.jsx("div",{className:"error-message",children:"Failed to load lending pool details"})]}),e.jsxs("div",{className:"lending-pool-actions",children:[e.jsxs("div",{className:"lending-pool-action-buttons",children:[e.jsx("button",{className:"lending-pool-action-button",onClick:()=>n(t==="depositCollateral"?"none":"depositCollateral"),children:t==="depositCollateral"?"Hide DepositCollateral":"DepositCollateral"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>n(t==="borrow"?"none":"borrow"),children:t==="borrow"?"Hide Borrow":"Borrow"}),e.jsx("button",{className:"lending-pool-action-button",onClick:()=>n(t==="repay"?"none":"repay"),children:t==="repay"?"Hide Repay":"Repay"})]}),e.jsx("button",{className:"lending-pool-refresh-button",onClick:u,disabled:l,children:l?"Loading...":"🔄 Refresh"})]}),t==="borrow"&&e.jsx("div",{className:"form-container",children:e.jsx(lo,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})}),t==="repay"&&e.jsx("div",{className:"form-container",children:e.jsx(uo,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})}),t==="depositCollateral"&&e.jsx("div",{className:"form-container",children:e.jsx(go,{pool:o,onSuccess:c=>{s(c),n("none"),u()}})})]})},ko=()=>{const o=I(),{connection:s}=P(),[a,i]=k.useState([]),[t,n]=k.useState(!1),[r,m]=k.useState(""),[l,g]=k.useState(""),u=async()=>{if(o){n(!0);try{const d=await ce(o,s);i(d)}catch(d){console.error("Error fetching pools:",d),m(d instanceof Error?d.message:"Failed to fetch pools")}finally{n(!1)}}};k.useEffect(()=>{u()},[o,s]);const c=d=>{g(d),u()};return e.jsxs("div",{className:"pool-list-container",children:[e.jsx("h2",{children:"Liquidity Pools"}),r&&e.jsx("div",{className:"error-message",children:r}),l&&e.jsxs("div",{className:"success-message",children:["Transaction successful!",e.jsx("a",{href:`https://explorer.solana.com/tx/${l}`,target:"_blank",rel:"noopener noreferrer",children:"View on Explorer"})]}),t?e.jsx("div",{className:"loading",children:"Loading pools..."}):a.length===0?e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"No pools found"})}):e.jsx("div",{className:"pool-list",children:a.map(d=>e.jsx(ho,{pool:d,onTxSuccess:c}))})]})},le="GUXNPX5ci1Qj76MZe2aRJ33zK48VmT6gXVyR86CsF4T5",fo=()=>{const{publicKey:o}=J(),[s,a]=k.useState("amm");return e.jsx(qe,{children:e.jsxs("div",{className:"defi-dashboard",children:[e.jsxs("div",{className:"tabs",children:[(o==null?void 0:o.toBase58())==le&&e.jsx("button",{className:`tab ${s==="amm"?"active":""}`,onClick:()=>a("amm"),children:"AMM"}),e.jsx("button",{className:`tab ${s==="pool"?"active":""}`,onClick:()=>a("pool"),children:"Swap"}),e.jsx("button",{className:`tab ${s==="lenderPool"?"active":""}`,onClick:()=>a("lenderPool"),children:"Lend"}),e.jsx("button",{className:`tab ${s==="borrowerPool"?"active":""}`,onClick:()=>a("borrowerPool"),children:"Borrow"}),e.jsx("button",{className:`tab ${s==="liquidate"?"active":""}`,onClick:()=>a("liquidate"),children:"Liquidate"})]}),e.jsx("div",{className:"content",children:s==="amm"&&(o==null?void 0:o.toBase58())==le?e.jsxs("div",{children:[e.jsx(Ke,{}),e.jsx(Me,{})]}):s==="pool"?e.jsxs("div",{children:[e.jsx(Xe,{}),e.jsx(Ge,{})]}):s==="lenderPool"?e.jsx("div",{children:e.jsx(io,{})}):s==="borrowerPool"?e.jsx("div",{children:e.jsx(ko,{})}):s==="liquidate"?e.jsx("div",{children:e.jsx(oo,{})}):e.jsx(bo,{})})]})})},bo=()=>e.jsx("div",{children:e.jsx("h3",{children:" Coming Soon..."})}),pe=k.createContext({network:"localnet",setNetwork:()=>{}}),wo=()=>k.useContext(pe),yo={"mainnet-beta":ae("mainnet-beta"),testnet:ae("testnet"),devnet:ae("devnet"),localnet:"http://127.0.0.1:8899"},_o=({onChange:o,value:s})=>e.jsx("div",{className:"solana-network-select-container",children:e.jsxs("select",{onChange:a=>o(a.target.value),value:s,className:"solana-network-select",children:[e.jsx("option",{value:"localnet",children:"Localnet"}),e.jsx("option",{value:"devnet",children:"Devnet"}),e.jsx("option",{value:"testnet",children:"Testnet"}),e.jsx("option",{value:"mainnet-beta",children:"Mainnet"})]})}),xo=({children:o})=>{const[s,a]=k.useState("localnet"),i=k.useMemo(()=>yo[s],[s]),t=k.useMemo(()=>[new xe],[]);return e.jsx(pe.Provider,{value:{network:s,setNetwork:a},children:e.jsx(ve,{endpoint:i,children:e.jsx(Ae,{wallets:t,autoConnect:!0,children:e.jsx(je,{children:o})})})})},vo=()=>{const{connected:o}=J(),{network:s,setNetwork:a}=wo();return e.jsxs("div",{className:"container",children:[e.jsx("nav",{className:"navbar",children:e.jsxs("div",{className:"navbar-content",children:[e.jsx(_o,{onChange:a,value:s}),e.jsx(Ne,{})]})}),e.jsx("main",{className:"main-content",children:o?e.jsx(fo,{}):e.jsx("div",{className:"connect-prompt",children:e.jsx("h2",{children:"Please connect your wallet to continue"})})})]})};typeof window<"u"&&(window.global=window,window.Buffer=f);Pe.createRoot(document.getElementById("root")).render(e.jsx(Se.StrictMode,{children:e.jsx(xo,{children:e.jsx(vo,{})})})); diff --git a/index.html b/index.html index ad62c85..9a3a02a 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Vite + React + TS - +