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

feat: Amped Finance #43

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b50d6ac
establish project
danenright Jan 20, 2025
c5fbabf
first push
danenright Jan 20, 2025
8447d7c
add liquidity
danenright Jan 20, 2025
a8e3ddf
recent additions
danenright Jan 21, 2025
a7369bd
updates
danenright Jan 23, 2025
68dd0b3
add liquidity function working - native and erc20
danenright Jan 25, 2025
d4b3a72
updates to tests and functions
danenright Jan 25, 2025
551dca8
some trading functionality
danenright Jan 25, 2025
5b6406f
use heyanon-sdk
danenright Jan 28, 2025
6a2b355
updated getPerpsLiquidity and getALPAPR functions
danenright Jan 28, 2025
3d4ea9f
add liquidity function added
danenright Jan 28, 2025
edfb815
checks for user provided liquidity
danenright Jan 28, 2025
f80ac4e
updates, now LP functions work correctly
danenright Jan 29, 2025
b66c9de
getPerpsLiquidity and openPosition
danenright Jan 29, 2025
4659dd1
get positions and close positions logic
danenright Jan 30, 2025
9251b1a
tidying up
danenright Jan 30, 2025
2ecffd0
update README.md and tidy up
danenright Jan 31, 2025
e7a63f8
tests and updates
danenright Feb 1, 2025
2e7c2b2
latest updates and tidy up
danenright Feb 2, 2025
3e3e598
remove external files
danenright Feb 2, 2025
9ac253f
update README
danenright Feb 2, 2025
6c422e0
formatting update on README
danenright Feb 2, 2025
1c3f0f4
remove unneeded detail on common tasks
danenright Feb 2, 2025
d4bb64e
address feedback
danenright Feb 5, 2025
382010e
update README for Amped
danenright Feb 11, 2025
2cc7998
updates in line with comments
danenright Feb 17, 2025
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
69 changes: 69 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
# SDK and build artifacts
*.log
.DS_Store
node_modules
dist

# Dependencies
jspm_packages

# Build outputs
build
out
*.tsbuildinfo

# Environment and config
.env
.env.local
.env.*
.npmrc

# Logs and debugging
logs
npm-debug.log*
lerna-debug.log*
.pnpm-debug.log*

# Cache and temp directories
.npm
.eslintcache
.stylelintcache
.node_repl_history
.cache
.temp
.tmp
*.pid
*.seed
*.pid.lock

# IDE and editor files
.idea
.vscode
*.swp
*.swo
.env.development.local
.env.test.local
.env.production.local

# Coverage and test outputs
coverage
.nyc_output
lib-cov

# Yarn specific
projects/amped/.yarn/*
!projects/amped/.yarn/patches
!projects/amped/.yarn/plugins
!projects/amped/.yarn/releases
!projects/amped/.yarn/sdks
!projects/amped/.yarn/versions
projects/amped/.pnp.*
.yarnrc.yml
yarn-debug.log*
yarn-error.log*
.yarn-integrity

# TypeScript
*.tsbuildinfo
.tscache
tsconfig.tsbuildinfo

# HeyAnon SDK specific
.heyanon-cache
.heyanon-debug.log*
1 change: 1 addition & 0 deletions projects/amped/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions projects/amped/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4,
"printWidth": 180
}
75 changes: 75 additions & 0 deletions projects/amped/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# amped

Integration with Amped Finance

## Supported Networks

- SONIC

## Common Tasks

1. Liquidity Operations
- "Add 100 USDC as liquidity in Amped on Sonic network"
- "Remove $50 of liquidity from Amped and get S tokens back"
- "Check my available liquidity in Amped"

2. Trading Operations
- "Open a long position worth 100 USD on ANON with 20 USDC as collateral in Amped"
- "Close my long ANON position in Amped"
- "Check my open positions in Amped"

3. Information Queries
- "Show my current positions in Amped"
- "Check my liquidity pool balance in Amped"
- "Calculate expected returns for my position in Amped"

## Available Functions

### Liquidity Management
- `addLiquidity`: Add tokens as liquidity to Amped Finance, receiving ALP tokens in return.
- `removeLiquidity`: Remove liquidity by redeeming ALP tokens for any supported token.
- `getUserLiquidity`: Get user's current liquidity position and ALP token balance.
- `getPoolLiquidity`: Get current liquidity pool information and token balances.
- `getUserTokenBalances`: Get balances and USD values of all supported tokens for a specific user.

### Trading Operations
- `openPosition`: Open a leveraged long or short position with specified collateral.
- `closePosition`: Close one or more leveraged positions, fully or partially.
- `getAllOpenPositions`: Get all open positions for a specific account.
- `getPosition`: Get detailed information about a specific position.
- `marketSwap`: Execute a market swap between two tokens.

### Information & Analytics
- `getPoolLiquidity`: Get total pool liquidity information including ALP supply and Assets Under Management (AUM).
- `getALPApr`: Calculate and retrieve the current APR for ALP tokens.
- `getEarnings`: Get earnings information for a user's positions and liquidity.
- `getPerpsLiquidity`: Get available liquidity information for perpetual trading.
- `getSwapsLiquidity`: Get information about available liquidity for token swaps.

### Rewards
- `claimRewards`: Claim any available rewards from liquidity provision or trading.

## What You Need to Know

1. Liquidity
- You can add any supported token as liquidity (e.g. S, EURC, USDC, ANON, WETH on Sonic)
- You receive ALP tokens in return
- ALP tokens can be redeemed later for any supported token

2. Trading
- You can trade with up to 11x leverage
- Minimum leverage size is 1.1x
- Minimum collateral is $10
- Available collateral and indextokens for longs: S, ANON, WETH
- Available collateral tokens for shorts: USDC, EURC

3. Safety Limits
- Default slippage protection is 0.3%
- Position sizes are limited by available liquidity
- Leverage is limited based on token and position size

## Installation

```bash
yarn add @heyanon/amped
```
95 changes: 95 additions & 0 deletions projects/amped/abis/ERC20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
export var ERC20 = [
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
];
95 changes: 95 additions & 0 deletions projects/amped/abis/ERC20.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
export const ERC20 = [
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
] as const;
Loading