Giter Site home page Giter Site logo

keep-starknet-strange / satoru Goto Github PK

View Code? Open in Web Editor NEW
110.0 8.0 74.0 8.83 MB

Synthetics platform for Starknet, inspired by GMX v2 design.

Home Page: https://book.satoru.run/

License: MIT License

Cairo 96.19% Shell 0.56% TypeScript 3.25%
cairo defi starknet synthetics

satoru's Introduction

⚡ Satoru ⚡

Synthetics platform for Starknet, inspired by GMX v2 design.

Project license Pull Requests welcome Read the Satoru Book

Exploration_Team

⚡ About Satoru ⚡

Satoru is a cutting-edge synthetics platform for Starknet, taking inspiration from the modular design of GMX v2.

Read the Satoru Book to learn more about the project.

🛠️ Build

To build the project, run:

scarb build

Satoru compatible frontends

You can find the list of Satoru-compatible frontends, all of which have been built on top of the Satoru platform :

🏛️ Infrastructure

🧪 Test

To test the project, run:

snforge

🚀 Deploy

To deploy the contracts of Satoru, you first need to setup a smart wallet :

  • Create a signer by following this tutorial : Signers

  • Create an account by following this tutorial : Accounts

Once your smart wallet is setup, you can now run deployment files to deploy contracts, for example :

cd scripts

./deploy_contract.sh

Deployed Contracts

  • RoleStore: 0x07eacab18c343f30edfa9336b8eacce9bc56303d43c92609a88e8da25177f5b3
  • DataStore: 0x0549539da18f4d574211365b6abd678ef940444b579900efedcb935210c41481
  • OrderVault: 0x01f1252d6d02feb14cfa88beff415e1524d1cebb31870056567aae257104b6fd
  • Router: 0x00dd0912017ee7c8151555394380acd1012a814916d384b12ca64afa0eae2bc5
  • EventEmitter: 0x0284ae712869c0af4f538e9297e6965d3c9ba9110830944047de8d35da7ea447
  • MarketToken: 0x044391e9498f440cc41ace136ea317f6bfa2080311085d1846529e421974a1d3
  • MarketFactory: 0x05766918626a91ca83f52003eb03bbf1f13174aa22e340c8057d8d5d6affbfcf
  • WithdrawalVault: 0x050c83c2bc74cc50676fdd5598b40f9d0d6d5ccf6ea3478a7999e29473da03f1
  • SwapHandler: 0x039aa67b479f4870878ec6d3002f9fa9b8e98d4d3d10c1f32b5d394a456aab28
  • ReferralStorage: 0x0189463034c24b2cb091dcb515287bea13a4767534f09e52692a4cdc30254001
  • DepositVault: 0x07d435e7ab3a5cd4b872e5725b02898833cb9a7c62e2d9a6a9db324d61e2925e

📚 Resources

Here are some resources to help you get started:

📖 License

This project is licensed under the MIT license. See LICENSE for more information.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Abdel @ StarkWare
Abdel @ StarkWare

💻
sparqet
sparqet

💻
zarboq
zarboq

💻
drspacemn
drspacemn

💻
Michel
Michel

💻
delaaxe
delaaxe

💻
danilowhk
danilowhk

💻
Erim
Erim

💻
parketh
parketh

💻
Mathieu
Mathieu

💻
gaetbout
gaetbout

💻
Alex Metelli
Alex Metelli

💻
Fabien C
Fabien C

💻
rmzlb
rmzlb

💻
0xTitan
0xTitan

💻
Bal7hazar @ Carbonable
Bal7hazar @ Carbonable

💻
Zizou
Zizou

💻
Darlington Nnam
Darlington Nnam

💻
Eytan Levy
Eytan Levy

💻
Daniel Bejarano
Daniel Bejarano

💻
Jordy Romuald
Jordy Romuald

💻
StarkFishinator
StarkFishinator

💻
Axel Izsak
Axel Izsak

💻
Luciefer
Luciefer

💻
tevrat aksoy
tevrat aksoy

💻
Piotr Magiera
Piotr Magiera

💻
ftupas
ftupas

💻
lambda-0x
lambda-0x

💻
Tbelleng
Tbelleng

💻
dic0de
dic0de

💻
akhercha
akhercha

💻
VictorONN
VictorONN

💻
kasteph
kasteph

💻
Khaeljy
Khaeljy

💻
JeanWoked
JeanWoked

💻
vuittont60
vuittont60

💻
Arnaud Berger
Arnaud Berger

💻
faytey
faytey

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

satoru's People

Contributors

0xandee avatar 0xtitan avatar abdelstark avatar akhercha avatar akinbola247 avatar ametel01 avatar axelizsak avatar danilowhk avatar dbejarano820 avatar delaaxe avatar enitrat avatar ermvrs avatar eytanlvy avatar fabiencoutant avatar gaetbout avatar khaeljy avatar lambda-0x avatar omahs avatar parketh avatar piotmag769 avatar prtk418 avatar rmzlb avatar sk8erboi84 avatar sparqet avatar starkfishinator avatar tbelleng avatar tevrat-aksoy avatar victoronn avatar vuittont60 avatar zarboq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

satoru's Issues

feat: implement internal `is_feature_disabled` function `FeatureUtils` contract.

Description

Implement the internal is_feature_disabled function in the FeatureUtils contract.

File: src/feature/feature_utils.cairo.

Function signature:

    /// Get whether a feature is disabled.
    /// # Arguments
    /// * `data_store` - DataStore.
    /// * `key` - the feature key.
    /// # Returns
    /// Whether the feature is disabled.
    fn is_feature_disabled(
        self: TContractState, data_store: DataStore, key: felt252
    ) -> bool;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `set_int` function `data_store` contract.

Description

Implement the set_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Set the int value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The value to set
    /// # Return
    /// The int value for the key.
    fn set_int(ref self: TContractState, key: felt252, value: i128) -> i128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `get_current_nonce` function `NonceUtils` contract.

Description

Implement the internal get_current_nonce function in the NonceUtils contract.

File: src/nonce/nonce_utils.cairo.

Function signature:

    /// Get the current nonce value.
    /// # Arguments/
    /// * `data_store` - DataStore.
    fn get_current_nonce(
        self: TContractState, data_store: DataStore
    ) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `current_block_number` function `chain` contract.

Description

Implement the current_block_number function in the chain contract.

File: src/chain/chain.cairo.

Function signature:

    /// Return the current block's number.
    /// # Return
    /// The current block's number.
    fn current_block_number() -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `get_int` function `data_store` contract.

Description

Implement the get_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Get the int value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    /// # Return
    /// The int value for the key.
    fn get_int(self: @TContractState, key: felt252) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `decrement_uint` function `data_store` contract.

Description

Implement the decrement_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Subtract the input uint value from the existing uint value.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input value
    /// # Return
    /// The new uint value.
    fn decrement_uint(ref self: TContractState, key: felt252, value: u128) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `is_empty` function in the `price` contract.

Description

Implement the is_empty function in the price contract.

File: src/price/price.cairo.

Function signature:

    /// Check if a price is empty.
    /// # Arguments
    /// `props` - Props
    /// # Return
    /// Whether a price is empty.
    fn is_empty(props: Props) -> bool;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `apply_delta_to_uint_128` function `data_store` contract.

Description

Implement the apply_delta_to_uint_128 function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input uint value to the existing uint value.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input value
    /// # Return
    /// The new uint value.
    fn apply_delta_to_uint_128(ref self: TContractState, key: felt252, value: u128) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `get_block_hash` function `chain` contract.

Description

Implement the get_block_hash function in the chain contract.

File: src/chain/chain.cairo.

Function signature:

    /// Return the current block's hash.
    /// # Arguments
    /// `block_number` - The block number
    /// # Return
    /// The current block's hash.
    fn get_block_hash(block_number: u128) -> felt252;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `remove_int` function `data_store` contract.

Description

Implement the remove_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Delete the int value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    fn remove_int(ref self: TContractState, key: felt252);

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `transfer_out` function Bank contract.

Description

Implement the internal transfer_out function in the Bank contract.

File: src/bank/bank.cairo.

Function signature:

    /// Transfer tokens from this contract to a receiver.
    /// # Arguments
    /// * `token` - The token to transfer
    /// * `receiver` - The address of the receiver.
    /// * `amount` - The amount of tokens to transfer.
    fn transfer_out(
        ref self: TContractState, token: ContractAddress, receiver: ContractAddress, amount: u128,
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `sync_token_balance` function `strict_bank` contract.

Description

Implement the sync_token_balance function in the strict_bank contract.

File: src/bank/strict_bank.cairo.

Function signature:

    /// This can be used to update the tokenBalances in case of token burns
    /// or similar balance changes.
    /// The prevBalance is not validated to be more than the nextBalance as this
    /// could allow someone to block this call by transferring into the contract.
    /// # Arguments
    /// * `token` - token the token to record the burn for.
    /// # Returns
    /// The new balance.
    fn sync_token_balance(
        ref self: TContractState, token: ContractAddress
    ) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `pick_price` function `price` contract.

Description

Implement the pick_price function in the price contract.

File: src/price/price.cairo.

Function signature:

    /// Pick either the min or max value.
    /// # Arguments
    /// `props` - Props
    /// `maximize` - Bool
    /// # Return
    /// Either the min or max value.
    fn pick_price(props: Props, maximize: Bool) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `get_next_key` function `NonceUtils` contract.

Description

Implement the internal get_next_key function in the NonceUtils contract.

File: src/nonce/nonce_utils.cairo.

Function signature:

    /// Convenience function to create a felt252 hash using the next nonce
    /// it would be possible to use the nonce directly as an ID / key
    /// however, for positions the key is a felt252 value based on a hash of
    /// the position values.
    /// so felt252 is used instead for a standard key type
    /// # Arguments/
    /// * `data_store` - DataStore.
    /// # Return
    /// felt252 hash using the next nonce value.
    fn get_next_key(
        ref self: TContractState, data_store: DataStore
    ) -> felt252;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `record_transfer_in` function `strict_bank` contract.

Description

Implement the record_transfer_in function in the strict_bank contract.

File: src/bank/strict_bank.cairo.

Function signature:

    /// Records a token transfer into the contract.
    /// # Arguments
    /// * `token` - The token to record the transfer for.
    /// # Returns
    /// The amount of tokens transferred in.
    fn record_transfer_in(
        ref self: TContractState, token: ContractAddress
    ) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `get_uint` function `data_store` contract.

Description

Implement the get_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Get the uint value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    /// # Return
    /// The uint value for the key.
    fn get_uint(self: @TContractState, key: felt252) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `transfer_out_unwrap` function `Bank` contract.

Description

Implement the transfer_out_unwrap function in the Bank contract.

File: src/bank/bank.cairo.

Function signature:

    /// Transfer tokens from this contract to a receiver.
    /// handles native token transfers as well
    /// # Arguments
    /// * `token` - The token address to transfer.
    /// * `receiver` - The address of the receiver.
    /// * `amount` - The amount of tokens to transfer.
    /// * `should_unwrap_native_token` - Whether to unwrap the wrapped native token
    fn transfer_out_unwrap(
        ref self: TContractState, token: ContractAddress, receiver: ContractAddress, amount: u128, should_unwrap_native_token: bool
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `decrement_int` function `data_store` contract.

Description

Implement the decrement_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Subtract the input int value from the existing int value.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input value
    /// # Return
    /// The new int value.
    fn decrement_int(ref self: TContractState, key: felt252, value: i128) -> i128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `wnt` function `token` contract.

Description

Implement the wnt function in the token contract.

File: src/token/token_utils.cairo.

Function signature:

    /// Returns the address of the WNT token.
    /// # Arguments
    /// `data_store` - DataStore contract instance where the address of the WNT token is stored.
    /// # Return
    /// The address of the WNT token.
    fn wnt(data_store: DataStore) -> ContractAddress;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `record_transfer_in` function `strict_bank` contract.

Description

Implement the internal record_transfer_in function in the strict_bank contract.

File: src/bank/strict_bank.cairo.

Function signature:

    /// Records a token transfer into the contract.
    /// # Arguments
    /// * `token` - The token to record the transfer for.
    /// # Returns
    /// The amount of tokens transferred in.
    fn record_transfer_in(
        ref self: TContractState, token: ContractAddress
    ) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `transfer_out_native_token` function `Bank` contract

Description

Implement the internal transfer_out_native_token function in the Bank contract.

File: src/bank/bank.cairo.

Function signature:

    /// Unwrap wrapped native tokens and transfer the native tokens from
    /// this contract to a receiver
    /// # Arguments
    /// * `token` - The token to transfer.
    /// * `receiver` - The address of the receiver.
    /// * `amount` - The amount of tokens to transfer.
    fn transfer_out_native_token(
        ref self: TContractState, token: ContractAddress, receiver: ContractAddress, amount: u128,
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal get_next_key function nonce_utils contract.

Description

Implement the internal get_next_key function in the nonce_utils contract.

File: src/nonce/nonce_utils.cairo.

Function signature:

    /// Convenience function to create a felt252 hash using the next nonce
    /// it would be possible to use the nonce directly as an ID / key
    /// however, for positions the key is a felt252 value based on a hash of
    /// the position values.
    /// so felt252 is used instead for a standard key type
    /// # Arguments/
    /// * `data_store` - DataStore.
    /// # Return
    /// felt252 hash using the next nonce value.
    fn get_next_key(
        ref self: TContractState, data_store: DataStore
    ) -> felt252;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `after_transfer_out` function `strict_bank` contract.

Description

Implement the internal after_transfer_out function in the strict_bank contract.

File: src/bank/strict_bank.cairo.

Function signature:

    /// Update the internal balance after tokens have been transferred out.
    /// This is called from the Bank contract.
    /// # Arguments
    /// * `token` - token the token that was transferred out.
    fn after_transfer_out(
        ref self: TContractState, token: ContractAddress
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `increment_int` function `data_store` contract.

Description

Implement the increment_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input int value to the existing int value
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input value
    /// # Return
    /// The new int value.
    fn increment_int(ref self: TContractState, key: felt252, value: i128) -> i128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `transfer_out_native_token` function `Bank` contract.

Description

Implement the transfer_out_native_token function in the Bank contract.

File: src/bank/bank.cairo.

Function signature:

    /// Transfer tokens from this contract to a receiver.
    /// # Arguments
    /// * `receiver` - The address of the receiver.
    /// * `amount` - The amount of tokens to transfer.
    fn transfer_out_native_token(
        ref self: TContractState, receiver: ContractAddress, amount: u128,
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `apply_bounded_delta_to_uint` function `data_store` contract.

Description

Implement the apply_bounded_delta_to_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input int value to the existing uint value, prevent the uint.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input int value 
    /// # Return
    /// The new uint value.
    fn apply_bounded_delta_to_uint(ref self: TContractState, key: felt252, value: i128) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `get_address` function `data_store` contract.

Description

Implement the get_address function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Get the address value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    /// # Return
    /// The address value for the key.
    fn get_address(self: @TContractState, key: felt252) -> ContractAddress;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `current_timestamp` function `chain` contract.

Description

Implement the current_timestamp function in the chain contract.

File: src/chain/chain.cairo.

Function signature:

    /// Return the current block's timestamp.
    /// # Returns
    /// The current block's timestamp.
    fn current_timestamp() -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `pick_price_for_pnl` function `price` contract.

Description

Implement the pick_price_for_pnl function in the price contract.

File: src/price/price.cairo.

Function signature:

    /// Pick the min or max price depending on whether it is for a long or short position.
    /// # Arguments
    /// `props` - Props
    /// `is_long` - Bool
    /// `maximize` - Bool
    /// # Return
    /// The min or max price.
    fn pick_price_for_pnl(props: Props, is_long: Bool, maximize: Bool) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `mid_price` function `price` contract.

Description

Implement the mid_price function in the price contract.

File: src/price/price.cairo.

Function signature:

    /// Get the average of the min and max values.
    /// # Arguments
    /// `props` - Props
    /// # Return
    /// The average of the min and max values.
    fn mid_price(props: Props) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `remove_uint` function `data_store` contract.

Description

Implement the remove_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Delete the uint value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    fn remove_uint(ref self: TContractState, key: felt252);

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `transfer_out` function `Bank` contract.

Description

Implement the transfer_out function in the Bank contract.

File: src/bank/bank.cairo.

Function signature:

    /// Transfer tokens from this contract to a receiver.
    /// # Arguments
    /// * `token` - The token address to transfer.
    /// * `receiver` - The address of the receiver.
    /// * `amount` - The amount of tokens to transfer.
    fn transfer_out(
        ref self: TContractState, token: ContractAddress, receiver: ContractAddress, amount: u128,
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `apply_delta_to_uint` function `data_store` contract.

Description

Implement the apply_delta_to_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input int value to the existing uint value.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input int value
    /// # Return
    /// The new uint value.
    fn apply_delta_to_uint(ref self: TContractState, key: felt252, value: i128, error_message: felt252) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `increment_nonce` function `NonceUtils` contract.

Description

Implement the internal increment_nonce function in the NonceUtils contract.

File: src/nonce/nonce_utils.cairo.

Function signature:

    /// Increment the current nonce value.
    /// # Arguments/
    /// * `data_store` - DataStore.
    /// # Returns
    /// The new nonce value.
    fn increment_nonce(
        ref self: TContractState, data_store: DataStore
    ) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `set_uint` function `data_store` contract.

Description

Implement the set_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Set the uint value for the given key.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The value to set
    /// # Return
    /// The uint value for the key.
    fn set_uint(ref self: TContractState, key: felt252, value: u128) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement `increment_uint` function `data_store` contract.

Description

Implement the increment_uint function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input uint value to the existing uint value
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input value
    /// # Return
    /// The new uint value.
    fn increment_uint(ref self: TContractState, key: felt252, value: u128) -> u128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Feat: Implement the internal `transfer` function `token` contract.

Description

Implement the transfer function in the token contract.

File: src/token/token_utils.cairo.

Function signature:

    /// Transfers the specified amount of `token` from the caller to `receiver`.
    /// limit the amount of gas forwarded so that a user cannot intentionally
    /// construct a token call that would consume all gas and prevent necessary
    /// actions like request cancellation from being executed
    /// # Arguments
    /// `data_store` - The data store that contains the `tokenTransferGasLimit` for the specified `token`.
    /// `token` - The address of the ERC20 token that is being transferred.
    /// `receiver` - The address of the recipient of the `token` transfer.
    /// `amount` - The amount of `token` to transfer.
    fn transfer(data_store: DataStore, token: ContractAddress, receiver: ContractAddress, amount: u128);

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

feat: implement internal `validate_feature` function `FeatureUtils` contract.

Description

Implement the internal validate_feature function in the FeatureUtils contract.

File: src/feature/feature_utils.cairo.

Function signature:

    /// Validate whether a feature is enabled, reverts if the feature is disabled.
    /// # Arguments
    /// * `data_store` - DataStore.
    /// * `key` - the feature key.
    fn validate_feature(
        self: TContractState, data_store: DataStore, key: felt252
    );

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

bug: store `Option<bool>` in `LegacyMap` does not work

Description

When trying to store Option<bool> in LegacyMap it fails with this error:

error: Trait has no implementation in context: core::starknet::storage_access::Store::<core::option::Option::<core::bool>>
 --> contract:285:50
                starknet::Store::<Option<bool>>::read(
                                                 ^**^

error: Trait has no implementation in context: core::starknet::storage_access::Store::<core::option::Option::<core::bool>>
 --> contract:293:50
                starknet::Store::<Option<bool>>::write(
                                                 ^***^

Reproduce bugs

    #[storage]
    struct Storage {
        bool_values: LegacyMap::<felt252, Option<bool>>,
    }

 fn get_bool(self: @ContractState, key: felt252) -> Option<bool> {
            self.bool_values.read(key)
 }

feat: implement `apply_delta_to_int` function `data_store` contract.

Description

Implement the apply_delta_to_int function in the data_store contract.

File: src/data/data_store.cairo.

Function signature:

    /// Add the input int value to the existing int value.
    /// # Arguments
    /// `key` - The key of the value
    /// `value` - The input int value
    /// # Return
    /// The new int value.
    fn apply_delta_to_int(ref self: TContractState, key: felt252, value: i128, error_message: felt252) -> i128;

Acceptance criteria

  • Function is implemented and well commented.
  • Associated unit tests (nominal and failure) are implemented and passing.

Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.