Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/decimals to zero #331

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clarity/Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "alex-v1"
requirements = []
[contracts.alex-reserve-pool]
path = "contracts/pool/alex-reserve-pool.clar"
depends_on = ["token-alex", "token-usda", "math-fixed-point", "trait-ownable", "trait-sip-010"]
depends_on = ["token-alex", "token-usda", "math-fixed-point", "trait-ownable", "trait-sip-010", "alex-vault"]

[contracts.alex-vault]
path = "contracts/alex-vault.clar"
Expand Down
8 changes: 8 additions & 0 deletions clarity/contracts/alex-vault.clar
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
)
)

(define-public (ft-transfer-multi (token-x <ft-trait>) (amount-x uint) (token-y <ft-trait>) (amount-y uint) (recipient principal))
(begin
(try! (transfer-ft token-x amount-x recipient))
(try! (transfer-ft token-y amount-y recipient))
(ok true)
)
)

;; contract initialisation
(begin
(map-set approved-contracts .alex-reserve-pool true)
Expand Down
22 changes: 5 additions & 17 deletions clarity/contracts/key-token/key-usda-23040-wbtc.clar
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@

(define-constant ONE_8 (pow u10 u8))

(define-private (pow-decimals)
(pow u10 (unwrap-panic (get-decimals)))
)

(define-read-only (fixed-to-decimals (amount uint))
(/ (* amount (pow-decimals)) ONE_8)
)

(define-private (decimals-to-fixed (amount uint))
(/ (* amount ONE_8) (pow-decimals))
)

(define-read-only (get-owner)
(ok (var-get contract-owner))
)
Expand All @@ -41,7 +29,7 @@
;; ---------------------------------------------------------

(define-read-only (get-total-supply)
(ok (decimals-to-fixed (ft-get-supply key-usda-23040-wbtc)))
(ok (ft-get-supply key-usda-23040-wbtc))
)

(define-read-only (get-name)
Expand All @@ -57,7 +45,7 @@
)

(define-read-only (get-balance (account principal))
(ok (decimals-to-fixed (ft-get-balance key-usda-23040-wbtc account)))
(ok (ft-get-balance key-usda-23040-wbtc account))
)

(define-public (set-token-uri (value (string-utf8 256)))
Expand All @@ -74,7 +62,7 @@
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
(begin
(asserts! (is-eq sender tx-sender) ERR-NOT-AUTHORIZED)
(match (ft-transfer? key-usda-23040-wbtc (fixed-to-decimals amount) sender recipient)
(match (ft-transfer? key-usda-23040-wbtc amount sender recipient)
response (begin
(print memo)
(ok response)
Expand All @@ -87,14 +75,14 @@
(define-public (mint (recipient principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-mint? key-usda-23040-wbtc (fixed-to-decimals amount) recipient)
(ft-mint? key-usda-23040-wbtc amount recipient)
)
)

(define-public (burn (sender principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-burn? key-usda-23040-wbtc (fixed-to-decimals amount) sender)
(ft-burn? key-usda-23040-wbtc amount sender)
)
)

Expand Down
2 changes: 1 addition & 1 deletion clarity/contracts/key-token/key-wbtc-59760-wbtc.clar
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@

(define-constant ONE_8 (pow u10 u8))

(define-private (pow-decimals)
(pow u10 (unwrap-panic (get-decimals)))
)

(define-read-only (fixed-to-decimals (amount uint))
(/ (* amount (pow-decimals)) ONE_8)
)

(define-private (decimals-to-fixed (amount uint))
(/ (* amount ONE_8) (pow-decimals))
)

(define-read-only (get-owner)
(ok (var-get contract-owner))
)
Expand All @@ -39,7 +27,7 @@
;; ---------------------------------------------------------

(define-read-only (get-total-supply)
(ok (decimals-to-fixed (ft-get-supply fwp-usda-23040-usda-74880)))
(ok (ft-get-supply fwp-usda-23040-usda-74880))
)

(define-read-only (get-name)
Expand All @@ -51,11 +39,11 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
(ok (decimals-to-fixed (ft-get-balance fwp-usda-23040-usda-74880 account)))
(ok (ft-get-balance fwp-usda-23040-usda-74880 account))
)

(define-public (set-token-uri (value (string-utf8 256)))
Expand All @@ -72,7 +60,7 @@
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
(begin
(asserts! (is-eq sender tx-sender) ERR-NOT-AUTHORIZED)
(match (ft-transfer? fwp-usda-23040-usda-74880 (fixed-to-decimals amount) sender recipient)
(match (ft-transfer? fwp-usda-23040-usda-74880 amount sender recipient)
response (begin
(print memo)
(ok response)
Expand All @@ -85,13 +73,13 @@
(define-public (mint (recipient principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-mint? fwp-usda-23040-usda-74880 (fixed-to-decimals amount) recipient)
(ft-mint? fwp-usda-23040-usda-74880 amount recipient)
)
)

(define-public (burn (sender principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-burn? fwp-usda-23040-usda-74880 (fixed-to-decimals amount) sender)
(ft-burn? fwp-usda-23040-usda-74880 amount sender)
)
)
24 changes: 6 additions & 18 deletions clarity/contracts/pool-token/fwp-wbtc-usda-50-50.clar
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@

(define-constant ONE_8 (pow u10 u8))

(define-private (pow-decimals)
(pow u10 (unwrap-panic (get-decimals)))
)

(define-read-only (fixed-to-decimals (amount uint))
(/ (* amount (pow-decimals)) ONE_8)
)

(define-private (decimals-to-fixed (amount uint))
(/ (* amount ONE_8) (pow-decimals))
)

(define-read-only (get-owner)
(ok (var-get contract-owner))
)
Expand All @@ -39,7 +27,7 @@
;; ---------------------------------------------------------

(define-read-only (get-total-supply)
(ok (decimals-to-fixed (ft-get-supply fwp-wbtc-usda-50-50)))
(ok (ft-get-supply fwp-wbtc-usda-50-50))
)

(define-read-only (get-name)
Expand All @@ -51,11 +39,11 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
(ok (decimals-to-fixed (ft-get-balance fwp-wbtc-usda-50-50 account)))
(ok (ft-get-balance fwp-wbtc-usda-50-50 account))
)

(define-public (set-token-uri (value (string-utf8 256)))
Expand All @@ -72,7 +60,7 @@
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
(begin
(asserts! (is-eq sender tx-sender) ERR-NOT-AUTHORIZED)
(match (ft-transfer? fwp-wbtc-usda-50-50 (fixed-to-decimals amount) sender recipient)
(match (ft-transfer? fwp-wbtc-usda-50-50 amount sender recipient)
response (begin
(print memo)
(ok response)
Expand All @@ -85,13 +73,13 @@
(define-public (mint (recipient principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-mint? fwp-wbtc-usda-50-50 (fixed-to-decimals amount) recipient)
(ft-mint? fwp-wbtc-usda-50-50 amount recipient)
)
)

(define-public (burn (sender principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-burn? fwp-wbtc-usda-50-50 (fixed-to-decimals amount) sender)
(ft-burn? fwp-wbtc-usda-50-50 amount sender)
)
)
24 changes: 6 additions & 18 deletions clarity/contracts/pool-token/lbp-alex-usda-90-10.clar
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@

(define-constant ONE_8 (pow u10 u8))

(define-private (pow-decimals)
(pow u10 (unwrap-panic (get-decimals)))
)

(define-read-only (fixed-to-decimals (amount uint))
(/ (* amount (pow-decimals)) ONE_8)
)

(define-private (decimals-to-fixed (amount uint))
(/ (* amount ONE_8) (pow-decimals))
)

(define-read-only (get-owner)
(ok (var-get contract-owner))
)
Expand All @@ -39,7 +27,7 @@
;; ---------------------------------------------------------

(define-read-only (get-total-supply)
(ok (decimals-to-fixed (ft-get-supply lbp-alex-usda-90-10)))
(ok (ft-get-supply lbp-alex-usda-90-10))
)

(define-read-only (get-name)
Expand All @@ -51,11 +39,11 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
(ok (decimals-to-fixed (ft-get-balance lbp-alex-usda-90-10 account)))
(ok (ft-get-balance lbp-alex-usda-90-10 account))
)

(define-public (set-token-uri (value (string-utf8 256)))
Expand All @@ -72,7 +60,7 @@
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
(begin
(asserts! (is-eq sender tx-sender) ERR-NOT-AUTHORIZED)
(match (ft-transfer? lbp-alex-usda-90-10 (fixed-to-decimals amount) sender recipient)
(match (ft-transfer? lbp-alex-usda-90-10 amount sender recipient)
response (begin
(print memo)
(ok response)
Expand All @@ -85,13 +73,13 @@
(define-public (mint (recipient principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-mint? lbp-alex-usda-90-10 (fixed-to-decimals amount) recipient)
(ft-mint? lbp-alex-usda-90-10 amount recipient)
)
)

(define-public (burn (sender principal) (amount uint))
(begin
(asserts! (is-eq contract-caller (var-get contract-owner)) ERR-NOT-AUTHORIZED)
(ft-burn? lbp-alex-usda-90-10 (fixed-to-decimals amount) sender)
(ft-burn? lbp-alex-usda-90-10 amount sender)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

(define-read-only (get-decimals)
(ok u8)
(ok u0)
)

(define-read-only (get-balance (account principal))
Expand Down
Loading