Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
}
```