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 support of both v1 & v1.1 family of scripts #101

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ WORKDIR /SOR
RUN cabal update
COPY cabal.project ./
COPY geniusyield-orderbot.cabal ./
COPY geniusyield-dex-api/geniusyield-dex-api.cabal ./geniusyield-dex-api/
COPY geniusyield-orderbot-framework/geniusyield-orderbot-framework.cabal geniusyield-orderbot-framework/

RUN cabal update
RUN cabal build geniusyield-dex-api --only-dependencies

COPY . .

Expand All @@ -62,15 +60,12 @@ RUN cabal install --global
LABEL org.opencontainers.image.source="https://github.com/geniusyield/smart-order-router"

# Default values:
ENV BOTC_FP_NFT_POLICY='compiled-scripts/minting-policy'
ENV BOTC_FP_ORDER_VALIDATOR='compiled-scripts/partial-order'
ENV BOTC_EXECUTION_STRAT='OneSellToManyBuy'
ENV BOTC_RESCAN_DELAY='30000000'
ENV BOTC_MAX_ORDERS_MATCHES='5'
ENV BOTC_MAX_TXS_PER_ITERATION='4'
ENV BOTC_RANDOMIZE_MATCHES_FOUND='True'
ENV BOTC_ASSET_FILTER='[{ "commodityAsset" : "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e.776f726c646d6f62696c65746f6b656e", "currencyAsset" : "lovelace"},{ "commodityAsset" : "1ddcb9c9de95361565392c5bdff64767492d61a96166cb16094e54be.4f5054", "currencyAsset" : "lovelace"},{ "commodityAsset" : "25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c.534f4349455459", "currencyAsset" : "lovelace"},{ "commodityAsset" : "279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f.534e454b", "currencyAsset" : "lovelace"},{ "commodityAsset" : "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6.4d494e", "currencyAsset" : "lovelace"},{ "commodityAsset" : "51a5e236c4de3af2b8020442e2a26f454fda3b04cb621c1294a0ef34.424f4f4b", "currencyAsset" : "lovelace"},{ "commodityAsset" : "533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0.494e4459", "currencyAsset" : "lovelace"},{ "commodityAsset" : "5c1c91a65bedac56f245b8184b5820ced3d2f1540e521dc1060fa683.4a454c4c59", "currencyAsset" : "lovelace"},{ "commodityAsset" : "5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d114.494147", "currencyAsset" : "lovelace"},{ "commodityAsset" : "5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc92843489.4e4d4b52", "currencyAsset" : "lovelace"},{ "commodityAsset" : "681b5d0383ac3b457e1bcc453223c90ccef26b234328f45fa10fd276.4a5047", "currencyAsset" : "lovelace"},{ "commodityAsset" : "682fe60c9918842b3323c43b5144bc3d52a23bd2fb81345560d73f63.4e45574d", "currencyAsset" : "lovelace"},{ "commodityAsset" : "6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d10.4d454c44", "currencyAsset" : "lovelace"},{ "commodityAsset" : "6c8642400e8437f737eb86df0fc8a8437c760f48592b1ba8f5767e81.456d706f7761", "currencyAsset" : "lovelace"},{ "commodityAsset" : "75fcc276057db5fc48eae0e11453c773c8a54604c3086bf9d95ac1b7.43485259", "currencyAsset" : "lovelace"},{ "commodityAsset" : "7914fae20eb2903ed6fd5021a415c1bd2626b64a2d86a304cb40ff5e.4c494649", "currencyAsset" : "lovelace"},{ "commodityAsset" : "804f5544c1962a40546827cab750a88404dc7108c0f588b72964754f.56594649", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa.4d494c4b", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8cfd6893f5f6c1cc954cec1a0a1460841b74da6e7803820dde62bb78.524a56", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8daefa391220bd0d8d007f3748d870f7f3c106040314c8515ccc35a5.464c4143", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61.446a65644d6963726f555344", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61.5368656e4d6963726f555344", "currencyAsset" : "lovelace"},{ "commodityAsset" : "8fef2d34078659493ce161a6c7fba4b56afefa8535296a5743f69587.41414441", "currencyAsset" : "lovelace"},{ "commodityAsset" : "95a427e384527065f2f8946f5e86320d0117839a5e98ea2c0b55fb00.48554e54", "currencyAsset" : "lovelace"},{ "commodityAsset" : "9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d77.53554e444145", "currencyAsset" : "lovelace"},{ "commodityAsset" : "9abf0afd2f236a19f2842d502d0450cbcd9c79f123a9708f96fd9b96.454e4353", "currencyAsset" : "lovelace"},{ "commodityAsset" : "a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235.484f534b59", "currencyAsset" : "lovelace"},{ "commodityAsset" : "a3931691f5c4e65d01c429e473d0dd24c51afdb6daf88e632a6c1e51.6f7263666178746f6b656e", "currencyAsset" : "lovelace"},{ "commodityAsset" : "b34b3ea80060ace9427bda98690a73d33840e27aaa8d6edb7f0c757a.634e455441", "currencyAsset" : "lovelace"},{ "commodityAsset" : "b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0.436f726e75636f70696173205b76696120436861696e506f72742e696f5d", "currencyAsset" : "lovelace"},{ "commodityAsset" : "c0ee29a85b13209423b10447d3c2e6a50641a15c57770e27cb9d5073.57696e67526964657273", "currencyAsset" : "lovelace"},{ "commodityAsset" : "da8c30857834c6ae7203935b89278c532b3995245295456f993e1d24.4c51", "currencyAsset" : "lovelace"},{ "commodityAsset" : "dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb.0014df1047454e53", "currencyAsset" : "lovelace"},{ "commodityAsset" : "e52964af4fffdb54504859875b1827b60ba679074996156461143dc1.4f5054494d", "currencyAsset" : "lovelace"},{ "commodityAsset" : "edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e99344479.4e5458", "currencyAsset" : "lovelace"},{ "commodityAsset" : "f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc535.41474958", "currencyAsset" : "lovelace"},{ "commodityAsset" : "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b69880.69425443", "currencyAsset" : "lovelace"},{ "commodityAsset" : "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b69880.69455448", "currencyAsset" : "lovelace"},{ "commodityAsset" : "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b69880.69555344", "currencyAsset" : "lovelace"},{ "commodityAsset" : "fbae99b8679369079a7f6f0da14a2cf1c2d6bfd3afdf3a96a64ab67a.0014df1047454e5358", "currencyAsset" : "lovelace"},{ "commodityAsset" : "577f0b1342f8f8f4aed3388b80a8535812950c7a892495c0ecdf0f1e.0014df10464c4454", "currencyAsset" : "lovelace"},{ "commodityAsset" : "fc11a9ef431f81b837736be5f53e4da29b9469c983d07f321262ce61.4652454e", "currencyAsset" : "lovelace"},{ "commodityAsset" : "af2e27f580f7f08e93190a81f72462f153026d06450924726645891b.44524950", "currencyAsset" : "lovelace"}]'
ENV BOTC_POREFS='{ "refAddr": "addr1w9zr09hgj7z6vz3d7wnxw0u4x30arsp5k8avlcm84utptls8uqd0z", "refNftAC": "fae686ea8f21d567841d703dea4d4221c2af071a6f2b433ff07c0af2.4aff78908ef2dce98bfe435fb3fd2529747b1c4564dff5adebedf4e46d0fc63d", "nftPolicyRef": "062f97b0e64130bc18b4a227299a62d6d59a4ea852a4c90db3de2204a2cd19ea#1" , "scriptRef": "062f97b0e64130bc18b4a227299a62d6d59a4ea852a4c90db3de2204a2cd19ea#2" }'


ENTRYPOINT ["/bin/bash", "./start.sh"]
52 changes: 0 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,6 @@ file. The complete bot configuration looks like this:
```json
{
"signingKeyFP": "bot.skey",
"nftMintingPolicyFP": "compiled-scripts/minting-policy",
"orderValidatorFP": "compiled-scripts/partial-order",
"validatorRefs": {
"refAddr": "addr_test1wrgvy8fermjrruaf7fnndtmpuw4xx4cnvfqjp5zqu8kscfcvh32qk",
"refNftAC": "fae686ea8f21d567841d703dea4d4221c2af071a6f2b433ff07c0af2.8309f9861928a55d37e84f6594b878941edce5e351f7904c2c63b559bde45c5c",
"scriptRef": "be6f8dc16d4e8d5aad566ff6b5ffefdda574817a60d503e2a0ea95f773175050#2",
"nftPolicyRef": "be6f8dc16d4e8d5aad566ff6b5ffefdda574817a60d503e2a0ea95f773175050#1"
},
"strategy": "OneSellToManyBuy",
"scanDelay": 40000000,
"maxOrderMatches": 5,
Expand All @@ -350,17 +342,6 @@ file. The complete bot configuration looks like this:
on a file.
- `collateral`, an optional field to specify the collateral for the bot. If not
present, Atlas will choose a suitable UTxO as collateral.
- `nftMintingPolicyFP` and `orderValidatorFP`, the filepath where the minting policy
and validator are stored.
- `"validatorsRefs"`, contains the information necessary for the validator. Contains 3
mandatory fields and 2 optional ones.
- `"refAddr"`, address where the reference NFT is placed.
- `"refNftAc"`, assetClass of the reference NFT is placed.
- `"refNftUtxoRef"`, UTxO reference where the reference NFT is placed.
- `"scriptRef"`, an optional parameter for the script reference. This UTxO has to
have the partial order validator as a script ref.
- `"nftPolicyRef"`, an optional parameter for the script reference of the partial
orders NFT. This UTxO has to have the partial order NFT minting policy as a script ref.
- `strategy`, currently the SOR supports one possible strategy: OneSellToManyBuy.
- `scanDelay`, the duration of time in µs we wait before re-initiating a complete iteration for the bot.
- `maxOrderMatches`, is the maximum amount of orders to be matched into a single transaction.
Expand Down Expand Up @@ -422,37 +403,6 @@ Assign the selected UTXO (hash + index) to `COLLATERAL_UTXO_REF` when running t

Alternatively, the UTXO information can also be obtained from a block explorer service such as https://cexplorer.io/

#### Deployed Contract

The SOR has the ability to use reference scripts on the filling transactions to
help minimize the fees. To do that, we need to use the official contract information
that is completely placed on the blockchain. That is the validator and the minting policy.

##### Preprod
```json
{
"validatorRefs": {
"refAddr": "addr_test1wrgvy8fermjrruaf7fnndtmpuw4xx4cnvfqjp5zqu8kscfcvh32qk",
"refNftAC": "fae686ea8f21d567841d703dea4d4221c2af071a6f2b433ff07c0af2.8309f9861928a55d37e84f6594b878941edce5e351f7904c2c63b559bde45c5c",
"scriptRef": "be6f8dc16d4e8d5aad566ff6b5ffefdda574817a60d503e2a0ea95f773175050#2",
"nftPolicyRef": "be6f8dc16d4e8d5aad566ff6b5ffefdda574817a60d503e2a0ea95f773175050#1"
}
}
```

##### Mainnet

```json
{
"validatorRefs":{
"refAddr": "addr1w9zr09hgj7z6vz3d7wnxw0u4x30arsp5k8avlcm84utptls8uqd0z",
"refNftAC": "fae686ea8f21d567841d703dea4d4221c2af071a6f2b433ff07c0af2.4aff78908ef2dce98bfe435fb3fd2529747b1c4564dff5adebedf4e46d0fc63d",
"scriptRef": "062f97b0e64130bc18b4a227299a62d6d59a4ea852a4c90db3de2204a2cd19ea#2",
"nftPolicyRef": "062f97b0e64130bc18b4a227299a62d6d59a4ea852a4c90db3de2204a2cd19ea#1"
}
}
```

#### Running

Once we compiled and configured the order bot, you can execute the SOR using the [Makefile](./Makefile):
Expand All @@ -472,8 +422,6 @@ For running the tests we can just simply execute `make orderbot-tests`.

The SOR is organized into 5 main folders:

- [`compiled-scripts`](./compiled-scripts), contains the compiled validator and minting policy of the DEX.
- [`geniusyield-dex-api`](./geniusyield-dex-api), defines the DEX interface to query and build transactions.
- [`geniusyield-orderbot-framework`](./geniusyield-orderbot-framework), implement the main abstract tools for the SOR.
- [`geniusyield-orderbot`](./geniusyield-orderbot), the executable is implemented here, together with the strategies.
- [`impl`](./impl), specific implementations of the orderbook and data-provider.
Expand Down
18 changes: 13 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ index-state:
, cardano-haskell-packages 2023-06-05T06:39:32Z

packages: .
packages: geniusyield-dex-api
packages: geniusyield-orderbot-framework

-- TODO: Default value should be @direct@ in upcoming 3.10 version of cabal, omit this line then.
Expand All @@ -33,8 +32,8 @@ package strict-containers
source-repository-package
type: git
location: https://github.com/maestro-org/haskell-sdk
tag: fb8e32869f7a8f5fa2585b542e4eb4207eaf735b
--sha256: sha256-LOiC9zPXjPFshKfb/SKkFBkAFnOuQDwCqeDB7ZyB3b0=
tag: 609515b3f8861efaa17adf4e599aa1b845775a6d
--sha256: sha256-8se+xlIB1BDEuKGwjaldmW5G4LpCujD1ABgBaY0cY6Y=

-- Unfortunately, cardano-node 8.1.2 is constrained with plutus-ledger-api 1.5.0.0 and we would like at least 1.6.0.0.
-- This is done in accordance with changes in https://github.com/input-output-hk/cardano-ledger/pull/3430/files.
Expand Down Expand Up @@ -64,8 +63,17 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/geniusyield/atlas
tag: be490dcc5b99d0ff10e9d7cd801c4e0ae3a4865a
--sha256: sha256-HxwD8p7eg1yMo3hVDtGduU9zOQobFPONKj+064fdjVU=
tag: 105ff78b32935ae5c18c53ccf4fb8462b8c1ca03
--sha256: sha256-Ee/UIoJ8OYBxgdnSv61hN8DH7CrIOPn4DjqOBxFL3Js=

source-repository-package
type: git
location: https://github.com/geniusyield/dex-contracts-api
Copy link
Member Author

Choose a reason for hiding this comment

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

Using commit from this PR.
Let's merge PR at dex-contracts-api side once our systems are all up to date, since that PR would create orders at v1.1 script.

tag: ef2904d2d06dd068e5b4e2ac2513bcf61d2ca74c
--sha256: sha256-vXA5mVG7POEbezxMUQlxfyQbApdX5kG7L9BRlar+th0=
subdir:
geniusyield-dex-api
geniusyield-onchain/geniusyield-common

source-repository-package
type: git
Expand Down
Loading
Loading