-
Notifications
You must be signed in to change notification settings - Fork 13
/
971.159bc206cda7d98adbeb.js
1 lines (1 loc) · 26.8 KB
/
971.159bc206cda7d98adbeb.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[971],{45014:(e,t,s)=>{s.d(t,{A:()=>u});var a=s(96540),n=s(91001),o=s(12569),i=s(72342),r=s(89247);class l extends a.Component{static propTypes={account:o.A.ChainAccount.isRequired,asset:o.A.ChainAsset.isRequired};static defaultProps={autosubscribe:!1};render(){let e=this.props.asset.get("id"),t=this.props.account.getIn(["balances",e]);return t?a.createElement(r.A,{balance:t,replace:this.props.replace}):a.createElement("span",null,"0 ",a.createElement(n.A,{name:this.props.asset.get("symbol"),replace:this.props.replace}))}}const u=(0,i.A)(l)},17071:(e,t,s)=>{s.d(t,{A:()=>P});var a=s(96540),n=s(80849),o=s.n(n),i=(s(9404),s(61594)),r=s.n(i),l=s(10658),u=s.n(l),m=s(9476),c=s(46128),h=s(8080),b=s(55840),g=s(50548),p=s(36234),d=s(45014),_=s(72342),N=s(12569),A=s(91001),y=s(72090);class w extends a.Component{static propTypes={pool:N.A.ChainLiquidityPool.isRequired};constructor(e){super(e),this.state={isModalVisible:e.isModalVisible,amountToSellTag:"a",minToReceiveTag:"b",amountToSell:null,minToReceive:null,fee:null,err:null},this.hideModal=this.hideModal.bind(this),this.onSubmit=this.onSubmit.bind(this),this.switchAsset=this.switchAsset.bind(this),this.getPairs=this.getPairs.bind(this),this.onChangeAmountToSell=this.onChangeAmountToSell.bind(this),this.onChangeMinToReceive=this.onChangeMinToReceive.bind(this)}componentWillReceiveProps(e){this.props.isModalVisible!==e.isModalVisible&&this.setState({isModalVisible:e.isModalVisible})}hideModal(){this.props.onHideModal()}onSubmit=()=>{const{pool:e,account:t}=this.props,{amountToSellTag:s,minToReceiveTag:a,amountToSell:n,minToReceive:o}=this.state;if(!n||!o)return void this.setState({err:u().translate("exchange.no_data")});this.setState({err:null});const i=new(r())(10).toPower(new(r())(e.getIn([`asset_${s}`,"precision"]))),l=new(r())(10).toPower(new(r())(e.getIn([`asset_${a}`,"precision"])));h.A.liquidityPoolExchange(t,e.get("id"),e.getIn([`asset_${s}`,"symbol"]),Math.round(parseFloat(n)*i),e.getIn([`asset_${a}`,"symbol"]),Math.round(parseFloat(o)*l)).then((()=>{console.log("exchange:"),this.hideModal()})).catch((e=>{console.error("exchange:",e)}))};switchAsset(){const e=this.state.amountToSellTag,t=this.state.minToReceiveTag;this.setState({amountToSellTag:t,minToReceiveTag:e,amountToSell:null,minToReceive:null,fee:null});const{pool:s,account:a}=this.props,{amountToSellTag:n,minToReceiveTag:o}=this.state,i=y.ChainStore.getAccount(a);let l=s.get(`asset_${n}`),u=s.get(`asset_${o}`),m=l.get("precision"),c=u.get("precision");const h=i.getIn(["balances",l.get("id")]),b=i.getIn(["balances",u.get("id")]);let g=new(r())(0),p=new(r())(0);if(h){const e=y.ChainStore.getObject(h);g=new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(m))}if(b){const e=y.ChainStore.getObject(b);p=new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(c))}return null==s?null:{amountToSell:{id:s.getIn([`asset_${n}`,"id"]),balance:g,name:s.getIn([`asset_${n}`,"symbol"]),precision:m},minToReceive:{id:s.getIn([`asset_${o}`,"id"]),balance:p,name:s.getIn([`asset_${o}`,"symbol"]),precision:c}}}getPairs(){const{pool:e,account:t}=this.props,{amountToSellTag:s,minToReceiveTag:a}=this.state,n=y.ChainStore.getAccount(t);let o=e.get(`asset_${s}`),i=e.get(`asset_${a}`),l=o.get("precision"),u=i.get("precision");const m=n.getIn(["balances",o.get("id")]),c=n.getIn(["balances",i.get("id")]);let h=new(r())(0),b=new(r())(0);if(m){const e=y.ChainStore.getObject(m);h=new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(l))}if(c){const e=y.ChainStore.getObject(c);b=new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(u))}return null==e?null:{amountToSell:{id:e.getIn([`asset_${s}`,"id"]),balance:h,name:e.getIn([`asset_${s}`,"symbol"]),precision:l},minToReceive:{id:e.getIn([`asset_${a}`,"id"]),balance:b,name:e.getIn([`asset_${a}`,"symbol"]),precision:u}}}onChangeAmountToSell(e){const t=this.state.amountToSellTag,s=this.state.minToReceiveTag;this.setState({amountToSellTag:t,minToReceiveTag:s,amountToSell:null,minToReceive:null,fee:null});const{pool:a,account:n}=this.props,{amountToSellTag:o,minToReceiveTag:i}=this.state,l=(y.ChainStore.getAccount(n),a.get(`asset_${t}`)),u=a.get(`asset_${s}`);let m=Number(a.get(`balance_${t}`)),c=Number(new(r())(10).toPower(a.get(`asset_${t}`).get("precision"))),h=Number(a.get(`balance_${s}`)),b=Number(new(r())(10).toPower(a.get(`asset_${s}`).get("precision")));const g=l.getIn(["options","market_fee_percent"]),p=u.getIn(["options","market_fee_percent"]);Number(e.amount),Number(c),Number(g),Number(e.amount),Number(b),Number(p);const d=l.getIn(["options","flags"]),_=u.getIn(["options","flags"]),N=l.getIn(["options","max_market_fee"]),A=u.getIn(["options","max_market_fee"]),w=l.getIn(["options","extensions","taker_fee_percent"]),P=u.getIn(["options","extensions","taker_fee_percent"]);let E=Number(m)-Math.ceil(Number(m)*Number(h)/(Number(h)+(Number(e.amount)*Number(b)-Number(_%2==0||0===p?0:p>0?Math.min(Number(A),Math.ceil(Number(e.amount)*Number(b)*(Number(p)/1e4))):void 0)))),f=Number(h)-Math.ceil(Number(h)*Number(m)/(Number(m)+(Number(e.amount)*Number(c)-Number(d%2==0||0===g?0:g>0?Math.min(Number(N),Math.ceil(Number(e.amount)*Number(c)*(Number(g)/1e4))):void 0)))),S=(Number(E),Number(a.get("taker_fee_percent")),Number(f)*Number(a.get("taker_fee_percent"))/1e4),v=(Number(d%2==0?0:void 0===w&&g>0?Number(g)/1e4:void 0===w&&0===g?0:Number(w)/1e4),Number(_%2==0?0:void 0===P&&p>0?Number(p)/1e4:void 0===P&&0===p?0:Number(P)/1e4)),T=(Math.floor(Number(f)),Math.ceil(Number(S)));Number(A),Math.ceil(T*Number(v)),this.setState({amountToSell:Number(e.amount),minToReceive:(Number(f)-Math.floor(Number(S))-Math.ceil(Math.min(Number(A),Math.ceil(Math.ceil(Number(f)*Number(v))))))/Number(b)})}onChangeMinToReceive(e){const t=this.state.amountToSellTag,s=this.state.minToReceiveTag;this.setState({minToReceive:null,fee:null});const{pool:a,account:n}=this.props,{amountToSellTag:o,minToReceiveTag:i}=this.state,l=(y.ChainStore.getAccount(n),a.get(`asset_${t}`)),u=a.get(`asset_${s}`);let m=Number(a.get(`balance_${t}`)),c=Number(new(r())(10).toPower(a.get(`asset_${t}`).get("precision"))),h=Number(a.get(`balance_${s}`)),b=Number(new(r())(10).toPower(a.get(`asset_${s}`).get("precision")));const g=l.getIn(["options","market_fee_percent"]),p=u.getIn(["options","market_fee_percent"]);Number(e.amount),Number(c),Number(g),Number(e.amount),Number(b),Number(p);const d=l.getIn(["options","flags"]),_=u.getIn(["options","flags"]),N=l.getIn(["options","max_market_fee"]),A=u.getIn(["options","max_market_fee"]),w=l.getIn(["options","extensions","taker_fee_percent"]),P=u.getIn(["options","extensions","taker_fee_percent"]);let E=Number(m)-Math.ceil(Number(m)*Number(h)/(Number(h)+(Number(e.amount)*Number(b)-Number(_%2==0||0===p?0:p>0?Math.min(Number(A),Math.ceil(Number(e.amount)*Number(b)*(Number(p)/1e4))):void 0)))),f=Number(h)-Math.ceil(Number(h)*Number(m)/(Number(m)+(Number(e.amount)*Number(c)-Number(d%2==0||0===g?0:g>0?Math.min(Number(N),Math.ceil(Number(e.amount)*Number(c)*(Number(g)/1e4))):void 0)))),S=(Number(E),Number(a.get("taker_fee_percent")),Number(f)*Number(a.get("taker_fee_percent"))/1e4),v=(Number(d%2==0?0:void 0===w&&g>0?Number(g)/1e4:void 0===w&&0===g?0:Number(w)/1e4),Number(_%2==0?0:void 0===P&&p>0?Number(p)/1e4:void 0===P&&0===p?0:Number(P)/1e4)),T=(Math.floor(Number(f)),Math.ceil(Number(S)));Number(A),Math.ceil(T*Number(v)),this.setState({minToReceive:Number(e.amount)})}render(){const{pool:e,account:t}=this.props;if(!e||0===e.size)return null;const{amountToSell:s,minToReceive:n}=this.state,i=this.getPairs();return a.createElement(c.Modal,{visible:this.state.isModalVisible,id:"pool_exchange_modal",overlay:!0,onCancel:this.hideModal,footer:[a.createElement(c.Button,{key:"submit",disabled:!this.props.account,onClick:this.props.account?this.onSubmit:null},u().translate("wallet.submit")),a.createElement(c.Button,{key:"Cancel",onClick:this.hideModal,style:{marginLeft:"20px"}},a.createElement(o(),{component:"span",content:"transfer.cancel"}))]},e.get("virtual_value")>0&&a.createElement(c.Form,null,null!==i&&a.createElement(c.Row,{className:"mt-10 mb-10"},a.createElement(c.Col,{span:24},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.amount_to_sell")),a.createElement(g.A,{assets:[i.amountToSell.name],asset:i.amountToSell.name,onChange:this.onChangeAmountToSell,amount:s}),t&&a.createElement("div",{style:{textAlign:"right"}},a.createElement("span",null,u().translate("transfer.available"),":"," "),a.createElement("a",{onClick:e=>{e.preventDefault();const t=this.getPairs();this.onChangeAmountToSell({amount:t.amountToSell.balance.toNumber(),asset:null})}},a.createElement(d.A,{account:t,asset:i.amountToSell.name})))),a.createElement(c.Col,{span:24,className:"mt-10 mb-10",style:{textAlign:"center"}},a.createElement(c.Button,{onClick:this.switchAsset},a.createElement(p.A,{name:"arrow-up-down",size:"1_5x"}))),a.createElement(c.Col,{span:24},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.min_to_receive")),a.createElement(g.A,{assets:[i.minToReceive.name],asset:i.minToReceive.name,amount:n,onChange:this.onChangeMinToReceive}),t&&a.createElement("div",{style:{textAlign:"right"}},a.createElement("span",null,u().translate("transfer.available"),":"," "),a.createElement("a",{onClick:e=>{e.preventDefault();const t=this.getPairs();this.onChangeMinToReceive({amount:t.minToReceive.balance.toNumber(),asset:null})}},a.createElement(d.A,{account:t,asset:i.minToReceive.name})))),this.state.fee&&a.createElement(c.Col,{span:24,style:{textAlign:"right"}},a.createElement("span",null,u().translate("poolmart.liquidity_pools.taker_fee_percent"),":"," "),`${this.state.fee} `,a.createElement(A.A,{noTip:!0,name:i.minToReceive.name})),this.state.err&&a.createElement(c.Col,{span:24,className:"mt-10 mb-10"},a.createElement(c.Alert,{message:this.state.err,type:"error"})))),0==e.get("virtual_value")&&a.createElement("div",null,a.createElement(c.Row,null,a.createElement(c.Col,{span:24},u().translate("poolmart.liquidity_pools.need_stake_first")))))}}const P=(0,m.N)((0,_.A)(w),{listenTo:()=>[b.A],getProps:e=>({account:b.A.getState().currentAccount})})},78740:(e,t,s)=>{s.d(t,{A:()=>w});var a=s(96540),n=s(80849),o=s.n(n),i=s(61594),r=s.n(i),l=s(10658),u=s.n(l),m=s(9476),c=s(46128),h=s(8080),b=s(55840),g=s(50548),p=s(36234),d=s(45014),_=s(72090),N=s(72342),A=s(12569);class y extends a.Component{static propTypes={pool:A.A.ChainLiquidityPool.isRequired};constructor(e){super(e),this.state={isModalVisible:e.isModalVisible,assetAAmount:null,assetBAmount:null,shareAssetAmount:null,assetAErr:{msg:null,status:null},assetBErr:{msg:null,status:null},shareAssetErr:{msg:null,status:null},currentTab:"stake"},this.hideModal=this.hideModal.bind(this),this.onSubmit=this.onSubmit.bind(this),this.onTabChange=this.onTabChange.bind(this),this.resetErr=this.resetErr.bind(this),this.onChangeAssetAAmount=this.onChangeAssetAAmount.bind(this),this.onChangeAssetBAmount=this.onChangeAssetBAmount.bind(this),this.onChangeShareAssetAmount=this.onChangeShareAssetAmount.bind(this)}UNSAFE_componentWillReceiveProps(e){this.props.isModalVisible!==e.isModalVisible&&this.setState({isModalVisible:e.isModalVisible})}hideModal(){this.props.onHideModal()}onSubmit(){const{assetAAmount:e,assetBAmount:t,shareAssetAmount:s,currentTab:a}=this.state,{pool:n,account:o}=this.props,i=new(r())(10).toPower(new(r())(n.getIn(["asset_a","precision"]))),l=new(r())(10).toPower(new(r())(n.getIn(["asset_b","precision"]))),u=new(r())(10).toPower(n.getIn(["share_asset","precision"]));"stake"===a?h.A.liquidityPoolDeposit(o,n.get("id"),n.getIn(["asset_a","symbol"]),n.getIn(["asset_b","symbol"]),Math.floor(Number(e)*Number(i)),Math.floor(Number(t)*Number(l))).then((e=>{console.log("exchange:",e),this.hideModal()})).catch((e=>{console.error("exchange:",e)})):"unstake"===a&&h.A.liquidityPoolWithdraw(o,n.get("id"),n.getIn(["share_asset","symbol"]),Math.floor(Number(s)*Number(u))).then((e=>{console.log("exchange:",e),this.hideModal()})).catch((e=>{console.error("exchange:",e)}))}onTabChange(e){this.setState({currentTab:e}),this.resetErr()}resetErr(){this.setState({assetAAmount:null,assetBAmount:null,shareAssetAmount:null,assetAErr:{msg:null,status:null},assetBErr:{msg:null,status:null},shareAssetErr:{msg:null,status:null}})}getShareAssetCurrentSupply(){const{pool:e,account:t}=this.props,s=e.get("share_asset"),a=s.get("precision"),n=_.ChainStore.getAccount(t).getIn(["balances",s.get("id")]);if(n){const e=_.ChainStore.getObject(n).get("balance");return new(r())(e).dividedBy(new(r())(10).toPower(a))}return new(r())(0)}getBalanceA(){const{pool:e,account:t}=this.props,s=e.get("asset_a"),a=s.get("precision"),n=_.ChainStore.getAccount(t).getIn(["balances",s.get("id")]);if(n){const e=_.ChainStore.getObject(n);return new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(a))}return new(r())(0)}getBalanceB(){const{pool:e,account:t}=this.props,s=e.get("asset_b"),a=s.get("precision"),n=_.ChainStore.getAccount(t).getIn(["balances",s.get("id")]);if(n){const e=_.ChainStore.getObject(n);return new(r())(e.get("balance")).dividedBy(new(r())(10).toPower(a))}return new(r())(0)}onChangeAssetAAmount(e){const{currentTab:t}=this.state,{pool:s}=this.props;if(void 0!==this.getShareAssetCurrentSupply()&&this.setState({assetAAmount:e.amount}),"stake"===t){const{assetBAmount:t}=this.state,a=s.get("asset_a").get("precision"),n=s.get("asset_b").get("precision"),o=s.get("share_asset").get("precision");let i=s.get("balance_a"),l=new(r())(10).toPower(s.get("asset_a").get("precision")),u=s.get("balance_b"),m=new(r())(10).toPower(s.get("asset_b").get("precision")),c=Number(s.getIn(["dynamic_share_asset","current_supply"]))/Number(new(r())(10).toPower(o));Number(e.amount)>0&&i>0&&this.setState({assetBAmount:Math.min(Number(e.amount)*(Number(u)/Number(m))/(Number(i)/Number(l))),shareAssetAmount:Math.min(Number(c)*Number(e.amount)*Number(new(r())(10).toPower(a))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)),Number(c)*t*Number(new(r())(10).toPower(n))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)))}),e.amount||this.setState({assetBAmount:0}),e.amount>0&&t>0&&this.setState({shareAssetAmount:Math.min(Number(c)*Number(e.amount)*Number(new(r())(10).toPower(a))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)),Number(c)*t*Number(new(r())(10).toPower(n))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)))})}}onChangeAssetBAmount(e){const{currentTab:t}=this.state,{pool:s}=this.props;if(void 0!==s.getIn(["dynamic_share_asset","current_supply"])&&this.setState({assetBAmount:e.amount}),"stake"===t){const{assetAAmount:t}=this.state,a=s.get("asset_a").get("precision"),n=s.get("asset_b").get("precision"),o=s.get("share_asset").get("precision");let i=s.get("balance_a"),l=new(r())(10).toPower(s.get("asset_a").get("precision")),u=s.get("balance_b"),m=new(r())(10).toPower(s.get("asset_b").get("precision")),c=Number(s.getIn(["dynamic_share_asset","current_supply"]))/Number(new(r())(10).toPower(o));Number(e.amount)>0&&u>0&&this.setState({assetAAmount:Math.min(Number(e.amount)*(Number(i)/Number(l))/(Number(u)/Number(m))),shareAssetAmount:Math.min(Number(c)*Number(e.amount)*Number(new(r())(10).toPower(n))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)),Number(c)*t*Number(new(r())(10).toPower(a))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)))}),e.amount||this.setState({assetAAmount:0}),e.amount>0&&t>0&&(this.setState({shareAssetAmount:Math.min(Number(c)*Number(e.amount)*Number(new(r())(10).toPower(n))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)),Number(c)*t*Number(new(r())(10).toPower(a))/(Number(i)/Number(new(r())(10).toPower(a)))/Number(new(r())(10).toPower(o)))}),console.log(t,a,e.amount,n))}}onChangeShareAssetAmount(e){const{currentTab:t}=this.state,{pool:s}=this.props,a=s.getIn(["dynamic_share_asset","current_supply"]);if("stake"===t)void 0!==a&&this.setState({shareAssetAmount:e.amount});else if("unstake"===t){void 0!==a&&this.setState({shareAssetAmount:e.amount});let t=this.getShareAssetCurrentSupply(),n=this.getBalanceA(),o=this.getBalanceB(),i=n.toNumber(),l=o.toNumber(),u=s.get("withdrawal_fee_percent")/100,m=s.get("balance_a"),c=new(r())(10).toPower(s.get("asset_a").get("precision")),h=s.get("balance_b"),b=new(r())(10).toPower(s.get("asset_b").get("precision"));const g=s.get("share_asset").get("precision");let p=Number(s.getIn(["dynamic_share_asset","current_supply"]))/Number(new(r())(10).toPower(g));0==t.toNumber()?(i=0,l=0):(i=Number(m)/Number(c)*Number(e.amount)/Number(p)-Number(m)/Number(c)*Number(e.amount)/Number(p)*Number(u/100),l=Number(h)/Number(b)*Number(e.amount)/Number(p)-Number(h)/Number(b)*Number(e.amount)/Number(p)*Number(u/100),console.log("PoolS:",p,"AmountA:",Number(m)/Number(c),"AmountB:",Number(h)/Number(b),Number(t.toNumber())),console.log(Number(m)/Number(c)*Number(e.amount)/Number(t.toNumber()),Number(u)),console.log(Number(h)/Number(b)*Number(e.amount)/Number(t.toNumber()),Number(u))),this.setState({assetAAmount:i,assetBAmount:l})}}render(){const{TabPane:e}=c.Tabs,{pool:t,account:s}=this.props,{assetAAmount:n,assetBAmount:i,shareAssetAmount:l,assetAErr:m,assetBErr:h,shareAssetErr:b,currentTab:N}=this.state,A=t.get("asset_a"),y=t.get("asset_b"),w=t.get("share_asset");return a.createElement(c.Modal,{visible:this.state.isModalVisible,id:"pool_stake_modal",overlay:!0,onCancel:this.hideModal,footer:[a.createElement(c.Button,{key:"send",disabled:!this.props.account,onClick:this.props.account?this.onSubmit.bind(this):null},u().translate("wallet.submit")),a.createElement(c.Button,{key:"Cancel",onClick:this.hideModal,style:{marginLeft:"20px"}},a.createElement(o(),{component:"span",content:"transfer.cancel"}))]},a.createElement(c.Tabs,{defaultActiveKey:N,onChange:this.onTabChange},a.createElement(e,{tab:u().translate("poolmart.liquidity_pools.stake"),key:"stake"},a.createElement(c.Form,null,a.createElement(c.Row,null,a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.asset_a")),a.createElement(g.A,{assets:[A.get("symbol")],asset:A.get("symbol"),validateStatus:m.status,help:m.msg,amount:n,onChange:this.onChangeAssetAAmount}),s&&a.createElement("div",{style:{textAlign:"right"}},a.createElement("span",null,u().translate("transfer.available"),":"," "),a.createElement("a",{onClick:e=>{e.preventDefault(),console.log("poolstakeModal: "),this.onChangeAssetAAmount({amount:this.getBalanceA().toNumber(),asset:null})}},a.createElement(d.A,{account:s,asset:A.get("symbol")})))),a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.asset_b")),a.createElement(g.A,{assets:[y.get("symbol")],asset:y.get("symbol"),validateStatus:h.status,help:h.msg,amount:i,onChange:this.onChangeAssetBAmount}),s&&a.createElement("div",{span:24,style:{textAlign:"right"}},a.createElement("span",null,u().translate("transfer.available"),":"," "),a.createElement("a",{onClick:e=>{e.preventDefault(),this.onChangeAssetBAmount({amount:this.getBalanceB().toNumber(),asset:null})}},a.createElement(d.A,{account:s,asset:y.get("symbol")})))),a.createElement(c.Col,{span:24,className:"mt-16",style:{textAlign:"center"}},a.createElement(p.A,{name:"arrow-down-1",size:"2x"})),a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.share_asset")),a.createElement(g.A,{assets:[w.get("symbol")],asset:w.get("symbol"),validateStatus:b.status,help:b.msg,amount:l}))))),a.createElement(e,{tab:u().translate("poolmart.liquidity_pools.unstake"),key:"unstake"},a.createElement(c.Form,null,a.createElement(c.Row,null,a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.share_asset")),a.createElement(g.A,{assets:[w.get("symbol")],asset:w.get("symbol"),validateStatus:b.status,help:b.msg,amount:l,onChange:this.onChangeShareAssetAmount}),s&&a.createElement("div",{style:{textAlign:"right"}},a.createElement("span",null,u().translate("transfer.available"),":"," "),a.createElement("a",{onClick:e=>{e.preventDefault();const a=t.get("share_asset").get("precision"),n=_.ChainStore.getAccount(s).getIn(["balances",w.get("id")]);let o=new(r())(0);if(n){const e=_.ChainStore.getObject(n).get("balance");o=new(r())(e).dividedBy(new(r())(10).toPower(a))}this.onChangeShareAssetAmount({amount:o.toNumber(),asset:null})}},a.createElement(d.A,{account:s,asset:w.get("symbol")})))),a.createElement(c.Col,{span:24,className:"mt-16",style:{textAlign:"center"}},a.createElement(p.A,{name:"arrow-down-1",size:"2x"})),a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.asset_a")),a.createElement(g.A,{assets:[A.get("symbol")],asset:A.get("symbol"),validateStatus:m.status,help:m.msg,amount:n})),a.createElement(c.Col,{span:24,className:"mt-16"},a.createElement("h4",null,u().translate("poolmart.liquidity_pools.asset_b")),a.createElement(g.A,{assets:[y.get("symbol")],asset:y.get("symbol"),validateStatus:h.status,help:h.msg,amount:i})))))))}}const w=(0,m.N)((0,N.A)(y),{listenTo:()=>[b.A],getProps:()=>({account:b.A.getState().currentAccount})})},27584:(e,t,s)=>{s.d(t,{A:()=>c});var a=s(96540),n=s(5556),o=s.n(n),i=s(46128),r=s(10658),l=s.n(r);function u(){return u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},u.apply(this,arguments)}const m=a.createRef();function c({onChange:e,value:t,placeholder:s,maxLength:n,style:o,className:r,name:l,autoComplete:c,onClear:h,type:b,...g}){return null==h&&(h=()=>{e({target:{value:""}}),m.current.focus()}),a.createElement(i.Input,u({ref:m,autoComplete:c,style:o,type:b,className:r+" search-input",placeholder:s,maxLength:n,name:l,value:t,onChange:e,addonAfter:a.createElement(i.Icon,{type:"search"}),suffix:h?a.createElement(i.Icon,{onClick:h,type:"close",className:t?"cursor-pointer":"hide"}):a.createElement("span",null)},g))}c.propTypes={onChange:o().func.isRequired,value:o().string,placeholder:o().string,style:o().object,className:o().string,type:o().string,name:o().string,autoComplete:o().string,maxLength:o().number,onClear:o().func},c.defaultProps={placeholder:l().translate("exchange.filter"),style:{width:"200px"},className:"",type:"text",name:"focus",autoComplete:"off",maxLength:16,onClear:void 0}},74806:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(49074),n=s(62716),o=s(9404),i=s.n(o);s(87040),s(2999),s(46863),s(72090),s(61594),s(28690);let r={};const l=a.A.createActions(class{getLiquidityPools(e,t,s,a){let o="",l=[];if(e&&t?(o="get_liquidity_pools_by_both_assets",l=[e,t,s,a]):e?(o="get_liquidity_pools_by_asset_a",l=[e,s,a]):t&&(o="get_liquidity_pools_by_asset_b",l=[t,s,a]),""===o)return e=>e({loading:!1,liquidityPools:i().Map()});const u=`${e}_${t}_${a}_${s}`;return e=>{r[u]||(r[u]=!0,e({loading:!0}),n.Apis.instance().db_api().exec(o,l).then((t=>{const s=[];t.forEach((e=>{-1===s.indexOf(e.asset_a)&&s.push(e.asset_a),-1===s.indexOf(e.asset_b)&&s.push(e.asset_b),-1===s.indexOf(e.share_asset)&&s.push(e.share_asset)})),n.Apis.instance().db_api().exec("lookup_asset_symbols",[s]).then((s=>{let a=i().Map();s.length&&s.forEach((e=>{a=a.set(e.id,i().fromJS(e))})),t.map((e=>(a.has(e.asset_a)?e.asset_a_obj=a.get(e.asset_a):e.asset_a_obj=void 0,a.has(e.asset_b)?e.asset_b_obj=a.get(e.asset_b):e.asset_b_obj=void 0,a.has(e.share_asset)?e.share_asset_obj=a.get(e.share_asset):e.share_asset_obj=void 0,e))),delete r[u],e({loading:!1,liquidityPools:t})}))})).catch((t=>{console.log("Error in PoolmartActions.getLiquidityPools: ",t),delete r[u],e({loading:!1,liquidityPools:i().Map(),reset:!0})})))}}getLiquidityPoolsByShareAsset(e){const t=`${e}_poolmart`;return s=>{r[t]||(r[t]=!0,s({loading:!0}),n.Apis.instance().db_api().exec("get_liquidity_pools_by_share_asset",[[e],!1]).then((e=>{const a=[];e.forEach((e=>{null!==e&&(-1===a.indexOf(e.asset_a)&&a.push(e.asset_a),-1===a.indexOf(e.asset_b)&&a.push(e.asset_b),-1===a.indexOf(e.share_asset)&&a.push(e.share_asset))})),a.length>0?n.Apis.instance().db_api().exec("lookup_asset_symbols",[a]).then((a=>{let n=i().Map();a.length&&a.forEach((e=>{n=n.set(e.id,i().fromJS(e))})),e.map((e=>(n.has(e.asset_a)?e.asset_a_obj=n.get(e.asset_a):e.asset_a_obj=void 0,n.has(e.asset_b)?e.asset_b_obj=n.get(e.asset_b):e.asset_b_obj=void 0,n.has(e.share_asset)?e.share_asset_obj=n.get(e.share_asset):e.share_asset_obj=void 0,e))),delete r[t],s({loading:!1,liquidityPools:e})})):(delete r[t],s({loading:!1,liquidityPools:[]}))})).catch((e=>{console.log("Error in PoolmartActions.getLiquidityPoolsByShareAsset: ",e),delete r[t],s({loading:!1,liquidityPools:i().Map(),reset:!0})})))}}resetLiquidityPools(){return e=>e(!0)}getLiquidityPoolsAccount(e){const t=`${e}_account`;return s=>{r[t]||(r[t]=!0,s({loading:!0}),n.Apis.instance().db_api().exec("get_liquidity_pools_by_owner",[e]).then((e=>{const a=[];e.forEach((e=>{null!==e&&(-1===a.indexOf(e.asset_a)&&a.push(e.asset_a),-1===a.indexOf(e.asset_b)&&a.push(e.asset_b),-1===a.indexOf(e.share_asset)&&a.push(e.share_asset))})),n.Apis.instance().db_api().exec("lookup_asset_symbols",[a]).then((a=>{let n=i().Map();a.length&&a.forEach((e=>{n=n.set(e.id,i().fromJS(e))})),e.map((e=>(n.has(e.asset_a)?e.asset_a_obj=n.get(e.asset_a):e.asset_a_obj=void 0,n.has(e.asset_b)?e.asset_b_obj=n.get(e.asset_b):e.asset_b_obj=void 0,n.has(e.share_asset)?e.share_asset_obj=n.get(e.share_asset):e.share_asset_obj=void 0,e))),delete r[t],s({loading:!1,liquidityPools:e})}))})).catch((e=>{console.log("Error in PoolmartActions.getLiquidityPoolsByShareAsset: ",e),delete r[t],s({loading:!1,liquidityPools:i().Map(),reset:!0})})))}}})},66897:(e,t,s)=>{s.d(t,{A:()=>u});var a=s(77736),n=s(9404),o=s.n(n),i=s(49074),r=(s(72090),s(74806));class l extends a.A{constructor(){super(),this.liquidityPools=o().Map(),this.liquidityPoolsLoading=!1,this.assets=o().Map(),this.lastPoolId=null,this.bindListeners({onGetLiquidityPools:r.A.GET_LIQUIDITY_POOLS,onGetLiquidityPoolsByShareAsset:r.A.GET_LIQUIDITY_POOLS_BY_SHARE_ASSET,onResetLiquidityPools:r.A.RESET_LIQUIDITY_POOLS,onGetLiquidityPoolsAccount:r.A.GET_LIQUIDITY_POOLS_ACCOUNT})}onGetLiquidityPools(e){if(!e)return!1;if(this.liquidityPoolsLoading=e.loading,e.liquidityPools){let t=o().Map();if(e.liquidityPools.forEach((e=>{t=t.set(e.id,e)})),0===t.size)return;this.lastPoolId=t.last().id,this.liquidityPools=this.liquidityPools.merge(t)}!0===e.reset&&(this.lastPoolId=null)}onGetLiquidityPoolsByShareAsset(e){if(!e)return!1;if(this.liquidityPoolsLoading=e.loading,e.liquidityPools){let t=o().Map();if(e.liquidityPools.forEach((e=>{t=t.set(e.id,e)})),0===t.size)return;this.lastPoolId=t.last().id,this.liquidityPools=this.liquidityPools.merge(t)}!0===e.reset&&(this.lastPoolId=null)}onGetLiquidityPoolsAccount(e){if(console.log("onGetLiquidityPoolsAccount"),!e)return!1;if(this.liquidityPoolsLoading=e.loading,e.liquidityPools){let t=o().Map();if(e.liquidityPools.forEach((e=>{t=t.set(e.id,e)})),0===t.size)return;this.lastPoolId=t.last().id,this.liquidityPools=t}!0===e.reset&&(this.lastPoolId=null)}onResetLiquidityPools(e){this.liquidityPools=o().Map()}}const u=i.A.createStore(l,"PoolmartStore")}}]);