(use-trait ft-trait 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.trait-sip-010.sip-010-trait) 

(define-constant ONE_6 u1000000)
(define-constant ONE_8 u100000000)

(define-constant ERR-NO-PRF (err u700))


(define-public (arkadiko-swap (token-x <ft-trait>) (token-y <ft-trait>) (dx uint) (min-dy uint))
    (ok (unwrap-panic (element-at  (try! (contract-call? 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.arkadiko-swap-v2-1 swap-x-for-y token-x token-y dx min-dy)) u1)))
)

(define-public (alex-swap (token-x <ft-trait>) (token-y <ft-trait>) (dx uint) (min-dy (optional uint)))
    (ok (try! (contract-call? 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.swap-helper-v1-01 swap-helper token-x token-y dx min-dy)))
)

(define-public (stx-usda-arkadiko-alex (spend uint) (min-receive uint))
    (begin 
        (let 
            (
                (swapped (unwrap-panic (arkadiko-swap 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.wrapped-stx-token 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.usda-token spend u0)))
                (received (unwrap-panic (alex-swap 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wusda 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx (/ (* swapped ONE_8) ONE_6) none)))
            )
            (ok (asserts! (>= received min-receive) ERR-NO-PRF))
        )
    )
)

(define-public (stx-usda-alex-arkadiko (spend uint) (min-receive uint))
    (begin 
        (let 
            (
                (swapped (unwrap-panic (alex-swap 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wusda (/ (* spend ONE_8) ONE_6) none)))
                (received (unwrap-panic (arkadiko-swap 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.usda-token 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.wrapped-stx-token (/ (* swapped ONE_6) ONE_8) u0)))
            )
            (ok (asserts! (>= received min-receive) ERR-NO-PRF))
        )
    )
)