Skip to content

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Jan 20, 2023

This is an example oracle AMM application using Pyth prices. I'll give you the context for why we need this on slack.

(I based this on @ali-bahjati 's ETH transfer example)

The frontend associated with this app is very janky at the moment. It works, but it needs some love. I'll come back to that in the next PR.
Screen Shot 2023-01-20 at 3 12 48 PM

@vercel
Copy link

vercel bot commented Jan 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
xc-admin-frontend ⬜️ Ignored (Inspect) Jan 25, 2023 at 4:38PM (UTC)


```
forge install foundry-rs/forge-std@2c7cbfc6fbede6d7c9e6b17afe997e3fdfe22fef --no-git --no-commit
forge install pyth-network/pyth-sdk-solidity@v1.0.1 --no-git --no-commit
Copy link
Collaborator

Choose a reason for hiding this comment

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

for future: we can update this sdk to the new version. the only change will be the getUpdateFee method.

@@ -0,0 +1,272 @@
[
Copy link
Collaborator

Choose a reason for hiding this comment

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

For future: maybe move abis to an abi directory?

}
}

// TODO: we should probably move something like this into the solidity sdk
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah i had the same impression for this too. But If it is an example we want to share with people, can we add this as an issue and remove it from here?


if (isBuy) {
// (Round up)
quoteSize += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is only true if the remainder of size * basePrice % quotePrice is positive, right? I guess its fine.

// (Round up)
quoteSize += 1;

quoteToken.transferFrom(msg.sender, address(this), quoteSize);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add that the transaction reverts if there is not enough fund in the users wallet or the contract.

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

It is awesome! I left some minor comments.

In general before merging it let's have a disclaimer in the readme that this is not intended for any production use. Also, the way this DEX works is not very practical.

}

function testSwap() public {
setupTokens(10e18, 10e18, 10e18, 10e18);
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe move this to setUp too?

@ali-behjati ali-behjati changed the title Ethereum token swap example application [eth] Add token swap example application Jan 23, 2023
@jayantk jayantk merged commit 3af759b into main Jan 25, 2023
@jayantk jayantk deleted the eth_example_swap branch January 25, 2023 16:38
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.

2 participants