Skip to content

Commit

Permalink
Merge pull request #35 from gateway-fm/API-304
Browse files Browse the repository at this point in the history
API-304
  • Loading branch information
asolovov authored Nov 29, 2023
2 parents 0bfbf36 + b5c7e6e commit 00e267d
Show file tree
Hide file tree
Showing 153 changed files with 65,751 additions and 38,838 deletions.
67 changes: 25 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
# generate go files for all contracts
generate-contracts-all: generate-contracts-goerli generate-contracts-optimism

# generate go files for goerli net contracts
generate-contracts-goerli: generate-core-goerli generate-spot_market-goerli generate-perps_market-goerli generate-susdt-goerli

# generate fo giles for optimism net contracts
generate-contracts-optimism: generate-core-optimism generate-spot_market-optimism
generate-contracts-andromeda: generate-core-andromeda generate-perps_market-andromeda generate-susdt-andromeda generate-forwarder-andromeda generate-erc7412-andromeda

# generate all mocks
mock-all: mock-service mock-events

# generate go file for SynthetixCore contract on goerli net
generate-core-goerli:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/420-SynthetixCore.json ./contracts/coreGoerli
abigen --abi=./contracts/420-SynthetixCore.json --pkg=coreGoerli --out=./contracts/coreGoerli/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/420-SynthetixCore.json

# generate go file for SpotMarket contract on goerli net
generate-spot_market-goerli:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/420-SpotMarket.json ./contracts/spotMarketGoerli
abigen --abi=./contracts/420-SpotMarket.json --pkg=spotMarketGoerli --out=./contracts/spotMarketGoerli/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/420-SpotMarket.json

# generate go file for PerpsMarket contract on goerli net
generate-perps_market-goerli:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/420-PerpsMarket.json ./contracts/perpsMarketGoerli
abigen --abi=./contracts/420-PerpsMarket.json --pkg=perpsMarketGoerli --out=./contracts/perpsMarketGoerli/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/420-PerpsMarket.json

# generate go file for snxUSDT contract on goerli net
generate-susdt-goerli:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/420-snxUSDToken.json ./contracts/sUSDTGoerli
abigen --abi=./contracts/420-snxUSDToken.json --pkg=sUSDTGoerli --out=./contracts/sUSDTGoerli/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/420-snxUSDToken.json

# generate go file for SynthetixCore contract on optimism net
generate-core-optimism:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/10-SynthetixCore.json ./contracts/coreOptimism
abigen --abi=./contracts/10-SynthetixCore.json --pkg=coreOptimism --out=./contracts/coreOptimism/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/10-SynthetixCore.json

# generate go file for SpotMarket contract on optimism net
generate-spot_market-optimism:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/10-SpotMarket.json ./contracts/spotMarketOptimism
abigen --abi=./contracts/10-SpotMarket.json --pkg=spotMarketOptimism --out=./contracts/spotMarketOptimism/contract.go
go run ./utils/getAbis/get-abis.go --rm ./contracts/10-SpotMarket.json
# generate go file for SynthetixCore contract on andromeda net
generate-core-andromeda:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/84531-andromeda-SynthetixCore.json ./contracts/core
abigen --abi=./contracts/84531-andromeda-SynthetixCore.json --pkg=core --out=./contracts/core/contract.go

# generate go file for PerpsMarket contract on andromeda net
generate-perps_market-andromeda:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/84531-andromeda-PerpsMarket.json ./contracts/perpsMarket
abigen --abi=./contracts/84531-andromeda-PerpsMarket.json --pkg=perpsMarket --out=./contracts/perpsMarket/contract.go

# generate go file for snxUSDT contract on andromeda net
generate-susdt-andromeda:
go run ./utils/getAbis/get-abis.go --get-mkdir ./Synthetix-Gitbook-v3/for-developers/abis/84531-andromeda-snxUSDToken.json ./contracts/sUSDT
abigen --abi=./contracts/84531-andromeda-snxUSDToken.json --pkg=sUSDT --out=./contracts/sUSDT/contract.go

# generate go file for TrustedMulticallForwarder contract on andromeda net
generate-forwarder-andromeda:
go run ./utils/getAbis/get-abis.go --get-mkdir ./additional-abis/84531-TrustedMulticallForwarder.json ./contracts/forwarder
abigen --abi=./contracts/84531-TrustedMulticallForwarder.json --pkg=forwarder --out=./contracts/forwarder/contract.go

# generate go file for ERC7412 contract on andromeda net
generate-erc7412-andromeda:
go run ./utils/getAbis/get-abis.go --get-mkdir ./additional-abis/84531-ERC7412.json ./contracts/ERC7412
abigen --abi=./contracts/84531-ERC7412.json --pkg=erc7412 --out=./contracts/ERC7412/contract.go

# update Synthetix-Gitbook-v3 subtree
update-subtree:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,4 @@ The goroutine will return events as a `Liquidation` model on the `LiquidationsCh
close the subscription use the `Close` function.

## License
This project is licensed under the MIT License.
This project is licensed under the MIT License.# asatruPythonE2E
11 changes: 10 additions & 1 deletion Synthetix-Gitbook-v3/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [Overview](README.md)
* [Development progress](development-progress.md)
* [V3 Frequently Asked Questions (FAQ)](v3-frequently-asked-questions-faq.md)

## For Liquidity Providers

Expand All @@ -24,7 +25,8 @@
## For Derivatives Market Builders

* [Build on v3](for-derivatives-market-builders/build-on-v3.md)
* [Integrating Synthetix](for-derivatives-market-builders/integrating-synthetix.md)
* [Build on v3 FAQ](for-derivatives-market-builders/build-on-v3-faq.md)
* [Operating a Market](for-derivatives-market-builders/integrating-synthetix.md)
* [Registering a Market](for-derivatives-market-builders/registering-a-market.md)

## For Traders
Expand All @@ -37,6 +39,13 @@
* [Synthetix Governance](for-governance-participants/synthetix-governance.md)
* [Elections](for-governance-participants/elections.md)

## FOR PERP INTEGRATORS

* [Perps V3](for-perp-integrators/perps-v3.md)
* [Sandbox with Perps](for-perp-integrators/sandbox-with-perps.md)
* [Base Andromeda](for-perp-integrators/base-andromeda.md)
* [Perps V3 Keeper](for-perp-integrators/perps-v3-keeper.md)

## For Developers

* [Quick Start](for-developers/quick-start.md)
Expand Down
2 changes: 1 addition & 1 deletion Synthetix-Gitbook-v3/development-progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Progress of major v3 milestones

# Development progress

<table><thead><tr><th width="234">Component</th><th width="150.33333333333331">Status</th><th>Notes / further reading</th></tr></thead><tbody><tr><td>Core system</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/synthetix-v3-is-on-mainnet/">V3 is on mainnet</a></td></tr><tr><td>v3 stablecoin</td><td>✅ on mainnet</td><td><a data-mention href="for-developers/addresses-+-abis.md">addresses-+-abis.md</a></td></tr><tr><td>Pools</td><td>✅ on mainnet</td><td><a data-mention href="for-liquidity-pool-managers/creating-and-configuring-pools.md">creating-and-configuring-pools.md</a></td></tr><tr><td>Market interface</td><td>✅ on mainnet</td><td><a data-mention href="for-derivatives-market-builders/registering-a-market.md">registering-a-market.md</a></td></tr><tr><td>Spot Market</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/spot-market-v3-alpha-release/">Spot Market Alpha release</a></td></tr><tr><td>Teleporter</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/synthetix-launches-teleporters-with-chainlinks-ccip/">Synthetix launches Teleporters</a></td></tr><tr><td>Crosschain Synthesis</td><td>🚧 in progress</td><td><a href="https://sips.synthetix.io/sips/sip-312/">SIP-312: Cross-chain Pool Synthesis</a></td></tr><tr><td>Perps v3 Market</td><td>🚧 in progress</td><td></td></tr><tr><td>Non-SNX collateral</td><td>❌ not enabled</td><td>Governance could enable as per <a href="https://sips.synthetix.io/sips/sip-302/">SIP-302</a> </td></tr><tr><td>Permissionless Pools</td><td>❌ not enabled</td><td>Governance could enable as per <a href="https://sips.synthetix.io/sips/sip-310/">SIP-310</a></td></tr><tr><td>Permissionless Markets</td><td>❌ not enabled</td><td>Governance could enable as per <a href="https://sips.synthetix.io/sips/sip-310/">SIP-310</a></td></tr></tbody></table>
<table><thead><tr><th width="234">Component</th><th width="150.33333333333331">Status</th><th>Notes / further reading</th></tr></thead><tbody><tr><td>Core system</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/synthetix-v3-is-on-mainnet/">V3 is on mainnet</a></td></tr><tr><td>v3 stablecoin</td><td>✅ on mainnet</td><td><a data-mention href="for-developers/addresses-+-abis.md">addresses-+-abis.md</a></td></tr><tr><td>Pools</td><td>✅ on mainnet</td><td><a data-mention href="for-liquidity-pool-managers/creating-and-configuring-pools.md">creating-and-configuring-pools.md</a></td></tr><tr><td>Market interface</td><td>✅ on mainnet</td><td><a data-mention href="for-derivatives-market-builders/registering-a-market.md">registering-a-market.md</a></td></tr><tr><td>Spot Market</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/spot-market-v3-alpha-release/">Spot Market Alpha release</a></td></tr><tr><td>Teleporter</td><td>✅ on mainnet</td><td><a href="https://blog.synthetix.io/synthetix-launches-teleporters-with-chainlinks-ccip/">Synthetix launches Teleporters</a></td></tr><tr><td>Perps v3 Market</td><td>🚧 in progress</td><td><a href="https://sips.synthetix.io/sips/sip-337/">SIP-337: Perps V3</a></td></tr><tr><td>Launch on new chain</td><td>🚧 in progress</td><td><a href="https://sips.synthetix.io/sips/sip-336/">SIP-336: Deploy Synthetix V3 Core on Base</a></td></tr><tr><td>Non-SNX collateral</td><td>🚧 in progress</td><td><a href="https://github.com/Synthetixio/SIPs/blob/master/content/sips/sip-348.md">SIP-348: Enable USDC for Andromeda on Base </a> </td></tr><tr><td>Crosschain Synthesis</td><td>🚧 in progress</td><td><a href="https://sips.synthetix.io/sips/sip-312/">SIP-312: Cross-chain Pool Synthesis</a></td></tr><tr><td>V2 to V3 Migration</td><td>🚧 in progress</td><td><a href="https://github.com/Synthetixio/SIPs/blob/master/content/sips/sip-306.md">SIP-306: V3 Migration</a><br><a href="https://sips.synthetix.io/sips/sip-323/">SIP-323: Adopt "s" prefix for Synthetix V3 asset tickers</a></td></tr><tr><td>Permissionless Pools</td><td>❌ not enabled</td><td>Governance could enable as per <a href="https://sips.synthetix.io/sips/sip-310/">SIP-310</a></td></tr><tr><td>Permissionless Markets</td><td>❌ not enabled</td><td>Governance could enable as per <a href="https://sips.synthetix.io/sips/sip-310/">SIP-310</a></td></tr></tbody></table>

{% embed url="https://mirror.xyz/cavalier.eth/nOTmVQcole7f0mnqhF93PHO2qbCMm1Y0JAAdiYX9tjU" %}
Further reading on the milestones for v3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
description: Considerations for creating new products on v3
---

# Build on v3 FAQ

> What all is needed to do this?
[#playbook-for-building-on-v3](build-on-v3.md#playbook-for-building-on-v3 "mention")

> Is a new Pool required?&#x20;
Not necessarily, because existing Pools could choose to delegate some of their collateral to your Market, but you need to convince the Pool owners to do so.

> Is a new Market required?&#x20;
Usually yes. Your Market is what draws on liquidity delegated to it, by existing Pools (or your own Pool if you create one). A profitable Market deposits earnings (and potentially rewards) to the Pools providing liquidity.

> Can a Market swap snxUSD for another assets? (eg WETH)
A Market must conform to the [IMarket](registering-a-market.md) interface, which means it can only deposit/withdraw snxUSD to/from Pools, but is free to interact with the wider defi ecosystem in any reasonable way.

> Can a Market accept another asset directly? (eg WETH)&#x20;
See above

> Can the Market owner impose a fee that incentivizes them?
Market owners are free to decide how their Markets function. Ultimately Markets are judged and compared on their performance (withdrawals and deposits to Pools) over time.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ An outline of v3, its components and possibilities
The case for building on Synthetix v3
{% endembed %}

{% embed url="https://t.me/+Jwf641J8a6M1ZTI1" %}
Telegram group for integrator discussions
{% endembed %}

## Why build on v3

Synthetix v3 solves the cold-start and scaling liquidity problems for derivate protocols, with more than $500m of liquidity waiting for new markets. Synthetix is an endlessly composable and configurable liquidity layer; backing derivative Markets, so they can scale faster, and LPs can accrue more fees.
Expand Down Expand Up @@ -48,6 +52,13 @@ Your high performing Market will be attractive to other Pools and Synthetix LPs.
* Want to create a novel derivatives product? You could create a v3 Market, then request one of the existing Pools to delegate your Market some collateral, or create a Pool.
* Want to control your own liquidity? You could propose to create a new Pool, and offer additional token incentives to Liquidity Providers with the Rewards Manager.&#x20;

## Next steps

1. Join the integrator telegram group to ask questions&#x20;
2. Follow [Synthetix Integrators](https://twitter.com/i/lists/1677086706246520832) list on X

{% embed url="https://t.me/+Jwf641J8a6M1ZTI1" %}

## Notes

* See [development-progress.md](../development-progress.md "mention") for more details on enabled collateral and other milestones.
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Integrating Synthetix

Derivatives market implementations can be [registered](registering-a-market.md) with the Synthetix protocol if they conform to the `IMarket` interface. This consists of just three functions:

* `function name(uint128 marketId) external view returns (string memory);` - A function which should return a human-readable name for the given market.
* `function reportedDebt(uint129 marketId) external view returns (uint);` - A function which should return the total value of debt issued by the market (to be collateralized by the assets in the pools backing it), denominated with 18 decimals places.
* `function minimumCredit(uint128 marketId) external view returns (uint);` - A function which returns the amount of credit under which pools cannot rescind credit delegated to the market. This value is dollar-denominated, with 18 decimals places. If the market implementation does not intend to lock collateral, this function can just `return 0;`. **Note that the amount of credit available to a market may still fall below this amount due to price action of the collateral backing it.**
# Operating a Market

## Managing Credit & Debt[](https://snx-v3-docs.vercel.app/pools-markets/integrating-markets#managing-credit--debt) <a href="#managing-credit--debt" id="managing-credit--debt"></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Markets can be integrated with the Synthetix protocol to access credit capacity
Before a market can interact with the protocol, it must be registered using the `registerMarket` function. This function accepts the address of a market, which will be able to integrate with Synthetix (to perform actions like depositing and withdrawing snxUSD) using the ID returned by the function.

Markets cannot be registered unless they conform to the `IMarket` interface. See [Integrating Synthetix](integrating-synthetix.md) for more information on the functions that must be implemented.

Derivatives market implementations can be [registered](registering-a-market.md) with the Synthetix protocol if they conform to the `IMarket` interface. This consists of just three functions:

* `function name(uint128 marketId) external view returns (string memory);` - A function which should return a human-readable name for the given market.
* `function reportedDebt(uint129 marketId) external view returns (uint);` - A function which should return the total value of debt issued by the market (to be collateralized by the assets in the pools backing it), denominated with 18 decimals places.
* `function minimumCredit(uint128 marketId) external view returns (uint);` - A function which returns the amount of credit under which pools cannot rescind credit delegated to the market. This value is dollar-denominated, with 18 decimals places. If the market implementation does not intend to lock collateral, this function can just `return 0;`. **Note that the amount of credit available to a market may still fall below this amount due to price action of the collateral backing it.**
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x12aE0D5CD26f212bFE242DA78139d463019f7a73",
"address": "0x47b8f4EC2D0ef7ADfa97927A597d2C73B3A7e81d",
"abi": [
{
"inputs": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x1b791d05E437C78039424749243F5A79E747525e",
"address": "0x6fBe7F0f515C2126638aAF60a351a98b27f62925",
"abi": [
{
"inputs": [
Expand Down
Loading

0 comments on commit 00e267d

Please sign in to comment.