Skip to content

Commit

Permalink
feat: aprs and liquidity splits
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmellis committed Nov 22, 2023
1 parent 7674e25 commit 6abff1c
Show file tree
Hide file tree
Showing 47 changed files with 1,335 additions and 784 deletions.
179 changes: 29 additions & 150 deletions packages/abi/src/json/CreateVaultZap.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,17 @@
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "InsufficientETHSent",
"type": "error"
},
{
"inputs": [],
"name": "InsufficientVTokensMinted",
"type": "error"
},
{
"inputs": [],
"name": "NotNFTOwner",
"type": "error"
},
{
"inputs": [],
"name": "R",
"type": "error"
},
{
"inputs": [],
"name": "T",
"type": "error"
},
{
"inputs": [],
"name": "UnableToSendETH",
"type": "error"
},
{ "inputs": [], "name": "InsufficientETHSent", "type": "error" },
{ "inputs": [], "name": "InsufficientVTokensMinted", "type": "error" },
{ "inputs": [], "name": "NotNFTOwner", "type": "error" },
{ "inputs": [], "name": "R", "type": "error" },
{ "inputs": [], "name": "T", "type": "error" },
{ "inputs": [], "name": "UnableToSendETH", "type": "error" },
{
"inputs": [],
"name": "WETH",
"outputs": [
{
"internalType": "contract IWETH9",
"name": "",
"type": "address"
}
{ "internalType": "contract IWETH9", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
Expand Down Expand Up @@ -87,26 +59,14 @@
"name": "assetAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "is1155",
"type": "bool"
},
{ "internalType": "bool", "name": "is1155", "type": "bool" },
{
"internalType": "bool",
"name": "allowAllItems",
"type": "bool"
},
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
}
{ "internalType": "string", "name": "name", "type": "string" },
{ "internalType": "string", "name": "symbol", "type": "string" }
],
"internalType": "struct CreateVaultZap.VaultInfo",
"name": "vaultInfo",
Expand All @@ -119,11 +79,7 @@
"name": "moduleIndex",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "initData",
"type": "bytes"
}
{ "internalType": "bytes", "name": "initData", "type": "bytes" }
],
"internalType": "struct CreateVaultZap.VaultEligibilityStorage",
"name": "eligibilityStorage",
Expand Down Expand Up @@ -178,11 +134,7 @@
"name": "upperNFTPriceInETH",
"type": "uint256"
},
{
"internalType": "uint24",
"name": "fee",
"type": "uint24"
},
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
{
"internalType": "uint256",
"name": "currentNFTPriceInETH",
Expand Down Expand Up @@ -216,11 +168,7 @@
],
"name": "createVault",
"outputs": [
{
"internalType": "uint256",
"name": "vaultId",
"type": "uint256"
}
{ "internalType": "uint256", "name": "vaultId", "type": "uint256" }
],
"stateMutability": "payable",
"type": "function"
Expand All @@ -242,109 +190,43 @@
"inputs": [],
"name": "nftxRouter",
"outputs": [
{
"internalType": "contract INFTXRouter",
"name": "",
"type": "address"
}
{ "internalType": "contract INFTXRouter", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "uint256[]", "name": "", "type": "uint256[]" },
{ "internalType": "uint256[]", "name": "", "type": "uint256[]" },
{ "internalType": "bytes", "name": "", "type": "bytes" }
],
"name": "onERC1155BatchReceived",
"outputs": [
{
"internalType": "bytes4",
"name": "",
"type": "bytes4"
}
],
"outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "uint256", "name": "", "type": "uint256" },
{ "internalType": "bytes", "name": "", "type": "bytes" }
],
"name": "onERC1155Received",
"outputs": [
{
"internalType": "bytes4",
"name": "",
"type": "bytes4"
}
],
"outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
Expand All @@ -361,8 +243,5 @@
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
{ "stateMutability": "payable", "type": "receive" }
]
14 changes: 14 additions & 0 deletions packages/api/src/assets/fetchAuctions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import config from '@nftx/config';
import { Asset } from '@nftx/types';
import { queryApi } from '../utils';

const fetchAuctions = ({
network = config.network,
}: { network?: number } = {}) => {
const url = `/${network}/auctions`;
type Response = { assets: Asset[] };

return queryApi<Response>({ url });
};

export default fetchAuctions;
1 change: 1 addition & 0 deletions packages/api/src/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as fetchAsset } from './fetchAsset';
export { default as fetchAllAssets } from './fetchAllAssets';
export { default as fetchAssets } from './fetchAssets';
export { default as streamAssets } from './streamAssets';
export { default as fetchAuctions } from './fetchAuctions';
4 changes: 4 additions & 0 deletions packages/api/src/pools/fetchLiquidityPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const fetchLiquidityPools = ({
vaultAddresses,
vaultId,
vaultIds,
exists,
}: {
network?: number;
/** Get pools that match the given liquidity pool addresses */
Expand All @@ -22,13 +23,16 @@ const fetchLiquidityPools = ({
vaultId?: string;
/** Get pools that match the given vault ids */
vaultIds?: string[];
/** Only return pools that actually exist */
exists?: boolean;
} = {}) => {
return queryApi<LiquidityPool[]>({
url: `/${network}/pools/liquidity`,
query: {
liquidityPoolId: poolIds,
id: vaultAddress ?? vaultAddresses,
vaultId: vaultId ?? vaultIds,
exists,
},
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/constants/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const OPENSEA_COLLECTION = a(

/** Zap specifically for creating new vaults */
export const CREATE_VAULT_ZAP = {
[Network.Goerli]: a('0x040fE06ABc3c099772DEe413dE138937bf053543'),
[Network.Goerli]: a('0xFE60863328735aE7EB289cAB99B37235add768Fa'),
};

/** Perform buy/sell/swaps */
Expand Down
1 change: 1 addition & 0 deletions packages/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './subgraph';
export * from './urls';
export * from './values';
export * from './feeTiers';
export * from './ticks';
2 changes: 1 addition & 1 deletion packages/constants/src/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ export const NFTX_SUBGRAPH = {
};

export const NFTX_UNISWAP_SUBGRAPH = {
[Network.Goerli]: `https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-uniswap-goerli`,
[Network.Goerli]: `https://api.thegraph.com/subgraphs/name/gundamdweeb/nftx-amm`,
};
4 changes: 4 additions & 0 deletions packages/constants/src/ticks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const MIN_TICK = -887272;
export const MAX_TICK = 887272;
export const TICK_PRICE_BASE = 1.0001;
export const TICK_LOG_BASE = Math.log(TICK_PRICE_BASE);
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@nftx/types": "^0.9.0",
"@nftx/utils": "^0.9.0",
"@uniswap/v3-sdk": "^3.10.0",
"@uniswap/sdk-core": "^4.0.0",
"decimal.js": "^10.4.3",
"jsbi": "^3.1.4",
"viem": "0.1.19"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/pools/fetchInventoryPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const makeFetchInventoryPool =
network?: number;
vaultId: string;
provider: Provider;
vaults: Pick<Vault, 'vaultId' | 'id' | 'vTokenToEth'>[];
vaults: Pick<Vault, 'vaultId' | 'id' | 'vTokenToEth' | 'createdAt'>[];
}) => {
const pools = await fetchInventoryPools({
network,
Expand Down
Loading

0 comments on commit 6abff1c

Please sign in to comment.