Liquidity Party adapter

This commit is contained in:
tim
2025-12-10 15:53:45 -04:00
parent f0f2f20c3c
commit f1e602d414
21 changed files with 1589 additions and 321 deletions

View File

@@ -1,2 +1,11 @@
export PATH := /home/linuxbrew/.linuxbrew/bin:$(PATH)
all: ethereum
build:
cargo build --target wasm32-unknown-unknown --release
cargo build --target wasm32-unknown-unknown --release
ethereum: build
substreams pack ethereum-liquidityparty.yaml -o ethereum-liquidityparty.spkg
.PHONY: build ethereum

View File

@@ -2,15 +2,15 @@
{
"type": "constructor",
"inputs": [
{
"name": "swapImpl_",
"type": "address",
"internalType": "contract PartyPoolSwapImpl"
},
{
"name": "mintImpl",
"type": "address",
"internalType": "contract PartyPoolMintImpl"
},
{
"name": "swapImpl_",
"type": "address",
"internalType": "contract PartyPoolSwapImpl"
}
],
"stateMutability": "nonpayable"
@@ -54,7 +54,7 @@
"internalType": "uint256"
},
{
"name": "inputTokenIndex",
"name": "outputTokenIndex",
"type": "uint256",
"internalType": "uint256"
}
@@ -64,6 +64,11 @@
"name": "amountOut",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "outFee",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
@@ -97,30 +102,6 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "flashRepaymentAmounts",
"inputs": [
{
"name": "pool",
"type": "address",
"internalType": "contract IPartyPool"
},
{
"name": "loanAmounts",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"outputs": [
{
"name": "repaymentAmounts",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "maxFlashLoan",
@@ -216,8 +197,8 @@
"outputs": [
{
"name": "",
"type": "int128",
"internalType": "int128"
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
@@ -249,12 +230,12 @@
"internalType": "uint256"
},
{
"name": "fee",
"name": "lpMinted",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "lpMinted",
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
@@ -298,11 +279,30 @@
"internalType": "uint256"
},
{
"name": "fee",
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "working",
"inputs": [
{
"name": "pool",
"type": "address",
"internalType": "contract IPartyPool"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
}
]

View File

@@ -23,14 +23,14 @@
"internalType": "contract PartyPoolMintImpl"
},
{
"name": "deployer_",
"name": "poolInitCodeStorage_",
"type": "address",
"internalType": "contract IPartyPoolDeployer"
"internalType": "contract PartyPoolInitCode"
},
{
"name": "balancedPairDeployer_",
"name": "balancedPairInitCodeStorage_",
"type": "address",
"internalType": "contract IPartyPoolDeployer"
"internalType": "contract PartyPoolBalancedPairInitCode"
},
{
"name": "protocolFeePpm_",
@@ -174,12 +174,91 @@
"internalType": "contract IERC20[]"
},
{
"name": "bases_",
"name": "kappa_",
"type": "int128",
"internalType": "int128"
},
{
"name": "swapFeesPpm_",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "kappa_",
"name": "flashFeePpm_",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "stable_",
"type": "bool",
"internalType": "bool"
},
{
"name": "payer",
"type": "address",
"internalType": "address"
},
{
"name": "receiver",
"type": "address",
"internalType": "address"
},
{
"name": "initialDeposits",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "initialLpAmount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "deadline",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "pool",
"type": "address",
"internalType": "contract IPartyPool"
},
{
"name": "lpAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "newPool",
"inputs": [
{
"name": "name_",
"type": "string",
"internalType": "string"
},
{
"name": "symbol_",
"type": "string",
"internalType": "string"
},
{
"name": "tokens_",
"type": "address[]",
"internalType": "contract IERC20[]"
},
{
"name": "tradeFrac_",
"type": "int128",
"internalType": "int128"
},
{
"name": "targetSlippage_",
"type": "int128",
"internalType": "int128"
},
@@ -258,17 +337,7 @@
"internalType": "contract IERC20[]"
},
{
"name": "bases_",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "tradeFrac_",
"type": "int128",
"internalType": "int128"
},
{
"name": "targetSlippage_",
"name": "kappa_",
"type": "int128",
"internalType": "int128"
},
@@ -340,6 +409,86 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "params",
"inputs": [],
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct IPartyPoolDeployer.DeployParams",
"components": [
{
"name": "nonce",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "name",
"type": "string",
"internalType": "string"
},
{
"name": "symbol",
"type": "string",
"internalType": "string"
},
{
"name": "tokens",
"type": "address[]",
"internalType": "contract IERC20[]"
},
{
"name": "kappa",
"type": "int128",
"internalType": "int128"
},
{
"name": "fees",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "flashFeePpm",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "protocolFeePpm",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "protocolFeeAddress",
"type": "address",
"internalType": "address"
},
{
"name": "wrapper",
"type": "address",
"internalType": "contract NativeWrapper"
},
{
"name": "swapImpl",
"type": "address",
"internalType": "contract PartyPoolSwapImpl"
},
{
"name": "mintImpl",
"type": "address",
"internalType": "contract PartyPoolMintImpl"
}
]
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "poolCount",
@@ -405,6 +554,19 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setProtocolFeeAddress",
"inputs": [
{
"name": "feeAddress",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "swapImpl",

View File

@@ -1,73 +1,7 @@
[
{
"type": "constructor",
"inputs": [
{
"name": "owner_",
"type": "address",
"internalType": "address"
},
{
"name": "name_",
"type": "string",
"internalType": "string"
},
{
"name": "symbol_",
"type": "string",
"internalType": "string"
},
{
"name": "tokens_",
"type": "address[]",
"internalType": "contract IERC20[]"
},
{
"name": "bases_",
"type": "uint256[]",
"internalType": "uint256[]"
},
{
"name": "kappa_",
"type": "int128",
"internalType": "int128"
},
{
"name": "swapFeePpm_",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "flashFeePpm_",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "protocolFeePpm_",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "protocolFeeAddress_",
"type": "address",
"internalType": "address"
},
{
"name": "wrapperToken_",
"type": "address",
"internalType": "contract NativeWrapper"
},
{
"name": "swapImpl_",
"type": "address",
"internalType": "contract PartyPoolSwapImpl"
},
{
"name": "mintImpl_",
"type": "address",
"internalType": "contract PartyPoolMintImpl"
}
],
"inputs": [],
"stateMutability": "nonpayable"
},
{
@@ -84,11 +18,6 @@
"type": "tuple",
"internalType": "struct LMSRStabilized.State",
"components": [
{
"name": "nAssets",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "kappa",
"type": "int128",
@@ -256,7 +185,7 @@
"internalType": "uint256"
},
{
"name": "inputTokenIndex",
"name": "outputTokenIndex",
"type": "uint256",
"internalType": "uint256"
},
@@ -273,7 +202,12 @@
],
"outputs": [
{
"name": "amountOutUint",
"name": "amountOut",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "outFee",
"type": "uint256",
"internalType": "uint256"
}
@@ -313,6 +247,43 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "fee",
"inputs": [
{
"name": "i",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "j",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "fees",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256[]",
"internalType": "uint256[]"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "flashFeePpm",
@@ -360,25 +331,6 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "getToken",
"inputs": [
{
"name": "i",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IERC20"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "initialMint",
@@ -478,7 +430,7 @@
{
"name": "",
"type": "address",
"internalType": "contract PartyPoolMintImpl"
"internalType": "address"
}
],
"stateMutability": "view"
@@ -555,6 +507,19 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setProtocolFeeAddress",
"inputs": [
{
"name": "feeAddress",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "swap",
@@ -564,6 +529,11 @@
"type": "address",
"internalType": "address"
},
{
"name": "fundingSelector",
"type": "bytes4",
"internalType": "bytes4"
},
{
"name": "receiver",
"type": "address",
@@ -598,6 +568,11 @@
"name": "unwrap",
"type": "bool",
"internalType": "bool"
},
{
"name": "cbData",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
@@ -612,7 +587,7 @@
"internalType": "uint256"
},
{
"name": "fee",
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
@@ -656,7 +631,7 @@
"internalType": "uint256"
},
{
"name": "fee",
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
@@ -665,13 +640,13 @@
},
{
"type": "function",
"name": "swapFeePpm",
"name": "swapImpl",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
@@ -707,27 +682,24 @@
}
],
"outputs": [
{
"name": "amountInUsed",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "lpMinted",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "payable"
},
{
"type": "function",
"name": "swapMintImpl",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract PartyPoolSwapImpl"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "swapToLimit",
@@ -737,6 +709,11 @@
"type": "address",
"internalType": "address"
},
{
"name": "fundingSelector",
"type": "bytes4",
"internalType": "bytes4"
},
{
"name": "receiver",
"type": "address",
@@ -766,6 +743,11 @@
"name": "unwrap",
"type": "bool",
"internalType": "bool"
},
{
"name": "cbData",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
@@ -780,7 +762,7 @@
"internalType": "uint256"
},
{
"name": "fee",
"name": "inFee",
"type": "uint256",
"internalType": "uint256"
}
@@ -800,6 +782,25 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "token",
"inputs": [
{
"name": "i",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IERC20"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "totalSupply",
@@ -1333,6 +1334,22 @@
"name": "FailedCall",
"inputs": []
},
{
"type": "error",
"name": "InsufficientBalance",
"inputs": [
{
"name": "balance",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "needed",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"type": "error",
"name": "OwnableInvalidOwner",

View File

@@ -0,0 +1,11 @@
#!/bin/bash
LMSR_HOME=../../../lmsr-amm
CHAIN_ID=11155111
abi() {
jq '.abi' $LMSR_HOME/deployment/$CHAIN_ID/v1/out/$1.sol/$1.json > abi/$2.abi.json
echo abi/$2.abi.json
}
abi PartyPlanner party_planner
abi PartyPool party_pool
abi PartyInfo party_info

View File

@@ -16,18 +16,17 @@ binaries:
type: wasm/rust-v1
file: ../target/wasm32-unknown-unknown/release/ethereum_liquidityparty.wasm
network: sepolia
network: mainnet
networks:
sepolia:
mainnet:
initialBlock:
map_protocol_components: 9460804
map_protocol_components: 23978797
params:
map_protocol_components: planner=0x0ad06C08ab5049e6Fd4d7f5AF457115A1475326b&viewer=0x750d63a39a4ccfCfB69D2f5aFDa065909C717cAB&mint_impl=0x25bb10BA84944F8aAEf1fD247C3B7Fe7271C23F9&swap_impl=0x69b4F102e0747f61F8529b3bbFf2FC4b27438d0F&deployer=0x0939F93BAa3c96226853F9F39A95beF48eA8fF04&bp_deployer=0xfda454fF7876aad9408517Ed2F0d11AA229Ad0a4
map_protocol_components: planner=0x42977f565971F6D288a05ddEbC87A17276F71A29&info=0x605F803cD27F5c1fa01440B2cbd5D3E4Cf7EE850&mint_impl=0xA0375403921e9B357E1BeD57bef3fA3FCE80acd0&swap_impl=0x6aA001e87F86E83bc4D569883332882cb47E2A13
modules:
- name: map_protocol_components
kind: map
initialBlock: 1
inputs:
- params: string
- source: sf.ethereum.type.v2.Block
@@ -36,7 +35,6 @@ modules:
- name: store_protocol_components
kind: store
initialBlock: 1
updatePolicy: set
valueType: string
inputs:
@@ -44,7 +42,6 @@ modules:
- name: map_relative_component_balance
kind: map
initialBlock: 1
inputs:
- source: sf.ethereum.type.v2.Block
- store: store_protocol_components
@@ -53,7 +50,6 @@ modules:
- name: store_balances
kind: store
initialBlock: 1
updatePolicy: add
valueType: bigint
inputs:
@@ -61,7 +57,6 @@ modules:
- name: map_protocol_changes
kind: map
initialBlock: 1
inputs:
- source: sf.ethereum.type.v2.Block
- map: map_protocol_components

View File

@@ -1,69 +1,40 @@
# Name of the substreams config file in your substreams module. Usually "./substreams.yaml"
substreams_yaml_path: ./substreams.yaml
# Name of the adapter contract, usually: ProtocolSwapAdapter"
adapter_contract: "SwapAdapter"
# Constructor signature of the Adapter contract"
adapter_build_signature: "constructor(address)"
# A comma separated list of args to be passed to the contructor of the Adapter contract"
adapter_build_args: "0x0000000000000000000000000000000000000000"
# Whether the testing script should skip checking balances of the protocol components.
# If set to `true` please always add a reason why it's skipped.
skip_balance_check: false
# Accounts that will be automatically initialized at test start
# IMPORTANT: These are TEST FIXTURES ONLY. Your actual code must still properly
# initialize these accounts. This configuration only eliminates the need to include
# historical blocks containing the initialization events in your test data.
#
# Example use case:
# - Your substream would normally initialize account XYZ at block 10000
# - Your test only includes blocks 20000-21000 for efficiency
# - You list XYZ here so the test environment will automatically initialize the account XYZ with the state it had at block 20000
# - Your actual substream code MUST STILL contain the initialization and state tracking logic for this contract
#
# Without this, you would need to include block 10000 in your test data or your
# test would fail because the account appears uninitialized to your code.
initialized_accounts:
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84" # Needed for ....
# A list of protocol types names created by your Substreams module.
substreams_yaml_path: ./sepolia-liquidityparty.yaml
adapter_contract: "LiquidityPartySwapAdapter"
adapter_build_signature: "constructor(address,address)"
# PartyPlanner, PartyInfo
adapter_build_args: "0x42977f565971F6D288a05ddEbC87A17276F71A29,0x605F803cD27F5c1fa01440B2cbd5D3E4Cf7EE850"
# Liquidity Party protocol fees are retained in the pool until collection, so the pool balance does not match the TVL.
skip_balance_check: true
protocol_type_names:
- "type_name_1"
- "type_name_2"
# A list of tests.
# The name of the protocol system
protocol_system: "protocol_name"
- "liquidityparty_pool"
protocol_system: "vm:liquidityparty"
initialized_accounts: [
"0x42977f565971F6D288a05ddEbC87A17276F71A29", # PartyPlanner
"0x605F803cD27F5c1fa01440B2cbd5D3E4Cf7EE850", # PartyInfo
"0xA0375403921e9B357E1BeD57bef3fA3FCE80acd0", # PartyPoolMintImpl
"0x6aA001e87F86E83bc4D569883332882cb47E2A13", # PartyPoolSwapImpl
]
tests:
# Name of the test
- name: test_pool_creation
# Indexed block range
start_block: 123
stop_block: 456
# Same as global `initialized_accounts` but only scoped to this test.
initialized_accounts:
- "0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963" # Needed for ....
# A list of expected component indexed in the block range. Each component must match perfectly the `ProtocolComponent` indexed by your subtreams module.
start_block: 23978797
stop_block: 23978798
initialized_accounts: []
expected_components:
- id: "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
- id: "0x2A804e94500AE379ee0CcC423a67B07cc0aF548C"
tokens:
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
- "0x6b175474e89094c44da98b954eedeac495271d0f"
static_attributes: { }
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
# Whether the script should skip trying to simulate a swap on this component.
# If set to `true` please always add a reason why it's skipped.
# Does this test whether the tokens are in the correct order?
- "0xdAC17F958D2ee523a2206206994597C13D831ec7" # USDT
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" # USDC
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" # WBTC
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # WETH
- "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984" # UNI
- "0xD31a59c85aE9D8edEFeC411D448f90841571b89c" # SOL
- "0x50327c6c5a14DCaDE707ABad2E27eB517df87AB5" # TRX
- "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" # AAVE
- "0x6982508145454Ce325dDbE47a25d4ec3d2311933" # PEPE
- "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE" # SHIB
static_attributes: {}
creation_tx: "0x5c8b1e1e6ec10143a1252799d14df09c7e84f6a99ccde95fc11295a61c20060e"
skip_simulation: false
# Whether the script should skip trying to simulate execution of a swap on this component.
# If set to `true` please always add a reason why it's skipped.
skip_execution: false
- name: test_something_else
start_block: 123
stop_block: 456
expected_components:
- id: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022"
tokens:
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
static_attributes: { }
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
skip_simulation: true # If true, always add a reason
skip_execution: true # If true, always add a reason

View File

@@ -1,4 +1,4 @@
mod.rs
party_planner.rs
party_pool.rs
party_pool_viewer.rs
party_info.rs

View File

@@ -53,6 +53,7 @@ fn map_protocol_components(
param_string: String,
block: eth::v2::Block
) -> Result<BlockTransactionProtocolComponents> {
substreams::log::debug!("Processing block {} for protocol components", block.number);
let params = Params::parse(&param_string)?;
Ok(BlockTransactionProtocolComponents {
tx_components: block
@@ -94,6 +95,7 @@ fn store_protocol_components(
map_protocol_components: BlockTransactionProtocolComponents,
store: StoreSetRaw,
) {
substreams::log::debug!("Storing {} protocol components", map_protocol_components.tx_components.len());
map_protocol_components
.tx_components
.into_iter()
@@ -129,6 +131,7 @@ fn map_relative_component_balance(
block: eth::v2::Block,
store: StoreGetRaw,
) -> Result<BlockBalanceDeltas, anyhow::Error> {
substreams::log::debug!("Processing block {} for balance changes", block.number);
let mut res = Vec::new();
for log in block.logs() {
@@ -239,6 +242,12 @@ fn map_protocol_changes(
balance_store: StoreDeltas,
deltas: BlockBalanceDeltas,
) -> Result<BlockChanges, substreams::errors::Error> {
substreams::log::debug!(
"Processing block {} changes: {} new components, {} balance deltas",
block.number,
new_components.tx_components.len(),
deltas.balance_deltas.len()
);
// We merge contract changes by transaction (identified by transaction index)
// making it easy to sort them at the very end.
let mut transaction_changes: HashMap<_, TransactionChangesBuilder> = HashMap::new();

View File

@@ -4,20 +4,17 @@ use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct StringParams {
planner: String,
viewer: String,
info: String,
mint_impl: String,
swap_impl: String,
deployer: String,
bp_deployer: String,
}
pub(crate) struct Params {
pub planner: Vec<u8>,
pub viewer: Vec<u8>,
#[allow(dead_code)] // We keep the unused info field for future pricing/view operations
pub info: Vec<u8>,
pub mint_impl: Vec<u8>,
pub swap_impl: Vec<u8>,
pub deployer: Vec<u8>,
pub bp_deployer: Vec<u8>,
}
impl StringParams {
@@ -44,11 +41,9 @@ impl Params {
Ok(Self {
planner: decode_addr(&params.planner)?,
viewer: decode_addr(&params.viewer)?,
info: decode_addr(&params.info)?,
mint_impl: decode_addr(&params.mint_impl)?,
swap_impl: decode_addr(&params.swap_impl)?,
deployer: decode_addr(&params.deployer)?,
bp_deployer: decode_addr(&params.bp_deployer)?,
})
}
}

View File

@@ -1,10 +1,10 @@
use crate::abi;
use crate::params::Params;
use substreams_ethereum::pb::eth::v2::{Call, Log, TransactionTrace};
use substreams_ethereum::Event;
use tycho_substreams::models::{
ChangeType, FinancialType, ImplementationType, ProtocolComponent, ProtocolType,
ImplementationType, ProtocolComponent,
};
use crate::abi;
use crate::params::Params;
/// Potentially constructs a new ProtocolComponent given a call
///
@@ -21,19 +21,10 @@ pub fn maybe_create_component(
) -> Option<ProtocolComponent> {
if call.address.as_slice() == params.planner {
if let Some(event) = abi::party_planner::events::PartyStarted::match_and_decode(_log) {
return Some(ProtocolComponent {
id: hex::encode(&event.pool),
tokens: event.tokens,
contracts: vec![event.pool.clone(), params.mint_impl.clone(), params.swap_impl.clone()],
static_att: vec![],
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "liquidity_party".to_string(),
financial_type: FinancialType::Swap.into(),
attribute_schema: vec![],
implementation_type: ImplementationType::Vm.into(),
}),
});
return Some(ProtocolComponent::new(&format!("0x{}", hex::encode(&event.pool)))
.with_tokens(&event.tokens.clone())
.with_contracts(&vec![event.pool.clone(), params.mint_impl.clone(), params.swap_impl.clone()])
.as_swap_type("liquidityparty_pool", ImplementationType::Vm));
}
}
None