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(ag-trade): place bid by discount #11

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

feat(ag-trade): place bid by discount #11

wants to merge 6 commits into from

Conversation

dckc
Copy link
Contributor

@dckc dckc commented Mar 3, 2024

Setup: endo, network, account As before, `make reserve-add` does account set-up, using some secrets:
$ cat .envrc 
PATH_add /Users/connolly/projects/endo/packages/cli/bin

# user1:  agoric1p2aqakv3ulz4qfy2nut86j9gx0dx0yw09h96md
export ALICE_SECRET="orbit bench..."

then:

$ make reserve-add
++ install cosmos fetch plugin
endo make --UNCONFINED src/cosmosFetch.js -n cosmos-fetch
Object [Alleged: CosmosFetch] {}
endo make src/net-local.js -n local -p cosmos-fetch
{ lcd: Object [Alleged: LCD] {}, rpc: Object [Alleged: RpcClient] {} }
++ start smart wallet caplet -- TODO: should not need UNSAFE
endo make --UNCONFINED src/smartWallet.js -n client-maker
Object [Alleged: SmartWalletFactory] {}
endo eval "E(wf).makeWalletKit('orbit bench...', local.rpc, local.lcd)" \
                local wf:client-maker -n alice-wk
{
  query: Object [Alleged: QueryTool] {},
  smartWallet: Object [Alleged: SmartWallet] {},
  tx: Object [Alleged: SigningClient] {}
}
endo make src/fresh-id.js -n fresh
Object [Alleged: FreshMaker] {}
endo make --UNCONFINED src/clock.js -n clock
Object [Alleged: Clock] {}
endo eval "E(fresh).start(clock, 'trade-')" fresh -n fresh-trade-id clock
Object [Alleged: Fresh] {}
endo mkguest alice
Object [Alleged: EndoGuest] {}
endo send alice @wallet:alice-wk
endo send alice @fresh:fresh-trade-id
endo inbox --as alice
# these 0/1 message numbers are fragile
endo adopt 0 wallet --as alice
endo adopt 1 fresh --as alice

and finally, it does...

endo run src/reserve-add.js 1 IST -p alice
{
  status: {
    error: 'Error: cannot grab 1000000uist coins: 40000uist is smaller than 1000000uist: insufficient funds',
    id: 'trade-0311.0',
    invitationSpec: {
      callPipe: [Array],
      instancePath: [Array],
      source: 'agoricContract'
    },
    proposal: { give: [Object] },
    result: [ [Object] ]
  },
  tx: {
    height: 9941,
    transactionHash: '069876AA2180BAD75FB847D4F6DF0313AF02F3F0ACA6131FBBB6AAB6A8F0E14D'
  }
}

Place a bid by discount

$ endo run src/auction-bid.js -p alice -- --give '0.01 IST' --maxBuy '1000 ATOM' --discount 0.05
vbankAssets [  'USDC_axl', 'USDT_grv', ... ]
{
  status: {
    id: 'trade-0255.3',
    invitationSpec: {
      callPipe: [Array],
      instancePath: [Array],
      source: 'agoricContract'
    },
    offerArgs: { maxBuy: [Object], offerBidScaling: [Object] },
    proposal: { give: [Object] },
    result: 'Your bid has been accepted'
  },
  tx: {
    height: 8991,
    transactionHash: 'BBFBA3C886428E95F101165073CE928F5E089A75A32825FCDDBD253603D45CF2'
  }
}

List Bids

$ endo run src/auction-bid.js -p alice -- --list
{"id":"trade-0255.3","invitationSpec":{"callPipe":[["makeBidInvitation",["[Alleged: ATOM brand#board05557]"]]],"instancePath":["auctioneer"],"source":"agoricContract"},"offerArgs":{"maxBuy":{"brand":"[Seen]","value":"[1000000000n]"},"offerBidScaling":{"denominator":{"brand":"[Alleged: IST brand#board0257]","value":"[100n]"},"numerator":{"brand":"[Seen]","value":"[95n]"}}},"proposal":{"give":{"Bid":{"brand":"[Seen]","value":"[10000n]"}}}}

With jq, i.e. endo run src/auction-bid.js -p alice -- --list|jq:

{
  "id": "trade-0255.3",
  "invitationSpec": {
    "callPipe": [
      [
        "makeBidInvitation",
        [
          "[Alleged: ATOM brand#board05557]"
        ]
      ]
    ],
    "instancePath": [
      "auctioneer"
    ],
    "source": "agoricContract"
  },
  "offerArgs": {
    "maxBuy": {
      "brand": "[Seen]",
      "value": "[1000000000n]"
    },
    "offerBidScaling": {
      "denominator": {
        "brand": "[Alleged: IST brand#board0257]",
        "value": "[100n]"
      },
      "numerator": {
        "brand": "[Seen]",
        "value": "[95n]"
      }
    }
  },
  "proposal": {
    "give": {
      "Bid": {
        "brand": "[Seen]",
        "value": "[10000n]"
      }
    }
  }
}

cc @dtribble @ivanlei @kriskowal

@dckc dckc force-pushed the dc-auction-bid branch from e69174a to 65044d9 Compare March 3, 2024 03:07
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.

1 participant