Skip to content
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

v1.3.2 #187

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion packages/app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ NEXT_PUBLIC_FATHOM_SITE_ID=

RPC_GNOSIS=
RPC_MAINNET=
RPC_ARBITRUM=
RPC_ARBITRUM=

NEXT_STACKLY_SUBGRAPH_API_KEY=
1 change: 1 addition & 0 deletions packages/landing/analytics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const EVENTS = {
WHAT_IS_STACK_CLICK: `${FAQ_WHAT_IS}-stack`,
WHAT_IS_DCA: `${FAQ_WHAT_IS}-dca`,
WHY_TO_DCA: `${FAQ}-why-to-dca`,
NETWORKS_AVAILABLE: `${FAQ}-networks-available`,
},
HERO_BANNER: {
STACK_NOW_CLICK: `${LAUNCH_APP}-hero-banner`,
Expand Down
7 changes: 7 additions & 0 deletions packages/landing/components/sections/FAQ/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ export const FAQ_QUESTIONS_AND_ANSWERS: FaqQa[] = [
],
trackEventName: EVENTS.SECTIONS.FAQ.HOW_CANCEL_STACK,
},
{
question: "Which networks is Stackly available?",
answers: [
`Currently Stackly supports Arbitrum, Gnosis and Ethereum mainnet networks.`,
],
trackEventName: EVENTS.SECTIONS.FAQ.NETWORKS_AVAILABLE,
},
];
29 changes: 29 additions & 0 deletions packages/landing/components/sections/HeroBanner/HeroBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@ import { STACKLY_APP_URL } from "@/constants";
export const HeroBanner = () => {
return (
<section className="px-6 pt-16 border-b border-gray-100 md:pt-20">
<div className="flex items-center px-3 py-2 mx-auto mb-3 space-x-2 border border-surface-75 rounded-3xl w-fit hover:border-primary-300">
<p className="text-xs text-em-med">Live on:</p>
<div className="flex items-center space-x-1">
<Image
src="/assets/images/ethereum-avatar.svg"
alt="ethereum logo"
width={20}
height={20}
title="live on ethereum mainnet network"
className="hover:scale-125"
/>
<Image
src="/assets/images/gnosis-avatar.svg"
alt="gnosis logo"
width={20}
height={20}
title="live on gnosis network"
className="hover:scale-125"
/>
<Image
src="/assets/images/arbitrum-avatar.svg"
alt="arbitrum logo"
width={20}
height={20}
title="live on arbitrum one network"
className="hover:scale-125"
/>
</div>
</div>
<div className="space-y-4 text-center md:space-y-6 ">
<DisplayText>Empower your portfolio</DisplayText>
<HeadingText className="!font-medium text-em-med max-w-2xl mx-auto">
Expand Down
15 changes: 15 additions & 0 deletions packages/landing/public/assets/images/arbitrum-avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/landing/public/assets/images/ethereum-avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/landing/public/assets/images/gnosis-avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions packages/sdk/src/vaults/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ export const COW_SETTLEMENT_ADDRESS_LIST: Record<ChainId, string> = {
[ChainId.ARBITRUM]: COW_SETTLEMENT_ADDRESS,
};

const STACKLY_SUBGRAPH_KEY = "5fdd9e74c326b644f8088068769d72af";
const STACKLY_SUBGRAPH_API_KEY =
process.env.STACKLY_SUBGRAPH_API_KEY ?? "e7b7ff845e506590498946cd6bf83bf6";

export const SUBGRAPH_ENDPOINT_LIST: Readonly<Record<string, string>> = {
[ChainId.ETHEREUM]: `https://gateway-arbitrum.network.thegraph.com/api/${STACKLY_SUBGRAPH_KEY}/subgraphs/id/5AMWcp9zv791teVUZT7Nm1jYeaLYmF4VYYnhh3JLZDGc`,
[ChainId.GNOSIS]: `https://gateway-arbitrum.network.thegraph.com/api/${STACKLY_SUBGRAPH_KEY}/subgraphs/id/29A9NjwmhSgF8UKRvEnRbXSyqFmYnrspyPF69mFAMVGX`,
[ChainId.ARBITRUM]: `https://api.studio.thegraph.com/query/63508/stackly-arbitrum-one/version/latest`, // todo: change to correct address
[ChainId.ETHEREUM]: `https://gateway-arbitrum.network.thegraph.com/api/${STACKLY_SUBGRAPH_API_KEY}/subgraphs/id/35bL4ohk2tnXqDnrp7NSyAKW8bbUmGDapyfe2ddCxV8H`,
[ChainId.GNOSIS]: `https://gateway-arbitrum.network.thegraph.com/api/${STACKLY_SUBGRAPH_API_KEY}/subgraphs/id/72Lysd4A2kZFqMqJtPQk3zMEEBExFfXeZbkJGTx8phRL`,
[ChainId.ARBITRUM]: `https://gateway-arbitrum.network.thegraph.com/api/${STACKLY_SUBGRAPH_API_KEY}/subgraphs/id/FNmemHB6tUh7eHmJnBFKYFf27U5GUAzXnatry4ZbrF7f`,
};

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"prepare:gnosis": "ts-node bin/build-subgraph.ts gnosis && bun run codegen",
"prepare:mainnet": "ts-node bin/build-subgraph.ts mainnet && bun run codegen",
"prepare:arbitrum-one": "ts-node bin/build-subgraph.ts arbitrum-one && bun run codegen",
"deploy:mainnet": "graph deploy --studio stackly-ethereum",
"deploy:gnosis": "graph deploy --studio stackly",
"deploy:arbitrum-one": "graph deploy --studio stackly-arbitrum-one",
"deploy:mainnet": "bun run prepare:mainnet && graph deploy --studio stackly-mainnet",
"deploy:gnosis": "bun run prepare:gnosis && graph deploy --studio stackly-gnosis",
"deploy:arbitrum-one": "bun run prepare:arbitrum-one && graph deploy --studio stackly-arbitrum-one",
"create-local": "graph create --node http://localhost:8020/ swaprhq/stackly",
"remove-local": "graph remove --node http://localhost:8020/ swaprhq/stackly",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 swaprhq/stackly",
Expand All @@ -23,8 +23,8 @@
"@stackly/sdk": "workspace:^"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.51.2",
"@graphprotocol/graph-ts": "0.31.0",
"@graphprotocol/graph-cli": "0.78.0",
"@graphprotocol/graph-ts": "0.35.1",
"@types/node": "^18.11.18",
"ts-node": "^10.8.2",
"yaml": "^2.2.1"
Expand Down
99 changes: 71 additions & 28 deletions packages/subgraph/src/mappings/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,106 @@ import { OrderFactory } from "../../generated/OrderFactory/OrderFactory";
const HUNDRED_PERCENT = BigInt.fromI32(10000);

export function createOrReturnTokenEntity(contractAddress: Address): Token {
// Persist token data if it doesn't already exist
let token = Token.load(contractAddress.toHex());
let tokenId = contractAddress.toHex();
let token = Token.load(tokenId);

// Return existing token if it's already in the store
if (token !== null) {
return token;
}

// Create a new token entity
token = new Token(tokenId);
let tokenContract = ERC20Contract.bind(contractAddress);
token = new Token(contractAddress.toHex());

// Set the address field
token.address = contractAddress;

token.name = "";
// Name
let tryName = tokenContract.try_name();
if (!tryName.reverted) {
token.name = tryName.value;
}
token.name = tryName.reverted ? "Unknown Token" : tryName.value;

token.symbol = "";
// Symbol
let trySymbol = tokenContract.try_symbol();
if (!trySymbol.reverted) {
token.symbol = trySymbol.value;
}
token.symbol = trySymbol.reverted ? "UNKNOWN" : trySymbol.value;

// Decimals
let tryDecimals = tokenContract.try_decimals();
token.decimals = tryDecimals.reverted ? 18 : tryDecimals.value;

token.decimals = tokenContract.decimals();
token.save();
return token;
}

export function handleDCAOrderInitialized(event: Initialized): void {
const orderContract = DCAOrderContract.bind(event.params.order);
const order = new DCAOrder(event.params.order.toHex());
const orderAddress = event.params.order;
const orderContract = DCAOrderContract.bind(orderAddress);
const order = new DCAOrder(orderAddress.toHex());

order.createdAt = event.block.timestamp;
order.owner = orderContract.owner();
order.sellToken = createOrReturnTokenEntity(orderContract.sellToken()).id;
order.buyToken = createOrReturnTokenEntity(orderContract.buyToken()).id;
order.receiver = orderContract.receiver();

let tryOwner = orderContract.try_owner();
order.owner = tryOwner.reverted
? Address.fromString("0x0000000000000000000000000000000000000000")
: tryOwner.value;

let trySellToken = orderContract.try_sellToken();
order.sellToken = trySellToken.reverted
? ""
: createOrReturnTokenEntity(trySellToken.value).id;

let tryBuyToken = orderContract.try_buyToken();
order.buyToken = tryBuyToken.reverted
? ""
: createOrReturnTokenEntity(tryBuyToken.value).id;

let tryReceiver = orderContract.try_receiver();
order.receiver = tryReceiver.reverted
? Address.fromString("0x0000000000000000000000000000000000000000")
: tryReceiver.value;

let orderSlots: Array<BigInt> = [BigInt.fromI32(0)];
let protocolFee: BigInt = BigInt.fromI32(0);
let orderFactoryAddress: Address = (
event.transaction.to !== null
? event.transaction.to
: Address.fromString("0x0")
)!;

let orderFactoryAddress: Address;
if (event.transaction.to !== null) {
orderFactoryAddress = event.transaction.to as Address;
} else {
orderFactoryAddress = Address.fromString(
"0x0000000000000000000000000000000000000000"
);
}

const factory = OrderFactory.bind(orderFactoryAddress);
let tryProtocolFee = factory.try_protocolFee();
if (!tryProtocolFee.reverted) {
protocolFee = BigInt.fromI32(tryProtocolFee.value);
}

order.amount = orderContract.amount();
let tryOrderSlots = orderContract.try_orderSlots();
if (!tryOrderSlots.reverted) {
orderSlots = tryOrderSlots.value;
}

let tryAmount = orderContract.try_amount();
order.amount = tryAmount.reverted ? BigInt.fromI32(0) : tryAmount.value;

order.fee = protocolFee;
order.feeAmount = order.amount
.times(protocolFee)
.div(HUNDRED_PERCENT.minus(protocolFee));
order.endTime = orderContract.endTime().toI32();
order.startTime = orderContract.startTime().toI32();
order.orderSlots = orderContract.orderSlots();
order.interval = orderContract.interval();

let tryEndTime = orderContract.try_endTime();
order.endTime = tryEndTime.reverted ? 0 : tryEndTime.value.toI32();

let tryStartTime = orderContract.try_startTime();
order.startTime = tryStartTime.reverted ? 0 : tryStartTime.value.toI32();

order.orderSlots = orderSlots;

let tryInterval = orderContract.try_interval();
order.interval = tryInterval.reverted ? BigInt.fromI32(0) : tryInterval.value;

order.save();
}

Expand Down