Code Monkey home page Code Monkey logo

sol-qualify-lp's Introduction

qualify-lp

Summary

Perform simple ABI checks, to determine if an address seems to behave like a Uniswap or Balancer LP pool token.

Using

Step 1 - qualify LP token

Call qualifyUniswapLP() or qualifyBalancerLP() to validate an LP token, and add it to the database.

Step 2 - query qualifications database

Import the interface file IQualifyLP.sol into a solidity contract, then treat as a simple mapping:

    function do_something_with_lp_token(address lpToken) internal returns (bool) {
	address LPQualAddr = address(0xeE87996440515154fb913Fada7aBB4F2Caecb14f);
	IQualifyLP lpQual = IQualifyLP(LPQualAddr);
	uint256 constant LP_UNISWAP = 1;

	// check QualifyLP's mapping of validated tokens
	uint256 qualResult = lpQual.qualified(lpToken);

	// require that lpToken is a Uniswap-like pair liquidity pool contract
	// Requires someone MUST have previously called qualifyUniswapLP() at some
	// point in the past.
	require(qualResult == LP_UNISWAP);
    }

Deployment

Ethereum mainnet deployment, v0.9.0: 0xeE87996440515154fb913Fada7aBB4F2Caecb14f

Caveats

This can only provide a minimum guarantee that the address provided seems to behave like a Uniswap or Balancer pool token. A fork such as SushiSwap, using the same ABI as Uniswap, will pass these qualifications (there is a plan to fix this limitation in the next version, by using the Uniswap Router).

sol-qualify-lp's People

Contributors

jgarzik avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

w1r2p1

sol-qualify-lp's Issues

Add unit tests

  • Also add solidity-coverage tool to measure test coverage

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.