Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chlenc/ba184ddd78100b29c05b709f55b0f8fe to your computer and use it in GitHub Desktop.
Save chlenc/ba184ddd78100b29c05b709f55b0f8fe to your computer and use it in GitHub Desktop.
# How to issue limit order on Waves using puzzleswap.org DEX SDK
# run this with your Ride code
let limitOrdersAddress = Address(base58'3PPrfNMnk8z8QhZcqMyJk69mF65s2Rbz3B6')
func getAssetBytes(assetIdStr: String) = {
if (assetIdStr == "WAVES") then {unit} else {assetIdStr.fromBase58String()}
}
# user says "im selling 1 PUZZLE for 18 USDN"
# token0 = PUZZLE, token1 = USDN
# amount0 = 1 * 1e8, amount1 = 18 * 1e6
let asset0 = "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS" # PUZZLE ASSET ID
let asset0Bytes = getAssetBytes(asset0)
let amount0 = 100000000 # 1 PUZZLE
let asset1 = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" # USDN ASSET ID
let amount1 = 18000000 # 18 USDN
strict txIdStr = match (invoke(limitOrdersAddress, "createOrder", [asset1, amount1], [AttachedPayment(asset0Bytes, amount0)])) {
case x: String => x
case _ => throw("something went wrong during the creation of order")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment