Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kybernetwork/kyberswap-dex-lib
DexLib is a library used by Kyberswap backend to integrate with decentralized exchanges. This library enables external DEX developers to integrate their DEX with Kyberswap by creating pull requests to this repository.
https://github.com/kybernetwork/kyberswap-dex-lib
Last synced: about 2 months ago
JSON representation
DexLib is a library used by Kyberswap backend to integrate with decentralized exchanges. This library enables external DEX developers to integrate their DEX with Kyberswap by creating pull requests to this repository.
- Host: GitHub
- URL: https://github.com/kybernetwork/kyberswap-dex-lib
- Owner: KyberNetwork
- Created: 2023-05-23T10:06:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:18:07.000Z (2 months ago)
- Last Synced: 2024-10-29T11:36:48.038Z (2 months ago)
- Language: Go
- Homepage:
- Size: 4.65 MB
- Stars: 19
- Watchers: 11
- Forks: 28
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# kyberswap-dex-lib
## Marshal/unmarshal pool simulator
When implementing a new pool simulator, to make it marshal-able and unmarshal-able, we have to notice the following:
* rerun `go generate ./...` to register the new pool simulator struct
* Because we might marshal/unmarshal a pool simulator under the `IPoolSimulator` interface. We have to register the underlying struct so we can unmarshal it as `IPoolSimulator`.* pointer aliases
* If the pool simulator struct contains pointer aliases, we must use `msgpack:"-"` tag to ignore the aliases and set them inside the `AfterMsgpackUnmarshal()` method. For an example:
```
type PoolSimulator struct {
vault *Vault
vaultUtils *VaultUtils
}
type VaultUtils struct {
vault *Vault `msgpack:"-"`
}func (p *PoolSimulator) AfterMsgpackUnmarshal() error {
if p.vaultUtils != nil {
p.vaultUtils.vault = p.vault
}
return nil
}
```