Source Code

(define-constant ERR-INSUFFICIENT-FUNDS (err u504))
(define-constant ERR-SWAP-FAILED (err u509))

(define-public (swap (stx-amount uint))
  (begin 
  (asserts! (> stx-amount u0) ERR-INSUFFICIENT-FUNDS)

  (let 
    (
      ;; Define the swap path
      (swap-path 
        (list
          (tuple 
            (a "u") 
            (b 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx-stone) 
            (c u79) 
            (d 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx) 
            (e 'SPQ5CEHETP8K4Q2FSNNK9ANMPAVBSA9NN86YSN59.stone-bonding-curve) 
            (f true)
          )
        )
      )    
    )
 
    
    ;; Swap STX to STONE using the specified path
    (let 
      (
        (swapped-stone 
          (asserts! 
          (is-ok  (contract-call? 
             'SP20X3DC5R091J8B6YPQT638J8NR1W83KN6TN5BJY.path-apply_staging
              apply 
              swap-path 
              stx-amount 
              (some 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.wstx) 
              (some 'SPQ5CEHETP8K4Q2FSNNK9ANMPAVBSA9NN86YSN59.stone-bonding-curve) 
              none 
              none
              none 
              (some 'SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.univ2-share-fee-to) 
              none 
              none
              none
              none
 
              none
              none
              none
              none 

               none
               none
               none 
               none 

               none
               none 
               none 
               none 

              none 
              none 
              none 
              none 

               none
               none 
               none 
               none 
              
            ) )
            ERR-SWAP-FAILED
          )
        )
      )
      
      ;; Return the swapped token amount
      (ok swapped-stone)
    )
  )
  )
)


  

    
     
  

Functions (1)

FunctionAccessArgs
swappublicstx-amount: uint