diff --git a/seasons/S7_defi_scores.md b/seasons/S7_defi_scores.md index bd790d8..1b19f05 100644 --- a/seasons/S7_defi_scores.md +++ b/seasons/S7_defi_scores.md @@ -142,7 +142,8 @@ TONCO is a CLMM DEX and every time user provides liquidity to the pool, new NFT User can withdraw entire amount of liquidity at any time, when it is done, liquidity goes back to the user and NFT marked as init=false. So to get all active liqudity positions by the user we are getting all NFTs from collections owner by [router contract](https://tonviewer.com/EQC_-t0nCnOFMdp7E7qPxAOCbCWGFz-e3pwxb6tTvFmshjt5) -and init=true. Next we are extracting initial liquidity transfers during the NFT mint transaction chain +which have not been withdrawn by sending [POSITIONNFTV3_POSITION_BURN#46ca335a](https://docs.tonco.io/technical-reference/contracts/position_nft) +message. Next we are extracting initial liquidity transfers during the NFT mint transaction chain and estimating that liquidity in USD based on the price of the assets at the time of the transaction. ### Farmix diff --git a/seasons/sql/s7_defi_tvl.sql b/seasons/sql/s7_defi_tvl.sql index 17b507d..ba7e974 100644 --- a/seasons/sql/s7_defi_tvl.sql +++ b/seasons/sql/s7_defi_tvl.sql @@ -478,7 +478,11 @@ tonco_collections as ( ), tonco_positions as ( -- get all NFT positions which is active now (init=true) select address, owner_address from public.nft_items ni - where collection_address in (select * from tonco_collections) and init + where collection_address in (select * from tonco_collections) -- and init + -- since we have to track which positions have been withdrawn we will exclude all positions with + -- POSITIONNFTV3_POSITION_BURN#46ca335a message before the end of the season + and not exists (select from messages where direction ='in' and destination = ni.address + and created_at < 1734433200 and opcode = 1187656538 order by created_at desc limit 1) ), tonco_positions_first_tx as ( -- get first transaction for every NFT position. This tx will be a part of mint tx chain -- to get the first transaction we will filter by end_status and orig_status and also filter @@ -505,7 +509,8 @@ tonco_collections as ( -- for all other jettons let's get latest agg price just before the event else (select price_usd from prices.agg_prices ap where ap.base = jetton_master_address and - price_time < tx_now + -- estimate using the price and the end of the season + price_time < 1734433200 order by price_time desc limit 1) end ) * amount / 1e6 as amount_usd from tonco_jetton_transfers