Technical Overview of the RWA Orderbook DEX
Technical Overview of Entry Points and Contract Functions
Below are the key entry points and their corresponding functionalities within the RWA Orderbook contract.
A) SuperAdmin Entry Points
Description: Sets a new SuperAdmin contract address.
Description: Allows the newly set SuperAdmin to claim control of the contract.
Description: Sets the KYC (Know Your Customer) address for verifying user compliance.
Parameters: updateMetadataParams : updateMetadataType
Description: Allows the Admin to update contract metadata.
Description:
Description: Admins can transfer tokens that were mistakenly sent to the contract.
%setSuperAdmin
%setSuperAdmin
Parameters: newSuperAdminAddress : address
Entrypoint that can only be called by the superAdmin contract to set a new superAdmin contract.
%claimSuperAdmin
%claimSuperAdmin
Parameters: none
Entrypoint that can only be called by a new superAdmin contract that had previously been set.
B) Admin Entry Points
%setKycAddress
%setKycAddress
Parameters: newKycAddress : address
Entrypoint that can only be called by a new superAdmin contract that had previously been set.
%updateMetadata
%updateMetadata
Parameters: updateMetadataParams : updateMetadataType
type updateMetadataType is [@layout:comb] record [
metadataKey : string;
metadataHash : bytes;
]
Admin can update the contract metadata
%updateConfig
%updateConfig
Parameters: updateConfigParams : updateConfigActionType
// config
type rwaOrderbookConfigType is [@layout:comb] record [
minExpiryTime : nat; //
minTimeBeforeClosingOrder : nat; // prevent spam e.g. 1mins
minBuyOrderAmount : nat; // prevent spam - rwa token amount
minBuyOrderValue : nat; // prevent spam - value of rwa token amount to buy
minSellOrderAmount : nat; // prevent spam - rwa token amount
minSellOrderValue : nat; // prevent spam - value of rwa token amount to sell
buyOrderFee : nat; // 4 decimals
sellOrderFee : nat; // 4 decimals
]
Admin can update the config of the RWA Orderbook contract
%mistakenTransfer
%mistakenTransfer
Parameters: mistakenTransferParams : transferActionType
Admin can transfer mav or tokens that had mistakenly been sent to the contract
C) Pause/Break Glass Entry Points
%togglePauseEntrypoint
%togglePauseEntrypoint
Parameters: togglePauseEntrypointParams : rwaOrderbookTogglePauseEntrypointType
type rwaOrderbookPausableEntrypointType is
PlaceBuyOrder of bool
| PlaceSellOrder of bool
| CancelOrder of bool
type rwaOrderbookTogglePauseEntrypointType is [@layout:comb] record [
targetEntrypoint : rwaOrderbookPausableEntrypointType;
empty : unit
];
Admin can pause or unpause entrypoints on the RWA Orderbook contract
D) Orderbook Admin Entry Points
%setCurrency
%setCurrency
Parameters: setCurrencyAction : setCurrencyActionType
type setCurrencyActionType is [@layout:comb] record [
actionType : string;
name : string;
decimals : nat;
token : currencyTokenType;
]
Admin can set the valid currencies (e.g. USDT/USDC token) to be used on the RWA Orderbook contract
%transferFees
%transferFees
Parameters: transferFeesAction : transferFeesActionType
type transferFeesActionType is [@layout:comb] record [
receiver : address;
currencySet : set(string);
]
Admin can transfer accumulated trading fees on the RWA Orderbook contract to a specified address
%adminCancelOrders
%adminCancelOrders
Parameters: adminCancelOrdersParams : list(orderIdAndTypeSingle)
type orderIdAndTypeSingle is [@layout:comb] record [
orderId : nat;
orderType : string;
]
type adminCancelOrdersActionType is list(orderIdAndTypeSingle)
Admin can cancel a list of buy or sell orders by their order ID
%clearExpiredOrders
%clearExpiredOrders
Parameters: clearExpiredOrdersParams : list(orderIdAndTypeSingle)
type orderIdAndTypeSingle is [@layout:comb] record [
orderId : nat;
orderType : string;
]
type clearExpiredOrdersActionType is list(orderIdAndTypeSingle)
Admin can clear expired buy or sell orders by their order ID
%matchOrders
%matchOrders
Parameters: numberOfOrdersToMatch : int
This entry point should be called regularly by a trusted source (e.g. Admin) to match orders in the RWA Orderbook contract
E) Orderbook Entry Points
%placeBuyOrder
%placeBuyOrder
Parameters: placeOrderActionParams : placeOrderActionType
type placeSingleOrderType is [@layout:comb] record [
rwaTokenAmount : nat;
pricePerRwaToken : nat;
currency : string; // use USDT or USDC only
orderExpiry : option(timestamp);
]
type placeOrderActionType is list(placeSingleOrderType)
Users can place a buy order for RWA Tokens. Currency tokens for the buy order will be transferred to the RWA Orderbook contract and held in escrow until orders are matched.
%placeSellOrder
%placeSellOrder
Parameters: placeOrderActionParams : placeOrderActionType
type placeSingleOrderType is [@layout:comb] record [
rwaTokenAmount : nat;
pricePerRwaToken : nat;
currency : string; // use USDT or USDC only
orderExpiry : option(timestamp);
]
type placeOrderActionType is list(placeSingleOrderType)
User can place a sell order for RWA Tokens. RWA tokens used for the buy order will be transferred to the RWA Orderbook contract to be held in escrow until orders are matched.
%cancelOrder
%cancelOrder
Parameters: cancelOrdersParams : list(orderIdAndTypeSingle)
type orderIdAndTypeSingle is [@layout:comb] record [
orderId : nat;
orderType : string;
]
type cancelOrderActionType is list(orderIdAndTypeSingle)
Users can cancel a list of buy orders or sell orders they have placed at any time, and be returned the corresponding amount of tokens they owe.
%processRefund
%processRefund
Parameters: processRefundParams : list(orderIdAndTypeSingle)
type orderIdAndTypeSingle is [@layout:comb] record [
orderId : nat;
orderType : string;
]
type processRefundActionType is list(orderIdAndTypeSingle)
Users with excess amounts left in their buy orders (from being matched with sell orders at lower prices) can process a refund of the corresponding tokens after their buy order is closed.
F) Lambda Entry points
%setLambda
%setLambda
Parameters: setLambdaParams : setLambdaType
Admins can set custom lambdas to implement specific contract behavior or automate actions.
Last updated