text: (window.webpackJsonp=window.webpackJsonp||[]).push([[40],{2122:function(e,t,a){"use strict";a.d(t,"b",function(){return d}),a.d(t,"c",function(){return u}),a.d(t,"d",function(){return p}),a.d(t,"a",function(){return m});var n=a(4),r=a.n(n),s=a(41),o=a(44),l=a(26),i=a(94),c=a(10);const d=e=>r()(e,"indexPrices.indexPrices"),u=e=>r()(e,"indexPrices.areIndexPricesLoaded"),p=Object(s.a)([o.e,d,l.d],(e,t,a)=>m({pair:e,allIndexPrices:t,allMarkets:a})),m=({pair:e,allIndexPrices:t,allMarkets:a})=>{const n=e.orderMarket,r=e.baseSymbol,s=e.quoteSymbol,o=Object(l.c)({allMarkets:a,symbol:r}),d=Object(l.c)({allMarkets:a,symbol:s}),u=t[n];if(u)return new i.a(u,o,d).getNaturalValue();const p=Object(l.c)({allMarkets:a,symbol:"DAI"});if(p&&p.oraclePrice){if("WETH-DAI"===n){if(t["WETH-USDC"])return new i.a(t["WETH-USDC"],o,Object(l.c)({allMarkets:a,symbol:"USDC"})).getNaturalValue().div(p.oraclePrice)}if("DAI-USDC"===n)return Object(c.a)(p.oraclePrice)}return null}},2125:function(e,t,a){e.exports={loadingDots:"_3jMPchhhIOb4dZOy6GLdPk",dot:"_2f58i9-DZX4n6MkcSDUG0","dot-keyframes":"j0RjL1ZlcGTCa4Xjy9tyY",newLoadingDots:"oppLNwiDeV9-rzLw4k37w","dot-animation":"_15KINsZKdzjYj3pK_pSvRH",compact:"_1WWoQQoq0KrhJIG9Mb9dfZ"}},2126:function(e,t,a){var n=a(921),r=a(619),s=a(385),o=9007199254740991,l=4294967295,i=Math.min;e.exports=function times(e,t){if((e=s(e))<1||e>o)return[];var a=l,c=i(e,l);t=r(t),e-=l;for(var d=n(c,t);++a<e;)t(a);return d}},2132:function(e,t,a){"use strict";var n=a(2126),r=a.n(n),s=a(0),o=a.n(s),l=a(1),i=a.n(l),c=a(2125),d=a.n(c);const u=({size:e=2})=>o.a.createElement("div",{className:d.a.loadingDots,style:{width:3*e+8}},r()(3,t=>o.a.createElement("div",{key:t,className:d.a.dot,style:{height:e,width:e}})));u.propTypes={size:i.a.number};var p=u,m=a(19),b=a.n(m);const g=({compact:e})=>o.a.createElement("div",{className:b()(d.a.newLoadingDots,{[d.a.compact]:e})});g.propTypes={compact:i.a.bool};var E=g;a.d(t,"b",function(){return p}),a.d(t,"a",function(){return E})},2190:function(e,t,a){e.exports={withReceipt:"_1XgtXOljETPmDV2RMD_zuD",container:"_1KSJY3ymebc_XX7esTa-Bv",row:"_3czUZmv5NRAhWXk7e4BeXt",label:"_3w9JeXQbjRWOihV4g0yLEx",value:"_1wdfbLcW3Y7NsjKZjiy9aD",regularFont:"_1rm9HlnGoqIMCwM7brFAWM",green:"_3R93GTFh8lN30elv0AYFzt",tag:"_14uhD-CacaKRqVnuzmNqNk"}},2191:function(e,t,a){e.exports={inputField:"_9jpup2dndkdIZHhKRKEgy",input:"WtsliSD4q1flPqAShEpRp",active:"_1Pne0H3t6xkuYMwEC-808a",centered:"_39ZsT6rbn0bgGV1IEh3Zbd",small:"AeUWp8wbdvK2oeHZURAZj",large:"JNAL3FY5IBs3E59ke9RFW",regularFont:"_3d1YYjk54xB1oLSG10EVSU",disabled:"VtnAMrgcEDQBv-MWgLQKI",tag:"Tmgg5zTEUcLdvJag3G71_",max:"_3GDGOwlV1g_T7_HOaGuLS2"}},2192:function(e,t,a){e.exports={message:"_1nDlju_OQsa7Fpu3i2cUQA",error:"_1lxrBdNKb7mbvm2e8yvi4D",title:"_2888coz9yxAoJQcmNng5rA",text:"_3j0TvNuUnrm1Q7lzyPr70J",info:"_1QXuXYTJVIjd_LypI75nfO",warning:"_3w6n7ECIC0jxPJd4vOPoaV"}},2209:function(e,t,a){"use strict";var n=a(118),r=a.n(n),s=a(0),o=a.n(s),l=a(1),i=a.n(l),c=a(19),d=a.n(c),u=a(2192),p=a.n(u);const m={ERROR:"ERROR",WARNING:"WARNING",INFO:"INFO"},b=({className:e,message:t,title:a,type:n=m.ERROR})=>o.a.createElement("div",{className:d()(p.a.message,{[p.a.error]:n===m.ERROR,[p.a.warning]:n===m.WARNING,[p.a.info]:n===m.INFO},e)},a&&o.a.createElement("div",{className:p.a.title},a),o.a.createElement("div",{className:p.a.text},t," "));b.propTypes={className:i.a.string,message:i.a.string.isRequired,title:i.a.string,type:i.a.oneOf(r()(m))};var g=b;a.d(t,"b",function(){return g}),a.d(t,"a",function(){return m})},2210:function(e,t,a){"use strict";var n=a(118),r=a.n(n),s=a(0),o=a.n(s),l=a(1),i=a.n(l),c=a(19),d=a.n(c),u=a(230),p=a.n(u),m=a(74),b=a(251),g=a(5),E=a(2191),y=a.n(E);const A={SMALL:"SMALL",LARGE:"LARGE"},f={PERCENT:"PERCENT",TEXT:"TEXT",NUMBER:"NUMBER"},O=({active:e,centered:t,disabled:a,max:n,onChange:r,onClickMax:s,placeholder:l,regularFont:i,size:c=A.LARGE,stringGetter:u,tag:m,type:E,value:O})=>{return o.a.createElement("div",{className:d()(y.a.inputField,{[y.a.active]:e,[y.a.centered]:t,[y.a.disabled]:a,[y.a.small]:c===A.SMALL,[y.a.large]:c===A.LARGE})},o.a.createElement(p.a,{className:d()(y.a.input,{[y.a.regularFont]:i}),onChange:e=>{const t=E===f.PERCENT?e.target.value.slice(0,-1):e.target.value;E!==f.TEXT&&E!==f.PERCENT&&Number.isNaN(Number(t))?O&&r(""):r(t)},placeholder:l,value:O,displayType:"input",allowNegative:!1,disabled:a,suffix:E===f.PERCENT?"%":"",isAllowed:e=>!n||e.floatValue<=n||!e.floatValue}),m&&o.a.createElement(b.a,{muted:!0,light:!0,className:y.a.tag},m),s&&o.a.createElement("div",{role:"button",tabIndex:0,className:y.a.max,onClick:s},u({key:g.a.MAX})))};O.propTypes={active:i.a.bool,centered:i.a.bool,disabled:i.a.bool,max:i.a.number,onChange:i.a.func.isRequired,onClickMax:i.a.func,placeholder:i.a.string,regularFont:i.a.bool,stringGetter:i.a.func,size:i.a.oneOf(r()(A)),tag:i.a.string,type:i.a.oneOf(r()(f)),value:i.a.string.isRequired},O.defaultProps={placeholder:"0.0000",type:f.NUMBER};var h=Object(m.k)(O);a.d(t,"c",function(){return h}),a.d(t,"a",function(){return A}),a.d(t,"b",function(){return f})},2211:function(e,t,a){"use strict";var n=a(0),r=a.n(n),s=a(1),o=a.n(s),l=a(19),i=a.n(l),c=a(251),d=a(2190),u=a.n(d);const p=({children:e,receiptConfig:t,receiptOnTop:a})=>r.a.createElement("div",{className:u.a.withReceipt},!a&&e,r.a.createElement("div",{className:u.a.container},t.map(({key:e,label:t,currency:a,value:n,regularFont:s,green:o})=>r.a.createElement("div",{key:e,className:u.a.row},r.a.createElement("div",{className:u.a.label},t),a&&r.a.createElement(c.a,{muted:!0,className:u.a.tag},a),r.a.createElement("span",{className:i()(u.a.value,{[u.a.regularFont]:s,[u.a.green]:o})},n)))),a&&e);p.propTypes={children:o.a.oneOfType([o.a.arrayOf(o.a.node),o.a.node]).isRequired,receiptConfig:o.a.arrayOf(o.a.shape({label:o.a.oneOfType([o.a.string,o.a.node]).isRequired,currency:o.a.string,value:o.a.oneOfType([o.a.string,o.a.node])})).isRequired,receiptOnTop:o.a.bool};var m=p;a.d(t,"a",function(){return m})},2247:function(e,t,a){e.exports={arrowDiff:"_3kMFACDxUF4K2-HIagn2th",regularFont:"_1H_LhdERrAeRIw00F89lbg",before:"_3OtMkqNt6rAKIyhLMd0fTq",arrowAndAfter:"qq1wyfcY5p_dVImKY5F1v",arrow:"_2ZtLNXp-1ZU0defH5eFHQ2",green:"_2mbKWeL_UkyBMRN50JFI60",red:"ZL2WZDjbB1jja34n6oxon",grey:"_2ZCuQblgqGCWf4OfoKs7S1"}},2267:function(e,t,a){"use strict";var n=a(118),r=a.n(n),s=a(0),o=a.n(s),l=a(1),i=a.n(l),c=a(19),d=a.n(c),u=a(2247),p=a.n(u);const m={RED:"RED",GREEN:"GREEN",GREY:"GREY"},b=({before:e,after:t,arrowColor:a=m.GREY,regularFont:n})=>o.a.createElement("div",{className:d()(p.a.arrowDiff,{[p.a.regularFont]:n})},o.a.createElement("span",{className:d()({[p.a.before]:!!t})},e),t&&o.a.createElement("span",{className:p.a.arrowAndAfter},o.a.createElement("span",{className:d()(p.a.arrow,{[p.a.green]:a===m.GREEN,[p.a.red]:a===m.RED,[p.a.grey]:a===m.GREY})},"\u2192"),t));b.propTypes={before:i.a.oneOfType([i.a.arrayOf(i.a.node),i.a.node]),after:i.a.oneOfType([i.a.arrayOf(i.a.node),i.a.node]),arrowColor:i.a.oneOf(r()(m)),regularFont:i.a.bool};var g=b;a.d(t,"b",function(){return g}),a.d(t,"a",function(){return m})},2472:function(e,t,a){e.exports={depositModal:"rxerdZJ-PtdWyTRdU99Ha",modalContent:"_39VXUqJlFR41gc4gsq_n3K",walletShort:"_3nVKV33FrKg2NhleQ5u9Wp",loading:"_2XeqE7LrkJ_2IIOHuNA8vl",red:"_391WX6NuVAbEzcwU0I_qw_",green:"_3I5v8mqEdCjxzXpyOYt1pK",flexVerticalAlign:"VXayTPLsWb78xXBVu8Biz",flexSpaceBetween:"_1_VOwUf6y-LUqcGqUsNfGU",settingsMenuPlacement:"_1A1LYHNNE1XLK47oVpv-P0",helpIcon:"_1XdGveHcznwVIdGgOQG5QU",settingsIcon:"AlTFmiyvSlycTKGvR687M",exchangeProvider:"_3k7tqtO9SEnQS8rwC05tBW",dropdownContainer:"_1CKd0SNceGr-UfYXr_Ql3c",dropdownLabel:"_3s2cqeMGkq3mfMq0yJff5P",setAllowanceArea:"_3pUyYuTxWzGDC25VkEb_er",setAllowanceTitle:"_5bwFprwbzWoPxzw3e0J5j",setAllowanceDescription:"_1mia7R9yfA5z1G7Itzplja",settingsMenuOverlay:"_1uRMH9yt-JFXh1XVyurkQk","transition-bg":"_2TM2C0vNLV7Nk1IDaYEWQX",settingsMenu:"Ei2IEa6y-rZi6BIF8ZWF_",settingsMenuContent:"_2pokwevfGKDE7aVkbWtE2c",slippageButtons:"_17S9E3kAfcTjxk4a90tSGz"}},2509:function(e,t,a){"use strict";a.r(t);var n=a(118),r=a.n(n),s=a(39),o=a.n(s),l=a(55),i=a.n(l),c=a(4),d=a.n(c),u=a(6),p=a.n(u),m=a(923),b=a.n(m),g=a(0),E=a.n(g),y=a(1),A=a.n(y),f=a(60),O=a(52),h=a(19),v=a.n(h),N=a(74),k=a(31),C=a(2144),w=a(2131),R=a(149),S=a(387),M=a(251),j=a(625),D=a(622),I=a(2211),T=a(2183),L=a(2209),P=a(2267),_=a(2210),x=a(2132),G=a(2127),F=a(2135),B=a(190),W=a(51),q=a(49),U=a(102),V=a(33),z=a(296),Z=a(44),X=a(250),Y=a(26),K=a(2122),H=a(171),Q=a(42),J=a(61),$=a(24),ee=a(5),te=a(297),ae=a(11),ne=a(388),re=a(57),se=a(94),oe=a(32),le=a(170),ie=a(10),ce=a(191),de=a(2),ue=a(85),pe=a(46),me=a(615),be=a(2472),ge=a.n(be);function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(a,!0).forEach(function(t){_defineProperty(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(a).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function asyncGeneratorStep(e,t,a,n,r,s,o){try{var l=e[s](o),i=l.value}catch(c){return void a(c)}l.done?t(i):Promise.resolve(i).then(n,r)}function _asyncToGenerator(e){return function(){var t=this,a=arguments;return new Promise(function(n,r){var s=e.apply(t,a);function _next(e){asyncGeneratorStep(s,n,r,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(s,n,r,_next,_throw,"throw",e)}_next(void 0)})}}const Ee="USER_WALLET",ye="SPOT_ACCOUNT",Ae="MARGIN_ACCOUNT",fe={error:null,amount:de.a.ZERO,inputValue:"",isMaxAmount:!1,expectedConversionAmount:null,isConversionLoading:!1,slippageInput:"",slippage:H.a};class Oe extends g.Component{constructor(e){var t;super(e),t=this,this.getConversionOrderData=_asyncToGenerator(function*(){const e=t.props.walletAddress,a=t.state,n=a.amount,r=a.slippage,s=a.destinationPair.orderMarket;if(n&&n.gt(0)){const a=yield Object(me.e)({amount:n,orderMarket:s,slippage:r,walletAddress:e}),o=a.exchangeWrapperAddress,l=a.expectedAmount,i=a.transactionData;t.exchangeWrapperAddress=o,t.conversionData=i,t.setState({expectedConversionAmount:l,isConversionLoading:!1})}}),this.onChangeInput=(e=>{const t=this.state.depositMarket,a={amount:Object(pe.c)(Object(ie.a)(e),t.currency.decimals),inputValue:e,isMaxAmount:!1,error:null};this.getDepositNeedsConversion()&&(this.getConversionOrderData(),a.isConversionLoading=!0,a.expectedConversionAmount=null),this.setState(a)}),this.onClickMax=(()=>{const e=this.props,t=e.getWalletBalance,a=e.spotAccount,n=e.marginAccount,r=this.state,s=r.depositMarket,o=r.selectedDepositFrom;let l;o===Ee?(l=t(s),Object(Y.h)(s)&&(l=l.minus(de.c))):l=Object(ie.a)(Object(U.b)({account:o===ye?a:n,market:s}).wei),l.lt(0)&&(l=de.a.ZERO);const i={amount:l,inputValue:Object(ce.e)(l,s.currency.decimals),isMaxAmount:!0,error:null};this.getDepositNeedsConversion()&&(this.getConversionOrderData(),i.isConversionLoading=!0,i.expectedConversionAmount=null),this.setState(i)}),this.onChangeDestination=(e=>{const t=this.props.allMarkets,a=this.state.selectedDepositFrom,n=_objectSpread({},fe,{selectedDestination:e}),r=p()([ye,Ae],e);if(r)n.destinationPair=null,n.depositMarket=Object(Y.c)({allMarkets:t,symbol:te.c[0]});else{const a=Object(Z.b)(e);n.destinationPair=a,n.depositMarket=Object(Y.c)({allMarkets:t,symbol:a.supportedDepositSymbols[0]})}(a===e||a!==Ee&&!r)&&(n.selectedDepositFrom=Ee),this.setState(n)}),this.onChangeDepositAsset=(e=>{const t=this.props,a=t.allMarkets,n=t.getWalletBalance,r=this.state.depositMarket,s=r.symbol;if(s===e)return;const o=n(r),l=n({currency:{symbol:"WETH"}});Object(ue.b)("deposit-modal","change-deposit-asset",{currentAsset:s,newAsset:e,userWalletHasAsset:o&&!o.isZero(),ethWalletBalance:l}),this.setState(_objectSpread({},fe,{depositMarket:Object(Y.c)({allMarkets:a,symbol:e})}))}),this.onClickSetAllowance=_asyncToGenerator(function*(){const e=t.props,a=e.setConversionProxyAllowance,n=e.setSoloAllowance,r=e.setPerpetualAllowance,s=e.walletAddress,o=t.state,l=o.depositMarket,i=o.selectedDestination,c=o.destinationPair,d=p()([ye,Ae],i),u=t.getDepositNeedsConversion();t.setState({isAllowanceLoading:!0});try{if(d)yield n(l.currency.contractAddress,s);else if(u)yield a(l.currency.contractAddress,s);else{const e=c.orderMarket;yield r({orderMarket:e,tokenAddress:l.currency.contractAddress,walletAddress:s})}}catch(m){}}),this.onClickCta=_asyncToGenerator(function*(){const e=t.props,a=e.closeSidebarModal,n=e.convertAndDeposit,r=e.depositSolo,s=e.depositPerpetual,o=e.stringGetter,l=e.transferSolo,i=e.walletAddress,c=e.walletType,d=t.state,u=d.amount,m=d.depositMarket,b=d.selectedDestination,g=d.selectedDepositFrom,E=d.destinationPair,y=d.isMaxAmount,A=p()([ye,Ae],b),f=t.getDepositNeedsConversion();t.setState({loading:!0});try{if(A)if(g===Ee)yield r({accountNumber:b===ye?Q.c:Q.b,depositFromAddress:Object(Y.h)(m)?oe.a.contracts.payableProxy.options.address:i,market:m,amount:u,walletAddress:i,walletType:c,isMaxAmount:y});else{const e=g===ye;yield l({walletAddress:i,fromAccountNumber:e?Q.c:Q.b,toAccountNumber:e?Q.b:Q.c,market:m,amount:u,transferAll:y})}else{const e=E.orderMarket;f?yield n({amount:u,depositData:t.conversionData,exchangeWrapperAddress:t.exchangeWrapperAddress,isMaxAmount:y,orderMarket:e,walletAddress:i,walletType:c}):yield s({amount:u,isMaxAmount:y,orderMarket:e,walletAddress:i,walletType:c})}a()}catch(O){const e=Object(le.j)({error:O,walletAddress:i,walletType:c,location:"deposit-modal",stringGetter:o}).message;t.setState({loading:!1,error:e})}});const a=e.allMarkets,n=e.currentPair,r=e.product,s=n.supportedDepositSymbols,o=n.orderMarket;let l,i,c;r===ne.a.PERPETUALS?(l=Object(Y.c)({allMarkets:a,symbol:s[0]}),i=o,c=n):(l=Object(Y.c)({allMarkets:a,symbol:te.c[0]}),i=r===ne.a.SPOT?ye:Ae,c=null),this.state=_objectSpread({loading:!1,isAllowanceLoading:!1,showSettingsMenu:!1,depositMarket:l,selectedDepositFrom:Ee,selectedDestination:i,destinationPair:c},fe),this.getConversionOrderData=b()(this.getConversionOrderData,500)}componentDidMount(){const e=this.props.allWalletBalances,t=this.state.depositMarket;Object(V.b)({allWalletBalances:e,market:t})&&this.sendInitialDepositMarketEvent()}componentDidUpdate(e){const t=this.props.allWalletBalances,a=e.allWalletBalances,n=this.state.depositMarket,r=Object(V.b)({allWalletBalances:a,market:n}),s=Object(V.b)({allWalletBalances:t,market:n});!r&&s&&this.sendInitialDepositMarketEvent()}sendInitialDepositMarketEvent(){const e=this.props.allWalletBalances,t=this.state.depositMarket,a=Object(V.b)({allWalletBalances:e,market:t}),n=Object(V.b)({allWalletBalances:e,market:{currency:{symbol:"WETH"}}});Object(ue.b)("deposit-modal","change-deposit-asset",{currentAsset:null,newAsset:t.symbol,userWalletHasAsset:a&&!a.isZero(),ethWalletBalance:n})}getIsAllowanceSet(){const e=this.props,t=e.marginAllowances,a=e.perpetualAllowances,n=e.perpetualConversionProxyAllowances,r=this.state,s=r.depositMarket,o=r.selectedDestination,l=r.destinationPair;if(Object(Y.h)(s))return!0;let i;if(p()([ye,Ae],o))i=d()(t,s.currency.contractAddress);else{const e=l.orderMarket,t=l.quoteSymbol;i=s.symbol!==t?n[s.currency.contractAddress]:d()(a,`[${e}][${s.currency.contractAddress}]`)}return i&&i.gt(0)}getDepositNeedsConversion(){const e=this.state,t=e.destinationPair,a=e.depositMarket;if(t){if(t.type===$.d.PERPETUAL){return("WETH"===t.settlementSymbol?"ETH":t.settlementSymbol)!==a.symbol}return t.quoteSymbol!==a.symbol}return!1}getError(){const e=this.props,t=e.getNewCollateralization,a=e.getWalletBalance,n=e.marginAccount,r=e.spotAccount,s=e.stringGetter,o=this.state,l=o.amount,i=o.depositMarket,c=o.selectedDepositFrom,d=c===Ee,u=c===Ae;let p;if((p=d?a(i):Object(ie.a)(Object(U.b)({account:c===ye?r:n,market:i}).wei)).lt(0))return s({key:ee.a.NEGATIVE_DEPOSIT_FROM_BALANCE,params:{SYMBOL:i.symbol}});if(l.gt(p))return s({key:ee.a.INSUFFICIENT_SYMBOL_BALANCE,params:{SYMBOL:i.symbol}});if(u){if(t(new re.a(l.negated(),i)).lt(ae.b))return s({key:ee.a.DEPOSIT_FROM_UNDERCOLLATERALIZED})}return d&&Object(Y.h)(i)&&!l.isZero()&&l.gt(p.minus(de.c))?s({key:ee.a.DOES_NOT_LEAVE_ENOUGH_ETH}):null}renderAmountInput(){const e=this.props.stringGetter,t=this.state,a=t.inputValue,n=t.loading,r=t.selectedDepositFrom,s=t.showSettingsMenu;return E.a.createElement(G.b,{label:E.a.createElement("div",{className:v()(ge.a.flexVerticalAlign,ge.a.settingsMenuPlacement)},e({key:ee.a.AMOUNT}),this.getDepositNeedsConversion()&&E.a.createElement(g.Fragment,null,E.a.createElement("div",{role:"button",tabIndex:0,className:v()(ge.a.flexVerticalAlign,ge.a.settingsIcon),onClick:()=>this.setState({showSettingsMenu:!0})},E.a.createElement(k.D,null)),s&&this.renderSettingsMenu()))},E.a.createElement(I.a,{receiptConfig:r===Ee?this.getDepositFromWalletReceiptConfig():this.getDepositFromSoloReceiptConfig()},E.a.createElement(_.c,{disabled:n,onChange:this.onChangeInput,onClickMax:this.onClickMax,value:a})))}renderSetAllowance(){const e=this.props.stringGetter,t=this.state,a=t.depositMarket,n=t.isAllowanceLoading;return E.a.createElement("div",{className:ge.a.setAllowanceArea},E.a.createElement("div",{className:ge.a.setAllowanceTitle},e({key:ee.a.GRANT_ACCESS})),E.a.createElement("div",{className:ge.a.setAllowanceDescription},e({key:ee.a.GRANT_ACCESS_DESCRIPTION,params:{SYMBOL:a.symbol}})),E.a.createElement(B.f,{fullWidth:!0,size:B.e.MEDIUM,onClick:this.onClickSetAllowance,isLoading:n},e({key:ee.a.ENABLE_SYMBOL,params:{SYMBOL:a.symbol}})))}renderSettingsMenu(){const e=this.props.stringGetter,t=this.state,a=t.slippage,n=t.slippageInput;return E.a.createElement("div",{className:ge.a.settingsMenu},E.a.createElement(S.a,{noBorder:!0,title:e({key:ee.a.SETTINGS}),closeModal:()=>this.setState({showSettingsMenu:!1})}),E.a.createElement("div",{className:ge.a.settingsMenuContent},E.a.createElement(G.b,{label:E.a.createElement(T.a,{tooltip:"perpetual-deposit-max-slippage",top:12,left:-38},e({key:ee.a.MAXIMUM_SLIPPAGE}))},E.a.createElement("div",{className:ge.a.slippageButtons},E.a.createElement(B.f,{uppercase:!1,size:B.e.SMALL,active:a&&a.eq(.001),onClick:()=>{this.getConversionOrderData(),this.setState({slippage:Object(ie.a)(.001),slippageInput:"",isConversionLoading:!0,expectedConversionAmount:null})}},"0.10%"),E.a.createElement(B.f,{uppercase:!1,size:B.e.SMALL,active:a&&a.eq(.0025),onClick:()=>{this.getConversionOrderData(),this.setState({slippage:Object(ie.a)(.0025),slippageInput:"",isConversionLoading:!0,expectedConversionAmount:null})}},"0.25%"),E.a.createElement(_.c,{centered:!0,regularFont:!0,active:!!n,size:_.a.SMALL,type:_.b.PERCENT,max:H.b.times(100).toNumber(),placeholder:e({key:ee.a.CUSTOM_INPUT}),value:n,onChange:e=>{this.getConversionOrderData(),this.setState({slippage:e?Object(ie.a)(e).div(100):H.a,slippageInput:e,isConversionLoading:!0,expectedConversionAmount:null})}})))))}renderSourceDropdown(){const e=this.props,t=e.isWalletInvalid,a=e.stringGetter,n=e.walletAddress,r=e.walletType,s=this.state,o=s.selectedDestination,l=s.selectedDepositFrom;let i=a({key:ee.a.NOT_CONNECTED});n&&!t&&(i=E.a.createElement(g.Fragment,null,a({key:ee.a.WALLET}),E.a.createElement(j.a,{className:ge.a.walletShort,hash:n})));const c=[{key:Ee,label:E.a.createElement("div",{className:ge.a.dropdownLabel},n&&E.a.createElement(D.a,{walletType:r}),i)}];return o===ye?c.push({key:Ae,label:E.a.createElement("div",{className:ge.a.dropdownLabel},a({key:ee.a.MARGIN_ACCOUNT})),icon:E.a.createElement(k.R,null),iconUsesFill:!0}):o===Ae&&c.push({key:ye,label:E.a.createElement("div",{className:ge.a.dropdownLabel},a({key:ee.a.SPOT_ACCOUNT})),icon:E.a.createElement(k.hb,null),iconUsesFill:!0}),E.a.createElement(G.b,{grey:!0,label:a({key:ee.a.SOURCE})},E.a.createElement("div",{className:ge.a.dropdownContainer},E.a.createElement(F.a,{selectedItemKey:l,onChangeSelection:e=>this.setState(_objectSpread({},fe,{selectedDepositFrom:e})),dropdownMenuItems:c})))}renderDestinationDropdown(){const e=this.props,t=e.isUserInUsa,a=e.stringGetter,n=e.walletAddress,r=this.state.selectedDestination,s={key:ye,label:E.a.createElement("div",{className:ge.a.dropdownLabel},a({key:ee.a.SPOT_ACCOUNT})),icon:E.a.createElement(k.hb,null),iconUsesFill:!0},o={key:Ae,label:E.a.createElement("div",{className:ge.a.dropdownLabel},a({key:ee.a.MARGIN_ACCOUNT})),icon:E.a.createElement(k.R,null),iconUsesFill:!0},l=i()($.f,({orderMarket:e,marketName:t,baseSymbol:n,displayQuoteSymbol:r})=>({key:e,label:E.a.createElement("div",{className:ge.a.dropdownLabel},t," ",a({key:ee.a.PERPETUAL_CONTRACT_SHORT})),icon:E.a.createElement(w.a,{baseSymbol:n,quoteSymbol:r})}));let c;return c=t&&!Object(me.d)(n)?[s,o]:[s,o,...l],E.a.createElement(G.b,{label:a({key:ee.a.DESTINATION})},E.a.createElement("div",{className:ge.a.dropdownContainer},E.a.createElement(F.a,{selectedItemKey:r,onChangeSelection:this.onChangeDestination,dropdownMenuItems:c})))}getConversionReceiptConfig(){const e=this.props,t=e.allMarkets,a=e.stringGetter,n=this.state,r=n.depositMarket,s=n.isConversionLoading,l=n.amount,i=n.destinationPair,c=n.expectedConversionAmount,d=this.getDepositNeedsConversion(),u=this.getError();let p="-";if(i&&o()(i.supportedDepositSymbols)>1){const e=de.a.ONE.toFixed(J.n);if(d){if(!u&&l&&!l.isZero())if(s||d&&!c)p=E.a.createElement(x.a,{compact:!0});else{const a=Object(Y.c)({allMarkets:t,symbol:i.quoteSymbol});p=`${e} \u2248 ${Object(ce.c)(new se.a(c.div(l),r,a).getNaturalValue(),J.n)}`}}else p=`${e} = ${e}`}const m=[{key:ee.a.SWAP,label:E.a.createElement("div",{className:ge.a.flexVerticalAlign},a({key:ee.a.SWAP}),E.a.createElement(T.a,{top:12,left:-78,tooltip:"perpetual-deposit-asset",className:v()(ge.a.flexVerticalAlign,ge.a.helpIcon)},E.a.createElement(k.I,null))),value:E.a.createElement(P.b,{before:E.a.createElement(M.a,null,r.symbol),after:E.a.createElement(M.a,null,i.displayQuoteSymbol)})},{key:ee.a.EXCHANGE_RATE,label:a({key:ee.a.EXCHANGE_RATE}),value:p}];return d&&m.push({key:ee.a.PROVIDER,label:a({key:ee.a.PROVIDER}),value:E.a.createElement("div",{className:ge.a.exchangeProvider},E.a.createElement("img",{src:"/curve.png",alt:""}),"Curve"),regularFont:!0}),m}renderAssetDropdown(){const e=this.props,t=e.allMarkets,a=e.stringGetter,n=this.state,r=n.depositMarket,s=n.destinationPair,o=n.selectedDestination,l=p()([Ae,ye],o),c=l?te.c:s.supportedDepositSymbols,d=E.a.createElement(F.a,{selectedItemKey:r.symbol,onChangeSelection:this.onChangeDepositAsset,dropdownMenuItems:i()(c,e=>{const a=Object(Y.c)({allMarkets:t,symbol:e}),n=a.symbol;return{key:n,label:a.name,tag:n,icon:E.a.createElement(w.a,{baseSymbol:n}),menuOnlyDetail:!l&&n!==s.settlementSymbol&&E.a.createElement(k.jb,null)}})}),u=r.totalSupplyAPR;return E.a.createElement(G.b,{label:a({key:ee.a.ASSET})},E.a.createElement(I.a,{receiptConfig:l?[{key:ee.a.INTEREST,label:a({key:ee.a.INTEREST}),value:a({key:ee.a.EARN_PERCENT,params:{PERCENT:Object(ie.a)(u).times(100).toFixed(J.d)}}),regularFont:!0,green:!0}]:this.getConversionReceiptConfig()},d))}getDepositFromWalletReceiptConfig(){const e=this.props,t=e.getWalletBalance,a=e.stringGetter,n=this.state,r=n.amount,s=n.depositMarket,o=t(s),l=s.symbol,i=s.currency,c=Object(ce.e)(o,i.decimals),d=o.minus(r),u=Object(ce.e)(d,i.decimals);return[{key:ee.a.AVAILABLE,label:E.a.createElement(g.Fragment,null,a({key:ee.a.AVAILABLE}),E.a.createElement(M.a,{marginLeft:!0},l)),value:E.a.createElement(P.b,{before:c,after:r.gt(0)&&E.a.createElement("div",{className:v()({[ge.a.red]:d.lt(0)})},u),arrowColor:P.a.RED})}]}getDepositFromSoloReceiptConfig(){const e=this.props,t=e.spotAccount,a=e.marginAccount,n=e.getNewCollateralization,r=e.hasBorrowsInMainAccount,s=e.marginAccountCollateralization,o=e.stringGetter,l=this.state,i=l.amount,c=l.depositMarket,d=l.selectedDepositFrom,u=l.isMaxAmount,p=d===ye,m=n(new re.a(i.negated(),c)),b=Object(ie.a)(Object(U.b)({account:p?t:a,market:c}).wei),g=Object(ce.e)(b,c.currency.decimals),y=u?de.a.ZERO:b.minus(i),A=Object(ce.e)(y,c.currency.decimals),f=!p&&r,O=[{key:ee.a.AVAILABLE_SYMBOL,label:o({key:ee.a.AVAILABLE_SYMBOL,params:{SYMBOL:c.symbol}}),value:E.a.createElement(P.b,{before:E.a.createElement("div",{className:v()({[ge.a.red]:b.lt(0)})},g),after:i.gt(0)&&E.a.createElement("div",{className:v()({[ge.a.red]:y.lt(0)})},A),arrowColor:P.a.RED})}];return f&&O.push({key:ee.a.COLLATERALIZATION,label:o({key:ee.a.COLLATERALIZATION}),value:E.a.createElement(P.b,{before:E.a.createElement(C.b,{className:"collateralization",collateralization:s}),after:i.gt(0)&&s.isFinite()&&!s.eq(m)&&E.a.createElement(C.b,{className:"collateralization",collateralization:m,red:m.lt(ae.b)}),arrowColor:P.a.RED})}),O}getSoloInterestRateReceiptConfig(){const e=this.props,t=e.spotAccount,a=e.marginAccount,n=e.stringGetter,r=this.state,s=r.amount,o=r.depositMarket,l=r.selectedDestination,i=o.totalBorrowAPR,c=o.totalSupplyAPR,d=Object(ie.a)(Object(U.b)({account:l===ye?t:a,market:o}).wei),u=d.plus(s),p=Object(ie.a)(c).times(100).toFixed(J.d),m=Object(ie.a)(i).times(100).toFixed(J.d);let b;b=d.eq(0)?"-":d.gt(0)?E.a.createElement("div",{className:ge.a.green},n({key:ee.a.EARNING})," ",p,"%"):E.a.createElement("div",{className:ge.a.red},n({key:ee.a.PAYING})," ",m,"%");const g=n({key:ee.a.INTEREST_RATE_APR});if(u.eq(0))return{key:g,label:g,value:E.a.createElement(P.b,{regularFont:!0,before:b,after:s.gt(0)&&"-"}),regularFont:!0};if(u.lt(0))return{key:g,label:g,value:b,regularFont:!0};const y=s.gt(0)&&d.lte(0);return{key:g,label:g,value:E.a.createElement(P.b,{regularFont:!0,before:b,after:y&&E.a.createElement("div",{className:ge.a.green},"Earn ",p,"% APR"),arrowColor:P.a.GREEN}),regularFont:!0}}getSoloDestinationReceiptConfig(){const e=this.props,t=e.spotAccount,a=e.marginAccount,n=e.getNewCollateralization,r=e.hasBorrowsInMainAccount,s=e.marginAccountCollateralization,o=e.stringGetter,l=this.state,i=l.amount,c=l.depositMarket,d=l.selectedDestination===ye,u=n(new re.a(i,c)),p=Object(ie.a)(Object(U.b)({account:d?t:a,market:c}).wei),m=Object(ce.e)(p,c.currency.decimals),b=Object(ce.e)(p.plus(i),c.currency.decimals),y=[{key:ee.a.BALANCE,label:E.a.createElement(g.Fragment,null,o({key:ee.a.BALANCE}),E.a.createElement(M.a,{marginLeft:!0},c.symbol)),value:E.a.createElement(P.b,{before:m,after:i.gt(0)&&b,arrowColor:P.a.GREEN})}];return!d&&r&&y.push({key:ee.a.COLLATERALIZATION,label:o({key:ee.a.COLLATERALIZATION}),value:E.a.createElement(P.b,{before:E.a.createElement(C.b,{className:"collateralization",collateralization:s}),after:i.gt(0)&&s.isFinite()&&!s.eq(u)&&E.a.createElement(C.b,{className:"collateralization",collateralization:u}),arrowColor:P.a.GREEN})}),y.push(this.getSoloInterestRateReceiptConfig()),y}getPerpetualDestinationReceiptConfig(){const e=this.props,t=e.allIndexPrices,a=e.allMarkets,n=e.perpetualBalances,r=e.stringGetter,s=this.state,o=s.amount,l=s.isConversionLoading,i=s.destinationPair,c=i.orderMarket,d=i.settlementSymbol,u=i.displaySettlementSymbol,p=i.maxLeverage,m=i.isInversePerpetual,b=s.expectedConversionAmount,y=n[c],A=t[c];if(!A||!y)return null;const f=Object(me.a)({balances:y,indexPrice:A,maxLeverage:p,isInversePerpetual:m}).equity,O=this.getDepositNeedsConversion(),h=!this.getError()&&o&&!o.isZero(),v=Object(Y.c)({allMarkets:a,symbol:d}).currency.decimals;let N="-";h&&(N=l||O&&!b?E.a.createElement(x.a,{compact:!0}):O?b?`\u2248 ${Object(ce.e)(b,v)}`:"-":Object(ce.e)(o,v));const k=O?b:o,C=Object(ce.e)(f,v),w=f.plus(k),R=Object(ce.e)(w,v),S=h&&o.gt(0)&&!w.isNaN(),j=Object(ie.a)(y.position),D=Object(ie.a)(y.margin),I=Object(me.c)({positionBN:j,marginBN:D,indexPrice:A,isInversePerpetual:m});let T;return I&&!I.isZero()&&S&&(T=Object(me.c)({positionBN:j,marginBN:D.plus(k),indexPrice:A,isInversePerpetual:m})),[{key:ee.a.DEPOSIT,label:E.a.createElement(g.Fragment,null,r({key:ee.a.DEPOSIT}),E.a.createElement(M.a,{marginLeft:!0},u)),value:N},{key:ee.a.EQUITY,label:E.a.createElement(g.Fragment,null,r({key:ee.a.EQUITY}),E.a.createElement(M.a,{marginLeft:!0},u)),value:E.a.createElement(P.b,{before:C,after:S&&R,arrowColor:P.a.GREEN})},{key:ee.a.LEVERAGE,label:r({key:ee.a.LEVERAGE}),value:E.a.createElement(P.b,{before:I.isZero()?"-":`${I.toFixed(J.e)}X`,after:T&&`${T.toFixed(J.e)}X`,arrowColor:P.a.GREEN})}]}renderModal(){const e=this.props,t=e.closeSidebarModal,a=e.stringGetter,n=e.walletAddress,r=this.state,s=r.amount,o=r.error,l=r.loading,i=r.selectedDestination,c=r.isConversionLoading,d=r.showSettingsMenu,u=this.getIsAllowanceSet(),m=this.getError()||o,b=!n||m||s.isNaN()||s.lte(0)||this.getDepositNeedsConversion()&&c,g=p()([Ae,ye],i);return E.a.createElement("div",{className:ge.a.depositModal},E.a.createElement(S.a,{noBorder:!0,title:a({key:ee.a.DEPOSIT}),closeModal:t}),E.a.createElement("div",{className:ge.a.modalContent},E.a.createElement("div",null,this.renderSourceDropdown(),this.renderDestinationDropdown(),this.renderAssetDropdown(),u?this.renderAmountInput():this.renderSetAllowance(),m?E.a.createElement(L.b,{type:L.a.ERROR,message:m}):null),E.a.createElement(I.a,{receiptOnTop:!0,receiptConfig:g?this.getSoloDestinationReceiptConfig():this.getPerpetualDestinationReceiptConfig()},E.a.createElement(B.f,{purple:!0,fullWidth:!0,size:B.e.LARGE,disabled:b||!u,onClick:this.onClickCta,isLoading:l},a({key:ee.a.CONFIRM_DEPOSIT}))),d&&E.a.createElement("div",{role:"button",tabIndex:0,className:ge.a.settingsMenuOverlay,onClick:()=>this.setState({showSettingsMenu:!1})})))}render(){const e=this.props,t=e.areSoloAccountsLoaded,a=e.areIndexPricesLoaded;return t&&a?this.renderModal():E.a.createElement("div",{className:ge.a.loading},E.a.createElement(R.a,null))}}Oe.propTypes={allIndexPrices:A.a.object.isRequired,allMarkets:A.a.array.isRequired,allWalletBalances:A.a.object.isRequired,areIndexPricesLoaded:A.a.bool.isRequired,areSoloAccountsLoaded:A.a.bool.isRequired,closeSidebarModal:A.a.func.isRequired,convertAndDeposit:A.a.func.isRequired,currentPair:A.a.object.isRequired,depositPerpetual:A.a.func.isRequired,depositSolo:A.a.func.isRequired,getNewCollateralization:A.a.func.isRequired,getWalletBalance:A.a.func.isRequired,hasBorrowsInMainAccount:A.a.bool.isRequired,isUserInUsa:A.a.bool.isRequired,isWalletInvalid:A.a.bool.isRequired,marginAccount:A.a.object,marginAccountCollateralization:A.a.object,marginAllowances:A.a.object,perpetualAllowances:A.a.object.isRequired,perpetualBalances:A.a.object.isRequired,perpetualConversionProxyAllowances:A.a.object.isRequired,product:A.a.oneOf(r()(ne.a)),setConversionProxyAllowance:A.a.func.isRequired,setPerpetualAllowance:A.a.func.isRequired,setSoloAllowance:A.a.func.isRequired,spotAccount:A.a.object,stringGetter:A.a.func.isRequired,transferSolo:A.a.func.isRequired,walletAddress:A.a.string,walletType:A.a.string};var he=Object(N.k)(Object(O.c)(e=>({allIndexPrices:Object(K.b)(e),allMarkets:Object(Y.d)(e),allWalletBalances:Object(V.o)(e),areIndexPricesLoaded:Object(K.c)(e),areSoloAccountsLoaded:Object(U.i)(e),currentPair:Object(Z.e)(e),getNewCollateralization:t=>Object(U.u)(e,[t]),getWalletBalance:t=>Object(V.n)(e,t),hasBorrowsInMainAccount:Object(U.k)(e),isUserInUsa:Object(X.c)(e),isWalletConnected:Object(V.u)(e),isWalletInvalid:Object(V.v)(e),marginAccount:Object(U.r)(e),marginAccountCollateralization:Object(U.s)(e),marginAllowances:Object(V.j)(e),perpetualAllowances:Object(z.h)(e),perpetualBalances:Object(z.e)(e),perpetualConversionProxyAllowances:Object(z.f)(e),spotAccount:Object(U.v)(e),walletAddress:Object(V.m)(e),walletType:Object(V.q)(e)}),e=>Object(f.b)({convertAndDeposit:W.a,depositSolo:q.a,depositPerpetual:W.c,setConversionProxyAllowance:W.h,setSoloAllowance:q.c,setPerpetualAllowance:W.j,transferSolo:q.e},e))(Oe));a.d(t,"default",function(){return he})}}]);