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

feat(swap): Integrate open orders with MuesliSwap API #2668

Merged
merged 10 commits into from
Sep 8, 2023

Conversation

michaeljscript
Copy link
Collaborator

@michaeljscript michaeljscript commented Sep 7, 2023

Resolves YOMO-628

To test the functionality, you may need to

  1. Have a mainnet wallet with some ADA
  2. Place limit order on muesli swap web
  3. Wait for the transaction to appear on the mobile
  4. Navigate to swap
  5. Navigate to open orders
  6. You should see your open order

@@ -442,7 +442,7 @@ export const makeShelleyWallet = (constants: typeof MAINNET | typeof TESTNET) =>
return Promise.resolve(result)
}

private async getStakingKey() {
public async getStakingKey() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muesliswap API needs a staking key to list all open orders. Not sure however if making this method public is the best way to go

@@ -45,8 +45,7 @@ export const asYoroiOrder = (openswapOrder: Order) => {
...rest,
from: asYoroiAmount(from),
to: asYoroiAmount(to),
// TODO: initialize the module with the primary token
deposit: asYoroiAmount({amount: deposit, token: ''}), // token = wallet.primaryTokenInfo['id']
deposit: deposit as Balance.Quantity,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deposit response is a string, so I've also changed it here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's supposed to be `asYoroiAmount({quantity: asQuantity(deposit), token: ''}), Yoroi will deal only with amounts in the Portfolio manager, token here is the wallet.primaryTokenInfo.id, we should add to the initialization when the factory is invoked.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's now updated


// TODO add icons for each pool and change it depending on name
/* eslint-disable @typescript-eslint/no-unused-vars */
export const PoolIcon = ({providerId, size}: {providerId: string; size: number}) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in pool selector and open orders list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the same as mentioned below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's now added

@michaeljscript michaeljscript marked this pull request as ready for review September 7, 2023 16:03
@@ -41,11 +41,12 @@ export const TxHistoryNavigator = () => {
const [modalInfoState, setModalInfoState] = React.useState(false)
const showModalInfo = () => setModalInfoState(true)
const hideModalInfo = () => setModalInfoState(false)
const stakingKey = useStakingKey(wallet)

const swapStorage = makeSwapStorage()
const swapAPI = makeSwapApi({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it also need the primary token info for some of the transformations

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be now updated

@@ -115,6 +116,18 @@ export const useUtxos = (wallet: YoroiWallet) => {
return wallet.utxos
}

export const useStakingKey = (wallet: YoroiWallet) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have it in the wallet. ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it in the constructor. The getStakingKey on wallet returns PublicKey and we need to use a string here.

@michaeljscript michaeljscript self-assigned this Sep 7, 2023
@michaeljscript michaeljscript changed the title feat(swap): Integrate open orders with muesliswap API feat(swap): Integrate open orders with MuesliSwap API Sep 7, 2023
@stackchain stackchain merged commit fcb290c into develop Sep 8, 2023
2 checks passed
@stackchain stackchain deleted the feat/open-orders branch September 8, 2023 08:08
@stackchain stackchain added this to the 5.0.0 milestone Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants