forked from Mythic-Project/governance-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AdrenaFoundation/adrena-instructions
Adrena instructions first batch
- Loading branch information
Showing
22 changed files
with
38,679 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { Connection } from '@solana/web3.js' | ||
|
||
const INSTRUCTIONS = { | ||
100: { | ||
name: 'Add Vest', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
101: { | ||
name: 'Mint Lm Tokens From Bucket', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
102: { | ||
name: 'Set Custody Allow Swap', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
103: { | ||
name: 'Set Custody Allow Trade', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
104: { | ||
name: 'Set Custody Max Cumulative Short Size USD', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
105: { | ||
name: 'Set Pool Allow Swap', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
106: { | ||
name: 'Set Pool Allow Trade', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
107: { | ||
name: 'Set Pool Aum Soft Cap USD', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
108: { | ||
name: 'Set Pool Liquidity State', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
109: { | ||
name: 'Set Staking Lm Emission Potentiometers', | ||
accounts: [], | ||
getDataUI: async (_connection: Connection, data: Uint8Array) => { | ||
return ( | ||
<> | ||
<div>{JSON.stringify(data)}</div> | ||
</> | ||
) | ||
}, | ||
}, | ||
} | ||
|
||
export const ADRENA_INSTRUCTIONS = { | ||
// TODO: Replace with the correct program id | ||
SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f: INSTRUCTIONS, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useEffect, useState } from 'react' | ||
import { PublicKey } from '@solana/web3.js' | ||
|
||
import { useConnection } from '@solana/wallet-adapter-react' | ||
import { AnchorProvider, Wallet } from '@coral-xyz/anchor' | ||
import useWalletOnePointOh from './useWalletOnePointOh' | ||
import AdrenaClient from '@tools/sdk/adrena/Adrena' | ||
|
||
export default function useAdrenaClient( | ||
programId: PublicKey | null | ||
): AdrenaClient | null { | ||
const { connection } = useConnection() | ||
const wallet = useWalletOnePointOh() | ||
const [adrenaClient, setAdrenaClient] = useState<AdrenaClient | null>(null) | ||
|
||
useEffect(() => { | ||
if (!programId) return setAdrenaClient(null) | ||
|
||
setAdrenaClient( | ||
new AdrenaClient( | ||
// The wallet type is compatible with the anchor provider, force typing | ||
new AnchorProvider(connection, (wallet as unknown) as Wallet, { | ||
commitment: 'processed', | ||
skipPreflight: true, | ||
}), | ||
programId | ||
) | ||
) | ||
}, [connection, wallet, programId]) | ||
|
||
return adrenaClient | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import AdrenaClient, { | ||
CustodyWithPubkey, | ||
PoolWithPubkey, | ||
} from '@tools/sdk/adrena/Adrena' | ||
|
||
export default function useAdrenaCustodies( | ||
adrenaClient: AdrenaClient | null, | ||
pool: PoolWithPubkey | null | ||
) { | ||
const [custodies, setCustodies] = useState<CustodyWithPubkey[] | null>(null) | ||
|
||
useEffect(() => { | ||
;(async () => { | ||
if (adrenaClient === null || pool === null) return setCustodies(null) | ||
|
||
setCustodies(await adrenaClient.getCustodies(pool)) | ||
})() | ||
}, [adrenaClient, pool]) | ||
|
||
return custodies | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import AdrenaClient, { PoolWithPubkey } from '@tools/sdk/adrena/Adrena' | ||
|
||
export default function useAdrenaPools(adrenaClient: AdrenaClient | null) { | ||
const [pools, setPools] = useState<PoolWithPubkey[] | null>(null) | ||
|
||
useEffect(() => { | ||
;(async () => { | ||
if (!adrenaClient) return setPools(null) | ||
|
||
setPools(await adrenaClient.getPools()) | ||
})() | ||
}, [adrenaClient]) | ||
|
||
return pools | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import AdrenaClient, { StakingWithPubkey } from '@tools/sdk/adrena/Adrena' | ||
|
||
export default function useAdrenaStakings(adrenaClient: AdrenaClient | null) { | ||
const [stakings, setStakings] = useState<StakingWithPubkey[] | null>(null) | ||
|
||
useEffect(() => { | ||
;(async () => { | ||
if (!adrenaClient) return setStakings(null) | ||
|
||
setStakings(await adrenaClient.getStakings()) | ||
})() | ||
}, [adrenaClient]) | ||
|
||
return stakings | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.