129129 <div class =" card" >
130130 <div class =" card-body" >
131131 <CoinInput
132- v-model =" fromCoinAmount "
132+ v-model =" fromCoinAmountMin "
133133 label =" Input"
134134 :mint-address =" fromCoin ? fromCoin.mintAddress : ''"
135135 :coin-name =" fromCoin ? fromCoin.symbol : ''"
156156 </div >
157157
158158 <CoinInput
159- v-model =" toCoinAmount "
159+ v-model =" toCoinAmountMin "
160160 label =" Input"
161161 :mint-address =" toCoin ? toCoin.mintAddress : ''"
162162 :coin-name =" toCoin ? toCoin.symbol : ''"
176176 @onSelect =" openToCoinSelect"
177177 />
178178
179- <LiquidityPoolInfo :initialized =" liquidity.initialized" :pool-info =" liquidity.infos[lpMintAddress]" />
179+ <LiquidityPoolInfo
180+ :fixed-coin-symbol ="
181+ toCoin !== null && fixedCoin === toCoin.mintAddress
182+ ? toCoin.symbol
183+ : fromCoin !== null && fixedCoin === fromCoin.mintAddress
184+ ? fromCoin.symbol
185+ : ''
186+ "
187+ :max-amount =" `${
188+ toCoin !== null && fixedCoin === toCoin.mintAddress
189+ ? fromCoinAmount
190+ : fromCoin !== null && fixedCoin === fromCoin.mintAddress
191+ ? toCoinAmount
192+ : 0
193+ } ${
194+ toCoin !== null && fromCoin !== null && fixedCoin === toCoin.mintAddress
195+ ? fromCoin.symbol
196+ : toCoin !== null && fromCoin !== null && fixedCoin === fromCoin.mintAddress
197+ ? toCoin.symbol
198+ : ''
199+ }`"
200+ :initialized =" liquidity.initialized"
201+ :pool-info =" liquidity.infos[lpMintAddress]"
202+ />
180203 <!-- <div v-if="officialPool === false">
181204 <div style="margin: 10px">
182205 <div>AMM ID:</div>
225248 !lpMintAddress ||
226249 !liquidity.initialized ||
227250 liquidity.loading ||
228- gt(fromCoinAmount , fromCoin.balance ? fromCoin.balance.fixed() : '0') ||
229- gt(toCoinAmount , toCoin.balance ? toCoin.balance.fixed() : '0') ||
251+ gt(fromCoinAmountMin , fromCoin.balance ? fromCoin.balance.fixed() : '0') ||
252+ gt(toCoinAmountMin , toCoin.balance ? toCoin.balance.fixed() : '0') ||
230253 suppling ||
231254 (fromCoin.mintAddress === TOKENS.xCOPE.mintAddress && gt(5, fromCoinAmount)) ||
232255 (toCoin.mintAddress === TOKENS.xCOPE.mintAddress && gt(5, toCoinAmount))
238261 <template v-else-if =" ! lpMintAddress || ! liquidity .initialized " > Invalid pair </template >
239262 <template v-else-if =" ! fromCoinAmount " > Enter an amount </template >
240263 <template v-else-if =" liquidity .loading " > Updating pool information </template >
241- <template v-else-if =" gt (fromCoinAmount , fromCoin .balance ? fromCoin .balance .fixed () : ' 0' )" >
264+ <template v-else-if =" gt (fromCoinAmountMin , fromCoin .balance ? fromCoin .balance .fixed () : ' 0' )" >
242265 Insufficient {{ fromCoin.symbol }} balance
243266 </template >
244- <template v-else-if =" gt (toCoinAmount , toCoin .balance ? toCoin .balance .fixed () : ' ' )" >
267+ <template v-else-if =" gt (toCoinAmountMin , toCoin .balance ? toCoin .balance .fixed () : ' 0 ' )" >
245268 Insufficient {{ toCoin.symbol }} balance
246269 </template >
247270 <template v-else-if =" fromCoin .mintAddress === TOKENS .xCOPE .mintAddress && gt (50 , fromCoinAmount )" >
@@ -321,6 +344,8 @@ export default Vue.extend({
321344
322345 fromCoin: RAY as TokenInfo | null ,
323346 toCoin: null as TokenInfo | null ,
347+ fromCoinAmountMin: ' ' ,
348+ toCoinAmountMin: ' ' ,
324349 fromCoinAmount: ' ' ,
325350 toCoinAmount: ' ' ,
326351
@@ -456,6 +481,8 @@ export default Vue.extend({
456481 this .findLiquidityPool ()
457482 this .fromCoinAmount = ' '
458483 this .toCoinAmount = ' '
484+ this .fromCoinAmountMin = ' '
485+ this .toCoinAmountMin = ' '
459486 }
460487 },
461488
@@ -468,6 +495,8 @@ export default Vue.extend({
468495 this .findLiquidityPool ()
469496 this .fromCoinAmount = ' '
470497 this .toCoinAmount = ' '
498+ this .fromCoinAmountMin = ' '
499+ this .toCoinAmountMin = ' '
471500 }
472501 },
473502
@@ -675,9 +704,14 @@ export default Vue.extend({
675704 changeCoinAmountPosition() {
676705 const tempFromCoinAmount = this .fromCoinAmount
677706 const tempToCoinAmount = this .toCoinAmount
707+ const tempFromCoinAmountMin = this .fromCoinAmountMin
708+ const tempToCoinAmountMin = this .toCoinAmountMin
678709
679710 this .fromCoinAmount = tempToCoinAmount
680711 this .toCoinAmount = tempFromCoinAmount
712+
713+ this .fromCoinAmountMin = tempToCoinAmountMin
714+ this .toCoinAmountMin = tempFromCoinAmountMin
681715 },
682716
683717 updateCoinInfo(tokenAccounts : any ) {
@@ -780,34 +814,38 @@ export default Vue.extend({
780814 const poolInfo = this .liquidity .infos [this .lpMintAddress ]
781815
782816 if (this .fixedCoin === this .fromCoin .mintAddress ) {
783- const amount = (poolInfo .version === 5 ? getOutAmountStable : getOutAmount )(
817+ const { outAmount, outMinAmount } = (poolInfo .version === 5 ? getOutAmountStable : getOutAmount )(
784818 poolInfo ,
785819 this .fromCoinAmount ,
786820 this .fromCoin .mintAddress ,
787821 this .toCoin .mintAddress ,
788822 this .setting .slippage
789823 )
790824
791- if (amount .isNaN () || ! amount .isFinite ()) {
825+ if (outAmount .isNaN () || ! outAmount .isFinite ()) {
792826 this .toCoinAmount = ' '
827+ this .toCoinAmountMin = ' '
793828 } else {
794- this .toCoinAmount = amount .toFixed (this .toCoin .decimals )
829+ this .toCoinAmountMin = outMinAmount .toFixed (this .toCoin .decimals )
830+ this .toCoinAmount = outAmount .toFixed (this .toCoin .decimals )
795831 }
796832 } else {
797833 const poolInfo = this .liquidity .infos [this .lpMintAddress ]
798834
799- const amount = (poolInfo .version === 5 ? getOutAmountStable : getOutAmount )(
835+ const { outAmount, outMinAmount } = (poolInfo .version === 5 ? getOutAmountStable : getOutAmount )(
800836 poolInfo ,
801837 this .toCoinAmount ,
802838 this .toCoin .mintAddress ,
803839 this .fromCoin .mintAddress ,
804840 this .setting .slippage
805841 )
806842
807- if (amount .isNaN () || ! amount .isFinite ()) {
843+ if (outAmount .isNaN () || ! outAmount .isFinite ()) {
808844 this .fromCoinAmount = ' '
845+ this .fromCoinAmountMin = ' '
809846 } else {
810- this .fromCoinAmount = amount .toFixed (this .toCoin .decimals )
847+ this .fromCoinAmountMin = outMinAmount .toFixed (this .toCoin .decimals )
848+ this .fromCoinAmount = outAmount .toFixed (this .toCoin .decimals )
811849 }
812850 }
813851 }
0 commit comments