Giter Club home page Giter Club logo

anchor-token-contracts's People

Contributors

ilovebusinessdevelopment avatar mandrean avatar msntcs avatar r-amiri avatar yun-yeo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anchor-token-contracts's Issues

[BUG] "error: failed to download `uint v0.9.3`" when execute with docker run .... command

Describe the bug
I'm trying to verify deployed smart contract against git's commit hash in order to see which revision in git that is actually deployed on chain. But I'm stuck at the execution of docker command (as seen in README.md file i.e. docker run --rm -v ....).

It shows the following error (please excuse that I use sudo as my user is not added as part of docker group)

$ sudo docker run --rm -v "$(pwd)":/code   --mount type=volume,source="$(basename "$(pwd)")_cache",target=
/code/target   --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry   cosmwasm/workspace-optimizer:0.11.5
1.54.0-x86_64-unknown-linux-musl (default)
cargo 1.54.0 (5ae8d74b3 2021-06-22)
Building artifacts in workspace ...
Found workspace member entries: ['packages/*', 'contracts/*']
Package directories: ['contracts/custody_base', 'contracts/custody_beth', 'contracts/custody_bluna', 'contracts/distribution_model', 'contracts/interest_model', 'contracts/liquidation', 'contracts/liquidation_queue', 'contracts/market', 'contracts/oracle', 'contracts/overseer', 'packages/moneymarket']
Contracts to be built: ['contracts/custody_base', 'contracts/custody_beth', 'contracts/custody_bluna', 'contracts/distribution_model', 'contracts/interest_model', 'contracts/liquidation', 'contracts/liquidation_queue', 'contracts/market', 'contracts/oracle', 'contracts/overseer']
Building contracts/custody_base ...
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/packages/moneymarket/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/custody_base/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/custody_beth/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/custody_bluna/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/distribution_model/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/interest_model/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/liquidation/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/liquidation_queue/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/market/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/oracle/Cargo.toml
workspace: /code/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /code/contracts/overseer/Cargo.toml
workspace: /code/Cargo.toml
 Downloading crates ...
error: failed to download `uint v0.9.3`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/uint-0.9.3/Cargo.toml`

Caused by:
  feature `edition2021` is required

  this Cargo does not support nightly features, but if you
  switch to nightly channel you can add
  `cargo-features = ["edition2021"]` to enable this feature
Traceback (most recent call last):
  File "/usr/local/bin/build_workspace.py", line 38, in <module>
    subprocess.check_call(cmd, cwd=contract)
  File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cargo', 'build', '--release', '--target=wasm32-unknown-unknown', '--locked']' returned non-zero exit status 101.

To Reproduce

  • git clone [email protected]:Anchor-Protocol/anchor-token-contracts.git (specifically I'm at the tip at the time of cloning which is b99f561)
  • cd anchor-token-contracts
  • rust up default stable (i'm using rust 1.60.0 for both cargo 1.60.0 (d1fd9fe 2022-03-01), and rustc 1.60.0 (7737e0b5c 2022-04-04))
  • rustup target add wasm32-unknown-unknown
  • docker run --rm -v "$(pwd)":/code --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry cosmwasm/workspace-optimizer:0.11.5
  • Then it shows error as above

Context & versions

  • Run on Ubuntu 20.04,
  • I'm using Rust 1.60.0, stable.
  • Anchor-Protocol/anchor-token-contracts -> at b99f561.
  • Docker: Docker version 20.10.14, build a224086

(if applicable) suggested solution
I didn't think about solution yet. But I work around by executing steps involved (compile, optimize, and get checksum for each contract file) manually by looking at cosmwasm/rust-optimizer's Dockfile and optimize.sh to see what commands it uses, then I do it manually to achieve my goal of verify the contract code.

So yeah, at last I would like to know if I did something wrong in order to be able to use docker run --rm -v ... command to ease in generating checksums for all contracts.

[BUG] Governance contract, Query bug

Hey guys, I Found this issue while copying your code to terra-vegas casino
This issue is a confusing query issue in the governance contract.
The confusion happens in this line
https://github.com/Anchor-Protocol/anchor-token-contracts/blob/main/contracts/gov/src/contract.rs#L598

This happens when the voting period is finished but no tx has happened yet to update the state.
This could be mitigated by adding a new condition on the query function to make sure we send the right response.
I opened a PR here #31
I put the Status to Expired because I did not want to add a new PollStatus::WaitingOnTransactionToEndPoll. But I believer a new status should be there to better describe the Poll status (Waiting On Transaction To End Poll)

Please check the Pull request

[BUG] gov contract - query shows in progress while cast vote errors with not in progress

Hey guys, I Found this issue while copying your code to terra-vegas casino
This issue is a confusing query issue in the governance contract.
The confusion happens in this line
https://github.com/Anchor-Protocol/anchor-token-contracts/blob/main/contracts/gov/src/contract.rs#L598

Please note that I ran into a situation where the query shows me that the poll_id 1 is in progress while casting the vote is not possible because it is "notInProgress"

I don't have the permissions to push a branch and PR so here are the suggested changes(all in contract.rs):

"-"    if a_poll.status != PollStatus::InProgress || env.block.height > a_poll.end_height {
"+"    if a_poll.status != PollStatus::InProgress {
         return Err(ContractError::PollNotInProgress {});
     }
 
"+"    if a_poll.status == PollStatus::InProgress && env.block.height > a_poll.end_height {
"+"        return Err(ContractError::PollNotInProgress {}); //We might want to add a new error here when we have this confusing stage
"+"     }
"+" 



 "#"[cfg_attr(not(feature = "library"), entry_point)]
"-" pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
"+" pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
     match msg {
         QueryMsg::Config {} => Ok(to_binary(&query_config(deps)?)?),
         QueryMsg::State {} => Ok(to_binary(&query_state(deps)?)?),
         QueryMsg::Staker { address } => Ok(to_binary(&query_staker(deps, address)?)?),
"-"         QueryMsg::Poll { poll_id } => Ok(to_binary(&query_poll(deps, poll_id)?)?),
"+"         QueryMsg::Poll { poll_id } => Ok(to_binary(&query_poll(deps, env, poll_id)?)?),
         QueryMsg::Polls {
             filter,
             start_after,
////
////
"-" fn query_poll(deps: Deps, poll_id: u64) -> Result<PollResponse, ContractError> {
"+" fn query_poll(deps: Deps, env: Env, poll_id: u64) -> Result<PollResponse, ContractError> {
     let poll = match poll_read(deps.storage).may_load(&poll_id.to_be_bytes())? {
         Some(poll) => Some(poll),
         None => return Err(ContractError::PollNotFound {}),
@@ -733,7 +737,11 @@ fn query_poll(deps: Deps, poll_id: u64) -> Result<PollResponse, ContractError> {
     Ok(PollResponse {
         id: poll.id,
         creator: deps.api.addr_humanize(&poll.creator)?.to_string(),
"-"       status: poll.status,
"+"         status: if  poll.status == PollStatus::InProgress && env.block.height > poll.end_height { 
"+"             PollStatus::Expired //not sure if this is the status you want to assign, especially that you marked Expired as depricated in your state file
"+"         } else {
"+"             poll.status
"+"         },

How to provide liquidity in a smart contract?

Currently, I have been working on a sample fork project of anchor protocol with my fellow mate. We have been working on our own version of RUST SC forked from anchor protocol, yet we usually get stuck when we start to think about liquidity providers.

IMAGINE
I have made an SC where I have added a feature where it gives me a staking reward on the testnet of Terra and it is only myself staking 5 LUNA in the SC. The ability of the SC states that a staker will get 25% of the total staked value after 7 days of staking. However here it is only myself staking on the contract and this contract does not allow MINTING of new tokens. The reward is given to the user in the staked token itself.
How can I possibly get the reward token IF I HAVE TWO OR THREE USERS STAKING ON THE SC?

[FEATURE] Astroport Support

Problem definition
Current anchor token contracts including staking and collector contracts work with terraswap contracts. Upon launching astroport, it is better to move contracts functionalities to astroport.

Feature specification

  • staking contracts supports:
  • Update different schedules
  • Time-based calculation instead of blocked based calculation.
  • collector contract supports:
  • Update config variables
  • Add Burn functionalities to anc buybacks
  • Support astroport factory in config
  • Support max_spread for anc buy backs

Staking contract query - block_height from past

Hello guys!
Found issue in my Staking contract (that was copypasted from yours): Nexus-Protocol/services-contracts#17

Your code here:

fn compute_reward(config: &Config, state: &mut State, block_height: u64) {

have the same issue

If you pass block_height from the past this part:

let passed_blocks = std::cmp::min(s.1, block_height) - std::cmp::max(s.0, state.last_distributed);

will fail

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.