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

#6 breakdown pt3 - add order_book module #12

Merged
merged 26 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
85a0793
refactor repo configs/readme
ribeirojose Apr 25, 2024
f2324d7
add codegen module
ribeirojose Apr 25, 2024
cd653d9
add common module
ribeirojose Apr 25, 2024
15df625
remove stale subgraphs/core modules
ribeirojose Apr 25, 2024
4b923e4
add contracts module
ribeirojose Apr 25, 2024
04f9139
add order_book module
ribeirojose Apr 25, 2024
661fe9b
add order posting example
ribeirojose Apr 25, 2024
8b78530
add generated api model
yvesfracari Aug 16, 2024
0f938d5
add python-dotenv package
yvesfracari Aug 16, 2024
5576b57
refactor importing sort
yvesfracari Aug 16, 2024
a3e1187
refactor .env usage and variables requested
yvesfracari Aug 16, 2024
0c9c04c
codegen: update reference openapi file for orderbook api codegen
ribeirojose Sep 9, 2024
48d660b
add E2E_SEPOLIA_TESTING_EOA_PRIVATE_KEY to .env.example
ribeirojose Sep 9, 2024
97ebc3a
codegen: regenerate order book models
ribeirojose Sep 9, 2024
2151934
api: refactor api base code to handle errors from orderbook api
ribeirojose Sep 10, 2024
b2d7ef7
orderbook: fix issue with type in order cancellation
ribeirojose Sep 10, 2024
f7e6d1b
tests(e2e): add e2e order posting test backed by vcr
ribeirojose Sep 10, 2024
4b7a26f
Merge branch 'main' into cow-4-order-book
ribeirojose Sep 10, 2024
4d48b42
ignore .env* files
ribeirojose Sep 10, 2024
dec2723
api(orderbook): refactor data serialization/deserialization
ribeirojose Sep 10, 2024
f97c695
tests(e2e): use gnosis mainnet for e2e test
ribeirojose Sep 10, 2024
b54f316
ci: stop using deprecated version of actions/upload-artifact
ribeirojose Sep 10, 2024
b88148e
chore: ignore pyright error when instantiating model with string posi…
ribeirojose Sep 10, 2024
ea2d831
chore: remove TODO/WIP comments from README
ribeirojose Sep 10, 2024
18fa6f2
ci: ensure E2E_GNOSIS_MAINNET_TESTING_EOA_PRIVATE_KEY is available wh…
ribeirojose Sep 10, 2024
895dd8f
chore(ci): revert actions/upload-artifact to v3 to avoid bug when sav…
ribeirojose Sep 10, 2024
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
Prev Previous commit
Next Next commit
refactor .env usage and variables requested
  • Loading branch information
yvesfracari committed Aug 16, 2024
commit a3e1187ee8867300dbd7949fd839b7407f7a869c
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
USER_ADDRESS=
PRIVATE_KEY=
19 changes: 13 additions & 6 deletions examples/order_posting_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
from dataclasses import asdict

from dotenv import load_dotenv
from web3 import Account

from cow_py.common.chains import Chain
Expand All @@ -30,16 +31,22 @@

BUY_TOKEN = "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14" # WETH
SELL_TOKEN = "0xbe72E441BF55620febc26715db68d3494213D8Cb" # USDC
SELL_AMOUNT_BEFORE_FEE = "10000000000000000000" # 100 USDC with 18 decimals
SELL_AMOUNT_BEFORE_FEE = "5000000000000000000" # 50 USDC with 18 decimals
ORDER_KIND = "sell"
CHAIN = Chain.SEPOLIA
CHAIN_ID = SupportedChainId.SEPOLIA

config = OrderBookAPIConfigFactory.get_config("prod", CHAIN_ID)
ORDER_BOOK_API = OrderBookApi(config)

ADDRESS = os.getenv("USER_ADDRESS")
ACCOUNT = Account.from_key(os.getenv("PRIVATE_KEY"))
load_dotenv()

PRIVATE_KEY = os.getenv("PRIVATE_KEY")

if not PRIVATE_KEY:
raise ValueError("Missing variables on .env file")

ACCOUNT = Account.from_key(PRIVATE_KEY)


async def get_order_quote(
Expand All @@ -62,7 +69,7 @@ def sign_order(order: Order) -> EcdsaSignature:
async def post_order(order: Order, signature: EcdsaSignature) -> UID:
order_creation = OrderCreation(
**{
"from": ADDRESS,
"from": ACCOUNT.address,
"sellToken": order.sellToken,
"buyToken": order.buyToken,
"sellAmount": order.sellAmount,
Expand All @@ -85,7 +92,7 @@ async def main():
**{
"sellToken": SELL_TOKEN,
"buyToken": BUY_TOKEN,
"from": ADDRESS,
"from": ACCOUNT.address,
}
)
order_side = OrderQuoteSide1(
Expand All @@ -100,7 +107,7 @@ async def main():
**{
"sellToken": SELL_TOKEN,
"buyToken": BUY_TOKEN,
"receiver": ADDRESS,
"receiver": ACCOUNT.address,
"validTo": order_quote_dict["validTo"],
"appData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sellAmount": SELL_AMOUNT_BEFORE_FEE, # Since it is a sell order, the sellAmountBeforeFee is the same as the sellAmount
Expand Down
Loading