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

St0x spec #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

St0x spec #23

wants to merge 3 commits into from

Conversation

hardyjosh
Copy link
Contributor

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

```
[
uint256 ioRatio, // Price ratio for the trading pair
uint256 pairHash, // keccak256 hash of the pair name (e.g. "TSLAUSD")
Copy link
Contributor

Choose a reason for hiding this comment

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

this would only be expressable in rainlang if the string is a compatible Intorastring that is being hashed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does rainlang need to hash it though? it could be hashed and inserted by the order writer

Copy link
Contributor

Choose a reason for hiding this comment

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

i'm expecting yes, otherwise the rainlang author can't use the input tokens from context to lookup pairs

Copy link
Contributor

Choose a reason for hiding this comment

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

the other way that we could do it is add more words to rainlang like utf8-hash() or something, that first convert the rain string to a utf8 string and then hash that instead

## Magic Numbers

- Web data metadata magic number: `0xff5dcce9b571ba42`
- st0x API magic number: `0x7374307870616972` ("st0xpair" in hex)
Copy link
Contributor

Choose a reason for hiding this comment

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

the point of a magic number is for it to have a negligible chance of colliding with any file that isn't what we're expecting, so that we don't misinterpret data

so at the least it should start with 0xff but it also shouldn't be a valid ascii string that could easily be found in the wild in other contexts

safer would be to use the initial bytes of the hash of st0xpair rather than literally the string, which would likely result in at least a few invalid ascii/utf8 chars and prevent it matching random strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok - i'll make another one

```
[
uint256 ioRatio, // Price ratio for the trading pair
uint256 pairHash, // keccak256 hash of the pair name (e.g. "TSLAUSD")
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm expecting yes, otherwise the rainlang author can't use the input tokens from context to lookup pairs

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