Source Code

(define-map swap-routes {from: (string-ascii 10), to: (string-ascii 10)} {pool: (string-ascii 30), fee-bps: uint, active: bool})
(define-data-var route-count uint u0)
(define-read-only (get-route (from (string-ascii 10)) (to (string-ascii 10))) (map-get? swap-routes {from: from, to: to}))
(define-public (add-route (from (string-ascii 10)) (to (string-ascii 10)) (pool (string-ascii 30)) (fee uint))
  (begin
    (map-set swap-routes {from: from, to: to} {pool: pool, fee-bps: fee, active: true})
    (var-set route-count (+ (var-get route-count) u1))
    (ok {from: from, to: to, pool: pool})))
(define-public (toggle-route (from (string-ascii 10)) (to (string-ascii 10)) (active bool))
  (match (map-get? swap-routes {from: from, to: to})
    route (begin (map-set swap-routes {from: from, to: to} (merge route {active: active})) (ok true))
    (err u1)))

Functions (3)

FunctionAccessArgs
get-routeread-onlyfrom: (string-ascii 10
add-routepublicfrom: (string-ascii 10
toggle-routepublicfrom: (string-ascii 10