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

[WIP] feat: cli for trading SDK #218

Draft
wants to merge 1 commit into
base: feat/swap-for-people
Choose a base branch
from

Conversation

shoom3301
Copy link
Contributor

@shoom3301 shoom3301 commented Sep 3, 2024

Example for python:

from subprocess import check_output
import json

args = [
'--action=getQuote',
'--chainId=11155111',
'--signer=574ed8a3c3baf4ed2c2fe5225a3bee6999b6a5ab735d297aca9dfc6c3f540000',
'--appCode="UtilsCliExample"',
'--orderKind="sell"',
'--sellToken="0x0625afb445c3b6b7b929342a04a22599fd5dbb59"',
'--sellTokenDecimals=18',
'--buyToken="0xbe72e441bf55620febc26715db68d3494213d8cb"',
'--buyTokenDecimals=6',
'--amount=12222000000000000000000',
'--env="prod"',
'--partiallyFillable=false',
'--slippageBps=0',
'--receiver=""',
'--validFor=300',
'--partnerFeeBps=0',
'--partnerFeeRecipient=""'
]

# after `npm install @cowprotocol/cow-sdk`
# rawResult = check_output(['npx', 'cow-sdk-trading-cli'] + args)

rawResult = check_output(['yarn', 'run', '--silent', 'trading-cli'] + args)
result = json.loads(rawResult)

print('orderToSign:', result['orderToSign'])
print('amountsAndCosts:', result['amountsAndCosts'])
print('quoteResponse:', result['quoteResponse'])

Copy link

socket-security bot commented Sep 3, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@jest/[email protected] None 0 27.7 kB simenb
npm/@jest/[email protected] None 0 6.06 kB simenb
npm/@jest/[email protected] None 0 32 kB simenb
npm/@sinclair/[email protected] None 0 359 kB sinclair
npm/@typechain/[email protected] filesystem 0 87.5 kB ethereum-ts-bot
npm/@types/[email protected] None 0 5.76 kB types
npm/@types/[email protected] None 0 77.1 kB types
npm/@types/[email protected] None 0 6.97 kB types
npm/[email protected] environment 0 20.2 kB sibiraj-s
npm/[email protected] None 0 46 kB simenb
npm/[email protected] None 0 145 kB simenb
npm/[email protected] environment, filesystem 0 32.5 kB isaacs
npm/[email protected] None 0 78.5 kB simenb
npm/[email protected] None 0 3.83 kB simenb
npm/[email protected] None 0 28.2 kB simenb
npm/[email protected] None 0 17 kB simenb
npm/[email protected] environment 0 35.6 kB simenb
npm/[email protected] None 0 60.4 kB simenb
npm/[email protected] environment 0 24 kB gnoff
npm/[email protected] unsafe 0 14.4 kB isaacs
npm/[email protected] None 0 69 kB krzkaczor

🚮 Removed packages: npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected])

View full report↗︎

@coveralls
Copy link
Collaborator

coveralls commented Sep 3, 2024

Coverage Status

coverage: 67.694% (-5.0%) from 72.645%
when pulling 4049712 on feat/swap-for-people-cli
into 92c7d14 on feat/swap-for-people.

Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Awesome!

How would this be installed as a cli app? Can it be exported as a binary of sorts or it must be the usual yarn/npm install?

src/trading/cli/consts.ts Outdated Show resolved Hide resolved
{ title: 'Prod', value: 'prod' },
{ title: 'Staging', value: 'staging' },
],
message: 'Environment',
Copy link
Contributor

Choose a reason for hiding this comment

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

Set default to prod

Suggested change
message: 'Environment',
message: 'Environment',
initial: 'prod',

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.

3 participants