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: Add price field to AddTranche #33

Merged
merged 5 commits into from
Jan 31, 2023

Conversation

NunoAlexandre
Copy link
Contributor

We add a price field to the AddTranche message which represents the price of the tranche token being added at that specific moment in time.

Internally, this value - and UpdateTokenPrice.price - is stored as Tranche.latestPrice. That struct field has u256 as its type, which is not compatible with the Cent-Chain side where a tranche price is typed as Rate(u128).

u128 encodes to 16 bytes while u256 encodes to 32 bytes. For that reason, to make both sides compatible, we parse and encode price as a u128 but keep the internal storage type as u256 for now.

Note: we will need to also apply this described parsing approach to UpdateTokenPrice in a follow up PR.

Something is off either in Solidity or on the cent-chain as the encoded
AddTranche messages are not matching across the two sides. On solidity
we get 217 byte-long messages which seems correct but nothing seems
apparently wrong in the Rust side.
@NunoAlexandre NunoAlexandre changed the base branch from main to add-withdaw-deposit January 31, 2023 10:30
@NunoAlexandre NunoAlexandre merged commit afb740c into add-withdaw-deposit Jan 31, 2023
@NunoAlexandre NunoAlexandre deleted the feat/add-trache-price branch January 31, 2023 14:07
NunoAlexandre added a commit that referenced this pull request Feb 9, 2023
* add withdraw & deposit

* make withdraw function public

* add sendMessages to router

* update deploy script and add test

* switch Nomad to XCM router in tests

* add happy case deposit & withdraw tests

* remove unused code

* add xAppConnectionManager

* add assertions for withdraw happu case

* add edges cases for transfer route

* add edge case tests for transferTo

* remove misleading messages

* remove misleading messages

* update origin address

* Use correct checksummed origin address

* Strip out nomad and testing dependencies from XCMRouter. Add ping function for testing.

* Update router

* fix naming

* Update centrifuge origin address

* fix updateMember parsing

* roll back updateMember change

* Clean up

* forge install: memview-sol

* Fix all the tests

* Fix deps

* Remove yarn steps from workflows

* Remove deploy test

* Remove nomad router's send message logic and tests pertaining to it

* Fix memview-sol branch submodule not found

* Drop "== true" blocks

* Fix `UpdateMember` encoding & decoding (#32)

* Fix 9-24: trancheId (16 bytes) docs

* feat: Add `price` field to `AddTranche` (#33)

* Make `UpdateTokenPrice.price` and `Tranche.latestPrice` `u128` (#34)

* Use cent-chain AddTranche message

Use a cent-chain generated message to test AddTranche encoding and
decoding functions.

* Align tests with cent chain (#36)

* Use cent-chain generated UpdateMember for decoding

* Drop toBytes16

* Chore/add tests and optimizations (#38)

* wip: add transfer test

* move memberlist check from connectors to restricted token

* fix tests

* revert restricted.sol changes

* revert unwanted changes to erc20 and memberlist

* fix test

* Feat/domain update (#35)

* remove domainLookup

* require destination domain to be cent chain

* fix tests

* clean up

* fix up

* rename Domains to Domain

* Add new domain lookup

* update domain enum

* move formatDomain to messages.sol

* fix tests

* update enum and domain encoding

* update domain encoding to output bytes9

* Update src/Connector.sol

* update domain encoding and add more tests

---------

Co-authored-by: Jeroen Offerijns <[email protected]>

* Fine-tune transfers encoding, decoding, and tests (#39)

* Fix transfer encoding / decoding

We need to encode address as 32 bytes and take in consideration when
decoding. Also, amount should be encoded as a u128.

* Fix transfer decoding

* Cover transfer to centrifuge

* Fix docs - thanks @AStox

* Add TODO and more tests

* Update test/Connector.t.sol

---------

Co-authored-by: Adam Stox <[email protected]>
Co-authored-by: Jeroen Offerijns <[email protected]>
Co-authored-by: nuno <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
Co-authored-by: Jeroen Offerijns <[email protected]>
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.

None yet

2 participants