Skip to content

Instantly share code, notes, and snippets.

@killerstorm
Created September 20, 2021 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerstorm/171663472156f6edee9709f70300905e to your computer and use it in GitHub Desktop.
Save killerstorm/171663472156f6edee9709f70300905e to your computer and use it in GitHub Desktop.
const gridSpec: any = [
[{elt: "text", variant: "h1", content: "Issue options"}],
[
[
{
elt: 'form',
children: [
{
elt: 'select', name: "asset", label: "Asset", outChannel: "asset",
options: [
{value: "ETH", label: "ETH"},
{value: "CHR", label: "CHR"},
{value: "HGET", label: "HGET"}
]
},
{
elt: 'select',
name: "type",
label: "Type",
outChannel: "option_type",
options: [{value: 0, label: "Put"}, {value: 1, label: "Call"}]
},
{
elt: 'input',
name: 'strike_price',
label: "Strike price",
outChannel: 'strike_price'
},
{elt: 'input', name: 'amount', label: "Amount", outChannel: 'amount'},
{elt: 'button', content: "Issue", handler: "issue_options"}
]
}
],
[
{elt: 'text', variant: 'h6', content: "Maturity"},
{elt: 'text', variant: 'h6', channel: "maturity_text"},
]
]
];
const channelDescriptors: any[] = [
{name: "asset", value: "ETH", type: "text"},
{name: "amount", value: 0, type: "integer",
proc: (v:any) => Math.round(parseFloat(v)*1000000)
},
{name: "strike_price", value: 0, type: "text"},
{
name: "asset_id", value: null, type: "integer",
query: {name: 'get_asset_by_name', args: {name: {channel: 'asset'}}}
},
{
name: "option_type", value: 0, type: "integer"
},
{
name: "usd_asset_id", value: null, type: "integer",
query: {name: 'get_asset_by_name', args: {name: "USD"}}
},
];
const handlerSpec: any[] = [
{
name: "issue_options", action: "post", operation: "issue_options", args: [
{channel: 'account_id'},
{channel: 'auth_descriptor_id'},
{channel: 'asset_id'},
{channel: 'usd_asset_id'},
{channel: 'strike_price'},
{channel: 'maturity'},
{channel: 'option_type'},
1 /*american*/,
1 /* cash */,
{channel: 'amount'}
]
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment