-
Notifications
You must be signed in to change notification settings - Fork 6k
Add LA Exchange Adapter #14596
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
base: main
Are you sure you want to change the base?
Add LA Exchange Adapter #14596
Conversation
The adapter at projects/laexchange exports TVL:
|
const LAUNCHPOOL_CONTRACT = "0x82Bcfb5695a7E5c3cE2a9f49bFAf6e28BB23F486" | ||
const CURRENCY_ADDRESS = "0xdAC17F958D2ee523a2206206994597C13D831ec7" // USDT | ||
|
||
const {currV, TVL } = await api.call({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use erc20:balanceOf or getBalance instead please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contract will create many sub-contracts, and the assets will be stored in the sub-contracts respectively. There is a function dedicated to calculating TVL, which can be obtained directly. The specific contract logic is open source, and you can refer to https://etherscan.io/address/0xf94342d9eb0f42ea6bb6901170db7479e3e88e52#code
function calcTVL(address currency) public view returns(uint currV, uint TVL) {
for(uint i=0; i<currencies.length; i++) {
address curr = currencies[i];
uint v;
if(curr == USDX)
v = totalCurrencyLast[curr];
else if(curr == USDT || curr == USDC)
v = totalCurrencyLast[curr].mul(1e18/1e6);
else if(curr == WETH)
v = totalCurrencyLast[curr].mul(uint(AggregatorInterface(oracleETH).latestAnswer())).div(1e8);
TVL = TVL.add(v);
if(curr == currency)
currV = v;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fetch a list of subcontracts from an API and then use erc20:balanceOf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course we can, but using the server's API will make it more centralized. We prefer an open source and decentralized approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cant use calcTVL()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it doesnt give us a breakdown of assets held
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalCurrencyLast is just for the convenience of making a statistical calculation of funds. Its underlying change logic is deposit and withdraw. We will update it at a reasonable position.
function deposit(uint value) external payable invest(msg.sender) {
uint amount;
if(totalSupply == 0)
amount = value;
else if(totalCurrencyLast == 0) { // Finished
if(msg.value > 0)
msg.sender.transfer(msg.value);
return;
} else
amount = value.mul(totalSupply).div(totalCurrencyLast);
if(msg.value >= value && currency == router.WETH())
IWETH(currency).deposit.value(msg.value)();
else {
currency.safeTransferFrom(msg.sender, address(this), value);
if(msg.value > 0)
msg.sender.transfer(msg.value);
}
balanceOf[msg.sender] = balanceOf[msg.sender].add(amount);
totalSupply = totalSupply.add(amount);
totalCurrencyLast = totalCurrencyLast.add(value);
lasttimeDepositOf[msg.sender] = now;
emit Transfer(address(0), msg.sender, amount);
emit Deposited(msg.sender, value);
}
event Deposited(address indexed account, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function withdraw(uint value) public invest(msg.sender) returns (uint, uint) {
uint amount = value.mul(totalSupply).div1(totalCurrencyLast);
if(amount > balanceOf[msg.sender]) {
amount = balanceOf[msg.sender];
value = currencyOf(msg.sender);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(amount);
totalSupply = totalSupply.sub(amount);
emit Transfer(msg.sender, address(0), amount);
totalCurrencyLast = totalCurrencyLast.sub(value);
uint tax = lasttimeDepositOf[msg.sender].add(withdrawTaxSpan) <= now ? 0 : value.mul(withdrawTaxRate).div(1 ether);
currency.safeTransfer(address(router), tax);
IUniswapV2Callee(address(router)).uniswapV2Call(underlying, uint(currency), tax, "");
value = value.sub(tax);
if(currency == router.WETH()) {
IWETH(currency).withdraw(value);
msg.sender.transfer(value);
} else
currency.safeTransfer(msg.sender, value);
emit Withdrawn(msg.sender, value, tax);
return (value, tax);
}
event Withdrawn(address indexed account, uint value, uint tax);
If this is unacceptable, do I need to write a set of APIs to return a bunch of addresses and then balanceOf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would use balanceOf across a list of holder addresses yeah
projects/laexchange/index.js
Outdated
methodology: 'Counts the amount of deposited ETH in the LPETH contract.', | ||
ethereum: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add misrepresentedTokens: true
here and we can use the current calcTVL() logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, please check.
The adapter at projects/laexchange exports TVL:
|
The adapter at projects/laexchange exports TVL:
|
Is TVL $0 expected? We need nonzero TVL to list |
Yes, the project has not started yet, but we want to launch a page on DefiLlama, which we will spread on social media. |
hi @laexchange, because we don't list zero tvl project, I will make this PR to be draft, let me know when your project is ready and have tvl, thanks. |
Name (to be shown on DefiLlama):
LA Exchange
Twitter Link:
https://x.com/LAexchange_ETH
List of audit links if any:
https://cert-api.salusec.io/api/v1/salus/contract/certificate/full/2025/La.Exchange_audit_report_2025-05-08.pdf
Website Link:
https://la.exchange
Logo (High resolution, will be shown with rounded borders):
https://drive.google.com/file/d/1WCgjhaDW6Wra-lLSC6pprbqKb6GDW_iz/view?usp=drive_link
Current TVL:
0
Treasury Addresses (if the protocol has treasury)
Chain:
Ethereum
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
LA.Exchange is an innovative all-in-one decentralized platform that combines a Launchpad powered by the Eternal Oversubscribe mechanism with a decentralized exchange (DEX). It is designed to enable continuous, fair, and transparent token distribution, seamlessly connected to on-chain liquidity, trading, and long-term ecosystem growth.
Token address and ticker if any:
Token address: 0xEB7F0CF3F5fdb2c0Ba6c940deF8902Ca4832001A;
Ticker: LA
Category (full list at https://defillama.com/categories) *Please choose only one:
launchpad
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.): Chainlink
Implementation Details: Briefly describe how the oracle is integrated into your project:
LA Exchange is a decentralized exchange powered by the Eternal Oversubscribe mechanism. The Eternal Oversubscribe Launchpool supports not only ETH, but also USDT, USDC, and USDX. User allocations are calculated based on the value of each deposited asset, with prices sourced from Chainlink oracles.
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
https://la-exchange.gitbook.io/la.exchange-docs/la-eternal-oversubscribe-launchpool
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
https://etherscan.io/address/0xf94342d9eb0f42ea6bb6901170db7479e3e88e52#code
function calcTVL(address currency) public view returns(uint currV, uint TVL)
Github org/user (Optional, if your code is open source, we can track activity):
https://github.com/laexchange/contracts