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

Update operations.js #37

Merged
merged 2 commits into from
Aug 3, 2024
Merged
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
81 changes: 78 additions & 3 deletions packages/serializer/src/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,25 @@ export const credit_deal_expired_operation_fee_parameters = new Serializer(
{}
);

export const liquidity_pool_update_operation_fee_parameters = new Serializer(
"liquidity_pool_update_operation_fee_parameters",
{
fee: uint64,
}
);

export const credit_deal_update_operation_fee_parameters = new Serializer(
"credit_deal_update_operation_fee_parameters",
{
fee: uint64,
}
);

export const limit_order_update_operation_fee_parameters = new Serializer(
"limit_order_update_operation_fee_parameters",
{ fee: uint64 }
);

var fee_parameters = static_variant([
transfer_operation_fee_parameters,
limit_order_create_operation_fee_parameters,
Expand Down Expand Up @@ -607,6 +626,9 @@ var fee_parameters = static_variant([
credit_offer_accept_operation_fee_parameters,
credit_deal_repay_operation_fee_parameters,
credit_deal_expired_operation_fee_parameters,
liquidity_pool_update_operation_fee_parameters,
credit_deal_update_operation_fee_parameters,
limit_order_update_operation_fee_parameters,
]);

export const fee_schedule = new Serializer("fee_schedule", {
Expand Down Expand Up @@ -676,14 +698,33 @@ export const transfer = new Serializer("transfer", {
extensions: set(future_extensions),
});

export const create_take_profit_order_action = new Serializer(
"create_take_profit_order_action",
{
fee_asset_id: protocol_id_type("asset"),
spread_percent: uint16,
size_percent: uint16,
expiration_seconds: uint32,
repeat: bool,
extensions: set(future_extensions),
}
);

var limit_order_auto_action = static_variant([create_take_profit_order_action]);

export const limit_order_create = new Serializer("limit_order_create", {
fee: asset,
seller: protocol_id_type("account"),
amount_to_sell: asset,
min_to_receive: asset,
expiration: time_point_sec,
fill_or_kill: bool,
extensions: set(future_extensions),
extensions: extension([
{
name: "on_fill",
type: array(limit_order_auto_action),
},
]),
});

export const limit_order_cancel = new Serializer("limit_order_cancel", {
Expand Down Expand Up @@ -1401,8 +1442,8 @@ export const restriction = new Serializer("restriction", {
set(protocol_id_type("vesting_balance")),
set(protocol_id_type("worker")),
set(protocol_id_type("balance")),
// array(restriction),
// array(array(restriction)),
array(restriction),
array(array(restriction)),
// fixme: pair<int64_t,std_vector<graphene::protocol::restriction>>
]),
extensions: set(future_extensions),
Expand Down Expand Up @@ -1626,6 +1667,37 @@ export const credit_deal_expired = new Serializer("credit_deal_expired", {
fee_rate: uint32,
});

// Op 75: liquidity_pool_update_operation
export const liquidity_pool_update = new Serializer("liquidity_pool_update", {
fee: asset,
account: protocol_id_type("account"),
pool: protocol_id_type("liquidity_pool"),
taker_fee_percent: optional(uint16),
withdrawal_fee_percent: optional(uint16),
extensions: set(future_extensions),
});

// Op 76: credit_deal_update_operation
export const credit_deal_update = new Serializer("credit_deal_update", {
fee: asset,
account: protocol_id_type("account"),
deal_id: protocol_id_type("credit_deal"),
auto_repay: uint8,
extensions: set(future_extensions),
});

// Op 77: limit_order_update_operation
export const limit_order_update = new Serializer("limit_order_update", {
fee: asset,
seller: protocol_id_type("account"),
order: protocol_id_type("limit_order"),
new_price: optional(price),
delta_amount_to_sell: optional(asset),
new_expiration: optional(time_point_sec),
on_fill: optional(array(limit_order_auto_action)),
extensions: set(future_extensions),
});

operation.st_operations = [
transfer,
limit_order_create,
Expand Down Expand Up @@ -1702,6 +1774,9 @@ operation.st_operations = [
credit_offer_accept,
credit_deal_repay,
credit_deal_expired,
liquidity_pool_update,
credit_deal_update,
limit_order_update,
];

export const transaction = new Serializer("transaction", {
Expand Down