Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added updated token info for mim swap #513

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/views/MimSwap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ export default {

"actionConfig.fromToken": {
async handler() {
this.isLoading = true;
// @ts-ignore
this.swapInfo = await getSwapInfo(
this.poolsList,
Expand All @@ -397,14 +396,12 @@ export default {
);

this.actionConfig.toInputValue = this.swapInfo.outputAmount;
this.isLoading = false;
},
deep: true,
},

"actionConfig.toToken": {
async handler() {
this.isLoading = true;
// @ts-ignore
this.swapInfo = await getSwapInfo(
this.poolsList,
Expand All @@ -414,7 +411,6 @@ export default {
);

this.actionConfig.toInputValue = this.swapInfo.outputAmount;
this.isLoading = false;
},
deep: true,
},
Expand Down Expand Up @@ -592,6 +588,8 @@ export default {
this.account
);

this.updatedTokenInfo();

this.poolsList = await getAllPoolsByChain(
this.selectedNetwork,
this.poolConfigs,
Expand All @@ -618,6 +616,27 @@ export default {
this.selectedNetwork = this.chainId;
}
},

updatedTokenInfo() {
if (this.actionConfig.fromToken.config.contract.address === "0x") return;
if (this.actionConfig.toToken.config.contract.address === "0x") return;

const fromToken = this.tokensList.find(
(token: TokenInfo) =>
this.actionConfig.fromToken.config.contract.address.toLowerCase() ===
token.config.contract.address.toLowerCase()
);

if (fromToken) this.actionConfig.fromToken = fromToken;

const toToken = this.tokensList.find(
(token: TokenInfo) =>
this.actionConfig.toToken.config.contract.address.toLowerCase() ===
token.config.contract.address.toLowerCase()
);

if (toToken) this.actionConfig.toToken = toToken;
},
},

async created() {
Expand Down